hgbook

annotate en/Makefile @ 559:b90b024729f1

WIP DocBook snapshot that all compiles. Mirabile dictu!
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Feb 18 00:22:09 2009 -0800 (2009-02-18)
parents 8631da51309b
children 27043f385f3f
rev   line source
bos@18 1 # This makefile requires GNU make.
bos@18 2
bos@2 3 sources := \
bos@2 4 00book.tex \
bos@2 5 99book.bib \
bos@2 6 99defs.tex \
bos@550 7 app*.tex \
bos@550 8 ch*.tex
bos@0 9
bos@11 10 image-sources := \
bos@179 11 feature-branches.dot \
bos@108 12 filelog.svg \
bos@103 13 kdiff3.png \
bos@109 14 metadata.svg \
bos@96 15 mq-stack.svg \
bos@149 16 note.png \
bos@112 17 revlog.svg \
bos@110 18 snapshot.svg \
bos@99 19 tour-history.svg \
bos@103 20 tour-merge-conflict.svg \
bos@103 21 tour-merge-merge.svg \
bos@100 22 tour-merge-pull.svg \
bos@113 23 tour-merge-sep-repos.svg \
bos@124 24 undo-manual.dot \
bos@124 25 undo-manual-merge.dot \
bos@124 26 undo-non-tip.dot \
bos@124 27 undo-simple.dot \
bos@113 28 wdir.svg \
bos@115 29 wdir-after-commit.svg \
bos@115 30 wdir-branch.svg \
bos@115 31 wdir-merge.svg \
bos@115 32 wdir-pre-branch.svg
bos@103 33
bos@558 34 xml-src-files := \
bos@558 35 00book.xml \
bos@559 36 app*.xml \
bos@559 37 ch*.xml
bos@558 38
bos@124 39 image-dot := $(filter %.dot,$(image-sources))
bos@103 40 image-svg := $(filter %.svg,$(image-sources))
bos@124 41 image-png := $(filter %.png,$(image-sources))
bos@11 42
bos@213 43 image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
bos@213 44 image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
bos@213 45
bos@4 46 example-sources := \
bos@124 47 backout \
bos@131 48 bisect \
bos@179 49 branching \
bos@202 50 branch-named \
bos@198 51 branch-repo \
bos@133 52 cmdref \
bos@117 53 daily.copy \
bos@86 54 daily.files \
bos@118 55 daily.rename \
bos@122 56 daily.revert \
bos@226 57 extdiff \
bos@133 58 filenames \
bos@86 59 hook.msglen \
bos@86 60 hook.simple \
bos@86 61 hook.ws \
bos@156 62 issue29 \
bos@104 63 mq.guards \
bos@86 64 mq.qinit-help \
bos@86 65 mq.dodiff \
bos@86 66 mq.id \
bos@86 67 mq.tarball \
bos@86 68 mq.tools \
bos@86 69 mq.tutorial \
bos@156 70 rename.divergent \
bos@121 71 rollback \
bos@196 72 tag \
bos@86 73 template.simple \
bos@87 74 template.svnstyle \
bos@103 75 tour \
bos@103 76 tour-merge-conflict
bos@4 77
bos@558 78 xsltproc := xsltproc
bos@558 79 xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
bos@558 80
bos@558 81 xmllint := xmllint
bos@558 82 xmllint-opts := --noout --nonet --valid
bos@558 83
bos@558 84 system-xsl-dir := $(firstword $(wildcard \
bos@558 85 /usr/share/sgml/docbook/xsl-stylesheets \
bos@558 86 /usr/share/xml/docbook/stylesheet/nwalsh \
bos@558 87 ))
bos@558 88
bos@558 89 # Bletcherousness.
bos@558 90
bos@558 91 ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
bos@558 92 dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
bos@558 93 else
bos@558 94 ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
bos@558 95 dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
bos@558 96 else
bos@558 97 $(error Do not know where to look for DocBook XML 4.4 DTD)
bos@558 98 endif
bos@558 99 endif
bos@558 100
bos@558 101 ifeq ($(system-xsl-dir),)
bos@558 102 $(error add a suitable directory to system-xsl-dir)
bos@558 103 endif
bos@558 104
bos@172 105 example-prereqs := \
bos@172 106 /usr/bin/merge
bos@172 107
bos@157 108 dist-sources := \
bos@159 109 ../html/hgicon.png \
bos@157 110 ../html/index.html.var \
bos@157 111 ../html/index.en.html
bos@157 112
bos@0 113 latex-options = \
bos@0 114 -interaction batchmode \
bos@0 115 -output-directory $(dir $(1)) \
bos@0 116 -jobname $(basename $(notdir $(1)))
bos@0 117
bos@177 118 hg = $(shell which hg)
bos@177 119
bos@269 120 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
bos@177 121
bos@177 122 hg-version = $(shell hg version -q | \
bos@242 123 sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
bos@177 124
bos@0 125 all: pdf html
bos@0 126
bos@0 127 pdf: pdf/hgbook.pdf
bos@0 128
bos@18 129 define pdf
bos@0 130 mkdir -p $(dir $@)
bos@21 131 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@2 132 cp 99book.bib $(dir $@)
bos@2 133 cd $(dir $@) && bibtex $(basename $(notdir $@))
bos@16 134 cd $(dir $@) && makeindex $(basename $(notdir $@))
bos@21 135 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@21 136 TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
bos@26 137 if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
bos@18 138 endef
bos@18 139
hg@307 140 pdf/hgbook.pdf: $(sources) examples $(image-pdf)
bos@18 141 $(call pdf)
bos@0 142
bos@149 143 html: onepage split
bos@149 144
bos@558 145 ../xsl/system-xsl: $(system-xsl-dir)
bos@558 146 ln -s $< $@
bos@558 147
bos@558 148 dbhtml: ../xsl/system-xsl $(xml-src-files) valid
bos@558 149 xsltproc $(xsltproc-opts) ../xsl/chunk-stylesheet.xsl 00book.xml
bos@558 150
bos@558 151 valid: .validated-00book.xml
bos@558 152
bos@558 153 .validated-00book.xml: $(xml-src-files)
bos@558 154 $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
bos@558 155 touch $@
bos@558 156
bos@213 157 onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
bos@213 158
bos@213 159 html/onepage/%: %
bos@213 160 cp $< $@
bos@213 161
bos@213 162 split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
bos@213 163
bos@213 164 html/split/%: %
bos@213 165 cp $< $@
bos@0 166
bos@18 167 # This is a horrible hack to work around the fact that the htlatex
bos@18 168 # command in tex4ht is itself a horrible hack. I really don't want to
bos@18 169 # include verbatim the big wad of TeX that is repeated in that script,
bos@171 170 # but I've given up and run a hacked copy as htlatex.book here.
bos@18 171
bos@0 172 define htlatex
bos@0 173 mkdir -p $(dir $(1))
bos@170 174 cp 99book.bib $(dir $(1))
bos@170 175 TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
bos@0 176 cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
bos@0 177 cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
bos@149 178 ./fixhtml.py $(dir $(1))/*.html
bos@214 179 rm $(dir $(1))/hgbook.css
bos@0 180 endef
bos@0 181
hg@307 182 html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
bos@0 183 $(call htlatex,$@,$<)
bos@213 184
bos@213 185 html/split/hgbook.html: $(sources) examples bookhtml.cfg
bos@0 186 $(call htlatex,$@,$<,2)
bos@18 187
bos@18 188 # Produce 90dpi PNGs for the web.
bos@18 189
bos@309 190 %.png: %.svg fixsvg
hg@307 191 ./fixsvg $<
bos@309 192 inkscape -D -e $@ $<-tmp.svg
bos@309 193 rm $<-tmp.svg
bos@11 194
bos@124 195 %.svg: %.dot
bos@124 196 dot -Tsvg -o $@ $<
bos@124 197
jeffpc@30 198 # Produce eps & pdf for the pdf
bos@18 199
jeffpc@30 200 %.pdf: %.eps
jeffpc@30 201 epstopdf $<
jeffpc@30 202
jeffpc@30 203 %.eps: %.svg
hg@307 204 ./fixsvg $<
hg@310 205 inkscape -E $@ $<-tmp.svg
hg@310 206 rm $<-tmp.svg
bos@11 207
bos@124 208 %.eps: %.dot
bos@124 209 dot -Tps -o $@ $<
bos@124 210
bos@172 211 examples: $(example-prereqs) examples/.run
bos@4 212
bos@86 213 examples/.run: $(example-sources:%=examples/%.run)
bos@45 214 touch examples/.run
bos@45 215
bos@45 216 examples/%.run: examples/% examples/run-example
bos@45 217 cd examples && ./run-example $(notdir $<)
bos@4 218
bos@250 219 changelog := $(wildcard ../.hg/store/00changelog.[id])
bos@250 220 ifeq ($(changelog),)
bos@250 221 changelog := $(wildcard ../.hg/00changelog.[id])
bos@250 222 endif
bos@250 223
bos@250 224 build_id.tex: $(changelog)
wbunaarfubss@249 225 echo -n '$(hg-id)' > build_id.tex
bos@177 226
bos@177 227 hg_id.tex: $(hg)
wbunaarfubss@249 228 echo -n '$(hg-version)' > hg_id.tex
bos@16 229
bos@0 230 clean:
bos@153 231 rm -rf dist html pdf \
bos@124 232 $(image-dot:%.dot=%.pdf) \
bos@124 233 $(image-dot:%.dot=%.png) \
bos@103 234 $(image-svg:%.svg=%.pdf) \
bos@103 235 $(image-svg:%.svg=%.png) \
bos@177 236 examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
bos@153 237
bos@157 238 install: pdf split $(dist-sources)
bos@153 239 rm -rf dist
bos@153 240 mkdir -p dist
bos@153 241 cp pdf/hgbook.pdf dist
bos@153 242 cp html/split/*.{css,html,png} dist
bos@157 243 cp $(dist-sources) dist
bos@153 244
bos@153 245 rsync: install
bos@153 246 rsync -avz --delete dist sp.red-bean.com:public_html/hgbook