hgbook

view en/Makefile @ 124:c9aad709bd3a

Document the backout command.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Dec 26 13:08:20 2006 -0800 (2006-12-26)
parents 3af28630fe8c
children 153efeaa8f57
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 daily.copy \
53 daily.files \
54 daily.rename \
55 daily.revert \
56 hook.msglen \
57 hook.simple \
58 hook.ws \
59 mq.guards \
60 mq.qinit-help \
61 mq.dodiff \
62 mq.id \
63 mq.tarball \
64 mq.tools \
65 mq.tutorial \
66 rollback \
67 template.simple \
68 template.svnstyle \
69 tour \
70 tour-merge-conflict
72 latex-options = \
73 -interaction batchmode \
74 -output-directory $(dir $(1)) \
75 -jobname $(basename $(notdir $(1)))
77 all: pdf html
79 pdf: pdf/hgbook.pdf
81 define pdf
82 mkdir -p $(dir $@)
83 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
84 cp 99book.bib $(dir $@)
85 cd $(dir $@) && bibtex $(basename $(notdir $@))
86 cd $(dir $@) && makeindex $(basename $(notdir $@))
87 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
88 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
89 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
90 endef
92 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
94 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
95 $(call pdf)
97 html: html/onepage/hgbook.html html/split/hgbook.html
99 # This is a horrible hack to work around the fact that the htlatex
100 # command in tex4ht is itself a horrible hack. I really don't want to
101 # include verbatim the big wad of TeX that is repeated in that script,
102 # so instead I mangle the script itself.
104 define htlatex
105 mkdir -p $(dir $(1))
106 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
107 cp 99book.bib $(dir $@)
108 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
109 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
110 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
111 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
112 chmod 755 $(dir $(1))/htlatex.book
113 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
114 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
115 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
116 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
117 endef
119 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
121 html/onepage/hgbook.html: $(sources) $(image-html) examples
122 $(call htlatex,$@,$<)
123 cp $(image-sources:%.svg=%.png) $(dir $@)
125 html/split/hgbook.html: $(sources) $(image-html) examples
126 $(call htlatex,$@,$<,2)
127 cp $(image-sources:%.svg=%.png) $(dir $@)
129 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
131 beta/%.tex: %.tex
132 ./fblinks $(hg_id) $(dir $@) $<
134 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
135 $(call pdf)
137 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
138 $(call htlatex,$@,$<)
139 cp $(image-sources:%.svg=%.png) $(dir $@)
141 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
142 $(call htlatex,$@,$<,2)
143 cp $(image-sources:%.svg=%.png) $(dir $@)
145 # Produce 90dpi PNGs for the web.
147 %.png: %.svg
148 inkscape -D -e $@ $<
150 %.svg: %.dot
151 dot -Tsvg -o $@ $<
153 # Produce eps & pdf for the pdf
155 %.pdf: %.eps
156 epstopdf $<
158 %.eps: %.svg
159 inkscape -E $@ $<
161 %.eps: %.dot
162 dot -Tps -o $@ $<
164 examples: examples/.run
166 examples/.run: $(example-sources:%=examples/%.run)
167 touch examples/.run
169 examples/%.run: examples/% examples/run-example
170 cd examples && ./run-example $(notdir $<)
172 build_id.tex: $(wildcard ../.hg/00changelog.[id])
173 echo -n $(hg_id) > build_id.tex
175 clean:
176 rm -rf beta html pdf \
177 $(image-dot:%.dot=%.pdf) \
178 $(image-dot:%.dot=%.png) \
179 $(image-svg:%.svg=%.pdf) \
180 $(image-svg:%.svg=%.png) \
181 examples/*.{out,run} examples/.run build_id.tex