-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
93 lines (76 loc) · 2.69 KB
/
Makefile
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
###
### must have the following commandline tools:
###
### itstool (Debian package: itstool)
### msgfmt (Debian package: gettext)
### msgmerge (Debian package: gettext)
### xmlto (Debian package: xmlto)
### xmllint (Debian package: libxml2-utils)
###
MANUAL_MASTER = manual.docbook
TUTORIAL_MASTER = tutorial.docbook
XMLTO_OPTS = --stringparam section.autolabel=1 \
--stringparam use.is.as.filename=1 \
--stringparam toc.max.depth=3 \
--stringparam xref.with.number.and.title=0 \
--stringparam section.label.includes.component.label=1 \
--stringparam admon.graphics.extension=.svg \
--stringparam admon.graphics=1 \
--stringparam admon.style="'margin-left: 5%;'" \
--stringparam ulink.target="_blank"
ITSTOOL = itstool
MSGMERGE = msgmerge
MSGFMT = msgfmt
XMLTO = xmlto
XMLLINT = xmllint
all: manual.pot manual_en.html tutorial.pot tutorial_en.html tutorial_fr.html tutorial_it.html clean
clean:
-rm -f *.mo *_validated *.dbk *.bak
# Derive language from filename (and extension)
define LANGUAGE =
$$(echo -n $(1) | sed 's/.*_\(..\)\.$(2)/\1/')
endef
%.html: %.dbk %.dbk_validated
sed -i "s%generated_en/%generated_$(call LANGUAGE,$<,dbk)/%g" $<
LL=$(call LANGUAGE,$<,dbk) ; \
$(XMLTO) html-nochunks $(XMLTO_OPTS) \
--stringparam l10n.gentext.language=$$LL \
--stringparam html.stylesheet='res/docbook.css' \
--stringparam html.script='res/docbook.js' \
--stringparam img.src.path=img/ \
--stringparam admon.graphics.path=img/admonitions/ \
-x res/xslt/html/docbook.xsl \
$<
LL=$(call LANGUAGE,$<,dbk) ; \
$(XMLTO) html -o $*_chunked $(XMLTO_OPTS) \
--stringparam l10n.gentext.language=$$LL \
--stringparam html.stylesheet='../res/docbook.css' \
--stringparam html.script='../res/docbook.js' \
--stringparam img.src.path=../img/ \
--stringparam admon.graphics.path=../img/admonitions/ \
-x res/xslt/html/chunk.xsl \
$<
%.dbk_validated: %.dbk
$(XMLLINT) --noout --valid $^
touch $@
## Special rule for master manual and tutorial
%_en.dbk: %.docbook
cp -f $^ $@
manual_%.dbk: manual_%.mo manual_%.po $(MANUAL_MASTER)
$(ITSTOOL) -m $< -o $@ --lang $* $(MANUAL_MASTER)
manual.pot: $(MANUAL_MASTER)
$(ITSTOOL) -o manual.pot $<
manual_%.po: manual.pot
$(MSGMERGE) -U $@ manual.pot --backup=simple --no-wrap --verbose
manual_%.mo: manual_%.po
`cat $< | sed 's/, fuzzy//g' > $<.bak`
$(MSGFMT) --check -o $@ $<.bak
tutorial_%.dbk: tutorial_%.mo tutorial_%.po $(TUTORIAL_MASTER)
$(ITSTOOL) -m $< -o $@ --lang $* $(TUTORIAL_MASTER)
tutorial.pot: $(TUTORIAL_MASTER)
$(ITSTOOL) -o tutorial.pot $<
tutorial_%.po: tutorial.pot
$(MSGMERGE) -U $@ tutorial.pot --backup=simple --no-wrap --verbose
tutorial_%.mo: tutorial_%.po
`cat $< | sed 's/, fuzzy//g' > $<.bak`
$(MSGFMT) --check -o $@ $<.bak