hgbook

view en/Makefile @ 196:4237e45506ee

Add early material describing tags.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Apr 16 16:11:24 2007 -0700 (2007-04-16)
parents 959357d01607
children 615f3c6b30e1
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 cmdref \
60 daily.copy \
61 daily.files \
62 daily.rename \
63 daily.revert \
64 filenames \
65 hook.msglen \
66 hook.simple \
67 hook.ws \
68 issue29 \
69 mq.guards \
70 mq.qinit-help \
71 mq.dodiff \
72 mq.id \
73 mq.tarball \
74 mq.tools \
75 mq.tutorial \
76 rename.divergent \
77 rollback \
78 tag \
79 template.simple \
80 template.svnstyle \
81 tour \
82 tour-merge-conflict
84 example-prereqs := \
85 /usr/bin/merge
87 dist-sources := \
88 ../html/hgicon.png \
89 ../html/index.html.var \
90 ../html/index.en.html
92 latex-options = \
93 -interaction batchmode \
94 -output-directory $(dir $(1)) \
95 -jobname $(basename $(notdir $(1)))
97 hg = $(shell which hg)
99 hg-id = $(shell hg parents --template '{node|short} \(dated {date|isodate}\)\n')
101 hg-version = $(shell hg version -q | \
102 sed 's,.*(version \(unknown\|[a-f0-9]*\)),\1,')
104 all: pdf html
106 pdf: pdf/hgbook.pdf
108 define pdf
109 mkdir -p $(dir $@)
110 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
111 cp 99book.bib $(dir $@)
112 cd $(dir $@) && bibtex $(basename $(notdir $@))
113 cd $(dir $@) && makeindex $(basename $(notdir $@))
114 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
115 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
116 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
117 endef
119 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
121 pdf/hgbook.pdf: $(sources) $(image-pdf) examples
122 $(call pdf)
124 html: onepage split
126 htlatex := /usr/bin/htlatex
128 onepage: $(htlatex) html/onepage/hgbook.html
130 split: $(htlatex) html/split/hgbook.html
132 # This is a horrible hack to work around the fact that the htlatex
133 # command in tex4ht is itself a horrible hack. I really don't want to
134 # include verbatim the big wad of TeX that is repeated in that script,
135 # but I've given up and run a hacked copy as htlatex.book here.
137 define htlatex
138 mkdir -p $(dir $(1))
139 cp 99book.bib $(dir $(1))
140 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
141 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
142 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
143 ./fixhtml.py $(dir $(1))/*.html
144 endef
146 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
148 html/onepage/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
149 $(call htlatex,$@,$<)
150 cp $(image-sources:%.svg=%.png) $(dir $@)
151 cp hgbook.css $(dir $@)
153 html/split/hgbook.html: $(sources) $(image-html) examples hgbook.css bookhtml.cfg
154 $(call htlatex,$@,$<,2)
155 cp $(image-sources:%.svg=%.png) $(dir $@)
156 cp hgbook.css $(dir $@)
158 # Produce 90dpi PNGs for the web.
160 %.png: %.svg
161 inkscape -D -e $@ $<
163 %.svg: %.dot
164 dot -Tsvg -o $@ $<
166 # Produce eps & pdf for the pdf
168 %.pdf: %.eps
169 epstopdf $<
171 %.eps: %.svg
172 inkscape -E $@ $<
174 %.eps: %.dot
175 dot -Tps -o $@ $<
177 examples: $(example-prereqs) examples/.run
179 examples/.run: $(example-sources:%=examples/%.run)
180 touch examples/.run
182 examples/%.run: examples/% examples/run-example
183 cd examples && ./run-example $(notdir $<)
185 build_id.tex: $(wildcard ../.hg/00changelog.[id])
186 echo -n $(hg-id) > build_id.tex
188 hg_id.tex: $(hg)
189 echo -n $(hg-version) > hg_id.tex
191 clean:
192 rm -rf dist html pdf \
193 $(image-dot:%.dot=%.pdf) \
194 $(image-dot:%.dot=%.png) \
195 $(image-svg:%.svg=%.pdf) \
196 $(image-svg:%.svg=%.png) \
197 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
199 install: pdf split $(dist-sources)
200 rm -rf dist
201 mkdir -p dist
202 cp pdf/hgbook.pdf dist
203 cp html/split/*.{css,html,png} dist
204 cp $(dist-sources) dist
206 rsync: install
207 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook