summaryrefslogtreecommitdiff
path: root/GNUmakefile
blob: 46fc58e89df954a382f872ce7578869e63c5b4ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# This file is in the public domain.

# Hardly anyone seems to read README files anymore, so keep this note here:
# Don't remove the variables for python etc. They exist
# because one system sticks with PEPs, and others opt
# for installing every version side-by-side,
# Same goes for babel.

include config.mk

# All: build HTML pages in all languages and compile the
# TypeScript logic in web-common.
.PHONY: all
all: locale template
	cd web-common && $(tsc)
	$(sh) make_sitemap.sh
	for x in en de fr it es ru pt ; do $(cp) robots.txt rendered/$$x ; done
	for x in en de fr it es ru pt ; do $(cp) favicon.ico rendered/$$x ; done
	for x in en de fr it es ru pt ; do $(cp) rendered/sitemap.xml rendered/$$x ; done
	$(cp) styles.css rendered/
	$(cp) -R images rendered/
	for x in en de fr it es ru pt ; do $(cp) -R images rendered/$$x ; done
	for x in en de fr it es ru pt ; do $(cp) -R web-common rendered/$$x ; done
	$(cp) -R dist rendered/
	$(cp) -R icons rendered/
	$(cp) -R papers rendered/
	$(cp) -R pdf rendered/
	$(cp) -R presentations rendered/

# Extract translateable strings from jinja2 templates.
locale/messages.pot: template/*.j2 common/*.j2 common/*.j2.inc
	$(env) PYTHONPATH="." $(BABEL) extract -F locale/babel.map -o locale/messages.pot .

# Update translation (.po) files with new strings.
.PHONY: locale-update
locale-update: locale/messages.pot
	$(msgmerge) -U -m --previous locale/en/LC_MESSAGES/messages.po locale/messages.pot
	$(msgmerge) -U -m --previous locale/de/LC_MESSAGES/messages.po locale/messages.pot
	$(msgmerge) -U -m --previous locale/fr/LC_MESSAGES/messages.po locale/messages.pot
	$(msgmerge) -U -m --previous locale/es/LC_MESSAGES/messages.po locale/messages.pot
	$(msgmerge) -U -m --previous locale/it/LC_MESSAGES/messages.po locale/messages.pot
	$(msgmerge) -U -m --previous locale/ru/LC_MESSAGES/messages.po locale/messages.pot
	$(msgmerge) -U -m --previous locale/pt/LC_MESSAGES/messages.po locale/messages.pot

	if $(grep) -nA1 '#-#-#-#-#' locale/*/LC_MESSAGES/messages.po; then $(echo) -e "\nERROR: Conflicts encountered in PO files.\n"; exit 1; fi

# Compile translation files for use.
.PHONY: locale-compile
locale-compile:
	$(pybabel) compile -d locale -l en --use-fuzzy
	$(pybabel) compile -d locale -l de --use-fuzzy
	$(pybabel) compile -d locale -l fr --use-fuzzy
	$(pybabel) compile -d locale -l it --use-fuzzy
	$(pybabel) compile -d locale -l es --use-fuzzy
	$(pybabel) compile -d locale -l ru --use-fuzzy
	$(pybabel) compile -d locale -l pt --use-fuzzy

# Process everything related to gettext translations.
.PHONY: locale
locale: locale-update locale-compile

# Run the jinja2 templating engine to expand templates to HTML
# incorporating translations.
template: locale-compile
	$(python) ./template.py

.PHONY: run
run: all
	$(browser) http://0.0.0.0:8000 &
	$(python) -m http.server

.PHONY: install
install: all
	$(mkdir) -p $(prefix)/share/taler-www
	$(cp) -r rendered/* $(prefix)/share/taler-www

.PHONY: uninstall
	$(rm) -rf $(prefix)/share/taler-www

.PHONY: clean
clean:
	$(rm) -rf __pycache__ *.pyc  *~ \.*~ \#*\#
	$(rm) -rf en/ de/ fr/ it/ es/ ru/
	$(rm) -rf rendered/

submodules/init:
	$(git) submodule update --init --recursive

submodules/update:
	$(git) submodule update --recursive --remote

.SILENT: show-help
show-help:
	$(printf) "install:\t\tInstall the website\n"
	$(printf) "all:\t\t\tBuild the website\n"
	$(printf) "locale/messages.pot:\tExtract translateable strings from jinja2 templates.\n"
	$(printf) "locale-update:\t\tUpdate translation files with new strings.\n"
	$(printf) "locale-compile:\t\tCompile translation files for use.\n"
	$(printf) "locale:\t\t\tProcess everything related to gettext translations.\n"
	$(printf) "template:\t\texpand jinja2 templates to html.\n"
	$(printf) "run:\t\t\tspawn python webserver and open the current directory.\n"
	$(printf) "clean:\t\t\tclean.\n"
	$(printf) "submodules/init:\tinit git submodules\n"
	$(printf) "submodules/update:\tupdate git submodules\n"