summaryrefslogtreecommitdiff
path: root/Makefile
blob: 309d899b20070db4edeae696b5eebf79ed3e75e2 (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
# Makefile for NetBSD make (portable version: "bmake"),
# GNU make will find 'GNUmakefile' first and use that file instead.
# This file is in the public domain.
#
# I keep and maintain this file for personal use, it is faster than
# the gmake approach.

.include "config.mk"

DESTDIR=$(prefix)

_LOCALELIST= en de fr it es ru pt
_DIRLIST= dist icons papers pdf presentations images

.PHONY:	all run locale-compile locale install clean

.OBJDIR=rendered

# Work this into an mk file

# All: build HTML pages in all languages and compile the
# TypeScript logic in web-common.
all: locale template
	cd web-common && $(tsc)
	$(sh) make_sitemap.sh
.for _lang in ${_LOCALELIST}
	$(cp) robots.txt rendered/${_lang}
	$(cp) favicon.ico rendered/${_lang}
	$(cp) rendered/sitemap.xml rendered/${_lang}
.endfor
.for _dir in ${_DIRLIST}
	$(cp) -R ${_dir} rendered/
.endfor
	$(cp) styles.css rendered/

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

# Update translation (.po) files with new strings.
locale-update: locale/messages.pot
.for _lang in ${_LOCALELIST}
	$(msgmerge) -q -U -m --previous locale/${_lang}/LC_MESSAGES/messages.po locale/messages.pot
.endfor
	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.
locale-compile:
.for _lang in ${_LOCALELIST}
	$(pybabel) -q compile -d locale -l ${_lang} --use-fuzzy
.endfor

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

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

run:
.if defined(browser) && !empty(DESTDIR) && !empty(python)
	$(browser) http://0.0.0.0:8000 &
	$(python) -m http.server
.endif

install:
	$(mkdir) -p $(prefix)/share/taler-www
	$(cp) -R rendered/* $(prefix)/share/taler-www

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

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

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

CLEANFILES+=    *.pyc *~ \.*~ *.core

.include <bsd.prog.mk>