hgbook

view en/Makefile @ 112:2fcead053b7a

More. Concept. Fun.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Nov 13 13:21:29 2006 -0800 (2006-11-13)
parents 75c076c7a374
children a0f57b3e677e
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg parents --template '{node|short}\n')
5 sources := \
6 00book.tex \
7 99book.bib \
8 99defs.tex \
9 build_id.tex \
10 concepts.tex \
11 daily.tex \
12 hook.tex \
13 intro.tex \
14 mq.tex \
15 mq-collab.tex \
16 mq-ref.tex \
17 preface.tex \
18 srcinstall.tex \
19 template.tex \
20 tour-basic.tex \
21 tour-merge.tex
23 image-sources := \
24 filelog.svg \
25 kdiff3.png \
26 metadata.svg \
27 mq-stack.svg \
28 revlog.svg \
29 snapshot.svg \
30 tour-history.svg \
31 tour-merge-conflict.svg \
32 tour-merge-merge.svg \
33 tour-merge-pull.svg \
34 tour-merge-sep-repos.svg
36 image-svg := $(filter %.svg,$(image-sources))
38 example-sources := \
39 daily.files \
40 hook.msglen \
41 hook.simple \
42 hook.ws \
43 mq.guards \
44 mq.qinit-help \
45 mq.dodiff \
46 mq.id \
47 mq.tarball \
48 mq.tools \
49 mq.tutorial \
50 template.simple \
51 template.svnstyle \
52 tour \
53 tour-merge-conflict
55 latex-options = \
56 -interaction batchmode \
57 -output-directory $(dir $(1)) \
58 -jobname $(basename $(notdir $(1)))
60 all: pdf html
62 pdf: pdf/hgbook.pdf
64 define pdf
65 mkdir -p $(dir $@)
66 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
67 cp 99book.bib $(dir $@)
68 cd $(dir $@) && bibtex $(basename $(notdir $@))
69 cd $(dir $@) && makeindex $(basename $(notdir $@))
70 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
71 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
72 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
73 endef
75 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
76 $(call pdf)
78 html: html/onepage/hgbook.html html/split/hgbook.html
80 # This is a horrible hack to work around the fact that the htlatex
81 # command in tex4ht is itself a horrible hack. I really don't want to
82 # include verbatim the big wad of TeX that is repeated in that script,
83 # so instead I mangle the script itself.
85 define htlatex
86 mkdir -p $(dir $(1))
87 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
88 cp 99book.bib $(dir $@)
89 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
90 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
91 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
92 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
93 chmod 755 $(dir $(1))/htlatex.book
94 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
95 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
96 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
97 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
98 endef
100 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
101 $(call htlatex,$@,$<)
102 cp $(image-sources:%.svg=%.png) $(dir $@)
104 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
105 $(call htlatex,$@,$<,2)
106 cp $(image-sources:%.svg=%.png) $(dir $@)
108 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
110 beta/%.tex: %.tex
111 ./fblinks $(hg_id) $(dir $@) $<
113 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
114 $(call pdf)
116 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
117 $(call htlatex,$@,$<)
118 cp $(image-sources:%.svg=%.png) $(dir $@)
120 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
121 $(call htlatex,$@,$<,2)
122 cp $(image-sources:%.svg=%.png) $(dir $@)
124 # Produce 90dpi PNGs for the web.
126 %.png: %.svg
127 inkscape -D -e $@ $<
129 # Produce eps & pdf for the pdf
131 %.pdf: %.eps
132 epstopdf $<
134 %.eps: %.svg
135 inkscape -E $@ $<
137 examples: examples/.run
139 examples/.run: $(example-sources:%=examples/%.run)
140 touch examples/.run
142 examples/%.run: examples/% examples/run-example
143 cd examples && ./run-example $(notdir $<)
145 build_id.tex: $(wildcard ../.hg/00changelog.[id])
146 echo -n $(hg_id) > build_id.tex
148 clean:
149 rm -rf beta html pdf \
150 $(image-svg:%.svg=%.pdf) \
151 $(image-svg:%.svg=%.png) \
152 examples/*.{out,run} examples/.run build_id.tex