hgbook

view Makefile @ 633:74da9b315396

Cleanup thoroughly, and run fixsvg when generate png files
author Dongsheng Song <dongsheng.song@gmail.com>
date Fri Mar 13 15:55:43 2009 +0800 (2009-03-13)
parents bae6d1503482
children 1c13ed2130a7
line source
1 #
2 # Makefile for the hgbook, top-level
3 #
5 FORMATS=html html-single pdf
7 PO_LANGUAGES := zh
8 DBK_LANGUAGES := en
9 LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES)
11 UPDATEPO = PERLLIB=../tools/po4a/lib/ ../tools/po4a/po4a-updatepo -M UTF-8 \
12 -f docbook -o doctype='docbook' -o includeexternal \
13 -o nodefault='<programlisting> <screen>' \
14 -o untranslated='<programlisting> <screen>'
15 TRANSLATE = PERLLIB=tools/po4a/lib/ tools/po4a/po4a-translate -M UTF-8 \
16 -f docbook -o doctype='docbook' \
17 -k 0
19 #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})')
20 rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})')
22 images := \
23 en/images/feature-branches.png \
24 en/images/filelog.png \
25 en/images/metadata.png \
26 en/images/mq-stack.png \
27 en/images/revlog.png \
28 en/images/snapshot.png \
29 en/images/tour-history.png \
30 en/images/tour-merge-conflict.png \
31 en/images/tour-merge-merge.png \
32 en/images/tour-merge-pull.png \
33 en/images/tour-merge-sep-repos.png \
34 en/images/undo-manual-merge.png \
35 en/images/undo-manual.png \
36 en/images/undo-non-tip.png \
37 en/images/undo-simple.png \
38 en/images/wdir-after-commit.png \
39 en/images/wdir-branch.png \
40 en/images/wdir-merge.png \
41 en/images/wdir.png \
42 en/images/wdir-pre-branch.png
44 help:
45 @echo " make html [LINGUA=en|zh|...]"
46 @echo " make html-single [LINGUA=en|zh|...]"
47 @echo " make pdf [LINGUA=en|zh|...]"
48 @echo " make validate [LINGUA=en|zh|...] # always before commit!"
49 @echo " make tidypo [LINGUA=zh|...] # always before commit!"
50 @echo " make updatepo [LINGUA=zh|...] # update po files."
51 @echo " make all [LINGUA=en|zh|...]"
52 @echo " make stat # print statistics about po files."
53 @echo " make clean # Remove the build files."
55 clean:
56 @rm -fr build po/*.mo hello en/hello en/html en/.validated-00book.xml \
57 stylesheets/system-xsl en/images/*-tmp.svg \
58 en/images/feature-branches.png \
59 en/images/filelog.png \
60 en/images/feature-branches.png \
61 en/images/filelog.png \
62 en/images/metadata.png \
63 en/images/mq-stack.png \
64 en/images/revlog.png \
65 en/images/snapshot.png \
66 en/images/tour-history.png \
67 en/images/tour-merge-conflict.png \
68 en/images/tour-merge-merge.png \
69 en/images/tour-merge-pull.png \
70 en/images/tour-merge-sep-repos.png \
71 en/images/undo-manual-merge.png \
72 en/images/undo-manual.png \
73 en/images/undo-non-tip.png \
74 en/images/undo-simple.png \
75 en/images/wdir-after-commit.png \
76 en/images/wdir-branch.png \
77 en/images/wdir-merge.png \
78 en/images/wdir-pre-branch.png \
79 en/images/wdir.png
81 all:
82 ifdef LINGUA
83 for f in $(FORMATS); do \
84 $(MAKE) LINGUA=$(LINGUA) $$f; \
85 done
86 else
87 for l in $(LANGUAGES); do \
88 for f in $(FORMATS); do \
89 $(MAKE) LINGUA=$$l $$f; \
90 done; \
91 done
92 endif
94 stat:
95 @( \
96 LANG=C; export LANG; cd po; \
97 for f in *.po; do \
98 printf "%s\t" $$f; \
99 msgfmt --statistics -c $$f; \
100 done; \
101 )
103 tidypo:
104 ifdef LINGUA
105 msgcat --sort-by-file --width=80 po/$(LINGUA).po > po/$(LINGUA).tmp && \
106 mv po/$(LINGUA).tmp po/$(LINGUA).po;
107 else
108 for po in $(wildcard po/*.po); do \
109 msgcat --sort-by-file --width=80 $$po > $$po.tmp && mv $$po.tmp $$po; \
110 done
111 endif
113 ifndef LINGUA
114 updatepo:
115 for l in $(PO_LANGUAGES); do \
116 $(MAKE) $@ LINGUA=$$l; \
117 done
118 else
119 updatepo:
120 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" ""
121 (cd po && $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po)
122 $(MAKE) tidypo LINGUA=$(LINGUA)
123 endif
124 endif
126 ifndef LINGUA
127 validate:
128 for l in $(LANGUAGES); do \
129 $(MAKE) $@ LINGUA=$$l; \
130 done
131 else
132 validate: build/$(LINGUA)/source/hgbook.xml
133 xmllint --nonet --noout --postvalid --xinclude $<
135 ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" ""
136 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(images)
137 mkdir -p build/$(LINGUA)/source
138 cp -r $(LINGUA)/* build/$(LINGUA)/source
139 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp $(LINGUA)/00book.xml
140 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
141 else
142 build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images)
143 mkdir -p build/$(LINGUA)/source
144 cp -r en/images build/$(LINGUA)/source
145 cp -r en/examples build/$(LINGUA)/source
146 cp en/book-shortcuts.xml build/$(LINGUA)/source
147 for f in en/*.xml; do \
148 if [ $$f != "en/book-shortcuts.xml" ]; then \
149 $(TRANSLATE) -m $$f -p po/$(LINGUA).po -l build/$(LINGUA)/source/`basename $$f`; \
150 fi \
151 done
152 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp build/$(LINGUA)/source/00book.xml
153 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
154 endif
156 endif
158 ifndef LINGUA
159 html:
160 for l in $(LANGUAGES); do \
161 $(MAKE) $@ LINGUA=$$l; \
162 done
163 else
164 html: build/$(LINGUA)/html/index.html
166 build/$(LINGUA)/html/index.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html.xsl stylesheets/$(LINGUA)/html.xsl
167 mkdir -p build/$(LINGUA)/html/images
168 cp en/images/*.png build/$(LINGUA)/html/images
169 cp stylesheets/hgbook.css build/$(LINGUA)/html
170 xsltproc --output build/$(LINGUA)/html/ \
171 stylesheets/$(LINGUA)/html.xsl build/$(LINGUA)/source/hgbook.xml
172 endif
174 ifndef LINGUA
175 html-single:
176 for l in $(LANGUAGES); do \
177 $(MAKE) $@ LINGUA=$$l; \
178 done
179 else
180 html-single: build/$(LINGUA)/html-single/hgbook.html
182 build/$(LINGUA)/html-single/hgbook.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html-single.xsl stylesheets/$(LINGUA)/html-single.xsl
183 mkdir -p build/$(LINGUA)/html-single/images
184 cp en/images/*.png build/$(LINGUA)/html-single/images
185 cp stylesheets/hgbook.css build/$(LINGUA)/html-single
186 xsltproc --output build/$(LINGUA)/html-single/hgbook.html \
187 stylesheets/$(LINGUA)/html-single.xsl build/$(LINGUA)/source/hgbook.xml
188 endif
190 ifndef LINGUA
191 pdf:
192 for l in $(LANGUAGES); do \
193 $(MAKE) $@ LINGUA=$$l; \
194 done
195 else
196 pdf: build/$(LINGUA)/pdf/hgbook.pdf
198 build/$(LINGUA)/pdf/hgbook.pdf: build/$(LINGUA)/source/hgbook.xml stylesheets/fo.xsl stylesheets/$(LINGUA)/fo.xsl
199 mkdir -p build/$(LINGUA)/pdf
200 java -classpath tools/fop/lib/saxon65.jar:tools/fop/lib/saxon65-dbxsl.jar:tools/fop/lib/xml-commons-resolver-1.2.jar:tools/fop/conf \
201 com.icl.saxon.StyleSheet \
202 -x org.apache.xml.resolver.tools.ResolvingXMLReader \
203 -y org.apache.xml.resolver.tools.ResolvingXMLReader \
204 -r org.apache.xml.resolver.tools.CatalogResolver \
205 -o build/$(LINGUA)/source/hgbook.fo \
206 build/$(LINGUA)/source/hgbook.xml \
207 stylesheets/$(LINGUA)/fo.xsl \
208 fop1.extensions=1
210 (cd build/$(LINGUA)/source && ../../../tools/fop/fop.sh hgbook.fo ../pdf/hgbook.pdf)
211 endif
213 en/images/%.png: en/images/%.svg en/fixsvg
214 en/fixsvg $<
215 inkscape -D -d 120 -e $@ $<-tmp.svg
217 en/images/%.svg: en/images/%.dot
218 dot -Tsvg -o $@ $<