hgbook

view en/Makefile @ 56:b8539d91c84d

Begining of concepts chapter
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Mon Jul 24 23:57:52 2006 -0400 (2006-07-24)
parents c0979ed1eabd
children fa8bafe467cb
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 concepts.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/concepts \
23 examples/mq.qinit-help \
24 examples/mq.diff \
25 examples/mq.tarball \
26 examples/mq.tools \
27 examples/mq.tutorial
29 latex-options = \
30 -interaction batchmode \
31 -output-directory $(dir $(1)) \
32 -jobname $(basename $(notdir $(1)))
34 all: pdf html
36 pdf: pdf/hgbook.pdf
38 define pdf
39 mkdir -p $(dir $@)
40 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
41 cp 99book.bib $(dir $@)
42 cd $(dir $@) && bibtex $(basename $(notdir $@))
43 cd $(dir $@) && makeindex $(basename $(notdir $@))
44 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
45 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
46 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
47 endef
49 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
50 $(call pdf)
52 html: html/onepage/hgbook.html html/split/hgbook.html
54 # This is a horrible hack to work around the fact that the htlatex
55 # command in tex4ht is itself a horrible hack. I really don't want to
56 # include verbatim the big wad of TeX that is repeated in that script,
57 # so instead I mangle the script itself.
59 define htlatex
60 mkdir -p $(dir $(1))
61 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
62 cp 99book.bib $(dir $@)
63 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
64 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
65 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
66 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
67 chmod 755 $(dir $(1))/htlatex.book
68 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
69 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
70 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
71 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
72 endef
74 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
75 $(call htlatex,$@,$<)
76 cp $(image-sources:%.svg=%.png) $(dir $@)
78 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
79 $(call htlatex,$@,$<,2)
80 cp $(image-sources:%.svg=%.png) $(dir $@)
82 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
84 beta/%.tex: %.tex
85 ./fblinks $(hg_id) $(dir $@) $<
87 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
88 $(call pdf)
90 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
91 $(call htlatex,$@,$<)
92 cp $(image-sources:%.svg=%.png) $(dir $@)
94 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
95 $(call htlatex,$@,$<,2)
96 cp $(image-sources:%.svg=%.png) $(dir $@)
98 # Produce 90dpi PNGs for the web.
100 %.png: %.svg
101 inkscape -D -e $@ $<
103 # Produce eps & pdf for the pdf
105 %.pdf: %.eps
106 epstopdf $<
108 %.eps: %.svg
109 inkscape -E $@ $<
111 examples: examples/.run
113 examples/.run: $(example-sources)
114 cd examples && ./run-example
116 build_id.tex: $(wildcard ../.hg/00changelog.[id])
117 echo -n $(hg_id) > build_id.tex
119 clean:
120 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
121 examples/*.out examples/.run build_id.tex