diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 70 |
1 files changed, 23 insertions, 47 deletions
@@ -3,86 +3,62 @@ | |||
3 | include build-system/config.mk | 3 | include build-system/config.mk |
4 | 4 | ||
5 | # List of all supported languages, add new languages here! | 5 | # List of all supported languages, add new languages here! |
6 | LANGUAGES="en de fr it es ar hi ja ko pt zh_Hant" | 6 | LANGUAGES="ar de en es fr hi it ja ko pt zh_Hant" |
7 | 7 | ||
8 | # All: build HTML pages in all languages and compile the | 8 | # All: build HTML pages in all languages and compile the |
9 | # TypeScript logic in web-common. | ||
10 | .PHONY: all | 9 | .PHONY: all |
11 | all: locale template | 10 | all: locale template |
12 | # ($(cp) rendered/static/javascript.html rendered/javascript.html) | 11 | env BASEURL=$(opt_baseurl) ./inc/make_site.py |
13 | ($(cp) rendered/static/robots.txt rendered/robots.txt) | ||
14 | ($(cp) rendered/static/robots.txt rendered/dist/robots.txt) | ||
15 | (for lang in `echo $(LANGUAGES)` ; do \ | ||
16 | $(cp) rendered/static/robots.txt rendered/$$lang/robots.txt; \ | ||
17 | done) | ||
18 | ($(python) inc/make_sitemap.py -i rendered) | ||
19 | ($(cp) sitemap.xml rendered/sitemap.xml) | ||
20 | ($(cp) sitemap.xml rendered/en/sitemap.xml) | ||
21 | (for lang in `echo $(LANGUAGES)` ; do \ | ||
22 | $(cp) rendered/sitemap.xml rendered/$$lang ; \ | ||
23 | done) | ||
24 | ($(cp) -R images rendered/static/) | ||
25 | (for lang in `echo $(LANGUAGES)` ; \ | ||
26 | do $(cp) -R images rendered/$$lang ; \ | ||
27 | done) | ||
28 | ($(cp) -R web-common/* rendered/static/) | ||
29 | (cd rendered; \ | ||
30 | for lang in `echo $(LANGUAGES)`; do \ | ||
31 | $(cp) $$lang/rss.xml $$lang/news/rss.xml; \ | ||
32 | done) | ||
33 | (for d in dist ; do \ | ||
34 | $(cp) -R $$d rendered/ ; \ | ||
35 | done) | ||
36 | # ($(cp) -R pdf rendered/static/) | ||
37 | ($(mkdir) -p rendered/.well-known ; $(cp) .well-known/security.txt rendered/.well-known/) | ||
38 | 12 | ||
39 | # Extract translateable strings from jinja2 templates. | 13 | # Extract translateable strings from jinja2 templates. |
40 | locale/messages.pot: template/*.j2 common/*.j2 common/*.j2.inc | 14 | locale/messages.pot: template/*.j2 template/news/*.j2 common/*.j2 common/*.j2.inc |
41 | $(python) inc/mybabel.py $(pybabel) extract -F locale/babel.map -o locale/messages.pot . | 15 | env PYTHONPATH=$$PWD/inc:$$PYTHONPATH $(pybabel) extract -F locale/babel.map -o locale/messages.pot . |
42 | 16 | ||
43 | # Update translation (.po) files with new strings. | 17 | # Update translation (.po) files with new strings. |
44 | .PHONY: locale-update | 18 | .PHONY: locale-update |
45 | locale-update: locale/messages.pot | 19 | locale-update: locale/messages.pot |
46 | (for lang in `echo $(LANGUAGES)`; do \ | 20 | for lang in `echo $(LANGUAGES)`; do \ |
47 | $(msgmerge) -q -U -m --previous locale/$$lang/LC_MESSAGES/messages.po locale/messages.pot ; \ | 21 | $(msgmerge) -q -U -m --previous locale/$$lang/LC_MESSAGES/messages.po locale/messages.pot ; \ |
48 | done) | 22 | done |
49 | if $(grep) -nA1 '#-#-#-#-#' locale/*/LC_MESSAGES/messages.po; then $(echo) -e "\nERROR: Conflicts encountered in PO files.\n"; exit 1; fi | 23 | if $(grep) -nA1 '#-#-#-#-#' locale/*/LC_MESSAGES/messages.po; then \ |
24 | $(echo) -e "\nERROR: Conflicts encountered in PO files.\n"; \ | ||
25 | exit 1; \ | ||
26 | fi | ||
50 | 27 | ||
51 | # Compile translation files for use. | 28 | # Compile translation files for use. |
52 | .PHONY: locale-compile | 29 | .PHONY: locale-compile |
53 | locale-compile: | 30 | locale-compile: |
54 | (for lang in `echo $(LANGUAGES)`; do \ | 31 | for lang in `echo $(LANGUAGES)`; do \ |
32 | echo compiling $$lang; \ | ||
55 | $(pybabel) -q compile -d locale -l $$lang --use-fuzzy ; \ | 33 | $(pybabel) -q compile -d locale -l $$lang --use-fuzzy ; \ |
56 | done) | 34 | done |
57 | 35 | ||
58 | # Process everything related to gettext translations. | 36 | # Process everything related to gettext translations. |
59 | .PHONY: locale | 37 | .PHONY: locale |
60 | locale: locale-update locale-compile | 38 | locale: locale-update locale-compile |
61 | 39 | ||
62 | # Run the jinja2 templating engine to expand templates to HTML | ||
63 | # incorporating translations. | ||
64 | template: locale-compile | ||
65 | $(python) ./make_site.py | ||
66 | |||
67 | .PHONY: run | 40 | .PHONY: run |
68 | run: all | 41 | run: all |
69 | $(browser) http://0.0.0.0:8000/rendered/en & | 42 | $(browser) http://0.0.0.0:8000/rendered/en & |
70 | $(python) -m http.server | 43 | $(python) -m http.server |
71 | 44 | ||
45 | variant = $(opt_variant) | ||
46 | |||
47 | ifndef variant | ||
48 | $(error variant is not set) | ||
49 | endif | ||
50 | |||
72 | .PHONY: install | 51 | .PHONY: install |
73 | install: all | 52 | install: all |
74 | $(mkdir) -p $(prefix)/ | 53 | $(mkdir) -p $(prefix)/$(variant) |
75 | $(cp) -r rendered/* $(prefix)/ | 54 | $(cp) -r rendered/* $(prefix)/$(variant)/ |
76 | $(cp) -r rendered/.well-known/ $(prefix)/ | 55 | $(cp) -r rendered/.well-known/ $(prefix)/$(variant)/ |
77 | |||
78 | .PHONY: uninstall | ||
79 | uninstall: | ||
80 | $(rm) -rf $(prefix)/ | ||
81 | 56 | ||
82 | .PHONY: clean | 57 | .PHONY: clean |
83 | clean: | 58 | clean: |
84 | $(rm) -rf __pycache__ *.pyc *~ \.*~ \#*\# | 59 | $(rm) -rf __pycache__ *.pyc *~ \.*~ \#*\# |
85 | $(rm) -rf rendered/ | 60 | $(rm) -rf rendered/ |
86 | 61 | ||
62 | .PHONY: submodules/update | ||
87 | submodules/update: | 63 | submodules/update: |
88 | $(git) submodule update --recursive --remote | 64 | $(git) submodule update --recursive --remote |