hgbook

view en/Makefile @ 44:012df94a02fe

Start hook examples. First is for trailing whitespace.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun Jul 23 23:25:52 2006 -0700 (2006-07-23)
parents 7ac85766db0f
children 6b7b0339e7d6
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg parents --template '{node|short}\n' | head -1)
5 sources := \
6 00book.tex \
7 99book.bib \
8 99defs.tex \
9 build_id.tex \
10 daily.tex \
11 hook.tex \
12 intro.tex \
13 mq.tex \
14 preface.tex
16 image-sources := \
17 mq-stack.svg
19 example-sources := \
20 examples/run-example \
21 examples/daily.files \
22 examples/hook.simple \
23 examples/hook.ws \
24 examples/mq.qinit-help \
25 examples/mq.diff \
26 examples/mq.tarball \
27 examples/mq.tools \
28 examples/mq.tutorial
30 latex-options = \
31 -interaction batchmode \
32 -output-directory $(dir $(1)) \
33 -jobname $(basename $(notdir $(1)))
35 all: pdf html
37 pdf: pdf/hgbook.pdf
39 define pdf
40 mkdir -p $(dir $@)
41 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
42 cp 99book.bib $(dir $@)
43 cd $(dir $@) && bibtex $(basename $(notdir $@))
44 cd $(dir $@) && makeindex $(basename $(notdir $@))
45 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
46 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
47 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
48 endef
50 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
51 $(call pdf)
53 html: html/onepage/hgbook.html html/split/hgbook.html
55 # This is a horrible hack to work around the fact that the htlatex
56 # command in tex4ht is itself a horrible hack. I really don't want to
57 # include verbatim the big wad of TeX that is repeated in that script,
58 # so instead I mangle the script itself.
60 define htlatex
61 mkdir -p $(dir $(1))
62 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
63 cp 99book.bib $(dir $@)
64 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
65 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
66 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
67 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
68 chmod 755 $(dir $(1))/htlatex.book
69 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
70 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
71 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
72 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
73 endef
75 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
76 $(call htlatex,$@,$<)
77 cp $(image-sources:%.svg=%.png) $(dir $@)
79 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
80 $(call htlatex,$@,$<,2)
81 cp $(image-sources:%.svg=%.png) $(dir $@)
83 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
85 beta/%.tex: %.tex
86 ./fblinks $(hg_id) $(dir $@) $<
88 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
89 $(call pdf)
91 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
92 $(call htlatex,$@,$<)
93 cp $(image-sources:%.svg=%.png) $(dir $@)
95 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
96 $(call htlatex,$@,$<,2)
97 cp $(image-sources:%.svg=%.png) $(dir $@)
99 # Produce 90dpi PNGs for the web.
101 %.png: %.svg
102 inkscape -D -e $@ $<
104 # Produce eps & pdf for the pdf
106 %.pdf: %.eps
107 epstopdf $<
109 %.eps: %.svg
110 inkscape -E $@ $<
112 examples: examples/.run
114 examples/.run: $(example-sources)
115 cd examples && ./run-example
117 build_id.tex: $(wildcard ../.hg/00changelog.[id])
118 echo -n $(hg_id) > build_id.tex
120 clean:
121 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
122 examples/*.out examples/.run build_id.tex