hgbook

annotate en/Makefile @ 117:6b0f4498569e

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