hgbook

view en/Makefile @ 131:153efeaa8f57

Fix stupid build bugs.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu Dec 28 14:10:23 2006 -0800 (2006-12-28)
parents c9aad709bd3a
children e1e2f3e0256a
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg parents --template '{node|short}\n')
5 sources := \
6 00book.tex \
7 99book.bib \
8 99defs.tex \
9 build_id.tex \
10 concepts.tex \
11 daily.tex \
12 hook.tex \
13 intro.tex \
14 mq.tex \
15 mq-collab.tex \
16 mq-ref.tex \
17 preface.tex \
18 srcinstall.tex \
19 template.tex \
20 tour-basic.tex \
21 tour-merge.tex \
22 undo.tex
24 image-sources := \
25 filelog.svg \
26 kdiff3.png \
27 metadata.svg \
28 mq-stack.svg \
29 revlog.svg \
30 snapshot.svg \
31 tour-history.svg \
32 tour-merge-conflict.svg \
33 tour-merge-merge.svg \
34 tour-merge-pull.svg \
35 tour-merge-sep-repos.svg \
36 undo-manual.dot \
37 undo-manual-merge.dot \
38 undo-non-tip.dot \
39 undo-simple.dot \
40 wdir.svg \
41 wdir-after-commit.svg \
42 wdir-branch.svg \
43 wdir-merge.svg \
44 wdir-pre-branch.svg
46 image-dot := $(filter %.dot,$(image-sources))
47 image-svg := $(filter %.svg,$(image-sources))
48 image-png := $(filter %.png,$(image-sources))
50 example-sources := \
51 backout \
52 bisect \
53 daily.copy \
54 daily.files \
55 daily.rename \
56 daily.revert \
57 hook.msglen \
58 hook.simple \
59 hook.ws \
60 mq.guards \
61 mq.qinit-help \
62 mq.dodiff \
63 mq.id \
64 mq.tarball \
65 mq.tools \
66 mq.tutorial \
67 rollback \
68 template.simple \
69 template.svnstyle \
70 tour \
71 tour-merge-conflict
73 latex-options = \
74 -interaction batchmode \
75 -output-directory $(dir $(1)) \
76 -jobname $(basename $(notdir $(1)))
78 all: pdf html
80 pdf: pdf/hgbook.pdf
82 define pdf
83 mkdir -p $(dir $@)
84 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
85 cp 99book.bib $(dir $@)
86 cd $(dir $@) && bibtex $(basename $(notdir $@))
87 cd $(dir $@) && makeindex $(basename $(notdir $@))
88 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
89 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
90 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
91 endef
93 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
95 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
96 $(call pdf)
98 html: html/onepage/hgbook.html html/split/hgbook.html
100 # This is a horrible hack to work around the fact that the htlatex
101 # command in tex4ht is itself a horrible hack. I really don't want to
102 # include verbatim the big wad of TeX that is repeated in that script,
103 # so instead I mangle the script itself.
105 define htlatex
106 mkdir -p $(dir $(1))
107 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
108 cp 99book.bib $(dir $@)
109 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
110 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
111 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
112 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
113 chmod 755 $(dir $(1))/htlatex.book
114 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
115 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
116 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
117 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
118 endef
120 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
122 html/onepage/hgbook.html: $(sources) $(image-html) examples
123 $(call htlatex,$@,$<)
124 cp $(image-sources:%.svg=%.png) $(dir $@)
126 html/split/hgbook.html: $(sources) $(image-html) examples
127 $(call htlatex,$@,$<,2)
128 cp $(image-sources:%.svg=%.png) $(dir $@)
130 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
132 beta/%.tex: %.tex
133 ./fblinks $(hg_id) $(dir $@) $<
135 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
136 $(call pdf)
138 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
139 $(call htlatex,$@,$<)
140 cp $(image-sources:%.svg=%.png) $(dir $@)
142 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
143 $(call htlatex,$@,$<,2)
144 cp $(image-sources:%.svg=%.png) $(dir $@)
146 # Produce 90dpi PNGs for the web.
148 %.png: %.svg
149 inkscape -D -e $@ $<
151 %.svg: %.dot
152 dot -Tsvg -o $@ $<
154 # Produce eps & pdf for the pdf
156 %.pdf: %.eps
157 epstopdf $<
159 %.eps: %.svg
160 inkscape -E $@ $<
162 %.eps: %.dot
163 dot -Tps -o $@ $<
165 examples: examples/.run
167 examples/.run: $(example-sources:%=examples/%.run)
168 touch examples/.run
170 examples/%.run: examples/% examples/run-example
171 cd examples && ./run-example $(notdir $<)
173 build_id.tex: $(wildcard ../.hg/00changelog.[id])
174 echo -n $(hg_id) > build_id.tex
176 clean:
177 rm -rf beta html pdf \
178 $(image-dot:%.dot=%.pdf) \
179 $(image-dot:%.dot=%.png) \
180 $(image-svg:%.svg=%.pdf) \
181 $(image-svg:%.svg=%.png) \
182 examples/*.{out,run} examples/.run build_id.tex