hgbook

view en/Makefile @ 198:615f3c6b30e1

Start to describe branch management.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Apr 16 17:21:38 2007 -0700 (2007-04-16)
parents 4237e45506ee
children 6f167e644762
line source
1 # This makefile requires GNU make.
3 sources := \
4 00book.tex \
5 99book.bib \
6 99defs.tex \
7 build_id.tex \
8 branch.tex \
9 cmdref.tex \
10 collab.tex \
11 concepts.tex \
12 daily.tex \
13 filenames.tex \
14 hg_id.tex \
15 hook.tex \
16 intro.tex \
17 mq.tex \
18 mq-collab.tex \
19 mq-ref.tex \
20 preface.tex \
21 srcinstall.tex \
22 template.tex \
23 tour-basic.tex \
24 tour-merge.tex \
25 undo.tex
27 image-sources := \
28 feature-branches.dot \
29 filelog.svg \
30 kdiff3.png \
31 metadata.svg \
32 mq-stack.svg \
33 note.png \
34 revlog.svg \
35 snapshot.svg \
36 tour-history.svg \
37 tour-merge-conflict.svg \
38 tour-merge-merge.svg \
39 tour-merge-pull.svg \
40 tour-merge-sep-repos.svg \
41 undo-manual.dot \
42 undo-manual-merge.dot \
43 undo-non-tip.dot \
44 undo-simple.dot \
45 wdir.svg \
46 wdir-after-commit.svg \
47 wdir-branch.svg \
48 wdir-merge.svg \
49 wdir-pre-branch.svg
51 image-dot := $(filter %.dot,$(image-sources))
52 image-svg := $(filter %.svg,$(image-sources))
53 image-png := $(filter %.png,$(image-sources))
55 example-sources := \
56 backout \
57 bisect \
58 branching \
59 branch-repo \
60 cmdref \
61 daily.copy \
62 daily.files \
63 daily.rename \
64 daily.revert \
65 filenames \
66 hook.msglen \
67 hook.simple \
68 hook.ws \
69 issue29 \
70 mq.guards \
71 mq.qinit-help \
72 mq.dodiff \
73 mq.id \
74 mq.tarball \
75 mq.tools \
76 mq.tutorial \
77 rename.divergent \
78 rollback \
79 tag \
80 template.simple \
81 template.svnstyle \
82 tour \
83 tour-merge-conflict
85 example-prereqs := \
86 /usr/bin/merge
88 dist-sources := \
89 ../html/hgicon.png \
90 ../html/index.html.var \
91 ../html/index.en.html
93 latex-options = \
94 -interaction batchmode \
95 -output-directory $(dir $(1)) \
96 -jobname $(basename $(notdir $(1)))
98 hg = $(shell which hg)
100 hg-id = $(shell hg parents --template '{node|short} \(dated {date|isodate}\)\n')
102 hg-version = $(shell hg version -q | \
103 sed 's,.*(version \(unknown\|[a-f0-9]*\)),\1,')
105 all: pdf html
107 pdf: pdf/hgbook.pdf
109 define pdf
110 mkdir -p $(dir $@)
111 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
112 cp 99book.bib $(dir $@)
113 cd $(dir $@) && bibtex $(basename $(notdir $@))
114 cd $(dir $@) && makeindex $(basename $(notdir $@))
115 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
116 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
117 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
118 endef
120 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
122 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
123 $(call pdf)
125 html: onepage split
127 htlatex := /usr/bin/htlatex
129 onepage: $(htlatex) html/onepage/hgbook.html
131 split: $(htlatex) html/split/hgbook.html
133 # This is a horrible hack to work around the fact that the htlatex
134 # command in tex4ht is itself a horrible hack. I really don't want to
135 # include verbatim the big wad of TeX that is repeated in that script,
136 # but I've given up and run a hacked copy as htlatex.book here.
138 define htlatex
139 mkdir -p $(dir $(1))
140 cp 99book.bib $(dir $(1))
141 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
142 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
143 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
144 ./fixhtml.py $(dir $(1))/*.html
145 endef
147 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
149 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
150 $(call htlatex,$@,$<)
151 cp $(image-sources:%.svg=%.png) $(dir $@)
152 cp hgbook.css $(dir $@)
154 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
155 $(call htlatex,$@,$<,2)
156 cp $(image-sources:%.svg=%.png) $(dir $@)
157 cp hgbook.css $(dir $@)
159 # Produce 90dpi PNGs for the web.
161 %.png: %.svg
162 inkscape -D -e $@ $<
164 %.svg: %.dot
165 dot -Tsvg -o $@ $<
167 # Produce eps & pdf for the pdf
169 %.pdf: %.eps
170 epstopdf $<
172 %.eps: %.svg
173 inkscape -E $@ $<
175 %.eps: %.dot
176 dot -Tps -o $@ $<
178 examples: $(example-prereqs) examples/.run
180 examples/.run: $(example-sources:%=examples/%.run)
181 touch examples/.run
183 examples/%.run: examples/% examples/run-example
184 cd examples && ./run-example $(notdir $<)
186 build_id.tex: $(wildcard ../.hg/00changelog.[id])
187 echo -n $(hg-id) > build_id.tex
189 hg_id.tex: $(hg)
190 echo -n $(hg-version) > hg_id.tex
192 clean:
193 rm -rf dist html pdf \
194 $(image-dot:%.dot=%.pdf) \
195 $(image-dot:%.dot=%.png) \
196 $(image-svg:%.svg=%.pdf) \
197 $(image-svg:%.svg=%.png) \
198 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
200 install: pdf split $(dist-sources)
201 rm -rf dist
202 mkdir -p dist
203 cp pdf/hgbook.pdf dist
204 cp html/split/*.{css,html,png} dist
205 cp $(dist-sources) dist
207 rsync: install
208 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook