hgbook

view Makefile @ 1101:5b6b0d5fc1b8

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