hgbook

view en/Makefile @ 76:df88df78288d

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