hgbook

view en/Makefile @ 42:cbfa08bcf181

Start the "Mercurial in daily use" chapter.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun Jul 23 09:46:26 2006 -0700 (2006-07-23)
parents c0979ed1eabd
children 7ac85766db0f
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/hook.simple \
22 examples/mq.qinit-help \
23 examples/mq.diff \
24 examples/mq.tarball \
25 examples/mq.tools \
26 examples/mq.tutorial
28 latex-options = \
29 -interaction batchmode \
30 -output-directory $(dir $(1)) \
31 -jobname $(basename $(notdir $(1)))
33 all: pdf html
35 pdf: pdf/hgbook.pdf
37 define pdf
38 mkdir -p $(dir $@)
39 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
40 cp 99book.bib $(dir $@)
41 cd $(dir $@) && bibtex $(basename $(notdir $@))
42 cd $(dir $@) && makeindex $(basename $(notdir $@))
43 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
44 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
45 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
46 endef
48 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
49 $(call pdf)
51 html: html/onepage/hgbook.html html/split/hgbook.html
53 # This is a horrible hack to work around the fact that the htlatex
54 # command in tex4ht is itself a horrible hack. I really don't want to
55 # include verbatim the big wad of TeX that is repeated in that script,
56 # so instead I mangle the script itself.
58 define htlatex
59 mkdir -p $(dir $(1))
60 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
61 cp 99book.bib $(dir $@)
62 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
63 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
64 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
65 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
66 chmod 755 $(dir $(1))/htlatex.book
67 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
68 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
69 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
70 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
71 endef
73 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
74 $(call htlatex,$@,$<)
75 cp $(image-sources:%.svg=%.png) $(dir $@)
77 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
78 $(call htlatex,$@,$<,2)
79 cp $(image-sources:%.svg=%.png) $(dir $@)
81 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
83 beta/%.tex: %.tex
84 ./fblinks $(hg_id) $(dir $@) $<
86 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
87 $(call pdf)
89 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
90 $(call htlatex,$@,$<)
91 cp $(image-sources:%.svg=%.png) $(dir $@)
93 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
94 $(call htlatex,$@,$<,2)
95 cp $(image-sources:%.svg=%.png) $(dir $@)
97 # Produce 90dpi PNGs for the web.
99 %.png: %.svg
100 inkscape -D -e $@ $<
102 # Produce eps & pdf for the pdf
104 %.pdf: %.eps
105 epstopdf $<
107 %.eps: %.svg
108 inkscape -E $@ $<
110 examples: examples/.run
112 examples/.run: $(example-sources)
113 cd examples && ./run-example
115 build_id.tex: $(wildcard ../.hg/00changelog.[id])
116 echo -n $(hg_id) > build_id.tex
118 clean:
119 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
120 examples/*.out examples/.run build_id.tex