comparison ja/Makefile @ 776:019040fbf5f5

merged to upstream: phase 1
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 21 Apr 2009 00:36:40 +0900
parents en/Makefile@3b33dd6aba87 en/Makefile@73aa295a40da
children 896ab6eaf1c6
comparison
equal deleted inserted replaced
389:5981a0f7540a 776:019040fbf5f5
1 # This makefile requires GNU make. 1 # This makefile requires GNU make.
2 2
3 sources := \ 3 image-sources := $(wildcard figs/*.dot figs/*.gif figs/*.png figs/*.svg)
4 00book.tex \ 4
5 99book.bib \ 5 xml-src-files := \
6 99defs.tex \ 6 00book.xml \
7 build_id.tex \ 7 app*.xml \
8 branch.tex \ 8 ch*.xml
9 cmdref.tex \
10 collab.tex \
11 concepts.tex \
12 daily.tex \
13 filenames.tex \
14 hg_id.tex \
15 hgext.tex \
16 hook.tex \
17 intro.tex \
18 mq.tex \
19 mq-collab.tex \
20 mq-ref.tex \
21 preface.tex \
22 srcinstall.tex \
23 template.tex \
24 tour-basic.tex \
25 tour-merge.tex \
26 undo.tex
27
28 image-sources := \
29 feature-branches.dot \
30 filelog.svg \
31 kdiff3.png \
32 metadata.svg \
33 mq-stack.svg \
34 note.png \
35 revlog.svg \
36 snapshot.svg \
37 tour-history.svg \
38 tour-merge-conflict.svg \
39 tour-merge-merge.svg \
40 tour-merge-pull.svg \
41 tour-merge-sep-repos.svg \
42 undo-manual.dot \
43 undo-manual-merge.dot \
44 undo-non-tip.dot \
45 undo-simple.dot \
46 wdir.svg \
47 wdir-after-commit.svg \
48 wdir-branch.svg \
49 wdir-merge.svg \
50 wdir-pre-branch.svg
51 9
52 image-dot := $(filter %.dot,$(image-sources)) 10 image-dot := $(filter %.dot,$(image-sources))
53 image-svg := $(filter %.svg,$(image-sources)) 11 image-svg := $(filter %.svg,$(image-sources))
54 image-png := $(filter %.png,$(image-sources)) 12 image-oth := $(filter %.gif %.png,$(image-sources))
55 13
56 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png) 14 obj-web := html
57 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png) 15 obj-websup := $(obj-web)/support
58 #image-eps := $(image-dot:%.dot=%.eps) $(image-svg:%.svg=%.eps) $(image-png) 16 obj-web-read := $(obj-web)/read
59 image-eps := $(image-dot:%.dot=%.eps) $(image-svg:%.svg=%.eps) $(image-png:%.png=%.eps) 17
60 18 image-web := \
61 example-sources := \ 19 $(image-dot:%.dot=$(obj-web-read)/%.png) \
20 $(image-svg:%.svg=$(obj-web-read)/%.png) \
21 $(image-oth:%=$(obj-web-read)/%)
22
23 example-sources-by-name := \
62 backout \ 24 backout \
63 bisect \ 25 bisect \
64 branching \ 26 branching \
65 branch-named \ 27 branch-named \
66 branch-repo \ 28 branch-repo \
88 template.simple \ 50 template.simple \
89 template.svnstyle \ 51 template.svnstyle \
90 tour \ 52 tour \
91 tour-merge-conflict 53 tour-merge-conflict
92 54
55 example-sources := \
56 $(example-sources-by-name:%=examples/%) \
57 $(wildcard examples/ch*/*)
58
59 extras-web-base := \
60 $(obj-web)/index.html \
61 $(obj-web)/robots.txt \
62 $(obj-websup)/form-min.js \
63 $(obj-websup)/form.js \
64 $(obj-websup)/hsbook.js \
65 $(obj-websup)/jquery-min.js \
66 $(obj-websup)/jquery.js \
67 $(obj-websup)/styles.css
68
69 extras-web := $(extras-web-base) $(extras-web-base:%=%.gz)
70
71 xsltproc := xsltproc
72 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
73
74 xmllint := xmllint
75 xmllint-opts := --noout --nonet --valid
76
77 system-xsl-dir := $(firstword $(wildcard \
78 /usr/share/sgml/docbook/xsl-stylesheets \
79 /usr/share/xml/docbook/stylesheet/nwalsh \
80 ))
81
82 # Bletcherousness.
83
84 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
85 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
86 else
87 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
88 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
89 else
90 $(error Do not know where to look for DocBook XML 4.4 DTD)
91 endif
92 endif
93
94 ifeq ($(system-xsl-dir),)
95 $(error add a suitable directory to system-xsl-dir)
96 endif
97
93 example-prereqs := \ 98 example-prereqs := \
94 /usr/bin/merge 99 /usr/bin/merge
95 100
96 dist-sources := \ 101 dist-sources := \
97 ../html/hgicon.png \ 102 ../html/hgicon.png \
98 ../html/index.html.var \ 103 ../html/index.html.var \
99 ../html/index.en.html 104 ../html/index.en.html
100 105
101 latex-options = \
102 -interaction batchmode \
103 -output-directory $(dir $(1)) \
104 -jobname $(basename $(notdir $(1)))
105
106 hg = $(shell which hg) 106 hg = $(shell which hg)
107 107
108 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n') 108 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
109 109
110 hg-version = $(shell hg version -q | \ 110 hg-version = $(shell hg version -q | \
111 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,') 111 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
112 112
113 all: dvi 113 all: web complete.xml
114 114
115 #dvi: $(sources) $(image-eps) examples 115 ../stylesheets/system-xsl: $(system-xsl-dir)
116 dvi: $(sources) $(image-eps) 116 ln -s $< $@
117 platex 00book.tex 117
118 118 web: ../stylesheets/system-xsl websup html
119 cp 00book.aux hgbook.aux 119
120 bibtex hgbook 120 html: $(obj-web-read)/index.html
121 121
122 platex 00book.tex 122 ../web/index-read.html.in: ../web/genindex.py $(xml-src-files)
123 platex 00book.tex 123 cd ../web && ./genindex.py
124 platex 00book.tex 124
125 125 $(obj-web-read)/index.html: ../stylesheets/system-xsl .validated-00book.xml ../web/index-read.html.in
126 126 xsltproc $(xsltproc-opts) -o $(obj-web-read)/x ../stylesheets/chunk-stylesheet.xsl 00book.xml
127 127 python ../web/texpand.py ../web/index-read.html.in html/read/index.html
128 128 for i in $(obj-web-read)/*.html; do \
129 129 gzip -9 -c $$i > $$i.gz; \
130 130 done
131 pdf: pdf/hgbook.pdf 131
132 132 websup: $(extras-web) $(image-web)
133 define pdf 133 mkdir -p $(obj-websup)/figs $(obj-web-read)/figs
134 cp ../stylesheets/system-xsl/images/*.png $(obj-websup)/figs
135 cp -f ../web/icons/*.png $(obj-websup)/figs
136
137 complete.xml: .validated-00book.xml
138 $(xsltproc) $(xsltproc-opts) -o $@ ../stylesheets/dtd-profile.xsl 00book.xml
139
140 all-ids.dat: ../stylesheets/all-ids.xsl $(xml-src-files)
141 $(xsltproc) $(xsltproc-opts) -o $@ ../stylesheets/all-ids.xsl 00book.xml
142
143 web: websup
144
145 valid: .validated-00book.xml
146
147 .validated-00book.xml: $(xml-src-files) examples/.run
148 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
149 touch $@
150
151 # Produce 90dpi PNGs for the web.
152
153 $(obj-web-read)/figs/%.png: $(obj-web-read)/figs/%.svg fixsvg
134 mkdir -p $(dir $@) 154 mkdir -p $(dir $@)
135 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) 155 ./fixsvg $<
136 156 inkscape -D -e $@ $<-tmp.svg
137 cp 99book.bib $(dir $@) 157 rm $<-tmp.svg
138 158
139 cd $(dir $@) && bibtex $(basename $(notdir $@)) 159 $(obj-web-read)/figs/%.png: figs/%.svg fixsvg
140 cd $(dir $@) && makeindex $(basename $(notdir $@)) 160 mkdir -p $(dir $@)
141 161 ./fixsvg $<
142 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) 162 inkscape -D -e $@ $<-tmp.svg
143 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) 163 rm $<-tmp.svg
144 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi 164
145 endef 165 $(obj-web-read)/figs/%.gif: figs/%.gif
146 166 cp $< $@
147 #pdf/hgbook.pdf: $(sources) $(image-pdf) examples 167
148 pdf/hgbook.pdf: $(sources) $(image-pdf) 168 $(obj-web-read)/figs/%.png: figs/%.png
149 $(call pdf) 169 cp $< $@
150 170
151 html: onepage split 171 $(obj-web-read)/figs/%.svg: figs/%.dot
152 172 mkdir -p $(dir $@)
153 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
154
155 html/onepage/%: %
156 cp $< $@
157
158 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
159
160 html/split/%: %
161 cp $< $@
162
163 # This is a horrible hack to work around the fact that the htlatex
164 # command in tex4ht is itself a horrible hack. I really don't want to
165 # include verbatim the big wad of TeX that is repeated in that script,
166 # but I've given up and run a hacked copy as htlatex.book here.
167
168 define htlatex
169 mkdir -p $(dir $(1))
170 cp 99book.bib $(dir $(1))
171 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
172 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
173 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
174 ./fixhtml.py $(dir $(1))/*.html
175 rm $(dir $(1))/hgbook.css
176 endef
177
178 #html/onepage/hgbook.html: $(sources) $(image-html) examples bookhtml.cfg
179 html/onepage/hgbook.html: $(sources) $(image-html) bookhtml.cfg
180 $(call htlatex,$@,$<)
181
182 #html/split/hgbook.html: $(sources) examples bookhtml.cfg
183 html/split/hgbook.html: $(sources) bookhtml.cfg
184 $(call htlatex,$@,$<,2)
185
186 # Produce 90dpi PNGs for the web.
187
188 %.png: %.svg
189 inkscape -D -e $@ $<
190
191 %.svg: %.dot
192 dot -Tsvg -o $@ $< 173 dot -Tsvg -o $@ $<
193 174
194 # Produce eps & pdf for the pdf
195
196 %.pdf: %.eps
197 epstopdf $<
198
199 %.eps: %.svg
200 inkscape -E $@ $<
201
202 %.eps: %.dot
203 dot -Tps -o $@ $<
204
205 %.eps: %.png
206 convert $< ps:$@
207
208 examples: $(example-prereqs) examples/.run 175 examples: $(example-prereqs) examples/.run
209 176
210 examples/.run: $(example-sources:%=examples/%.run) 177 examples/.run: $(example-sources)
211 touch examples/.run 178 cd examples && ./run-example -a
212 179
213 examples/%.run: examples/% examples/run-example 180 examples/%.run: examples/% examples/run-example
214 cd examples && ./run-example $(notdir $<)
215
216 changelog := $(wildcard ../.hg/store/00changelog.[id])
217 ifeq ($(changelog),)
218 changelog := $(wildcard ../.hg/00changelog.[id])
219 endif
220
221 build_id.tex: $(changelog)
222 echo -n '$(hg-id)' > build_id.tex
223
224 hg_id.tex: $(hg)
225 echo -n '$(hg-version)' > hg_id.tex
226 181
227 clean: 182 clean:
228 rm -rf dist html pdf \ 183 -rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \
229 $(image-dot:%.dot=%.pdf) \ 184 $(image-svg:%.svg=%.png) examples/*.{lxo,run} examples/.run
230 $(image-dot:%.dot=%.png) \ 185
231 $(image-svg:%.svg=%.pdf) \ 186 install: html $(dist-sources)
232 $(image-svg:%.svg=%.png) \
233 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
234
235 install: pdf split $(dist-sources)
236 rm -rf dist 187 rm -rf dist
237 mkdir -p dist 188 mkdir -p dist
238 cp pdf/hgbook.pdf dist 189 cp html/*.{css,html,png} dist
239 cp html/split/*.{css,html,png} dist
240 cp $(dist-sources) dist 190 cp $(dist-sources) dist
241 191
192 rsync: install
193 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
194
195 vpath %.css ../web
196 vpath %.html.in ../web
197 vpath %.js ../web/javascript
198
199 $(obj-websup)/%.css: %.css
200 @mkdir -p $(dir $@)
201 cp $< $@
202
203 $(obj-websup)/%.jpg: %.jpg
204 @mkdir -p $(dir $@)
205 cp $< $@
206
207 $(obj-websup)/%.js: %.js
208 @mkdir -p $(dir $@)
209 cp $< $@
210
211 $(obj-web)/%: ../web/%
212 @mkdir -p $(dir $@)
213 cp $< $@
214
215 $(obj-web)/%.html: %.html.in
216 @mkdir -p $(dir $@)
217 python ../web/texpand.py $< $@
218
219 %.gz: %
220 gzip -9 -c $< > $@