hgbook

view en/Makefile @ 84:43b9793b4e38

Begin tour chapter.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Oct 04 13:11:40 2006 -0700 (2006-10-04)
parents b476081a9c04
children b7c69a68b0cc
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 template.tex \
17 tour.tex
19 image-sources := \
20 mq-stack.svg
22 example-sources := \
23 examples/daily.files \
24 examples/hook.msglen \
25 examples/hook.simple \
26 examples/hook.ws \
27 examples/mq.qinit-help \
28 examples/mq.dodiff \
29 examples/mq.id \
30 examples/mq.tarball \
31 examples/mq.tools \
32 examples/mq.tutorial \
33 examples/template.simple \
34 examples/template.svnstyle
36 latex-options = \
37 -interaction batchmode \
38 -output-directory $(dir $(1)) \
39 -jobname $(basename $(notdir $(1)))
41 all: pdf html
43 pdf: pdf/hgbook.pdf
45 define pdf
46 mkdir -p $(dir $@)
47 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
48 cp 99book.bib $(dir $@)
49 cd $(dir $@) && bibtex $(basename $(notdir $@))
50 cd $(dir $@) && makeindex $(basename $(notdir $@))
51 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
52 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
53 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
54 endef
56 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
57 $(call pdf)
59 html: html/onepage/hgbook.html html/split/hgbook.html
61 # This is a horrible hack to work around the fact that the htlatex
62 # command in tex4ht is itself a horrible hack. I really don't want to
63 # include verbatim the big wad of TeX that is repeated in that script,
64 # so instead I mangle the script itself.
66 define htlatex
67 mkdir -p $(dir $(1))
68 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
69 cp 99book.bib $(dir $@)
70 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
71 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
72 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
73 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
74 chmod 755 $(dir $(1))/htlatex.book
75 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
76 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
77 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
78 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
79 endef
81 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
82 $(call htlatex,$@,$<)
83 cp $(image-sources:%.svg=%.png) $(dir $@)
85 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
86 $(call htlatex,$@,$<,2)
87 cp $(image-sources:%.svg=%.png) $(dir $@)
89 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
91 beta/%.tex: %.tex
92 ./fblinks $(hg_id) $(dir $@) $<
94 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
95 $(call pdf)
97 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
98 $(call htlatex,$@,$<)
99 cp $(image-sources:%.svg=%.png) $(dir $@)
101 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
102 $(call htlatex,$@,$<,2)
103 cp $(image-sources:%.svg=%.png) $(dir $@)
105 # Produce 90dpi PNGs for the web.
107 %.png: %.svg
108 inkscape -D -e $@ $<
110 # Produce eps & pdf for the pdf
112 %.pdf: %.eps
113 epstopdf $<
115 %.eps: %.svg
116 inkscape -E $@ $<
118 examples: examples/.run
120 examples/.run: $(example-sources:%=%.run)
121 touch examples/.run
123 examples/%.run: examples/% examples/run-example
124 cd examples && ./run-example $(notdir $<)
126 build_id.tex: $(wildcard ../.hg/00changelog.[id])
127 echo -n $(hg_id) > build_id.tex
129 clean:
130 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
131 examples/*.{out,run} examples/.run build_id.tex