Mercurial > hgbook
comparison Makefile @ 776:019040fbf5f5
merged to upstream: phase 1
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 21 Apr 2009 00:36:40 +0900 |
parents | 55e2953f82d6 |
children |
comparison
equal
deleted
inserted
replaced
389:5981a0f7540a | 776:019040fbf5f5 |
---|---|
1 # | |
2 # Makefile for the hgbook, top-level | |
3 # | |
4 include Makefile.vars | |
5 | |
6 FORMATS=html html-single pdf epub | |
7 | |
8 PO_LANGUAGES := zh | |
9 DBK_LANGUAGES := en | |
10 LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES) | |
11 | |
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 | |
21 | |
22 #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})') | |
23 rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})') | |
24 | |
25 images := \ | |
26 en/figs/feature-branches.png \ | |
27 en/figs/filelog.png \ | |
28 en/figs/metadata.png \ | |
29 en/figs/mq-stack.png \ | |
30 en/figs/revlog.png \ | |
31 en/figs/snapshot.png \ | |
32 en/figs/tour-history.png \ | |
33 en/figs/tour-merge-conflict.png \ | |
34 en/figs/tour-merge-merge.png \ | |
35 en/figs/tour-merge-pull.png \ | |
36 en/figs/tour-merge-sep-repos.png \ | |
37 en/figs/undo-manual-merge.png \ | |
38 en/figs/undo-manual.png \ | |
39 en/figs/undo-non-tip.png \ | |
40 en/figs/undo-simple.png \ | |
41 en/figs/wdir-after-commit.png \ | |
42 en/figs/wdir-branch.png \ | |
43 en/figs/wdir-merge.png \ | |
44 en/figs/wdir.png \ | |
45 en/figs/wdir-pre-branch.png | |
46 | |
47 help: | |
48 @echo " make epub [LINGUA=en|zh|...]" | |
49 @echo " make html [LINGUA=en|zh|...]" | |
50 @echo " make html-single [LINGUA=en|zh|...]" | |
51 @echo " make pdf [LINGUA=en|zh|...]" | |
52 @echo " make validate [LINGUA=en|zh|...] # always before commit!" | |
53 @echo " make tidypo [LINGUA=zh|...] # always before commit!" | |
54 @echo " make updatepo [LINGUA=zh|...] # update po files." | |
55 @echo " make all [LINGUA=en|zh|...]" | |
56 @echo " make stat # print statistics about po files." | |
57 @echo " make clean # Remove the build files." | |
58 | |
59 clean: | |
60 @rm -fr build po/*.mo hello en/hello en/html en/.validated-00book.xml en/examples/.run en/examples/results \ | |
61 stylesheets/system-xsl en/figs/*-tmp.svg \ | |
62 en/figs/feature-branches.png \ | |
63 en/figs/filelog.png \ | |
64 en/figs/feature-branches.png \ | |
65 en/figs/filelog.png \ | |
66 en/figs/metadata.png \ | |
67 en/figs/mq-stack.png \ | |
68 en/figs/revlog.png \ | |
69 en/figs/snapshot.png \ | |
70 en/figs/tour-history.png \ | |
71 en/figs/tour-merge-conflict.png \ | |
72 en/figs/tour-merge-merge.png \ | |
73 en/figs/tour-merge-pull.png \ | |
74 en/figs/tour-merge-sep-repos.png \ | |
75 en/figs/undo-manual-merge.png \ | |
76 en/figs/undo-manual.png \ | |
77 en/figs/undo-non-tip.png \ | |
78 en/figs/undo-simple.png \ | |
79 en/figs/wdir-after-commit.png \ | |
80 en/figs/wdir-branch.png \ | |
81 en/figs/wdir-merge.png \ | |
82 en/figs/wdir-pre-branch.png \ | |
83 en/figs/wdir.png | |
84 | |
85 all: | |
86 ifdef LINGUA | |
87 for f in $(FORMATS); do \ | |
88 $(MAKE) LINGUA=$(LINGUA) $$f; \ | |
89 done | |
90 else | |
91 for l in $(LANGUAGES); do \ | |
92 for f in $(FORMATS); do \ | |
93 $(MAKE) LINGUA=$$l $$f; \ | |
94 done; \ | |
95 done | |
96 endif | |
97 | |
98 stat: | |
99 @( \ | |
100 LANG=C; export LANG; cd po; \ | |
101 for f in *.po; do \ | |
102 printf "%s\t" $$f; \ | |
103 msgfmt --statistics -c $$f; \ | |
104 done; \ | |
105 ) | |
106 | |
107 tidypo: | |
108 ifdef LINGUA | |
109 msgcat --sort-by-file --width=80 po/$(LINGUA).po > po/$(LINGUA).tmp && \ | |
110 mv po/$(LINGUA).tmp po/$(LINGUA).po; | |
111 else | |
112 for po in $(wildcard po/*.po); do \ | |
113 msgcat --sort-by-file --width=80 $$po > $$po.tmp && mv $$po.tmp $$po; \ | |
114 done | |
115 endif | |
116 | |
117 ifndef LINGUA | |
118 updatepo: | |
119 for l in $(PO_LANGUAGES); do \ | |
120 $(MAKE) $@ LINGUA=$$l; \ | |
121 done | |
122 else | |
123 updatepo: | |
124 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" "" | |
125 (cd po; \ | |
126 $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po; \ | |
127 ) | |
128 $(MAKE) tidypo LINGUA=$(LINGUA) | |
129 endif | |
130 endif | |
131 | |
132 ifndef LINGUA | |
133 validate: | |
134 for l in $(LANGUAGES); do \ | |
135 $(MAKE) $@ LINGUA=$$l; \ | |
136 done | |
137 else | |
138 validate: build/$(LINGUA)/source/hgbook.xml | |
139 xmllint --nonet --noout --postvalid --xinclude $< | |
140 | |
141 ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" "" | |
142 $(LINGUA)/examples/.run: | |
143 (cd $(LINGUA)/examples; ./run-example -v -a) | |
144 | |
145 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(images) $(LINGUA)/examples/.run | |
146 mkdir -p build/$(LINGUA)/source/figs | |
147 cp $(LINGUA)/figs/*.png build/$(LINGUA)/source/figs | |
148 cp stylesheets/hgbook.css build/$(LINGUA)/source | |
149 (cd $(LINGUA); xmllint --nonet --noent --xinclude --postvalid --output ../$@.tmp 00book.xml) | |
150 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ | |
151 else | |
152 en/examples/.run: | |
153 (cd en/examples; ./run-example -v -a) | |
154 | |
155 build/en/source/hgbook.xml: | |
156 ${MAKE} LINGUA=en $@ | |
157 | |
158 build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images) | |
159 mkdir -p build/$(LINGUA)/source/figs | |
160 cp en/figs/*.png build/$(LINGUA)/source/figs | |
161 cp stylesheets/hgbook.css build/$(LINGUA)/source | |
162 $(TRANSLATE) -m en/00book.xml -p po/$(LINGUA).po -l en/hgbook.xml.$(LINGUA) | |
163 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp en/hgbook.xml.$(LINGUA) | |
164 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ | |
165 mv en/hgbook.xml.$(LINGUA) build/$(LINGUA)/source | |
166 endif | |
167 | |
168 endif | |
169 | |
170 ifndef LINGUA | |
171 epub: | |
172 for l in $(LANGUAGES); do \ | |
173 $(MAKE) $@ LINGUA=$$l; \ | |
174 done | |
175 else | |
176 epub: build/$(LINGUA)/epub/hgbook.epub | |
177 | |
178 build/$(LINGUA)/epub/hgbook.epub: build/$(LINGUA)/source/hgbook.xml | |
179 mkdir -p build/$(LINGUA)/epub | |
180 (cd build/$(LINGUA)/source; $(DB2EPUB) -c hgbook.css -v hgbook.xml; mv hgbook.epub ../epub) | |
181 endif | |
182 | |
183 ifndef LINGUA | |
184 html: | |
185 for l in $(LANGUAGES); do \ | |
186 $(MAKE) $@ LINGUA=$$l; \ | |
187 done | |
188 else | |
189 html: build/$(LINGUA)/html/index.html | |
190 | |
191 build/$(LINGUA)/html/index.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html.xsl stylesheets/$(LINGUA)/html.xsl | |
192 mkdir -p build/$(LINGUA)/html/figs | |
193 cp en/figs/*.png build/$(LINGUA)/html/figs | |
194 cp stylesheets/hgbook.css build/$(LINGUA)/html | |
195 xsltproc --output build/$(LINGUA)/html/ \ | |
196 stylesheets/$(LINGUA)/html.xsl build/$(LINGUA)/source/hgbook.xml | |
197 endif | |
198 | |
199 ifndef LINGUA | |
200 html-single: | |
201 for l in $(LANGUAGES); do \ | |
202 $(MAKE) $@ LINGUA=$$l; \ | |
203 done | |
204 else | |
205 html-single: build/$(LINGUA)/html-single/hgbook.html | |
206 | |
207 build/$(LINGUA)/html-single/hgbook.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html-single.xsl stylesheets/$(LINGUA)/html-single.xsl | |
208 mkdir -p build/$(LINGUA)/html-single/figs | |
209 cp en/figs/*.png build/$(LINGUA)/html-single/figs | |
210 cp stylesheets/hgbook.css build/$(LINGUA)/html-single | |
211 xsltproc --output build/$(LINGUA)/html-single/hgbook.html \ | |
212 stylesheets/$(LINGUA)/html-single.xsl build/$(LINGUA)/source/hgbook.xml | |
213 endif | |
214 | |
215 ifndef LINGUA | |
216 pdf: | |
217 for l in $(LANGUAGES); do \ | |
218 $(MAKE) $@ LINGUA=$$l; \ | |
219 done | |
220 else | |
221 pdf: build/$(LINGUA)/pdf/hgbook.pdf | |
222 | |
223 build/$(LINGUA)/pdf/hgbook.pdf: build/$(LINGUA)/source/hgbook.xml stylesheets/fo.xsl stylesheets/$(LINGUA)/fo.xsl | |
224 mkdir -p build/$(LINGUA)/pdf | |
225 java -classpath $(JAVA_LIB)/saxon65.jar:$(JAVA_LIB)/saxon65-dbxsl.jar:$(JAVA_LIB)/xml-commons-resolver-1.2.jar:$(JAVA_LIB) \ | |
226 com.icl.saxon.StyleSheet \ | |
227 -x org.apache.xml.resolver.tools.ResolvingXMLReader \ | |
228 -y org.apache.xml.resolver.tools.ResolvingXMLReader \ | |
229 -r org.apache.xml.resolver.tools.CatalogResolver \ | |
230 -o build/$(LINGUA)/source/hgbook.fo \ | |
231 build/$(LINGUA)/source/hgbook.xml \ | |
232 stylesheets/$(LINGUA)/fo.xsl \ | |
233 fop1.extensions=1 | |
234 | |
235 (cd build/$(LINGUA)/source && $(FOP_HOME)/fop.sh -c $(FOP_HOME)/conf/userconfig.xml hgbook.fo ../pdf/hgbook.pdf) | |
236 endif | |
237 | |
238 en/figs/%.png: en/figs/%.svg en/fixsvg | |
239 en/fixsvg $< | |
240 inkscape -D -d 120 -e $@ $<-tmp.svg | |
241 | |
242 en/figs/%.svg: en/figs/%.dot | |
243 dot -Tsvg -o $@ $< |