hgbook

view en/Makefile @ 177:c54f4c106fd5

Record the version of Mercurial used.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Mar 28 23:01:57 2007 -0700 (2007-03-28)
parents 5f305adeb584
children 5fc4a45c069f
line source
1 # This makefile requires GNU make.
3 sources := \
4 00book.tex \
5 99book.bib \
6 99defs.tex \
7 build_id.tex \
8 cmdref.tex \
9 collab.tex \
10 concepts.tex \
11 daily.tex \
12 filenames.tex \
13 hg_id.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 note.png \
32 revlog.svg \
33 snapshot.svg \
34 tour-history.svg \
35 tour-merge-conflict.svg \
36 tour-merge-merge.svg \
37 tour-merge-pull.svg \
38 tour-merge-sep-repos.svg \
39 undo-manual.dot \
40 undo-manual-merge.dot \
41 undo-non-tip.dot \
42 undo-simple.dot \
43 wdir.svg \
44 wdir-after-commit.svg \
45 wdir-branch.svg \
46 wdir-merge.svg \
47 wdir-pre-branch.svg
49 image-dot := $(filter %.dot,$(image-sources))
50 image-svg := $(filter %.svg,$(image-sources))
51 image-png := $(filter %.png,$(image-sources))
53 example-sources := \
54 backout \
55 bisect \
56 cmdref \
57 daily.copy \
58 daily.files \
59 daily.rename \
60 daily.revert \
61 filenames \
62 hook.msglen \
63 hook.simple \
64 hook.ws \
65 issue29 \
66 mq.guards \
67 mq.qinit-help \
68 mq.dodiff \
69 mq.id \
70 mq.tarball \
71 mq.tools \
72 mq.tutorial \
73 rename.divergent \
74 rollback \
75 template.simple \
76 template.svnstyle \
77 tour \
78 tour-merge-conflict
80 example-prereqs := \
81 /usr/bin/merge
83 dist-sources := \
84 ../html/hgicon.png \
85 ../html/index.html.var \
86 ../html/index.en.html
88 latex-options = \
89 -interaction batchmode \
90 -output-directory $(dir $(1)) \
91 -jobname $(basename $(notdir $(1)))
93 hg = $(shell which hg)
95 hg-id = $(shell hg parents --template '{node|short}\n')
97 hg-version = $(shell hg version -q | \
98 sed 's,.*(version \(unknown\|[a-f0-9]*\)),\1,')
100 all: pdf html
102 pdf: pdf/hgbook.pdf
104 define pdf
105 mkdir -p $(dir $@)
106 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
107 cp 99book.bib $(dir $@)
108 cd $(dir $@) && bibtex $(basename $(notdir $@))
109 cd $(dir $@) && makeindex $(basename $(notdir $@))
110 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
111 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
112 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
113 endef
115 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
117 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
118 $(call pdf)
120 html: onepage split
122 htlatex := /usr/bin/htlatex
124 onepage: $(htlatex) html/onepage/hgbook.html
126 split: $(htlatex) html/split/hgbook.html
128 # This is a horrible hack to work around the fact that the htlatex
129 # command in tex4ht is itself a horrible hack. I really don't want to
130 # include verbatim the big wad of TeX that is repeated in that script,
131 # but I've given up and run a hacked copy as htlatex.book here.
133 define htlatex
134 mkdir -p $(dir $(1))
135 cp 99book.bib $(dir $(1))
136 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
137 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
138 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
139 ./fixhtml.py $(dir $(1))/*.html
140 endef
142 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
144 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
145 $(call htlatex,$@,$<)
146 cp $(image-sources:%.svg=%.png) $(dir $@)
147 cp hgbook.css $(dir $@)
149 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
150 $(call htlatex,$@,$<,2)
151 cp $(image-sources:%.svg=%.png) $(dir $@)
152 cp hgbook.css $(dir $@)
154 # Produce 90dpi PNGs for the web.
156 %.png: %.svg
157 inkscape -D -e $@ $<
159 %.svg: %.dot
160 dot -Tsvg -o $@ $<
162 # Produce eps & pdf for the pdf
164 %.pdf: %.eps
165 epstopdf $<
167 %.eps: %.svg
168 inkscape -E $@ $<
170 %.eps: %.dot
171 dot -Tps -o $@ $<
173 examples: $(example-prereqs) examples/.run
175 examples/.run: $(example-sources:%=examples/%.run)
176 touch examples/.run
178 examples/%.run: examples/% examples/run-example
179 cd examples && ./run-example $(notdir $<)
181 build_id.tex: $(wildcard ../.hg/00changelog.[id])
182 echo -n $(hg-id) > build_id.tex
184 hg_id.tex: $(hg)
185 echo -n $(hg-version) > hg_id.tex
187 clean:
188 rm -rf dist html pdf \
189 $(image-dot:%.dot=%.pdf) \
190 $(image-dot:%.dot=%.png) \
191 $(image-svg:%.svg=%.pdf) \
192 $(image-svg:%.svg=%.png) \
193 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
195 install: pdf split $(dist-sources)
196 rm -rf dist
197 mkdir -p dist
198 cp pdf/hgbook.pdf dist
199 cp html/split/*.{css,html,png} dist
200 cp $(dist-sources) dist
202 rsync: install
203 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook