hgbook

view en/Makefile @ 103:5b80c922ebdd

More merge content.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu Oct 19 15:18:07 2006 -0700 (2006-10-19)
parents 272146fab009
children 32bf9a5f22c0
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 preface.tex \
16 srcinstall.tex \
17 template.tex \
18 tour-basic.tex \
19 tour-merge.tex
21 image-sources := \
22 kdiff3.png \
23 mq-stack.svg \
24 tour-history.svg \
25 tour-merge-conflict.svg \
26 tour-merge-merge.svg \
27 tour-merge-pull.svg \
28 tour-merge-sep-repos.svg
30 image-svg := $(filter %.svg,$(image-sources))
32 example-sources := \
33 daily.files \
34 hook.msglen \
35 hook.simple \
36 hook.ws \
37 mq.qinit-help \
38 mq.dodiff \
39 mq.id \
40 mq.tarball \
41 mq.tools \
42 mq.tutorial \
43 template.simple \
44 template.svnstyle \
45 tour \
46 tour-merge-conflict
48 latex-options = \
49 -interaction batchmode \
50 -output-directory $(dir $(1)) \
51 -jobname $(basename $(notdir $(1)))
53 all: pdf html
55 pdf: pdf/hgbook.pdf
57 define pdf
58 mkdir -p $(dir $@)
59 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
60 cp 99book.bib $(dir $@)
61 cd $(dir $@) && bibtex $(basename $(notdir $@))
62 cd $(dir $@) && makeindex $(basename $(notdir $@))
63 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
64 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
65 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
66 endef
68 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
69 $(call pdf)
71 html: html/onepage/hgbook.html html/split/hgbook.html
73 # This is a horrible hack to work around the fact that the htlatex
74 # command in tex4ht is itself a horrible hack. I really don't want to
75 # include verbatim the big wad of TeX that is repeated in that script,
76 # so instead I mangle the script itself.
78 define htlatex
79 mkdir -p $(dir $(1))
80 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
81 cp 99book.bib $(dir $@)
82 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
83 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
84 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
85 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
86 chmod 755 $(dir $(1))/htlatex.book
87 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
88 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
89 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
90 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
91 endef
93 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
94 $(call htlatex,$@,$<)
95 cp $(image-sources:%.svg=%.png) $(dir $@)
97 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
98 $(call htlatex,$@,$<,2)
99 cp $(image-sources:%.svg=%.png) $(dir $@)
101 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
103 beta/%.tex: %.tex
104 ./fblinks $(hg_id) $(dir $@) $<
106 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
107 $(call pdf)
109 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
110 $(call htlatex,$@,$<)
111 cp $(image-sources:%.svg=%.png) $(dir $@)
113 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
114 $(call htlatex,$@,$<,2)
115 cp $(image-sources:%.svg=%.png) $(dir $@)
117 # Produce 90dpi PNGs for the web.
119 %.png: %.svg
120 inkscape -D -e $@ $<
122 # Produce eps & pdf for the pdf
124 %.pdf: %.eps
125 epstopdf $<
127 %.eps: %.svg
128 inkscape -E $@ $<
130 examples: examples/.run
132 examples/.run: $(example-sources:%=examples/%.run)
133 touch examples/.run
135 examples/%.run: examples/% examples/run-example
136 cd examples && ./run-example $(notdir $<)
138 build_id.tex: $(wildcard ../.hg/00changelog.[id])
139 echo -n $(hg_id) > build_id.tex
141 clean:
142 rm -rf beta html pdf \
143 $(image-svg:%.svg=%.pdf) \
144 $(image-svg:%.svg=%.png) \
145 examples/*.{out,run} examples/.run build_id.tex