hgbook

view en/Makefile @ 117:6b0f4498569e

Beef up daily routine material. Focus on merge-across-copy.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Nov 14 15:11:22 2006 -0800 (2006-11-14)
parents b74102b56df5
children 1ee53cb37a99
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
23 image-sources := \
24 filelog.svg \
25 kdiff3.png \
26 metadata.svg \
27 mq-stack.svg \
28 revlog.svg \
29 snapshot.svg \
30 tour-history.svg \
31 tour-merge-conflict.svg \
32 tour-merge-merge.svg \
33 tour-merge-pull.svg \
34 tour-merge-sep-repos.svg \
35 wdir.svg \
36 wdir-after-commit.svg \
37 wdir-branch.svg \
38 wdir-merge.svg \
39 wdir-pre-branch.svg
41 image-svg := $(filter %.svg,$(image-sources))
43 example-sources := \
44 daily.copy \
45 daily.files \
46 hook.msglen \
47 hook.simple \
48 hook.ws \
49 mq.guards \
50 mq.qinit-help \
51 mq.dodiff \
52 mq.id \
53 mq.tarball \
54 mq.tools \
55 mq.tutorial \
56 template.simple \
57 template.svnstyle \
58 tour \
59 tour-merge-conflict
61 latex-options = \
62 -interaction batchmode \
63 -output-directory $(dir $(1)) \
64 -jobname $(basename $(notdir $(1)))
66 all: pdf html
68 pdf: pdf/hgbook.pdf
70 define pdf
71 mkdir -p $(dir $@)
72 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
73 cp 99book.bib $(dir $@)
74 cd $(dir $@) && bibtex $(basename $(notdir $@))
75 cd $(dir $@) && makeindex $(basename $(notdir $@))
76 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
77 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
78 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
79 endef
81 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
82 $(call pdf)
84 html: html/onepage/hgbook.html html/split/hgbook.html
86 # This is a horrible hack to work around the fact that the htlatex
87 # command in tex4ht is itself a horrible hack. I really don't want to
88 # include verbatim the big wad of TeX that is repeated in that script,
89 # so instead I mangle the script itself.
91 define htlatex
92 mkdir -p $(dir $(1))
93 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
94 cp 99book.bib $(dir $@)
95 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
96 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
97 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
98 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
99 chmod 755 $(dir $(1))/htlatex.book
100 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
101 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
102 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
103 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
104 endef
106 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
107 $(call htlatex,$@,$<)
108 cp $(image-sources:%.svg=%.png) $(dir $@)
110 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
111 $(call htlatex,$@,$<,2)
112 cp $(image-sources:%.svg=%.png) $(dir $@)
114 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
116 beta/%.tex: %.tex
117 ./fblinks $(hg_id) $(dir $@) $<
119 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
120 $(call pdf)
122 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
123 $(call htlatex,$@,$<)
124 cp $(image-sources:%.svg=%.png) $(dir $@)
126 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
127 $(call htlatex,$@,$<,2)
128 cp $(image-sources:%.svg=%.png) $(dir $@)
130 # Produce 90dpi PNGs for the web.
132 %.png: %.svg
133 inkscape -D -e $@ $<
135 # Produce eps & pdf for the pdf
137 %.pdf: %.eps
138 epstopdf $<
140 %.eps: %.svg
141 inkscape -E $@ $<
143 examples: examples/.run
145 examples/.run: $(example-sources:%=examples/%.run)
146 touch examples/.run
148 examples/%.run: examples/% examples/run-example
149 cd examples && ./run-example $(notdir $<)
151 build_id.tex: $(wildcard ../.hg/00changelog.[id])
152 echo -n $(hg_id) > build_id.tex
154 clean:
155 rm -rf beta html pdf \
156 $(image-svg:%.svg=%.pdf) \
157 $(image-svg:%.svg=%.png) \
158 examples/*.{out,run} examples/.run build_id.tex