hgbook

view en/Makefile @ 57:fa8bafe467cb

Merge with upstream
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Tue Jul 25 00:02:24 2006 -0400 (2006-07-25)
parents b8539d91c84d dd657c4d3a47
children 3649ee841264
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 daily.tex \
12 hook.tex \
13 intro.tex \
14 mq.tex \
15 preface.tex
17 image-sources := \
18 mq-stack.svg
20 example-sources := \
21 examples/daily.files \
22 examples/hook.simple \
23 examples/hook.ws \
24 examples/concepts \
25 examples/mq.qinit-help \
26 examples/mq.dodiff \
27 examples/mq.tarball \
28 examples/mq.tools \
29 examples/mq.tutorial
31 latex-options = \
32 -interaction batchmode \
33 -output-directory $(dir $(1)) \
34 -jobname $(basename $(notdir $(1)))
36 all: pdf html
38 pdf: pdf/hgbook.pdf
40 define pdf
41 mkdir -p $(dir $@)
42 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
43 cp 99book.bib $(dir $@)
44 cd $(dir $@) && bibtex $(basename $(notdir $@))
45 cd $(dir $@) && makeindex $(basename $(notdir $@))
46 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
47 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
48 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
49 endef
51 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
52 $(call pdf)
54 html: html/onepage/hgbook.html html/split/hgbook.html
56 # This is a horrible hack to work around the fact that the htlatex
57 # command in tex4ht is itself a horrible hack. I really don't want to
58 # include verbatim the big wad of TeX that is repeated in that script,
59 # so instead I mangle the script itself.
61 define htlatex
62 mkdir -p $(dir $(1))
63 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
64 cp 99book.bib $(dir $@)
65 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
66 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
67 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
68 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
69 chmod 755 $(dir $(1))/htlatex.book
70 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
71 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
72 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
73 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
74 endef
76 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
77 $(call htlatex,$@,$<)
78 cp $(image-sources:%.svg=%.png) $(dir $@)
80 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
81 $(call htlatex,$@,$<,2)
82 cp $(image-sources:%.svg=%.png) $(dir $@)
84 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
86 beta/%.tex: %.tex
87 ./fblinks $(hg_id) $(dir $@) $<
89 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
90 $(call pdf)
92 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
93 $(call htlatex,$@,$<)
94 cp $(image-sources:%.svg=%.png) $(dir $@)
96 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
97 $(call htlatex,$@,$<,2)
98 cp $(image-sources:%.svg=%.png) $(dir $@)
100 # Produce 90dpi PNGs for the web.
102 %.png: %.svg
103 inkscape -D -e $@ $<
105 # Produce eps & pdf for the pdf
107 %.pdf: %.eps
108 epstopdf $<
110 %.eps: %.svg
111 inkscape -E $@ $<
113 examples: examples/.run
115 examples/.run: $(example-sources:%=%.run)
116 touch examples/.run
118 examples/%.run: examples/% examples/run-example
119 cd examples && ./run-example $(notdir $<)
121 build_id.tex: $(wildcard ../.hg/00changelog.[id])
122 echo -n $(hg_id) > build_id.tex
124 clean:
125 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
126 examples/*.{out,run} examples/.run build_id.tex