comparison Makefile @ 760:65b82a891cf7

Add epub format
author Dongsheng Song <dongsheng.song@gmail.com>
date Tue, 31 Mar 2009 11:04:18 +0800
parents 8d130de70ebe
children 605af0a90e3e
comparison
equal deleted inserted replaced
759:f7add9f718a8 760:65b82a891cf7
1 # 1 #
2 # Makefile for the hgbook, top-level 2 # Makefile for the hgbook, top-level
3 # 3 #
4 include Makefile.vars 4 include Makefile.vars
5 5
6 FORMATS=html html-single pdf 6 FORMATS=html html-single pdf epub
7 7
8 PO_LANGUAGES := zh 8 PO_LANGUAGES := zh
9 DBK_LANGUAGES := en 9 DBK_LANGUAGES := en
10 LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES) 10 LANGUAGES := $(DBK_LANGUAGES) $(PO_LANGUAGES)
11 11
12 UPDATEPO = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-updatepo -M UTF-8 \ 12 UPDATEPO = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-updatepo -M UTF-8 \
13 -f docbook -o doctype='docbook' -o includeexternal \ 13 -f docbook -o doctype=docbook -o includeexternal \
14 -o nodefault='<programlisting> <screen>' \ 14 -o nodefault="<programlisting> <screen>" \
15 -o untranslated='<programlisting> <screen>' 15 -o untranslated="<programlisting> <screen>"
16 TRANSLATE = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-translate -M UTF-8 \ 16 TRANSLATE = PERLLIB=$(PO4A_LIB) $(PO4A_HOME)/po4a-translate -M UTF-8 \
17 -f docbook -o doctype='docbook' \ 17 -f docbook -o doctype=docbook \
18 -k 0 18 -k 0
19 19
20 #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})') 20 #rev_id = $(shell hg parents --template '{node|short} ({date|isodate})')
21 rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})') 21 rev_id = $(shell hg parents --template '{node|short} ({date|shortdate})')
22 22
41 en/figs/wdir-merge.png \ 41 en/figs/wdir-merge.png \
42 en/figs/wdir.png \ 42 en/figs/wdir.png \
43 en/figs/wdir-pre-branch.png 43 en/figs/wdir-pre-branch.png
44 44
45 help: 45 help:
46 @echo " make epub [LINGUA=en|zh|...]"
46 @echo " make html [LINGUA=en|zh|...]" 47 @echo " make html [LINGUA=en|zh|...]"
47 @echo " make html-single [LINGUA=en|zh|...]" 48 @echo " make html-single [LINGUA=en|zh|...]"
48 @echo " make pdf [LINGUA=en|zh|...]" 49 @echo " make pdf [LINGUA=en|zh|...]"
49 @echo " make validate [LINGUA=en|zh|...] # always before commit!" 50 @echo " make validate [LINGUA=en|zh|...] # always before commit!"
50 @echo " make tidypo [LINGUA=zh|...] # always before commit!" 51 @echo " make tidypo [LINGUA=zh|...] # always before commit!"
117 $(MAKE) $@ LINGUA=$$l; \ 118 $(MAKE) $@ LINGUA=$$l; \
118 done 119 done
119 else 120 else
120 updatepo: 121 updatepo:
121 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" "" 122 ifneq "$(findstring $(LINGUA),$(PO_LANGUAGES))" ""
122 (cd po && $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po) 123 (cd po; \
124 $(UPDATEPO) -m ../en/00book.xml -p $(LINGUA).po; \
125 cat $(LINGUA).po | sed 's/&emdash;/—/' > $(LINGUA).po.tmp; \
126 mv $(LINGUA).po.tmp $(LINGUA).po \
127 )
123 $(MAKE) tidypo LINGUA=$(LINGUA) 128 $(MAKE) tidypo LINGUA=$(LINGUA)
124 endif 129 endif
125 endif 130 endif
126 131
127 ifndef LINGUA 132 ifndef LINGUA
138 (cd $(LINGUA)/examples; ./run-example -v -a) 143 (cd $(LINGUA)/examples; ./run-example -v -a)
139 144
140 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(images) $(LINGUA)/examples/.run $(images) 145 build/$(LINGUA)/source/hgbook.xml: $(wildcard $(LINGUA)/*.xml) $(images) $(LINGUA)/examples/.run $(images)
141 mkdir -p build/$(LINGUA)/source/figs 146 mkdir -p build/$(LINGUA)/source/figs
142 cp $(LINGUA)/figs/*.png build/$(LINGUA)/source/figs 147 cp $(LINGUA)/figs/*.png build/$(LINGUA)/source/figs
148 cp stylesheets/hgbook.css build/$(LINGUA)/source
143 (cd $(LINGUA); xmllint --nonet --noent --xinclude --postvalid --output ../$@.tmp 00book.xml) 149 (cd $(LINGUA); xmllint --nonet --noent --xinclude --postvalid --output ../$@.tmp 00book.xml)
144 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ 150 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
145 else 151 else
146 en/examples/.run: 152 en/examples/.run:
147 (cd en/examples; ./run-example -v -a) 153 (cd en/examples; ./run-example -v -a)
150 ${MAKE} LINGUA=en $@ 156 ${MAKE} LINGUA=en $@
151 157
152 build/$(LINGUA)/source/hgbook.xml: build/en/source/hgbook.xml po/$(LINGUA).po $(images) 158 build/$(LINGUA)/source/hgbook.xml: build/en/source/hgbook.xml po/$(LINGUA).po $(images)
153 mkdir -p build/$(LINGUA)/source/figs 159 mkdir -p build/$(LINGUA)/source/figs
154 cp en/figs/*.png build/$(LINGUA)/source/figs 160 cp en/figs/*.png build/$(LINGUA)/source/figs
161 cp stylesheets/hgbook.css build/$(LINGUA)/source
155 $(TRANSLATE) -m build/en/source/hgbook.xml -p po/$(LINGUA).po -l $@.tmp 162 $(TRANSLATE) -m build/en/source/hgbook.xml -p po/$(LINGUA).po -l $@.tmp
156 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@ 163 cat $@.tmp | sed 's/\$$rev_id\$$/${rev_id}/' > $@
157 endif 164 endif
158 165
166 endif
167
168 ifndef LINGUA
169 epub:
170 for l in $(LANGUAGES); do \
171 $(MAKE) $@ LINGUA=$$l; \
172 done
173 else
174 epub: build/$(LINGUA)/epub/hgbook.epub
175
176 build/$(LINGUA)/epub/hgbook.epub: build/$(LINGUA)/source/hgbook.xml
177 mkdir -p build/$(LINGUA)/epub
178 (cd build/$(LINGUA)/source; $(DB2EPUB) -c hgbook.css -v hgbook.xml; mv hgbook.epub ../epub)
159 endif 179 endif
160 180
161 ifndef LINGUA 181 ifndef LINGUA
162 html: 182 html:
163 for l in $(LANGUAGES); do \ 183 for l in $(LANGUAGES); do \