hgbook

view en/Makefile @ 121:9094c9fda8ec

Start chapter on error recovery.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Nov 15 15:59:41 2006 -0800 (2006-11-15)
parents 1ee53cb37a99
children 3af28630fe8c
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 wdir.svg \
37 wdir-after-commit.svg \
38 wdir-branch.svg \
39 wdir-merge.svg \
40 wdir-pre-branch.svg
42 image-svg := $(filter %.svg,$(image-sources))
44 example-sources := \
45 daily.copy \
46 daily.files \
47 daily.rename \
48 hook.msglen \
49 hook.simple \
50 hook.ws \
51 mq.guards \
52 mq.qinit-help \
53 mq.dodiff \
54 mq.id \
55 mq.tarball \
56 mq.tools \
57 mq.tutorial \
58 rollback \
59 template.simple \
60 template.svnstyle \
61 tour \
62 tour-merge-conflict
64 latex-options = \
65 -interaction batchmode \
66 -output-directory $(dir $(1)) \
67 -jobname $(basename $(notdir $(1)))
69 all: pdf html
71 pdf: pdf/hgbook.pdf
73 define pdf
74 mkdir -p $(dir $@)
75 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
76 cp 99book.bib $(dir $@)
77 cd $(dir $@) && bibtex $(basename $(notdir $@))
78 cd $(dir $@) && makeindex $(basename $(notdir $@))
79 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
80 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
81 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
82 endef
84 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
85 $(call pdf)
87 html: html/onepage/hgbook.html html/split/hgbook.html
89 # This is a horrible hack to work around the fact that the htlatex
90 # command in tex4ht is itself a horrible hack. I really don't want to
91 # include verbatim the big wad of TeX that is repeated in that script,
92 # so instead I mangle the script itself.
94 define htlatex
95 mkdir -p $(dir $(1))
96 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
97 cp 99book.bib $(dir $@)
98 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
99 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
100 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
101 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
102 chmod 755 $(dir $(1))/htlatex.book
103 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
104 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
105 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
106 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
107 endef
109 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
110 $(call htlatex,$@,$<)
111 cp $(image-sources:%.svg=%.png) $(dir $@)
113 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
114 $(call htlatex,$@,$<,2)
115 cp $(image-sources:%.svg=%.png) $(dir $@)
117 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
119 beta/%.tex: %.tex
120 ./fblinks $(hg_id) $(dir $@) $<
122 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
123 $(call pdf)
125 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
126 $(call htlatex,$@,$<)
127 cp $(image-sources:%.svg=%.png) $(dir $@)
129 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
130 $(call htlatex,$@,$<,2)
131 cp $(image-sources:%.svg=%.png) $(dir $@)
133 # Produce 90dpi PNGs for the web.
135 %.png: %.svg
136 inkscape -D -e $@ $<
138 # Produce eps & pdf for the pdf
140 %.pdf: %.eps
141 epstopdf $<
143 %.eps: %.svg
144 inkscape -E $@ $<
146 examples: examples/.run
148 examples/.run: $(example-sources:%=examples/%.run)
149 touch examples/.run
151 examples/%.run: examples/% examples/run-example
152 cd examples && ./run-example $(notdir $<)
154 build_id.tex: $(wildcard ../.hg/00changelog.[id])
155 echo -n $(hg_id) > build_id.tex
157 clean:
158 rm -rf beta html pdf \
159 $(image-svg:%.svg=%.pdf) \
160 $(image-svg:%.svg=%.png) \
161 examples/*.{out,run} examples/.run build_id.tex