hgbook

annotate en/Makefile @ 96:7d7ddc3a57af

Split tour into two chapters.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri Oct 13 15:34:54 2006 -0700 (2006-10-13)
parents 47ea206351d5
children 06383f9e46e4
rev   line source
bos@18 1 # This makefile requires GNU make.
bos@18 2
gb@69 3 hg_id := $(shell hg parents --template '{node|short}\n')
bos@18 4
bos@2 5 sources := \
bos@2 6 00book.tex \
bos@2 7 99book.bib \
bos@2 8 99defs.tex \
bos@34 9 build_id.tex \
bos@59 10 concepts.tex \
bos@42 11 daily.tex \
bos@34 12 hook.tex \
bos@16 13 intro.tex \
bos@16 14 mq.tex \
bos@76 15 preface.tex \
bos@85 16 srcinstall.tex \
bos@84 17 template.tex \
bos@95 18 tour-basic.tex \
bos@95 19 tour-merge.tex
bos@0 20
bos@11 21 image-sources := \
bos@96 22 mq-stack.svg \
bos@96 23 tour-history.svg
bos@11 24
bos@4 25 example-sources := \
bos@86 26 daily.files \
bos@86 27 hook.msglen \
bos@86 28 hook.simple \
bos@86 29 hook.ws \
bos@86 30 mq.qinit-help \
bos@86 31 mq.dodiff \
bos@86 32 mq.id \
bos@86 33 mq.tarball \
bos@86 34 mq.tools \
bos@86 35 mq.tutorial \
bos@86 36 template.simple \
bos@87 37 template.svnstyle \
bos@87 38 tour
bos@4 39
bos@0 40 latex-options = \
bos@0 41 -interaction batchmode \
bos@0 42 -output-directory $(dir $(1)) \
bos@0 43 -jobname $(basename $(notdir $(1)))
bos@0 44
bos@0 45 all: pdf html
bos@0 46
bos@0 47 pdf: pdf/hgbook.pdf
bos@0 48
bos@18 49 define pdf
bos@0 50 mkdir -p $(dir $@)
bos@21 51 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@2 52 cp 99book.bib $(dir $@)
bos@2 53 cd $(dir $@) && bibtex $(basename $(notdir $@))
bos@16 54 cd $(dir $@) && makeindex $(basename $(notdir $@))
bos@21 55 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@21 56 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@26 57 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
bos@18 58 endef
bos@18 59
jeffpc@30 60 pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%.pdf) examples
bos@18 61 $(call pdf)
bos@0 62
bos@0 63 html: html/onepage/hgbook.html html/split/hgbook.html
bos@0 64
bos@18 65 # This is a horrible hack to work around the fact that the htlatex
bos@18 66 # command in tex4ht is itself a horrible hack. I really don't want to
bos@18 67 # include verbatim the big wad of TeX that is repeated in that script,
bos@18 68 # so instead I mangle the script itself.
bos@18 69
bos@0 70 define htlatex
bos@0 71 mkdir -p $(dir $(1))
bos@7 72 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
bos@7 73 cp 99book.bib $(dir $@)
bos@7 74 echo '(cd $(dir $@) && bibtex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
bos@16 75 echo '(cd $(dir $@) && makeindex $(basename $(notdir $@)))' >> $(dir $(1))/htlatex.book
bos@7 76 head -3 $(shell which htlatex) >> $(dir $(1))/htlatex.book
bos@7 77 echo 'echo status $$$$' >> $(dir $(1))/htlatex.book
bos@0 78 chmod 755 $(dir $(1))/htlatex.book
bos@21 79 TEXINPUTS=$(dir $(2)): $(dir $(1))/htlatex.book $(2) "xhtml,html4-uni,$(3)" " -cunihtf -utf8" "" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
bos@0 80 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
bos@0 81 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
bos@7 82 perl -pi -e 's/&#x00([0-7][0-9a-f]);/chr(hex($$1))/egi' $(dir $(1))/*.html
bos@0 83 endef
bos@0 84
bos@11 85 html/onepage/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
bos@0 86 $(call htlatex,$@,$<)
bos@11 87 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@0 88
bos@11 89 html/split/hgbook.html: $(sources) $(image-sources:%.svg=%.png) examples
bos@0 90 $(call htlatex,$@,$<,2)
bos@11 91 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@0 92
bos@18 93 beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
bos@18 94
bos@18 95 beta/%.tex: %.tex
bos@18 96 ./fblinks $(hg_id) $(dir $@) $<
bos@18 97
jeffpc@30 98 beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.pdf) examples fblinks
bos@18 99 $(call pdf)
bos@18 100
bos@18 101 beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
bos@18 102 $(call htlatex,$@,$<)
bos@18 103 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@18 104
bos@18 105 beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
bos@18 106 $(call htlatex,$@,$<,2)
bos@18 107 cp $(image-sources:%.svg=%.png) $(dir $@)
bos@18 108
bos@18 109 # Produce 90dpi PNGs for the web.
bos@18 110
bos@11 111 %.png: %.svg
bos@11 112 inkscape -D -e $@ $<
bos@11 113
jeffpc@30 114 # Produce eps & pdf for the pdf
bos@18 115
jeffpc@30 116 %.pdf: %.eps
jeffpc@30 117 epstopdf $<
jeffpc@30 118
jeffpc@30 119 %.eps: %.svg
bos@32 120 inkscape -E $@ $<
bos@11 121
bos@4 122 examples: examples/.run
bos@4 123
bos@86 124 examples/.run: $(example-sources:%=examples/%.run)
bos@45 125 touch examples/.run
bos@45 126
bos@45 127 examples/%.run: examples/% examples/run-example
bos@45 128 cd examples && ./run-example $(notdir $<)
bos@4 129
bos@18 130 build_id.tex: $(wildcard ../.hg/00changelog.[id])
bos@29 131 echo -n $(hg_id) > build_id.tex
bos@16 132
bos@0 133 clean:
jeffpc@30 134 rm -rf beta html pdf *.eps *.pdf *.png *.aux *.dvi *.log *.out \
bos@46 135 examples/*.{out,run} examples/.run build_id.tex