hgbook

view en/Makefile @ 146:65f6f9d18fa1

Oops! I forgot that I need the undoctored output files in the book!
Now they're named "*.lxo", instead of "*.out". Ugh.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Mar 06 21:55:48 2007 -0800 (2007-03-06)
parents 1e013fbe35f7
children 16f02802f448
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 cmdref.tex \
11 concepts.tex \
12 daily.tex \
13 filenames.tex \
14 hook.tex \
15 intro.tex \
16 mq.tex \
17 mq-collab.tex \
18 mq-ref.tex \
19 preface.tex \
20 srcinstall.tex \
21 template.tex \
22 tour-basic.tex \
23 tour-merge.tex \
24 undo.tex
26 image-sources := \
27 filelog.svg \
28 kdiff3.png \
29 metadata.svg \
30 mq-stack.svg \
31 revlog.svg \
32 snapshot.svg \
33 tour-history.svg \
34 tour-merge-conflict.svg \
35 tour-merge-merge.svg \
36 tour-merge-pull.svg \
37 tour-merge-sep-repos.svg \
38 undo-manual.dot \
39 undo-manual-merge.dot \
40 undo-non-tip.dot \
41 undo-simple.dot \
42 wdir.svg \
43 wdir-after-commit.svg \
44 wdir-branch.svg \
45 wdir-merge.svg \
46 wdir-pre-branch.svg
48 image-dot := $(filter %.dot,$(image-sources))
49 image-svg := $(filter %.svg,$(image-sources))
50 image-png := $(filter %.png,$(image-sources))
52 example-sources := \
53 backout \
54 bisect \
55 cmdref \
56 daily.copy \
57 daily.files \
58 daily.rename \
59 daily.revert \
60 filenames \
61 hook.msglen \
62 hook.simple \
63 hook.ws \
64 mq.guards \
65 mq.qinit-help \
66 mq.dodiff \
67 mq.id \
68 mq.tarball \
69 mq.tools \
70 mq.tutorial \
71 rollback \
72 template.simple \
73 template.svnstyle \
74 tour \
75 tour-merge-conflict
77 latex-options = \
78 -interaction batchmode \
79 -output-directory $(dir $(1)) \
80 -jobname $(basename $(notdir $(1)))
82 all: pdf html
84 pdf: pdf/hgbook.pdf
86 define pdf
87 mkdir -p $(dir $@)
88 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
89 cp 99book.bib $(dir $@)
90 cd $(dir $@) && bibtex $(basename $(notdir $@))
91 cd $(dir $@) && makeindex $(basename $(notdir $@))
92 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
93 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
94 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
95 endef
97 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
99 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
100 $(call pdf)
102 html: html/onepage/hgbook.html html/split/hgbook.html
104 # This is a horrible hack to work around the fact that the htlatex
105 # command in tex4ht is itself a horrible hack. I really don't want to
106 # include verbatim the big wad of TeX that is repeated in that script,
107 # so instead I mangle the script itself.
109 define htlatex
110 mkdir -p $(dir $(1))
111 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
112 cp 99book.bib $(dir $@)
113 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
114 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
115 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
116 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
117 chmod 755 $(dir $(1))/htlatex.book
118 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
119 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
120 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
121 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
122 endef
124 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
126 html/onepage/hgbook.html: $(sources) $(image-html) examples
127 $(call htlatex,$@,$<)
128 cp $(image-sources:%.svg=%.png) $(dir $@)
130 html/split/hgbook.html: $(sources) $(image-html) examples
131 $(call htlatex,$@,$<,2)
132 cp $(image-sources:%.svg=%.png) $(dir $@)
134 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
136 beta/%.tex: %.tex
137 ./fblinks $(hg_id) $(dir $@) $<
139 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
140 $(call pdf)
142 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
143 $(call htlatex,$@,$<)
144 cp $(image-sources:%.svg=%.png) $(dir $@)
146 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
147 $(call htlatex,$@,$<,2)
148 cp $(image-sources:%.svg=%.png) $(dir $@)
150 # Produce 90dpi PNGs for the web.
152 %.png: %.svg
153 inkscape -D -e $@ $<
155 %.svg: %.dot
156 dot -Tsvg -o $@ $<
158 # Produce eps & pdf for the pdf
160 %.pdf: %.eps
161 epstopdf $<
163 %.eps: %.svg
164 inkscape -E $@ $<
166 %.eps: %.dot
167 dot -Tps -o $@ $<
169 examples: examples/.run
171 examples/.run: $(example-sources:%=examples/%.run)
172 touch examples/.run
174 examples/%.run: examples/% examples/run-example
175 cd examples && ./run-example $(notdir $<)
177 build_id.tex: $(wildcard ../.hg/00changelog.[id])
178 echo -n $(hg_id) > build_id.tex
180 clean:
181 rm -rf beta html pdf \
182 $(image-dot:%.dot=%.pdf) \
183 $(image-dot:%.dot=%.png) \
184 $(image-svg:%.svg=%.pdf) \
185 $(image-svg:%.svg=%.png) \
186 examples/*.{lxo,run} examples/.run build_id.tex