hgbook

view en/Makefile @ 307:fb5c0d56d7f1

Fix test 'tour'.

Executing 'tour' test now creates some files in /tmp to store the
revision numbers as they are created on the fly and appear in the output
files. When SVG files are to be converted to PNG or EPS files within the
Makefile, a tool 'fixsvg' will be invoked to substitute some placeholder
markup by the real version number which fits to the test output, before
the final conversion takes place.
author Guido Ostkamp <hg@ostkamp.fastmail.fm>
date Wed Aug 20 22:15:35 2008 +0200 (2008-08-20)
parents dc3d42f3a288
children 028543f67bea
line source
1 # This makefile requires GNU make.
3 sources := \
4 00book.tex \
5 99book.bib \
6 99defs.tex \
7 build_id.tex \
8 branch.tex \
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
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
52 image-dot := $(filter %.dot,$(image-sources))
53 image-svg := $(filter %.svg,$(image-sources))
54 image-png := $(filter %.png,$(image-sources))
56 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
57 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
59 example-sources := \
60 backout \
61 bisect \
62 branching \
63 branch-named \
64 branch-repo \
65 cmdref \
66 daily.copy \
67 daily.files \
68 daily.rename \
69 daily.revert \
70 extdiff \
71 filenames \
72 hook.msglen \
73 hook.simple \
74 hook.ws \
75 issue29 \
76 mq.guards \
77 mq.qinit-help \
78 mq.dodiff \
79 mq.id \
80 mq.tarball \
81 mq.tools \
82 mq.tutorial \
83 rename.divergent \
84 rollback \
85 tag \
86 template.simple \
87 template.svnstyle \
88 tour \
89 tour-merge-conflict
91 example-prereqs := \
92 /usr/bin/merge
94 dist-sources := \
95 ../html/hgicon.png \
96 ../html/index.html.var \
97 ../html/index.en.html
99 latex-options = \
100 -interaction batchmode \
101 -output-directory $(dir $(1)) \
102 -jobname $(basename $(notdir $(1)))
104 hg = $(shell which hg)
106 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
108 hg-version = $(shell hg version -q | \
109 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
111 all: pdf html
113 pdf: pdf/hgbook.pdf
115 define pdf
116 mkdir -p $(dir $@)
117 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
118 cp 99book.bib $(dir $@)
119 cd $(dir $@) && bibtex $(basename $(notdir $@))
120 cd $(dir $@) && makeindex $(basename $(notdir $@))
121 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
122 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
123 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
124 endef
126 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
127 $(call pdf)
129 html: onepage split
131 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
133 html/onepage/%: %
134 cp $< $@
136 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
138 html/split/%: %
139 cp $< $@
141 # This is a horrible hack to work around the fact that the htlatex
142 # command in tex4ht is itself a horrible hack. I really don't want to
143 # include verbatim the big wad of TeX that is repeated in that script,
144 # but I've given up and run a hacked copy as htlatex.book here.
146 define htlatex
147 mkdir -p $(dir $(1))
148 cp 99book.bib $(dir $(1))
149 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
150 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
151 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
152 ./fixhtml.py $(dir $(1))/*.html
153 rm $(dir $(1))/hgbook.css
154 endef
156 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
157 $(call htlatex,$@,$<)
159 html/split/hgbook.html: $(sources) examples bookhtml.cfg
160 $(call htlatex,$@,$<,2)
162 # Produce 90dpi PNGs for the web.
164 %.png: %.svg
165 ./fixsvg $<
166 mv $<.tmp foobar.svg
167 inkscape -D -e $@ foobar.svg
169 %.svg: %.dot
170 dot -Tsvg -o $@ $<
172 # Produce eps & pdf for the pdf
174 %.pdf: %.eps
175 epstopdf $<
177 %.eps: %.svg
178 ./fixsvg $<
179 mv $<.tmp foobar.svg
180 inkscape -E $@ foobar.svg
182 %.eps: %.dot
183 dot -Tps -o $@ $<
185 examples: $(example-prereqs) examples/.run
187 examples/.run: $(example-sources:%=examples/%.run)
188 touch examples/.run
190 examples/%.run: examples/% examples/run-example
191 cd examples && ./run-example $(notdir $<)
193 changelog := $(wildcard ../.hg/store/00changelog.[id])
194 ifeq ($(changelog),)
195 changelog := $(wildcard ../.hg/00changelog.[id])
196 endif
198 build_id.tex: $(changelog)
199 echo -n '$(hg-id)' > build_id.tex
201 hg_id.tex: $(hg)
202 echo -n '$(hg-version)' > hg_id.tex
204 clean:
205 rm -rf dist html pdf \
206 $(image-dot:%.dot=%.pdf) \
207 $(image-dot:%.dot=%.png) \
208 $(image-svg:%.svg=%.pdf) \
209 $(image-svg:%.svg=%.png) \
210 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
212 install: pdf split $(dist-sources)
213 rm -rf dist
214 mkdir -p dist
215 cp pdf/hgbook.pdf dist
216 cp html/split/*.{css,html,png} dist
217 cp $(dist-sources) dist
219 rsync: install
220 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook