hgbook

view en/Makefile @ 113:a0f57b3e677e

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