hgbook

view en/Makefile @ 110:75c076c7a374

More concepts stuff.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri Nov 10 15:09:49 2006 -0800 (2006-11-10)
parents 1b67dc96f27a
children 2fcead053b7a
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 snapshot.svg \
29 tour-history.svg \
30 tour-merge-conflict.svg \
31 tour-merge-merge.svg \
32 tour-merge-pull.svg \
33 tour-merge-sep-repos.svg
35 image-svg := $(filter %.svg,$(image-sources))
37 example-sources := \
38 daily.files \
39 hook.msglen \
40 hook.simple \
41 hook.ws \
42 mq.guards \
43 mq.qinit-help \
44 mq.dodiff \
45 mq.id \
46 mq.tarball \
47 mq.tools \
48 mq.tutorial \
49 template.simple \
50 template.svnstyle \
51 tour \
52 tour-merge-conflict
54 latex-options = \
55 -interaction batchmode \
56 -output-directory $(dir $(1)) \
57 -jobname $(basename $(notdir $(1)))
59 all: pdf html
61 pdf: pdf/hgbook.pdf
63 define pdf
64 mkdir -p $(dir $@)
65 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
66 cp 99book.bib $(dir $@)
67 cd $(dir $@) && bibtex $(basename $(notdir $@))
68 cd $(dir $@) && makeindex $(basename $(notdir $@))
69 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
70 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
71 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
72 endef
74 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
75 $(call pdf)
77 html: html/onepage/hgbook.html html/split/hgbook.html
79 # This is a horrible hack to work around the fact that the htlatex
80 # command in tex4ht is itself a horrible hack. I really don't want to
81 # include verbatim the big wad of TeX that is repeated in that script,
82 # so instead I mangle the script itself.
84 define htlatex
85 mkdir -p $(dir $(1))
86 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
87 cp 99book.bib $(dir $@)
88 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
89 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
90 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
91 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
92 chmod 755 $(dir $(1))/htlatex.book
93 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
94 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
95 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
96 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
97 endef
99 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
100 $(call htlatex,$@,$<)
101 cp $(image-sources:%.svg=%.png) $(dir $@)
103 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
104 $(call htlatex,$@,$<,2)
105 cp $(image-sources:%.svg=%.png) $(dir $@)
107 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
109 beta/%.tex: %.tex
110 ./fblinks $(hg_id) $(dir $@) $<
112 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
113 $(call pdf)
115 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
116 $(call htlatex,$@,$<)
117 cp $(image-sources:%.svg=%.png) $(dir $@)
119 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
120 $(call htlatex,$@,$<,2)
121 cp $(image-sources:%.svg=%.png) $(dir $@)
123 # Produce 90dpi PNGs for the web.
125 %.png: %.svg
126 inkscape -D -e $@ $<
128 # Produce eps & pdf for the pdf
130 %.pdf: %.eps
131 epstopdf $<
133 %.eps: %.svg
134 inkscape -E $@ $<
136 examples: examples/.run
138 examples/.run: $(example-sources:%=examples/%.run)
139 touch examples/.run
141 examples/%.run: examples/% examples/run-example
142 cd examples && ./run-example $(notdir $<)
144 build_id.tex: $(wildcard ../.hg/00changelog.[id])
145 echo -n $(hg_id) > build_id.tex
147 clean:
148 rm -rf beta html pdf \
149 $(image-svg:%.svg=%.pdf) \
150 $(image-svg:%.svg=%.png) \
151 examples/*.{out,run} examples/.run build_id.tex