hgbook

view en/Makefile @ 85:b7c69a68b0cc

A little progress on "lightning tour".
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Oct 04 15:15:54 2006 -0700 (2006-10-04)
parents 43b9793b4e38
children 796738d75876
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.tex
20 image-sources := \
21 mq-stack.svg
23 example-sources := \
24 examples/daily.files \
25 examples/hook.msglen \
26 examples/hook.simple \
27 examples/hook.ws \
28 examples/mq.qinit-help \
29 examples/mq.dodiff \
30 examples/mq.id \
31 examples/mq.tarball \
32 examples/mq.tools \
33 examples/mq.tutorial \
34 examples/template.simple \
35 examples/template.svnstyle
37 latex-options = \
38 -interaction batchmode \
39 -output-directory $(dir $(1)) \
40 -jobname $(basename $(notdir $(1)))
42 all: pdf html
44 pdf: pdf/hgbook.pdf
46 define pdf
47 mkdir -p $(dir $@)
48 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
49 cp 99book.bib $(dir $@)
50 cd $(dir $@) && bibtex $(basename $(notdir $@))
51 cd $(dir $@) && makeindex $(basename $(notdir $@))
52 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
53 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
54 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
55 endef
57 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
58 $(call pdf)
60 html: html/onepage/hgbook.html html/split/hgbook.html
62 # This is a horrible hack to work around the fact that the htlatex
63 # command in tex4ht is itself a horrible hack. I really don't want to
64 # include verbatim the big wad of TeX that is repeated in that script,
65 # so instead I mangle the script itself.
67 define htlatex
68 mkdir -p $(dir $(1))
69 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
70 cp 99book.bib $(dir $@)
71 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
72 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
73 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
74 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
75 chmod 755 $(dir $(1))/htlatex.book
76 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
77 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
78 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
79 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
80 endef
82 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
83 $(call htlatex,$@,$<)
84 cp $(image-sources:%.svg=%.png) $(dir $@)
86 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
87 $(call htlatex,$@,$<,2)
88 cp $(image-sources:%.svg=%.png) $(dir $@)
90 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
92 beta/%.tex: %.tex
93 ./fblinks $(hg_id) $(dir $@) $<
95 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
96 $(call pdf)
98 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
99 $(call htlatex,$@,$<)
100 cp $(image-sources:%.svg=%.png) $(dir $@)
102 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
103 $(call htlatex,$@,$<,2)
104 cp $(image-sources:%.svg=%.png) $(dir $@)
106 # Produce 90dpi PNGs for the web.
108 %.png: %.svg
109 inkscape -D -e $@ $<
111 # Produce eps & pdf for the pdf
113 %.pdf: %.eps
114 epstopdf $<
116 %.eps: %.svg
117 inkscape -E $@ $<
119 examples: examples/.run
121 examples/.run: $(example-sources:%=%.run)
122 touch examples/.run
124 examples/%.run: examples/% examples/run-example
125 cd examples && ./run-example $(notdir $<)
127 build_id.tex: $(wildcard ../.hg/00changelog.[id])
128 echo -n $(hg_id) > build_id.tex
130 clean:
131 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
132 examples/*.{out,run} examples/.run build_id.tex