hgbook

view en/Makefile @ 95:47ea206351d5

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