hgbook

view Makefile @ 880:a821682ea3a5

Attach it to building
author Dongsheng Song <dongsheng.song@gmail.com>
date Wed Oct 21 16:10:27 2009 +0800 (2009-10-21)
parents c3863298abc7
children 3df0c9cfe902
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-src := $(wildcard en/figs/*.dot en/figs/*.svg en/figs/*.png)
27 images-dot := $(filter %.dot, $(images-src))
28 images-svg := $(filter %.svg, $(images-src))
30 images-dst := $(images-src:dot=png)
31 images-dst := $(images-dst:svg=png)
33 images-out := $(images-dot:dot=svg)
34 images-out += $(images-dot:dot=png)
35 images-out += $(images-svg:svg=png)
37 help:
38 @echo " make epub [LINGUA=en|it|zh|...]"
39 @echo " make html [LINGUA=en|it|zh|...]"
40 @echo " make html-single [LINGUA=en|it|zh|...]"
41 @echo " make pdf [LINGUA=en|it|zh|...]"
42 @echo " make validate [LINGUA=en|it|zh|...] # always before commit!"
43 @echo " make tidypo [LINGUA=zh|...] # always before commit!"
44 @echo " make updatepo [LINGUA=zh|...] # update po files."
45 @echo " make all [LINGUA=en|it|zh|...]"
46 @echo " make stat # print statistics about po files."
47 @echo " make clean # Remove the build files."
49 clean:
50 @rm -fr build hello po/*.mo en/hello en/html en/.validated-00book.xml \
51 en/examples/.run en/examples/results en/figs/*-tmp.svg \
52 stylesheets/system-xsl web/index-read.html.in
54 @(for l in $(DBK_LANGUAGES); do \
55 rm -fr $(subst en/figs/, $$l/figs/, $(images-out)) ;\
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 updatepo:
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
105 endif
107 ifndef LINGUA
108 validate:
109 for l in $(LANGUAGES); do \
110 $(MAKE) $@ LINGUA=$$l; \
111 done
112 else
113 validate: build/$(LINGUA)/source/hgbook.xml
114 xmllint --nonet --noout --postvalid --xinclude $<
116 ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" ""
117 $(LINGUA)/examples/.run:
118 if test -x $(LINGUA)/examples/run-example; then \
119 (cd $(LINGUA)/examples; ./run-example -v -a); \
120 else \
121 touch $@; \
122 fi
124 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(subst en/figs/, $(LINGUA)/figs/, $(images-dst)) $(LINGUA)/examples/.run
125 mkdir -p build/$(LINGUA)/source/figs
126 cp $(LINGUA)/figs/*.png build/$(LINGUA)/source/figs
127 cp stylesheets/hgbook.css build/$(LINGUA)/source
128 (cd $(LINGUA); xmllint --nonet --noent --xinclude --postvalid --output ../$@.tmp 00book.xml)
129 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
130 else
131 en/examples/.run:
132 (cd en/examples; ./run-example -v -a)
134 build/en/source/hgbook.xml:
135 ${MAKE} LINGUA=en $@
137 build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images-dst)
138 mkdir -p build/$(LINGUA)/source/figs
139 cp en/figs/*.png build/$(LINGUA)/source/figs
140 cp stylesheets/hgbook.css build/$(LINGUA)/source
141 $(TRANSLATE) -m en/00book.xml -p po/$(LINGUA).po -l en/hgbook.xml.$(LINGUA)
142 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp en/hgbook.xml.$(LINGUA)
143 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
144 mv en/hgbook.xml.$(LINGUA) build/$(LINGUA)/source
145 endif
147 endif
149 ifndef LINGUA
150 epub:
151 for l in $(LANGUAGES); do \
152 $(MAKE) $@ LINGUA=$$l; \
153 done
154 else
155 epub: build/$(LINGUA)/epub/hgbook.epub
157 build/$(LINGUA)/epub/hgbook.epub: build/$(LINGUA)/source/hgbook.xml
158 mkdir -p build/$(LINGUA)/epub
159 (cd build/$(LINGUA)/source; $(DB2EPUB) -c hgbook.css -v hgbook.xml; mv hgbook.epub ../epub)
160 endif
162 ifndef LINGUA
163 html:
164 for l in $(LANGUAGES); do \
165 $(MAKE) $@ LINGUA=$$l; \
166 done
167 else
168 html: build/$(LINGUA)/html/index.html
170 build/$(LINGUA)/html/index.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html.xsl stylesheets/$(LINGUA)/html.xsl
171 mkdir -p build/$(LINGUA)/html/figs
172 cp en/figs/*.png build/$(LINGUA)/html/figs
173 cp stylesheets/hgbook.css build/$(LINGUA)/html
174 xsltproc --output build/$(LINGUA)/html/ \
175 stylesheets/$(LINGUA)/html.xsl build/$(LINGUA)/source/hgbook.xml
176 endif
178 ifndef LINGUA
179 html-single:
180 for l in $(LANGUAGES); do \
181 $(MAKE) $@ LINGUA=$$l; \
182 done
183 else
184 html-single: build/$(LINGUA)/html-single/hgbook.html
186 build/$(LINGUA)/html-single/hgbook.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html-single.xsl stylesheets/$(LINGUA)/html-single.xsl
187 mkdir -p build/$(LINGUA)/html-single/figs
188 cp en/figs/*.png build/$(LINGUA)/html-single/figs
189 cp stylesheets/hgbook.css build/$(LINGUA)/html-single
190 xsltproc --output build/$(LINGUA)/html-single/hgbook.html \
191 stylesheets/$(LINGUA)/html-single.xsl build/$(LINGUA)/source/hgbook.xml
192 endif
194 ifndef LINGUA
195 pdf:
196 for l in $(LANGUAGES); do \
197 $(MAKE) $@ LINGUA=$$l; \
198 done
199 else
200 pdf: build/$(LINGUA)/pdf/hgbook.pdf
202 build/$(LINGUA)/pdf/hgbook.pdf: build/$(LINGUA)/source/hgbook.xml stylesheets/fo.xsl stylesheets/$(LINGUA)/fo.xsl
203 mkdir -p build/$(LINGUA)/pdf
204 java -classpath $(JAVA_LIB)/saxon65.jar:$(JAVA_LIB)/saxon65-dbxsl.jar:$(JAVA_LIB)/xml-commons-resolver-1.2.jar:$(JAVA_LIB) \
205 com.icl.saxon.StyleSheet \
206 -x org.apache.xml.resolver.tools.ResolvingXMLReader \
207 -y org.apache.xml.resolver.tools.ResolvingXMLReader \
208 -r org.apache.xml.resolver.tools.CatalogResolver \
209 -o build/$(LINGUA)/source/hgbook.fo \
210 build/$(LINGUA)/source/hgbook.xml \
211 stylesheets/$(LINGUA)/fo.xsl \
212 fop1.extensions=1
214 (cd build/$(LINGUA)/source && $(FOP_HOME)/fop.sh -c $(FOP_HOME)/conf/userconfig.xml hgbook.fo ../pdf/hgbook.pdf)
215 endif
217 $(LINGUA)/figs/%.png: $(LINGUA)/figs/%.svg
218 if test -x $(LINGUA)/fixsvg; then \
219 $(LINGUA)/fixsvg $<; \
220 inkscape -D -d 120 -e $@ $<-tmp.svg; \
221 else \
222 inkscape -D -d 120 -e $@ $<; \
223 fi
225 $(LINGUA)/figs/%.svg: $(LINGUA)/figs/%.dot
226 dot -Tsvg -o $@ $<
228 en/figs/%.png: en/figs/%.svg en/fixsvg
229 en/fixsvg $<
230 inkscape -D -d 120 -e $@ $<-tmp.svg
232 en/figs/%.svg: en/figs/%.dot
233 dot -Tsvg -o $@ $<