rev |
line source |
bos@18
|
1 # This makefile requires GNU make.
|
bos@18
|
2
|
bos@2
|
3 sources := \
|
bos@2
|
4 00book.tex \
|
bos@2
|
5 99book.bib \
|
bos@2
|
6 99defs.tex \
|
bos@550
|
7 app*.tex \
|
bos@550
|
8 ch*.tex
|
bos@0
|
9
|
bos@11
|
10 image-sources := \
|
bos@179
|
11 feature-branches.dot \
|
bos@108
|
12 filelog.svg \
|
bos@103
|
13 kdiff3.png \
|
bos@109
|
14 metadata.svg \
|
bos@96
|
15 mq-stack.svg \
|
bos@149
|
16 note.png \
|
bos@112
|
17 revlog.svg \
|
bos@110
|
18 snapshot.svg \
|
bos@99
|
19 tour-history.svg \
|
bos@103
|
20 tour-merge-conflict.svg \
|
bos@103
|
21 tour-merge-merge.svg \
|
bos@100
|
22 tour-merge-pull.svg \
|
bos@113
|
23 tour-merge-sep-repos.svg \
|
bos@124
|
24 undo-manual.dot \
|
bos@124
|
25 undo-manual-merge.dot \
|
bos@124
|
26 undo-non-tip.dot \
|
bos@124
|
27 undo-simple.dot \
|
bos@113
|
28 wdir.svg \
|
bos@115
|
29 wdir-after-commit.svg \
|
bos@115
|
30 wdir-branch.svg \
|
bos@115
|
31 wdir-merge.svg \
|
bos@115
|
32 wdir-pre-branch.svg
|
bos@103
|
33
|
bos@558
|
34 xml-src-files := \
|
bos@558
|
35 00book.xml \
|
bos@558
|
36 ch01-intro.xml \
|
bos@558
|
37 ch02-tour-basic.xml \
|
bos@558
|
38 ch12-mq.xml
|
bos@558
|
39
|
bos@124
|
40 image-dot := $(filter %.dot,$(image-sources))
|
bos@103
|
41 image-svg := $(filter %.svg,$(image-sources))
|
bos@124
|
42 image-png := $(filter %.png,$(image-sources))
|
bos@11
|
43
|
bos@213
|
44 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
|
bos@213
|
45 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
|
bos@213
|
46
|
bos@4
|
47 example-sources := \
|
bos@124
|
48 backout \
|
bos@131
|
49 bisect \
|
bos@179
|
50 branching \
|
bos@202
|
51 branch-named \
|
bos@198
|
52 branch-repo \
|
bos@133
|
53 cmdref \
|
bos@117
|
54 daily.copy \
|
bos@86
|
55 daily.files \
|
bos@118
|
56 daily.rename \
|
bos@122
|
57 daily.revert \
|
bos@226
|
58 extdiff \
|
bos@133
|
59 filenames \
|
bos@86
|
60 hook.msglen \
|
bos@86
|
61 hook.simple \
|
bos@86
|
62 hook.ws \
|
bos@156
|
63 issue29 \
|
bos@104
|
64 mq.guards \
|
bos@86
|
65 mq.qinit-help \
|
bos@86
|
66 mq.dodiff \
|
bos@86
|
67 mq.id \
|
bos@86
|
68 mq.tarball \
|
bos@86
|
69 mq.tools \
|
bos@86
|
70 mq.tutorial \
|
bos@156
|
71 rename.divergent \
|
bos@121
|
72 rollback \
|
bos@196
|
73 tag \
|
bos@86
|
74 template.simple \
|
bos@87
|
75 template.svnstyle \
|
bos@103
|
76 tour \
|
bos@103
|
77 tour-merge-conflict
|
bos@4
|
78
|
bos@558
|
79 xsltproc := xsltproc
|
bos@558
|
80 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
|
bos@558
|
81
|
bos@558
|
82 xmllint := xmllint
|
bos@558
|
83 xmllint-opts := --noout --nonet --valid
|
bos@558
|
84
|
bos@558
|
85 system-xsl-dir := $(firstword $(wildcard \
|
bos@558
|
86 /usr/share/sgml/docbook/xsl-stylesheets \
|
bos@558
|
87 /usr/share/xml/docbook/stylesheet/nwalsh \
|
bos@558
|
88 ))
|
bos@558
|
89
|
bos@558
|
90 # Bletcherousness.
|
bos@558
|
91
|
bos@558
|
92 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
|
bos@558
|
93 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
|
bos@558
|
94 else
|
bos@558
|
95 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
|
bos@558
|
96 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
|
bos@558
|
97 else
|
bos@558
|
98 $(error Do not know where to look for DocBook XML 4.4 DTD)
|
bos@558
|
99 endif
|
bos@558
|
100 endif
|
bos@558
|
101
|
bos@558
|
102 ifeq ($(system-xsl-dir),)
|
bos@558
|
103 $(error add a suitable directory to system-xsl-dir)
|
bos@558
|
104 endif
|
bos@558
|
105
|
bos@172
|
106 example-prereqs := \
|
bos@172
|
107 /usr/bin/merge
|
bos@172
|
108
|
bos@157
|
109 dist-sources := \
|
bos@159
|
110 ../html/hgicon.png \
|
bos@157
|
111 ../html/index.html.var \
|
bos@157
|
112 ../html/index.en.html
|
bos@157
|
113
|
bos@0
|
114 latex-options = \
|
bos@0
|
115 -interaction batchmode \
|
bos@0
|
116 -output-directory $(dir $(1)) \
|
bos@0
|
117 -jobname $(basename $(notdir $(1)))
|
bos@0
|
118
|
bos@177
|
119 hg = $(shell which hg)
|
bos@177
|
120
|
bos@269
|
121 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
|
bos@177
|
122
|
bos@177
|
123 hg-version = $(shell hg version -q | \
|
bos@242
|
124 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
|
bos@177
|
125
|
bos@0
|
126 all: pdf html
|
bos@0
|
127
|
bos@0
|
128 pdf: pdf/hgbook.pdf
|
bos@0
|
129
|
bos@18
|
130 define pdf
|
bos@0
|
131 mkdir -p $(dir $@)
|
bos@21
|
132 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@2
|
133 cp 99book.bib $(dir $@)
|
bos@2
|
134 cd $(dir $@) && bibtex $(basename $(notdir $@))
|
bos@16
|
135 cd $(dir $@) && makeindex $(basename $(notdir $@))
|
bos@21
|
136 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@21
|
137 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@26
|
138 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
|
bos@18
|
139 endef
|
bos@18
|
140
|
hg@307
|
141 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
|
bos@18
|
142 $(call pdf)
|
bos@0
|
143
|
bos@149
|
144 html: onepage split
|
bos@149
|
145
|
bos@558
|
146 ../xsl/system-xsl: $(system-xsl-dir)
|
bos@558
|
147 ln -s $< $@
|
bos@558
|
148
|
bos@558
|
149 dbhtml: ../xsl/system-xsl $(xml-src-files) valid
|
bos@558
|
150 xsltproc $(xsltproc-opts) ../xsl/chunk-stylesheet.xsl 00book.xml
|
bos@558
|
151
|
bos@558
|
152 valid: .validated-00book.xml
|
bos@558
|
153
|
bos@558
|
154 .validated-00book.xml: $(xml-src-files)
|
bos@558
|
155 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
|
bos@558
|
156 touch $@
|
bos@558
|
157
|
bos@213
|
158 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
|
bos@213
|
159
|
bos@213
|
160 html/onepage/%: %
|
bos@213
|
161 cp $< $@
|
bos@213
|
162
|
bos@213
|
163 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
|
bos@213
|
164
|
bos@213
|
165 html/split/%: %
|
bos@213
|
166 cp $< $@
|
bos@0
|
167
|
bos@18
|
168 # This is a horrible hack to work around the fact that the htlatex
|
bos@18
|
169 # command in tex4ht is itself a horrible hack. I really don't want to
|
bos@18
|
170 # include verbatim the big wad of TeX that is repeated in that script,
|
bos@171
|
171 # but I've given up and run a hacked copy as htlatex.book here.
|
bos@18
|
172
|
bos@0
|
173 define htlatex
|
bos@0
|
174 mkdir -p $(dir $(1))
|
bos@170
|
175 cp 99book.bib $(dir $(1))
|
bos@170
|
176 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
|
bos@0
|
177 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
|
bos@0
|
178 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
|
bos@149
|
179 ./fixhtml.py $(dir $(1))/*.html
|
bos@214
|
180 rm $(dir $(1))/hgbook.css
|
bos@0
|
181 endef
|
bos@0
|
182
|
hg@307
|
183 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
|
bos@0
|
184 $(call htlatex,$@,$<)
|
bos@213
|
185
|
bos@213
|
186 html/split/hgbook.html: $(sources) examples bookhtml.cfg
|
bos@0
|
187 $(call htlatex,$@,$<,2)
|
bos@18
|
188
|
bos@18
|
189 # Produce 90dpi PNGs for the web.
|
bos@18
|
190
|
bos@309
|
191 %.png: %.svg fixsvg
|
hg@307
|
192 ./fixsvg $<
|
bos@309
|
193 inkscape -D -e $@ $<-tmp.svg
|
bos@309
|
194 rm $<-tmp.svg
|
bos@11
|
195
|
bos@124
|
196 %.svg: %.dot
|
bos@124
|
197 dot -Tsvg -o $@ $<
|
bos@124
|
198
|
jeffpc@30
|
199 # Produce eps & pdf for the pdf
|
bos@18
|
200
|
jeffpc@30
|
201 %.pdf: %.eps
|
jeffpc@30
|
202 epstopdf $<
|
jeffpc@30
|
203
|
jeffpc@30
|
204 %.eps: %.svg
|
hg@307
|
205 ./fixsvg $<
|
hg@310
|
206 inkscape -E $@ $<-tmp.svg
|
hg@310
|
207 rm $<-tmp.svg
|
bos@11
|
208
|
bos@124
|
209 %.eps: %.dot
|
bos@124
|
210 dot -Tps -o $@ $<
|
bos@124
|
211
|
bos@172
|
212 examples: $(example-prereqs) examples/.run
|
bos@4
|
213
|
bos@86
|
214 examples/.run: $(example-sources:%=examples/%.run)
|
bos@45
|
215 touch examples/.run
|
bos@45
|
216
|
bos@45
|
217 examples/%.run: examples/% examples/run-example
|
bos@45
|
218 cd examples && ./run-example $(notdir $<)
|
bos@4
|
219
|
bos@250
|
220 changelog := $(wildcard ../.hg/store/00changelog.[id])
|
bos@250
|
221 ifeq ($(changelog),)
|
bos@250
|
222 changelog := $(wildcard ../.hg/00changelog.[id])
|
bos@250
|
223 endif
|
bos@250
|
224
|
bos@250
|
225 build_id.tex: $(changelog)
|
wbunaarfubss@249
|
226 echo -n '$(hg-id)' > build_id.tex
|
bos@177
|
227
|
bos@177
|
228 hg_id.tex: $(hg)
|
wbunaarfubss@249
|
229 echo -n '$(hg-version)' > hg_id.tex
|
bos@16
|
230
|
bos@0
|
231 clean:
|
bos@153
|
232 rm -rf dist html pdf \
|
bos@124
|
233 $(image-dot:%.dot=%.pdf) \
|
bos@124
|
234 $(image-dot:%.dot=%.png) \
|
bos@103
|
235 $(image-svg:%.svg=%.pdf) \
|
bos@103
|
236 $(image-svg:%.svg=%.png) \
|
bos@177
|
237 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
|
bos@153
|
238
|
bos@157
|
239 install: pdf split $(dist-sources)
|
bos@153
|
240 rm -rf dist
|
bos@153
|
241 mkdir -p dist
|
bos@153
|
242 cp pdf/hgbook.pdf dist
|
bos@153
|
243 cp html/split/*.{css,html,png} dist
|
bos@157
|
244 cp $(dist-sources) dist
|
bos@153
|
245
|
bos@153
|
246 rsync: install
|
bos@153
|
247 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
|