hgbook

view en/Makefile @ 108:e0b961975c5e

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