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