Mercurial > hgbook
comparison Makefile @ 725:83a687a996b2
Basically completed Docbook xml make environment
author | Dongsheng Song <dongsheng.song@gmail.com> |
---|---|
date | Thu, 12 Mar 2009 15:52:36 +0800 |
parents | |
children | 0e3d8f66bbb7 |
comparison
equal
deleted
inserted
replaced
724:cfdb601a3c8b | 725:83a687a996b2 |
---|---|
1 # | |
2 # Makefile for the hgbook, top-level | |
3 # | |
4 | |
5 FORMATS=html html-single pdf | |
6 | |
7 PO_LANGUAGES := zh | |
8 DBK_LANGUAGES := en | |
9 LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES) | |
10 | |
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 | |
18 | |
19 #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})') | |
20 rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})') | |
21 | |
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 | |
43 | |
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." | |
54 | |
55 clean: | |
56 @rm -fr build po/*.mo | |
57 | |
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 | |
70 | |
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 ) | |
79 | |
80 tidypo: | |
81 ifdef LINGUA | |
82 msgcat --sort-by-file --width=80 po/$(LINGUA).po > po/$(LINGUA).tmp && \ | |
83 mv po/$(LINGUA).tmp po/$(LINGUA).po; | |
84 else | |
85 for po in $(wildcard po/*.po); do \ | |
86 msgcat --sort-by-file --width=80 $$po > $$po.tmp && mv $$po.tmp $$po; \ | |
87 done | |
88 endif | |
89 | |
90 ifndef LINGUA | |
91 updatepo: | |
92 for l in $(PO_LANGUAGES); do \ | |
93 $(MAKE) $@ LINGUA=$$l; \ | |
94 done | |
95 else | |
96 updatepo: | |
97 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" "" | |
98 (cd po && $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po) | |
99 $(MAKE) tidypo LINGUA=$(LINGUA) | |
100 endif | |
101 endif | |
102 | |
103 ifndef LINGUA | |
104 validate: | |
105 for l in $(LANGUAGES); do \ | |
106 $(MAKE) $@ LINGUA=$$l; \ | |
107 done | |
108 else | |
109 validate: build/$(LINGUA)/source/hgbook.xml | |
110 xmllint --nonet --noout --postvalid --xinclude $< | |
111 | |
112 ifneq "$(findstring $(LINGUA),$(DBK_LANGUAGES))" "" | |
113 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(images) | |
114 mkdir -p build/$(LINGUA)/source | |
115 cp -r $(LINGUA)/* build/$(LINGUA)/source | |
116 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp $(LINGUA)/00book.xml | |
117 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ | |
118 else | |
119 build/$(LINGUA)/source/hgbook.xml: $(wildcard en/*.xml) po/$(LINGUA).po $(images) | |
120 mkdir -p build/$(LINGUA)/source | |
121 cp -r en/images build/$(LINGUA)/source | |
122 cp -r en/examples build/$(LINGUA)/source | |
123 cp en/book-shortcuts.xml build/$(LINGUA)/source | |
124 for f in en/*.xml; do \ | |
125 if [ $$f != "en/book-shortcuts.xml" ]; then \ | |
126 $(TRANSLATE) -m $$f -p po/$(LINGUA).po -l build/$(LINGUA)/source/`basename $$f`; \ | |
127 fi \ | |
128 done | |
129 xmllint --nonet --noent --xinclude --postvalid --output $@.tmp build/$(LINGUA)/source/00book.xml | |
130 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ | |
131 endif | |
132 | |
133 endif | |
134 | |
135 ifndef LINGUA | |
136 html: | |
137 for l in $(LANGUAGES); do \ | |
138 $(MAKE) $@ LINGUA=$$l; \ | |
139 done | |
140 else | |
141 html: build/$(LINGUA)/html/index.html | |
142 | |
143 build/$(LINGUA)/html/index.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html.xsl stylesheets/$(LINGUA)/html.xsl | |
144 mkdir -p build/$(LINGUA)/html/images | |
145 cp en/images/*.png build/$(LINGUA)/html/images | |
146 cp stylesheets/hgbook.css build/$(LINGUA)/html | |
147 xsltproc --output build/$(LINGUA)/html/ \ | |
148 stylesheets/$(LINGUA)/html.xsl build/$(LINGUA)/source/hgbook.xml | |
149 endif | |
150 | |
151 ifndef LINGUA | |
152 html-single: | |
153 for l in $(LANGUAGES); do \ | |
154 $(MAKE) $@ LINGUA=$$l; \ | |
155 done | |
156 else | |
157 html-single: build/$(LINGUA)/html-single/hgbook.html | |
158 | |
159 build/$(LINGUA)/html-single/hgbook.html: build/$(LINGUA)/source/hgbook.xml stylesheets/html-single.xsl stylesheets/$(LINGUA)/html-single.xsl | |
160 mkdir -p build/$(LINGUA)/html-single/images | |
161 cp en/images/*.png build/$(LINGUA)/html-single/images | |
162 cp stylesheets/hgbook.css build/$(LINGUA)/html-single | |
163 xsltproc --output build/$(LINGUA)/html-single/hgbook.html \ | |
164 stylesheets/$(LINGUA)/html-single.xsl build/$(LINGUA)/source/hgbook.xml | |
165 endif | |
166 | |
167 ifndef LINGUA | |
168 pdf: | |
169 for l in $(LANGUAGES); do \ | |
170 $(MAKE) $@ LINGUA=$$l; \ | |
171 done | |
172 else | |
173 pdf: build/$(LINGUA)/pdf/hgbook.pdf | |
174 | |
175 build/$(LINGUA)/pdf/hgbook.pdf: build/$(LINGUA)/source/hgbook.xml stylesheets/fo.xsl stylesheets/$(LINGUA)/fo.xsl | |
176 mkdir -p build/$(LINGUA)/pdf | |
177 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 \ | |
178 com.icl.saxon.StyleSheet \ | |
179 -x org.apache.xml.resolver.tools.ResolvingXMLReader \ | |
180 -y org.apache.xml.resolver.tools.ResolvingXMLReader \ | |
181 -r org.apache.xml.resolver.tools.CatalogResolver \ | |
182 -o build/$(LINGUA)/source/hgbook.fo \ | |
183 build/$(LINGUA)/source/hgbook.xml \ | |
184 stylesheets/$(LINGUA)/fo.xsl \ | |
185 fop1.extensions=1 | |
186 | |
187 (cd build/$(LINGUA)/source && ../../../tools/fop/fop.sh hgbook.fo ../pdf/hgbook.pdf) | |
188 endif | |
189 | |
190 en/images/%.png: en/images/%.svg | |
191 inkscape -D -d 120 -e $@ $< | |
192 | |
193 en/images/%.svg: en/images/%.dot | |
194 dot -Tsvg -o $@ $< |