hgbook

annotate en/Makefile @ 111:34b8b7a15ea1

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