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@124
|
34 image-dot := $(filter %.dot,$(image-sources))
|
bos@103
|
35 image-svg := $(filter %.svg,$(image-sources))
|
bos@124
|
36 image-png := $(filter %.png,$(image-sources))
|
bos@11
|
37
|
bos@213
|
38 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
|
bos@213
|
39 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
|
bos@213
|
40
|
bos@4
|
41 example-sources := \
|
bos@124
|
42 backout \
|
bos@131
|
43 bisect \
|
bos@179
|
44 branching \
|
bos@202
|
45 branch-named \
|
bos@198
|
46 branch-repo \
|
bos@133
|
47 cmdref \
|
bos@117
|
48 daily.copy \
|
bos@86
|
49 daily.files \
|
bos@118
|
50 daily.rename \
|
bos@122
|
51 daily.revert \
|
bos@226
|
52 extdiff \
|
bos@133
|
53 filenames \
|
bos@86
|
54 hook.msglen \
|
bos@86
|
55 hook.simple \
|
bos@86
|
56 hook.ws \
|
bos@156
|
57 issue29 \
|
bos@104
|
58 mq.guards \
|
bos@86
|
59 mq.qinit-help \
|
bos@86
|
60 mq.dodiff \
|
bos@86
|
61 mq.id \
|
bos@86
|
62 mq.tarball \
|
bos@86
|
63 mq.tools \
|
bos@86
|
64 mq.tutorial \
|
bos@156
|
65 rename.divergent \
|
bos@121
|
66 rollback \
|
bos@196
|
67 tag \
|
bos@86
|
68 template.simple \
|
bos@87
|
69 template.svnstyle \
|
bos@103
|
70 tour \
|
bos@103
|
71 tour-merge-conflict
|
bos@4
|
72
|
bos@172
|
73 example-prereqs := \
|
bos@172
|
74 /usr/bin/merge
|
bos@172
|
75
|
bos@157
|
76 dist-sources := \
|
bos@159
|
77 ../html/hgicon.png \
|
bos@157
|
78 ../html/index.html.var \
|
bos@157
|
79 ../html/index.en.html
|
bos@157
|
80
|
bos@0
|
81 latex-options = \
|
bos@0
|
82 -interaction batchmode \
|
bos@0
|
83 -output-directory $(dir $(1)) \
|
bos@0
|
84 -jobname $(basename $(notdir $(1)))
|
bos@0
|
85
|
bos@177
|
86 hg = $(shell which hg)
|
bos@177
|
87
|
bos@269
|
88 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
|
bos@177
|
89
|
bos@177
|
90 hg-version = $(shell hg version -q | \
|
bos@242
|
91 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
|
bos@177
|
92
|
bos@0
|
93 all: pdf html
|
bos@0
|
94
|
bos@0
|
95 pdf: pdf/hgbook.pdf
|
bos@0
|
96
|
bos@18
|
97 define pdf
|
bos@0
|
98 mkdir -p $(dir $@)
|
bos@21
|
99 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@2
|
100 cp 99book.bib $(dir $@)
|
bos@2
|
101 cd $(dir $@) && bibtex $(basename $(notdir $@))
|
bos@16
|
102 cd $(dir $@) && makeindex $(basename $(notdir $@))
|
bos@21
|
103 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@21
|
104 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
|
bos@26
|
105 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
|
bos@18
|
106 endef
|
bos@18
|
107
|
hg@307
|
108 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
|
bos@18
|
109 $(call pdf)
|
bos@0
|
110
|
bos@149
|
111 html: onepage split
|
bos@149
|
112
|
bos@213
|
113 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
|
bos@213
|
114
|
bos@213
|
115 html/onepage/%: %
|
bos@213
|
116 cp $< $@
|
bos@213
|
117
|
bos@213
|
118 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
|
bos@213
|
119
|
bos@213
|
120 html/split/%: %
|
bos@213
|
121 cp $< $@
|
bos@0
|
122
|
bos@18
|
123 # This is a horrible hack to work around the fact that the htlatex
|
bos@18
|
124 # command in tex4ht is itself a horrible hack. I really don't want to
|
bos@18
|
125 # include verbatim the big wad of TeX that is repeated in that script,
|
bos@171
|
126 # but I've given up and run a hacked copy as htlatex.book here.
|
bos@18
|
127
|
bos@0
|
128 define htlatex
|
bos@0
|
129 mkdir -p $(dir $(1))
|
bos@170
|
130 cp 99book.bib $(dir $(1))
|
bos@170
|
131 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
|
132 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
|
bos@0
|
133 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
|
bos@149
|
134 ./fixhtml.py $(dir $(1))/*.html
|
bos@214
|
135 rm $(dir $(1))/hgbook.css
|
bos@0
|
136 endef
|
bos@0
|
137
|
hg@307
|
138 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
|
bos@0
|
139 $(call htlatex,$@,$<)
|
bos@213
|
140
|
bos@213
|
141 html/split/hgbook.html: $(sources) examples bookhtml.cfg
|
bos@0
|
142 $(call htlatex,$@,$<,2)
|
bos@18
|
143
|
bos@18
|
144 # Produce 90dpi PNGs for the web.
|
bos@18
|
145
|
bos@309
|
146 %.png: %.svg fixsvg
|
hg@307
|
147 ./fixsvg $<
|
bos@309
|
148 inkscape -D -e $@ $<-tmp.svg
|
bos@309
|
149 rm $<-tmp.svg
|
bos@11
|
150
|
bos@124
|
151 %.svg: %.dot
|
bos@124
|
152 dot -Tsvg -o $@ $<
|
bos@124
|
153
|
jeffpc@30
|
154 # Produce eps & pdf for the pdf
|
bos@18
|
155
|
jeffpc@30
|
156 %.pdf: %.eps
|
jeffpc@30
|
157 epstopdf $<
|
jeffpc@30
|
158
|
jeffpc@30
|
159 %.eps: %.svg
|
hg@307
|
160 ./fixsvg $<
|
hg@310
|
161 inkscape -E $@ $<-tmp.svg
|
hg@310
|
162 rm $<-tmp.svg
|
bos@11
|
163
|
bos@124
|
164 %.eps: %.dot
|
bos@124
|
165 dot -Tps -o $@ $<
|
bos@124
|
166
|
bos@172
|
167 examples: $(example-prereqs) examples/.run
|
bos@4
|
168
|
bos@86
|
169 examples/.run: $(example-sources:%=examples/%.run)
|
bos@45
|
170 touch examples/.run
|
bos@45
|
171
|
bos@45
|
172 examples/%.run: examples/% examples/run-example
|
bos@45
|
173 cd examples && ./run-example $(notdir $<)
|
bos@4
|
174
|
bos@250
|
175 changelog := $(wildcard ../.hg/store/00changelog.[id])
|
bos@250
|
176 ifeq ($(changelog),)
|
bos@250
|
177 changelog := $(wildcard ../.hg/00changelog.[id])
|
bos@250
|
178 endif
|
bos@250
|
179
|
bos@250
|
180 build_id.tex: $(changelog)
|
wbunaarfubss@249
|
181 echo -n '$(hg-id)' > build_id.tex
|
bos@177
|
182
|
bos@177
|
183 hg_id.tex: $(hg)
|
wbunaarfubss@249
|
184 echo -n '$(hg-version)' > hg_id.tex
|
bos@16
|
185
|
bos@0
|
186 clean:
|
bos@153
|
187 rm -rf dist html pdf \
|
bos@124
|
188 $(image-dot:%.dot=%.pdf) \
|
bos@124
|
189 $(image-dot:%.dot=%.png) \
|
bos@103
|
190 $(image-svg:%.svg=%.pdf) \
|
bos@103
|
191 $(image-svg:%.svg=%.png) \
|
bos@177
|
192 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
|
bos@153
|
193
|
bos@157
|
194 install: pdf split $(dist-sources)
|
bos@153
|
195 rm -rf dist
|
bos@153
|
196 mkdir -p dist
|
bos@153
|
197 cp pdf/hgbook.pdf dist
|
bos@153
|
198 cp html/split/*.{css,html,png} dist
|
bos@157
|
199 cp $(dist-sources) dist
|
bos@153
|
200
|
bos@153
|
201 rsync: install
|
bos@153
|
202 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
|