bos@18: # This makefile requires GNU make. bos@18: bos@11: image-sources := \ bos@179: feature-branches.dot \ bos@108: filelog.svg \ bos@103: kdiff3.png \ bos@109: metadata.svg \ bos@96: mq-stack.svg \ bos@149: note.png \ bos@112: revlog.svg \ bos@110: snapshot.svg \ bos@99: tour-history.svg \ bos@103: tour-merge-conflict.svg \ bos@103: tour-merge-merge.svg \ bos@100: tour-merge-pull.svg \ bos@113: tour-merge-sep-repos.svg \ bos@124: undo-manual.dot \ bos@124: undo-manual-merge.dot \ bos@124: undo-non-tip.dot \ bos@124: undo-simple.dot \ bos@113: wdir.svg \ bos@115: wdir-after-commit.svg \ bos@115: wdir-branch.svg \ bos@115: wdir-merge.svg \ bos@115: wdir-pre-branch.svg bos@103: bos@558: xml-src-files := \ bos@558: 00book.xml \ bos@559: app*.xml \ bos@559: ch*.xml bos@558: bos@124: image-dot := $(filter %.dot,$(image-sources)) bos@103: image-svg := $(filter %.svg,$(image-sources)) bos@124: image-png := $(filter %.png,$(image-sources)) bos@11: bos@213: image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png) bos@213: bos@580: example-sources-by-name := \ bos@124: backout \ bos@131: bisect \ bos@179: branching \ bos@202: branch-named \ bos@198: branch-repo \ bos@133: cmdref \ bos@117: daily.copy \ bos@86: daily.files \ bos@118: daily.rename \ bos@122: daily.revert \ bos@226: extdiff \ bos@133: filenames \ bos@86: hook.msglen \ bos@86: hook.simple \ bos@86: hook.ws \ bos@156: issue29 \ bos@104: mq.guards \ bos@86: mq.qinit-help \ bos@86: mq.dodiff \ bos@86: mq.id \ bos@86: mq.tarball \ bos@86: mq.tools \ bos@86: mq.tutorial \ bos@156: rename.divergent \ bos@121: rollback \ bos@196: tag \ bos@86: template.simple \ bos@87: template.svnstyle \ bos@103: tour \ bos@103: tour-merge-conflict bos@4: bos@580: example-sources := \ bos@580: $(example-sources-by-name:%=examples/%) \ bos@580: $(wildcard examples/ch*/*) bos@580: bos@575: obj-web := html bos@575: obj-websup := html/support bos@575: bos@575: extras-web-base := \ bos@575: $(obj-web)/index.html \ bos@575: $(obj-web)/robots.txt \ bos@575: $(obj-websup)/form-min.js \ bos@575: $(obj-websup)/form.js \ bos@575: $(obj-websup)/hsbook.js \ bos@575: $(obj-websup)/jquery-min.js \ bos@575: $(obj-websup)/jquery.js \ bos@575: $(obj-websup)/styles.css bos@575: bos@575: extras-web := $(extras-web-base) $(extras-web-base:%=%.gz) bos@575: bos@558: xsltproc := xsltproc bos@558: xsltproc-opts := --nonet --xinclude --path '$(xml-path)' bos@558: bos@558: xmllint := xmllint bos@558: xmllint-opts := --noout --nonet --valid bos@558: bos@558: system-xsl-dir := $(firstword $(wildcard \ bos@558: /usr/share/sgml/docbook/xsl-stylesheets \ bos@558: /usr/share/xml/docbook/stylesheet/nwalsh \ bos@558: )) bos@558: bos@558: # Bletcherousness. bos@558: bos@558: ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),) bos@558: dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*) bos@558: else bos@558: ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),) bos@558: dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4) bos@558: else bos@558: $(error Do not know where to look for DocBook XML 4.4 DTD) bos@558: endif bos@558: endif bos@558: bos@558: ifeq ($(system-xsl-dir),) bos@558: $(error add a suitable directory to system-xsl-dir) bos@558: endif bos@558: bos@172: example-prereqs := \ bos@172: /usr/bin/merge bos@172: bos@157: dist-sources := \ bos@159: ../html/hgicon.png \ bos@157: ../html/index.html.var \ bos@157: ../html/index.en.html bos@157: bos@177: hg = $(shell which hg) bos@177: bos@269: hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n') bos@177: bos@177: hg-version = $(shell hg version -q | \ bos@242: sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,') bos@177: bos@575: all: web bos@149: dongsheng@650: ../xsl/system-xsl: $(system-xsl-dir) bos@558: ln -s $< $@ bos@558: bos@581: web: ../xsl/system-xsl websup html bos@575: dongsheng@650: html: ../xsl/system-xsl $(xml-src-files) valid dongsheng@650: xsltproc $(xsltproc-opts) -o html/read/x ../xsl/chunk-stylesheet.xsl 00book.xml bos@575: for i in html/read/*.html; do \ bos@575: gzip -9 -c $$i > $$i.gz; \ bos@575: done bos@575: bos@575: websup: $(extras-web) dongsheng@650: mkdir -p $(obj-websup)/figs dongsheng@650: cp ../xsl/system-xsl/images/*.png $(obj-websup)/figs dongsheng@650: cp -f ../web/icons/*.png $(obj-websup)/figs dongsheng@650: dongsheng@650: all-ids.dat: ../xsl/all-ids.xsl $(xml-src-files) dongsheng@650: $(xsltproc) $(xsltproc-opts) -o $@ ../xsl/all-ids.xsl 00book.xml bos@575: bos@575: web: websup bos@558: bos@558: valid: .validated-00book.xml bos@558: bos@558: .validated-00book.xml: $(xml-src-files) bos@558: $(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $< bos@558: touch $@ bos@558: bos@18: # Produce 90dpi PNGs for the web. bos@18: bos@309: %.png: %.svg fixsvg hg@307: ./fixsvg $< bos@309: inkscape -D -e $@ $<-tmp.svg bos@309: rm $<-tmp.svg bos@11: bos@124: %.svg: %.dot bos@124: dot -Tsvg -o $@ $< bos@124: bos@172: examples: $(example-prereqs) examples/.run bos@4: bos@580: examples/.run: $(example-sources) bos@580: cd examples && ./run-example bos@45: bos@45: examples/%.run: examples/% examples/run-example bos@4: bos@571: clean: bos@571: -rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \ bos@571: $(image-svg:%.svg=%.png) examples/*.{lxo,run} examples/.run bos@250: bos@571: install: html $(dist-sources) bos@153: rm -rf dist bos@153: mkdir -p dist bos@571: cp html/*.{css,html,png} dist bos@157: cp $(dist-sources) dist bos@153: bos@153: rsync: install bos@153: rsync -avz --delete dist sp.red-bean.com:public_html/hgbook bos@575: bos@575: vpath %.css ../web bos@575: vpath %.js ../web/javascript bos@575: bos@575: $(obj-websup)/%.css: %.css bos@575: @mkdir -p $(dir $@) bos@575: cp $< $@ bos@575: bos@575: $(obj-websup)/%.jpg: %.jpg bos@575: @mkdir -p $(dir $@) bos@575: cp $< $@ bos@575: bos@575: $(obj-websup)/%.js: %.js bos@575: @mkdir -p $(dir $@) bos@575: cp $< $@ bos@575: bos@575: $(obj-web)/%: ../web/% bos@575: @mkdir -p $(dir $@) bos@575: cp $< $@ bos@575: bos@575: $(obj-web)/%.html: %.html.in bos@575: @mkdir -p $(dir $@) bos@575: python ../web/texpand.py $< $@ bos@575: bos@575: %.gz: % bos@575: gzip -9 -c $< > $@