hgbook

view en/Makefile @ 100:272146fab009

Add yet another illustration of the merge process.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Oct 18 12:06:56 2006 -0700 (2006-10-18)
parents 06383f9e46e4
children 5b80c922ebdd
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 mq-stack.svg \
23 tour-history.svg \
24 tour-merge-sep-repos.svg \
25 tour-merge-pull.svg \
26 tour-merge-merge.svg
28 example-sources := \
29 daily.files \
30 hook.msglen \
31 hook.simple \
32 hook.ws \
33 mq.qinit-help \
34 mq.dodiff \
35 mq.id \
36 mq.tarball \
37 mq.tools \
38 mq.tutorial \
39 template.simple \
40 template.svnstyle \
41 tour
43 latex-options = \
44 -interaction batchmode \
45 -output-directory $(dir $(1)) \
46 -jobname $(basename $(notdir $(1)))
48 all: pdf html
50 pdf: pdf/hgbook.pdf
52 define pdf
53 mkdir -p $(dir $@)
54 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
55 cp 99book.bib $(dir $@)
56 cd $(dir $@) && bibtex $(basename $(notdir $@))
57 cd $(dir $@) && makeindex $(basename $(notdir $@))
58 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
59 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
60 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
61 endef
63 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
64 $(call pdf)
66 html: html/onepage/hgbook.html html/split/hgbook.html
68 # This is a horrible hack to work around the fact that the htlatex
69 # command in tex4ht is itself a horrible hack. I really don't want to
70 # include verbatim the big wad of TeX that is repeated in that script,
71 # so instead I mangle the script itself.
73 define htlatex
74 mkdir -p $(dir $(1))
75 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
76 cp 99book.bib $(dir $@)
77 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
78 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
79 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
80 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
81 chmod 755 $(dir $(1))/htlatex.book
82 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
83 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
84 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
85 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
86 endef
88 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
89 $(call htlatex,$@,$<)
90 cp $(image-sources:%.svg=%.png) $(dir $@)
92 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
93 $(call htlatex,$@,$<,2)
94 cp $(image-sources:%.svg=%.png) $(dir $@)
96 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
98 beta/%.tex: %.tex
99 ./fblinks $(hg_id) $(dir $@) $<
101 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
102 $(call pdf)
104 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
105 $(call htlatex,$@,$<)
106 cp $(image-sources:%.svg=%.png) $(dir $@)
108 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
109 $(call htlatex,$@,$<,2)
110 cp $(image-sources:%.svg=%.png) $(dir $@)
112 # Produce 90dpi PNGs for the web.
114 %.png: %.svg
115 inkscape -D -e $@ $<
117 # Produce eps & pdf for the pdf
119 %.pdf: %.eps
120 epstopdf $<
122 %.eps: %.svg
123 inkscape -E $@ $<
125 examples: examples/.run
127 examples/.run: $(example-sources:%=examples/%.run)
128 touch examples/.run
130 examples/%.run: examples/% examples/run-example
131 cd examples && ./run-example $(notdir $<)
133 build_id.tex: $(wildcard ../.hg/00changelog.[id])
134 echo -n $(hg_id) > build_id.tex
136 clean:
137 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
138 examples/*.{out,run} examples/.run build_id.tex