hgbook

view en/Makefile @ 109:1b67dc96f27a

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