hgbook

view en/Makefile @ 179:5fc4a45c069f

Continue documentation of collaboration models.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri Mar 30 23:05:28 2007 -0700 (2007-03-30)
parents c54f4c106fd5
children 404e7951dd04 b60e2de6dbc3
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 feature-branches.dot \
28 filelog.svg \
29 kdiff3.png \
30 metadata.svg \
31 mq-stack.svg \
32 note.png \
33 revlog.svg \
34 snapshot.svg \
35 tour-history.svg \
36 tour-merge-conflict.svg \
37 tour-merge-merge.svg \
38 tour-merge-pull.svg \
39 tour-merge-sep-repos.svg \
40 undo-manual.dot \
41 undo-manual-merge.dot \
42 undo-non-tip.dot \
43 undo-simple.dot \
44 wdir.svg \
45 wdir-after-commit.svg \
46 wdir-branch.svg \
47 wdir-merge.svg \
48 wdir-pre-branch.svg
50 image-dot := $(filter %.dot,$(image-sources))
51 image-svg := $(filter %.svg,$(image-sources))
52 image-png := $(filter %.png,$(image-sources))
54 example-sources := \
55 backout \
56 bisect \
57 branching \
58 cmdref \
59 daily.copy \
60 daily.files \
61 daily.rename \
62 daily.revert \
63 filenames \
64 hook.msglen \
65 hook.simple \
66 hook.ws \
67 issue29 \
68 mq.guards \
69 mq.qinit-help \
70 mq.dodiff \
71 mq.id \
72 mq.tarball \
73 mq.tools \
74 mq.tutorial \
75 rename.divergent \
76 rollback \
77 template.simple \
78 template.svnstyle \
79 tour \
80 tour-merge-conflict
82 example-prereqs := \
83 /usr/bin/merge
85 dist-sources := \
86 ../html/hgicon.png \
87 ../html/index.html.var \
88 ../html/index.en.html
90 latex-options = \
91 -interaction batchmode \
92 -output-directory $(dir $(1)) \
93 -jobname $(basename $(notdir $(1)))
95 hg = $(shell which hg)
97 hg-id = $(shell hg parents --template '{node|short}\n')
99 hg-version = $(shell hg version -q | \
100 sed 's,.*(version \(unknown\|[a-f0-9]*\)),\1,')
102 all: pdf html
104 pdf: pdf/hgbook.pdf
106 define pdf
107 mkdir -p $(dir $@)
108 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
109 cp 99book.bib $(dir $@)
110 cd $(dir $@) && bibtex $(basename $(notdir $@))
111 cd $(dir $@) && makeindex $(basename $(notdir $@))
112 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
113 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
114 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
115 endef
117 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
119 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
120 $(call pdf)
122 html: onepage split
124 htlatex := /usr/bin/htlatex
126 onepage: $(htlatex) html/onepage/hgbook.html
128 split: $(htlatex) html/split/hgbook.html
130 # This is a horrible hack to work around the fact that the htlatex
131 # command in tex4ht is itself a horrible hack. I really don't want to
132 # include verbatim the big wad of TeX that is repeated in that script,
133 # but I've given up and run a hacked copy as htlatex.book here.
135 define htlatex
136 mkdir -p $(dir $(1))
137 cp 99book.bib $(dir $(1))
138 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
139 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
140 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
141 ./fixhtml.py $(dir $(1))/*.html
142 endef
144 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
146 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
147 $(call htlatex,$@,$<)
148 cp $(image-sources:%.svg=%.png) $(dir $@)
149 cp hgbook.css $(dir $@)
151 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
152 $(call htlatex,$@,$<,2)
153 cp $(image-sources:%.svg=%.png) $(dir $@)
154 cp hgbook.css $(dir $@)
156 # Produce 90dpi PNGs for the web.
158 %.png: %.svg
159 inkscape -D -e $@ $<
161 %.svg: %.dot
162 dot -Tsvg -o $@ $<
164 # Produce eps & pdf for the pdf
166 %.pdf: %.eps
167 epstopdf $<
169 %.eps: %.svg
170 inkscape -E $@ $<
172 %.eps: %.dot
173 dot -Tps -o $@ $<
175 examples: $(example-prereqs) examples/.run
177 examples/.run: $(example-sources:%=examples/%.run)
178 touch examples/.run
180 examples/%.run: examples/% examples/run-example
181 cd examples && ./run-example $(notdir $<)
183 build_id.tex: $(wildcard ../.hg/00changelog.[id])
184 echo -n $(hg-id) > build_id.tex
186 hg_id.tex: $(hg)
187 echo -n $(hg-version) > hg_id.tex
189 clean:
190 rm -rf dist html pdf \
191 $(image-dot:%.dot=%.pdf) \
192 $(image-dot:%.dot=%.png) \
193 $(image-svg:%.svg=%.pdf) \
194 $(image-svg:%.svg=%.png) \
195 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
197 install: pdf split $(dist-sources)
198 rm -rf dist
199 mkdir -p dist
200 cp pdf/hgbook.pdf dist
201 cp html/split/*.{css,html,png} dist
202 cp $(dist-sources) dist
204 rsync: install
205 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook