rev |
line source |
dongsheng@626
|
1 #
|
dongsheng@626
|
2 # Makefile for the hgbook, top-level
|
dongsheng@626
|
3 #
|
songdongsheng@657
|
4 include Makefile.vars
|
dongsheng@626
|
5
|
dongsheng@661
|
6 FORMATS=html html-single pdf epub
|
dongsheng@626
|
7
|
dongsheng@626
|
8 PO_LANGUAGES := zh
|
belaran@1025
|
9 DBK_LANGUAGES := en it fr
|
dongsheng@626
|
10 LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES)
|
dongsheng@626
|
11
|
songdongsheng@657
|
12 UPDATEPO = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-updatepo -M UTF-8 \
|
dongsheng@661
|
13 -f docbook -o doctype=docbook -o includeexternal \
|
dongsheng@661
|
14 -o nodefault="<programlisting> <screen>" \
|
dongsheng@661
|
15 -o untranslated="<programlisting> <screen>"
|
songdongsheng@657
|
16 TRANSLATE = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-translate -M UTF-8 \
|
songdongsheng@668
|
17 -f docbook -o doctype=docbook -o includeexternal \
|
songdongsheng@668
|
18 -o nodefault="<programlisting> <screen>" \
|
songdongsheng@668
|
19 -o untranslated="<programlisting> <screen>" \
|
dongsheng@626
|
20 -k 0
|
dongsheng@626
|
21
|
dongsheng@626
|
22 #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})')
|
dongsheng@626
|
23 rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})')
|
dongsheng@626
|
24
|
dongsheng@885
|
25 images-dot := $(wildcard en/figs/*.dot)
|
dongsheng@885
|
26
|
dongsheng@885
|
27 images-svg := $(wildcard en/figs/*.svg)
|
dongsheng@885
|
28 images-svg :=$(filter-out %-tmp.svg, $(images-svg))
|
dongsheng@885
|
29 images-svg -= $(images-dot:dot=svg)
|
dongsheng@885
|
30
|
dongsheng@885
|
31 images-dst := $(wildcard en/figs/*.png)
|
dongsheng@885
|
32 images-dst += $(images-dot:dot=png)
|
dongsheng@885
|
33 images-dst += $(images-svg:svg=png)
|
dongsheng@885
|
34
|
dongsheng@885
|
35 images-gen := $(images-dot:dot=png)
|
dongsheng@885
|
36 images-gen += $(images-svg:svg=png)
|
dongsheng@885
|
37 images-gen += $(wildcard en/figs/*-tmp.svg)
|
dongsheng@626
|
38
|
dongsheng@626
|
39 help:
|
dongsheng@880
|
40 @echo " make epub [LINGUA=en|it|zh|...]"
|
dongsheng@880
|
41 @echo " make html [LINGUA=en|it|zh|...]"
|
dongsheng@880
|
42 @echo " make html-single [LINGUA=en|it|zh|...]"
|
dongsheng@880
|
43 @echo " make pdf [LINGUA=en|it|zh|...]"
|
dongsheng@880
|
44 @echo " make validate [LINGUA=en|it|zh|...] # always before commit!"
|
dongsheng@626
|
45 @echo " make tidypo [LINGUA=zh|...] # always before commit!"
|
dongsheng@626
|
46 @echo " make updatepo [LINGUA=zh|...] # update po files."
|
dongsheng@880
|
47 @echo " make all [LINGUA=en|it|zh|...]"
|
dongsheng@626
|
48 @echo " make stat # print statistics about po files."
|
dongsheng@626
|
49 @echo " make clean # Remove the build files."
|
dongsheng@626
|
50
|
dongsheng@626
|
51 clean:
|
dongsheng@885
|
52 @rm -fr build hello po/*.mo /tmp/REV*-hello en/examples/results
|
dongsheng@880
|
53
|
dongsheng@880
|
54 @(for l in $(DBK_LANGUAGES); do \
|
dongsheng@885
|
55 rm -fr $(subst en/figs/, $$l/figs/, $(images-gen)) $$l/examples/.run;\
|
dongsheng@880
|
56 done)
|
dongsheng@626
|
57
|
dongsheng@626
|
58 all:
|
dongsheng@626
|
59 ifdef LINGUA
|
dongsheng@626
|
60 for f in $(FORMATS); do \
|
dongsheng@626
|
61 $(MAKE) LINGUA=$(LINGUA) $$f; \
|
dongsheng@626
|
62 done
|
dongsheng@626
|
63 else
|
dongsheng@626
|
64 for l in $(LANGUAGES); do \
|
dongsheng@626
|
65 for f in $(FORMATS); do \
|
dongsheng@626
|
66 $(MAKE) LINGUA=$$l $$f; \
|
dongsheng@626
|
67 done; \
|
dongsheng@626
|
68 done
|
dongsheng@626
|
69 endif
|
dongsheng@626
|
70
|
dongsheng@626
|
71 stat:
|
dongsheng@626
|
72 @( \
|
dongsheng@626
|
73 LANG=C; export LANG; cd po; \
|
dongsheng@626
|
74 for f in *.po; do \
|
dongsheng@626
|
75 printf "%s\t" $$f; \
|
dongsheng@626
|
76 msgfmt --statistics -c $$f; \
|
dongsheng@626
|
77 done; \
|
dongsheng@626
|
78 )
|
dongsheng@626
|
79
|
dongsheng@626
|
80 tidypo:
|
dongsheng@626
|
81 ifdef LINGUA
|
dongsheng@882
|
82 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" ""
|
dongsheng@626
|
83 msgcat --sort-by-file --width=80 po/$(LINGUA).po > po/$(LINGUA).tmp && \
|
dongsheng@626
|
84 mv po/$(LINGUA).tmp po/$(LINGUA).po;
|
dongsheng@882
|
85 endif
|
dongsheng@626
|
86 else
|
dongsheng@626
|
87 for po in $(wildcard po/*.po); do \
|
dongsheng@626
|
88 msgcat --sort-by-file --width=80 $$po > $$po.tmp && mv $$po.tmp $$po; \
|
dongsheng@626
|
89 done
|
dongsheng@626
|
90 endif
|
dongsheng@626
|
91
|
dongsheng@626
|
92 ifndef LINGUA
|
dongsheng@626
|
93 updatepo:
|
dongsheng@626
|
94 for l in $(PO_LANGUAGES); do \
|
dongsheng@626
|
95 $(MAKE) $@ LINGUA=$$l; \
|
dongsheng@626
|
96 done
|
dongsheng@626
|
97 else
|
dongsheng@881
|
98 po/$(LINGUA).po: $(wildcard en/*.xml)
|
dongsheng@881
|
99 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" ""
|
dongsheng@661
|
100 (cd po; \
|
dongsheng@661
|
101 $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po; \
|
dongsheng@661
|
102 )
|
dongsheng@626
|
103 $(MAKE) tidypo LINGUA=$(LINGUA)
|
dongsheng@881
|
104 endif
|
dongsheng@881
|
105
|
dongsheng@881
|
106 updatepo: po/$(LINGUA).po
|
dongsheng@626
|
107 endif
|
dongsheng@626
|
108
|
dongsheng@626
|
109 ifndef LINGUA
|
dongsheng@626
|
110 validate:
|
dongsheng@626
|
111 for l in $(LANGUAGES); do \
|
dongsheng@626
|
112 $(MAKE) $@ LINGUA=$$l; \
|
dongsheng@626
|
113 done
|
dongsheng@626
|
114 else
|
dongsheng@626
|
115 validate: build/$(LINGUA)/source/hgbook.xml
|
dongsheng@626
|
116 xmllint --nonet --noout --postvalid --xinclude $<
|
dongsheng@626
|
117
|
dongsheng@882
|
118 ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" ""
|
dongsheng@654
|
119 $(LINGUA)/examples/.run:
|
dongsheng@880
|
120 if test -x $(LINGUA)/examples/run-example; then \
|
dongsheng@885
|
121 (cd $(LINGUA)/examples; ./run-example -a); \
|
dongsheng@880
|
122 else \
|
dongsheng@880
|
123 touch $@; \
|
dongsheng@880
|
124 fi
|
dongsheng@880
|
125
|
dongsheng@880
|
126 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(subst en/figs/, $(LINGUA)/figs/, $(images-dst)) $(LINGUA)/examples/.run
|
dongsheng@654
|
127 mkdir -p build/$(LINGUA)/source/figs
|
dongsheng@654
|
128 cp $(LINGUA)/figs/*.png build/$(LINGUA)/source/figs
|
dongsheng@661
|
129 cp stylesheets/hgbook.css build/$(LINGUA)/source
|
dongsheng@654
|
130 (cd $(LINGUA); xmllint --nonet --noent --xinclude --postvalid --output ../$@.tmp 00book.xml)
|
dongsheng@626
|
131 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
|
dongsheng@882
|
132 else
|
dongsheng@654
|
133 en/examples/.run:
|
dongsheng@885
|
134 (cd en/examples; ./run-example -a)
|
dongsheng@654
|
135
|
dongsheng@654
|
136 build/en/source/hgbook.xml:
|
dongsheng@654
|
137 ${MAKE} LINGUA=en $@
|
dongsheng@654
|
138
|
dongsheng@885
|
139 build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images-dst) en/examples/.run
|
dongsheng@654
|
140 mkdir -p build/$(LINGUA)/source/figs
|
songdongsheng@657
|
141 cp en/figs/*.png build/$(LINGUA)/source/figs
|
dongsheng@661
|
142 cp stylesheets/hgbook.css build/$(LINGUA)/source
|
songdongsheng@668
|
143 $(TRANSLATE) -m en/00book.xml -p po/$(LINGUA).po -l en/hgbook.xml.$(LINGUA)
|
songdongsheng@668
|
144 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp en/hgbook.xml.$(LINGUA)
|
dongsheng@626
|
145 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
|
songdongsheng@668
|
146 mv en/hgbook.xml.$(LINGUA) build/$(LINGUA)/source
|
dongsheng@882
|
147 endif
|
dongsheng@626
|
148
|
dongsheng@626
|
149 endif
|
dongsheng@626
|
150
|
dongsheng@626
|
151 ifndef LINGUA
|
dongsheng@661
|
152 epub:
|
dongsheng@661
|
153 for l in $(LANGUAGES); do \
|
dongsheng@661
|
154 $(MAKE) $@ LINGUA=$$l; \
|
dongsheng@661
|
155 done
|
dongsheng@661
|
156 else
|
dongsheng@661
|
157 epub: build/$(LINGUA)/epub/hgbook.epub
|
dongsheng@661
|
158
|
dongsheng@661
|
159 build/$(LINGUA)/epub/hgbook.epub: build/$(LINGUA)/source/hgbook.xml
|
dongsheng@661
|
160 mkdir -p build/$(LINGUA)/epub
|
dongsheng@661
|
161 (cd build/$(LINGUA)/source; $(DB2EPUB) -c hgbook.css -v hgbook.xml; mv hgbook.epub ../epub)
|
dongsheng@661
|
162 endif
|
dongsheng@661
|
163
|
dongsheng@661
|
164 ifndef LINGUA
|
dongsheng@626
|
165 html:
|
dongsheng@626
|
166 for l in $(LANGUAGES); do \
|
dongsheng@626
|
167 $(MAKE) $@ LINGUA=$$l; \
|
dongsheng@626
|
168 done
|
dongsheng@626
|
169 else
|
dongsheng@626
|
170 html: build/$(LINGUA)/html/index.html
|
dongsheng@626
|
171
|
dongsheng@629
|
172 build/$(LINGUA)/html/index.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html.xsl stylesheets/$(LINGUA)/html.xsl
|
dongsheng@654
|
173 mkdir -p build/$(LINGUA)/html/figs
|
dongsheng@654
|
174 cp en/figs/*.png build/$(LINGUA)/html/figs
|
dongsheng@629
|
175 cp stylesheets/hgbook.css build/$(LINGUA)/html
|
dongsheng@626
|
176 xsltproc --output build/$(LINGUA)/html/ \
|
dongsheng@629
|
177 stylesheets/$(LINGUA)/html.xsl build/$(LINGUA)/source/hgbook.xml
|
dongsheng@626
|
178 endif
|
dongsheng@626
|
179
|
dongsheng@626
|
180 ifndef LINGUA
|
dongsheng@626
|
181 html-single:
|
dongsheng@626
|
182 for l in $(LANGUAGES); do \
|
dongsheng@626
|
183 $(MAKE) $@ LINGUA=$$l; \
|
dongsheng@626
|
184 done
|
dongsheng@626
|
185 else
|
dongsheng@626
|
186 html-single: build/$(LINGUA)/html-single/hgbook.html
|
dongsheng@626
|
187
|
dongsheng@629
|
188 build/$(LINGUA)/html-single/hgbook.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html-single.xsl stylesheets/$(LINGUA)/html-single.xsl
|
dongsheng@654
|
189 mkdir -p build/$(LINGUA)/html-single/figs
|
dongsheng@654
|
190 cp en/figs/*.png build/$(LINGUA)/html-single/figs
|
dongsheng@629
|
191 cp stylesheets/hgbook.css build/$(LINGUA)/html-single
|
dongsheng@626
|
192 xsltproc --output build/$(LINGUA)/html-single/hgbook.html \
|
dongsheng@629
|
193 stylesheets/$(LINGUA)/html-single.xsl build/$(LINGUA)/source/hgbook.xml
|
dongsheng@626
|
194 endif
|
dongsheng@626
|
195
|
dongsheng@626
|
196 ifndef LINGUA
|
dongsheng@626
|
197 pdf:
|
dongsheng@626
|
198 for l in $(LANGUAGES); do \
|
dongsheng@626
|
199 $(MAKE) $@ LINGUA=$$l; \
|
dongsheng@626
|
200 done
|
dongsheng@626
|
201 else
|
dongsheng@626
|
202 pdf: build/$(LINGUA)/pdf/hgbook.pdf
|
dongsheng@626
|
203
|
dongsheng@629
|
204 build/$(LINGUA)/pdf/hgbook.pdf: build/$(LINGUA)/source/hgbook.xml stylesheets/fo.xsl stylesheets/$(LINGUA)/fo.xsl
|
dongsheng@626
|
205 mkdir -p build/$(LINGUA)/pdf
|
songdongsheng@668
|
206 java -classpath $(JAVA_LIB)/saxon65.jar:$(JAVA_LIB)/saxon65-dbxsl.jar:$(JAVA_LIB)/xml-commons-resolver-1.2.jar:$(JAVA_LIB) \
|
dongsheng@626
|
207 com.icl.saxon.StyleSheet \
|
dongsheng@626
|
208 -x org.apache.xml.resolver.tools.ResolvingXMLReader \
|
dongsheng@626
|
209 -y org.apache.xml.resolver.tools.ResolvingXMLReader \
|
dongsheng@626
|
210 -r org.apache.xml.resolver.tools.CatalogResolver \
|
dongsheng@626
|
211 -o build/$(LINGUA)/source/hgbook.fo \
|
dongsheng@626
|
212 build/$(LINGUA)/source/hgbook.xml \
|
dongsheng@629
|
213 stylesheets/$(LINGUA)/fo.xsl \
|
dongsheng@626
|
214 fop1.extensions=1
|
dongsheng@626
|
215
|
dongsheng@659
|
216 (cd build/$(LINGUA)/source && $(FOP_HOME)/fop.sh -c $(FOP_HOME)/conf/userconfig.xml hgbook.fo ../pdf/hgbook.pdf)
|
dongsheng@626
|
217 endif
|
dongsheng@626
|
218
|
dongsheng@880
|
219 $(LINGUA)/figs/%.png: $(LINGUA)/figs/%.svg
|
dongsheng@880
|
220 if test -x $(LINGUA)/fixsvg; then \
|
dongsheng@880
|
221 $(LINGUA)/fixsvg $<; \
|
dongsheng@880
|
222 inkscape -D -d 120 -e $@ $<-tmp.svg; \
|
dongsheng@880
|
223 else \
|
dongsheng@880
|
224 inkscape -D -d 120 -e $@ $<; \
|
dongsheng@880
|
225 fi
|
dongsheng@880
|
226
|
dongsheng@880
|
227 $(LINGUA)/figs/%.svg: $(LINGUA)/figs/%.dot
|
dongsheng@880
|
228 dot -Tsvg -o $@ $<
|
dongsheng@880
|
229
|
dongsheng@654
|
230 en/figs/%.png: en/figs/%.svg en/fixsvg
|
dongsheng@633
|
231 en/fixsvg $<
|
dongsheng@633
|
232 inkscape -D -d 120 -e $@ $<-tmp.svg
|
dongsheng@626
|
233
|
dongsheng@654
|
234 en/figs/%.svg: en/figs/%.dot
|
dongsheng@626
|
235 dot -Tsvg -o $@ $<
|