hgbook

view en/Makefile @ 29:6e988159394b

Add revision ID to output.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Jul 12 00:33:27 2006 -0700 (2006-07-12)
parents 1bc6c1f0192a
children 51d94bd2804c
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 preface.tex \
10 intro.tex \
11 mq.tex \
12 build_id.tex
14 image-sources := \
15 mq-stack.svg
17 example-sources := \
18 examples/run-example \
19 examples/mq.qinit-help \
20 examples/mq.diff \
21 examples/mq.tarball \
22 examples/mq.tools \
23 examples/mq.tutorial
25 latex-options = \
26 -interaction batchmode \
27 -output-directory $(dir $(1)) \
28 -jobname $(basename $(notdir $(1)))
30 all: pdf html
32 pdf: pdf/hgbook.pdf
34 define pdf
35 mkdir -p $(dir $@)
36 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
37 cp 99book.bib $(dir $@)
38 cd $(dir $@) && bibtex $(basename $(notdir $@))
39 cd $(dir $@) && makeindex $(basename $(notdir $@))
40 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
41 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
42 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
43 endef
45 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%_pdf.png) examples
46 $(call pdf)
48 html: html/onepage/hgbook.html html/split/hgbook.html
50 # This is a horrible hack to work around the fact that the htlatex
51 # command in tex4ht is itself a horrible hack. I really don't want to
52 # include verbatim the big wad of TeX that is repeated in that script,
53 # so instead I mangle the script itself.
55 define htlatex
56 mkdir -p $(dir $(1))
57 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
58 cp 99book.bib $(dir $@)
59 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
60 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
61 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
62 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
63 chmod 755 $(dir $(1))/htlatex.book
64 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
65 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
66 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
67 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
68 endef
70 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
71 $(call htlatex,$@,$<)
72 cp $(image-sources:%.svg=%.png) $(dir $@)
74 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
75 $(call htlatex,$@,$<,2)
76 cp $(image-sources:%.svg=%.png) $(dir $@)
78 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
80 beta/%.tex: %.tex
81 ./fblinks $(hg_id) $(dir $@) $<
83 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%_pdf.png) examples fblinks
84 $(call pdf)
86 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
87 $(call htlatex,$@,$<)
88 cp $(image-sources:%.svg=%.png) $(dir $@)
90 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
91 $(call htlatex,$@,$<,2)
92 cp $(image-sources:%.svg=%.png) $(dir $@)
94 # Produce 90dpi PNGs for the web.
96 %.png: %.svg
97 inkscape -D -e $@ $<
99 # Produce 300dpi PNGs for PDF.
101 %_pdf.png: %.svg
102 inkscape -D -d 300 -e $@ $<
104 examples: examples/.run
106 examples/.run: $(example-sources)
107 cd examples && ./run-example
109 build_id.tex: $(wildcard ../.hg/00changelog.[id])
110 echo -n $(hg_id) > build_id.tex
112 clean:
113 rm -rf beta html pdf *.eps *.png *.aux *.dvi *.log *.out \
114 examples/*.out examples/.run build_id.tex