hgbook

view en/Makefile @ 19:187702df428b

Piles of new content for MQ chapter - cookbook stuff.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri Jul 07 19:56:53 2006 -0700 (2006-07-07)
parents e6f4088ebe52
children a752b0fd3c10
line source
1 # This makefile requires GNU make.
3 hg_id := $(shell hg id 2>/dev/null | sed -e 's/ tip\>//' -e 's/ /,/g' || echo external)
5 sources := \
6 00book.tex \
7 99book.bib \
8 99defs.tex \
9 intro.tex \
10 mq.tex \
11 build_id.tex
13 image-sources := \
14 mq-stack.svg
16 example-sources := \
17 examples/run-example \
18 examples/mq.qinit-help \
19 examples/mq.diff \
20 examples/mq.tarball \
21 examples/mq.tools \
22 examples/mq.tutorial
24 latex-options = \
25 -interaction batchmode \
26 -output-directory $(dir $(1)) \
27 -jobname $(basename $(notdir $(1)))
29 all: pdf html
31 pdf: pdf/hgbook.pdf
33 define pdf
34 mkdir -p $(dir $@)
35 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
36 cp 99book.bib $(dir $@)
37 cd $(dir $@) && bibtex $(basename $(notdir $@))
38 cd $(dir $@) && makeindex $(basename $(notdir $@))
39 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
40 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
41 endef
43 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%_pdf.png) examples
44 $(call pdf)
46 html: html/onepage/hgbook.html html/split/hgbook.html
48 # This is a horrible hack to work around the fact that the htlatex
49 # command in tex4ht is itself a horrible hack. I really don't want to
50 # include verbatim the big wad of TeX that is repeated in that script,
51 # so instead I mangle the script itself.
53 define htlatex
54 mkdir -p $(dir $(1))
55 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
56 cp 99book.bib $(dir $@)
57 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
58 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
59 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
60 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
61 chmod 755 $(dir $(1))/htlatex.book
62 $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
63 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
64 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
65 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
66 endef
68 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
69 $(call htlatex,$@,$<)
70 cp $(image-sources:%.svg=%.png) $(dir $@)
72 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
73 $(call htlatex,$@,$<,2)
74 cp $(image-sources:%.svg=%.png) $(dir $@)
76 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
78 beta/%.tex: %.tex
79 ./fblinks $(hg_id) $(dir $@) $<
81 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%_pdf.png) examples fblinks
82 $(call pdf)
84 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
85 $(call htlatex,$@,$<)
86 cp $(image-sources:%.svg=%.png) $(dir $@)
88 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
89 $(call htlatex,$@,$<,2)
90 cp $(image-sources:%.svg=%.png) $(dir $@)
92 # Produce 90dpi PNGs for the web.
94 %.png: %.svg
95 inkscape -D -e $@ $<
97 # Produce 300dpi PNGs for PDF.
99 %_pdf.png: %.svg
100 inkscape -D -d 300 -e $@ $<
102 examples: examples/.run
104 examples/.run: $(example-sources)
105 cd examples && ./run-example
107 build_id.tex: $(wildcard ../.hg/00changelog.[id])
108 echo $(hg_id) > build_id.tex
110 clean:
111 rm -rf beta html pdf *.eps *.png *.aux *.dvi *.log *.out \
112 examples/*.out examples/.run build_id.tex