hgbook

view en/Makefile @ 122:3af28630fe8c

How to goodbye depression by reverting one thousand times daily.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Nov 15 16:57:29 2006 -0800 (2006-11-15)
parents 9094c9fda8ec
children c9aad709bd3a
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 daily.revert \
49 hook.msglen \
50 hook.simple \
51 hook.ws \
52 mq.guards \
53 mq.qinit-help \
54 mq.dodiff \
55 mq.id \
56 mq.tarball \
57 mq.tools \
58 mq.tutorial \
59 rollback \
60 template.simple \
61 template.svnstyle \
62 tour \
63 tour-merge-conflict
65 latex-options = \
66 -interaction batchmode \
67 -output-directory $(dir $(1)) \
68 -jobname $(basename $(notdir $(1)))
70 all: pdf html
72 pdf: pdf/hgbook.pdf
74 define pdf
75 mkdir -p $(dir $@)
76 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
77 cp 99book.bib $(dir $@)
78 cd $(dir $@) && bibtex $(basename $(notdir $@))
79 cd $(dir $@) && makeindex $(basename $(notdir $@))
80 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
81 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
82 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
83 endef
85 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
86 $(call pdf)
88 html: html/onepage/hgbook.html html/split/hgbook.html
90 # This is a horrible hack to work around the fact that the htlatex
91 # command in tex4ht is itself a horrible hack. I really don't want to
92 # include verbatim the big wad of TeX that is repeated in that script,
93 # so instead I mangle the script itself.
95 define htlatex
96 mkdir -p $(dir $(1))
97 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
98 cp 99book.bib $(dir $@)
99 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
100 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
101 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
102 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
103 chmod 755 $(dir $(1))/htlatex.book
104 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
105 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
106 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
107 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
108 endef
110 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
111 $(call htlatex,$@,$<)
112 cp $(image-sources:%.svg=%.png) $(dir $@)
114 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
115 $(call htlatex,$@,$<,2)
116 cp $(image-sources:%.svg=%.png) $(dir $@)
118 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
120 beta/%.tex: %.tex
121 ./fblinks $(hg_id) $(dir $@) $<
123 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
124 $(call pdf)
126 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
127 $(call htlatex,$@,$<)
128 cp $(image-sources:%.svg=%.png) $(dir $@)
130 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
131 $(call htlatex,$@,$<,2)
132 cp $(image-sources:%.svg=%.png) $(dir $@)
134 # Produce 90dpi PNGs for the web.
136 %.png: %.svg
137 inkscape -D -e $@ $<
139 # Produce eps & pdf for the pdf
141 %.pdf: %.eps
142 epstopdf $<
144 %.eps: %.svg
145 inkscape -E $@ $<
147 examples: examples/.run
149 examples/.run: $(example-sources:%=examples/%.run)
150 touch examples/.run
152 examples/%.run: examples/% examples/run-example
153 cd examples && ./run-example $(notdir $<)
155 build_id.tex: $(wildcard ../.hg/00changelog.[id])
156 echo -n $(hg_id) > build_id.tex
158 clean:
159 rm -rf beta html pdf \
160 $(image-svg:%.svg=%.pdf) \
161 $(image-svg:%.svg=%.png) \
162 examples/*.{out,run} examples/.run build_id.tex