igor@323: # This makefile requires GNU make. igor@323: igor@323: sources := \ igor@323: 00book.tex \ igor@323: 99book.bib \ igor@323: 99defs.tex \ igor@323: build_id.tex \ igor@323: branch.tex \ igor@323: cmdref.tex \ igor@323: collab.tex \ igor@323: concepts.tex \ igor@323: daily.tex \ igor@323: filenames.tex \ igor@323: hg_id.tex \ igor@323: hgext.tex \ igor@323: hook.tex \ igor@323: intro.tex \ igor@323: mq.tex \ igor@323: mq-collab.tex \ igor@323: mq-ref.tex \ igor@323: preface.tex \ igor@323: srcinstall.tex \ igor@323: template.tex \ igor@323: tour-basic.tex \ igor@323: tour-merge.tex \ igor@323: undo.tex igor@323: igor@323: image-sources := \ igor@323: feature-branches.dot \ igor@323: filelog.svg \ igor@323: kdiff3.png \ igor@323: metadata.svg \ igor@323: mq-stack.svg \ igor@323: note.png \ igor@323: revlog.svg \ igor@323: snapshot.svg \ igor@323: tour-history.svg \ igor@323: tour-merge-conflict.svg \ igor@323: tour-merge-merge.svg \ igor@323: tour-merge-pull.svg \ igor@323: tour-merge-sep-repos.svg \ igor@323: undo-manual.dot \ igor@323: undo-manual-merge.dot \ igor@323: undo-non-tip.dot \ igor@323: undo-simple.dot \ igor@323: wdir.svg \ igor@323: wdir-after-commit.svg \ igor@323: wdir-branch.svg \ igor@323: wdir-merge.svg \ igor@323: wdir-pre-branch.svg igor@323: igor@323: image-dot := $(filter %.dot,$(image-sources)) igor@323: image-svg := $(filter %.svg,$(image-sources)) igor@323: image-png := $(filter %.png,$(image-sources)) igor@323: igor@323: image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png) igor@323: image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png) igor@323: igor@323: example-sources := \ igor@323: backout \ igor@323: bisect \ igor@323: branching \ igor@323: branch-named \ igor@323: branch-repo \ igor@323: cmdref \ igor@323: daily.copy \ igor@323: daily.files \ igor@323: daily.rename \ igor@323: daily.revert \ igor@323: extdiff \ igor@323: filenames \ igor@323: hook.msglen \ igor@323: hook.simple \ igor@323: hook.ws \ igor@323: issue29 \ igor@323: mq.guards \ igor@323: mq.qinit-help \ igor@323: mq.dodiff \ igor@323: mq.id \ igor@323: mq.tarball \ igor@323: mq.tools \ igor@323: mq.tutorial \ igor@323: rename.divergent \ igor@323: rollback \ igor@323: tag \ igor@323: template.simple \ igor@323: template.svnstyle \ igor@323: tour \ igor@323: tour-merge-conflict igor@323: igor@323: example-prereqs := \ igor@323: /usr/bin/merge igor@323: igor@323: dist-sources := \ igor@323: ../html/hgicon.png \ igor@323: ../html/index.html.var \ igor@323: ../html/index.en.html igor@323: igor@323: latex-options = \ igor@323: -interaction batchmode \ igor@323: -output-directory $(dir $(1)) \ igor@323: -jobname $(basename $(notdir $(1))) igor@323: igor@323: hg = $(shell which hg) igor@323: igor@323: hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n') igor@323: igor@323: hg-version = $(shell hg version -q | \ igor@323: sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,') igor@323: igor@323: all: pdf html igor@323: igor@323: pdf: pdf/hgbook.pdf igor@323: igor@323: define pdf igor@323: mkdir -p $(dir $@) igor@323: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) igor@323: cp 99book.bib $(dir $@) igor@323: cd $(dir $@) && bibtex $(basename $(notdir $@)) igor@323: cd $(dir $@) && makeindex $(basename $(notdir $@)) igor@323: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) igor@323: TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) igor@323: if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi igor@323: endef igor@323: igor@323: pdf/hgbook.pdf: $(sources) examples $(image-pdf) igor@323: $(call pdf) igor@323: igor@323: html: onepage split igor@323: igor@323: onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%) igor@323: igor@323: html/onepage/%: % igor@323: cp $< $@ igor@323: igor@323: split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%) igor@323: igor@323: html/split/%: % igor@323: cp $< $@ igor@323: igor@323: # This is a horrible hack to work around the fact that the htlatex igor@323: # command in tex4ht is itself a horrible hack. I really don't want to igor@323: # include verbatim the big wad of TeX that is repeated in that script, igor@323: # but I've given up and run a hacked copy as htlatex.book here. igor@323: igor@323: define htlatex igor@323: mkdir -p $(dir $(1)) igor@323: cp 99book.bib $(dir $(1)) igor@323: TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1) igor@323: cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf igor@323: cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1))) igor@323: ./fixhtml.py $(dir $(1))/*.html igor@323: rm $(dir $(1))/hgbook.css igor@323: endef igor@323: igor@323: html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg igor@323: $(call htlatex,$@,$<) igor@323: igor@323: html/split/hgbook.html: $(sources) examples bookhtml.cfg igor@323: $(call htlatex,$@,$<,2) igor@323: igor@323: # Produce 90dpi PNGs for the web. igor@323: igor@323: %.png: %.svg fixsvg igor@323: ./fixsvg $< igor@323: inkscape -D -e $@ $<-tmp.svg igor@323: rm $<-tmp.svg igor@323: igor@323: %.svg: %.dot igor@323: dot -Tsvg -o $@ $< igor@323: igor@323: # Produce eps & pdf for the pdf igor@323: igor@323: %.pdf: %.eps igor@323: epstopdf $< igor@323: igor@323: %.eps: %.svg igor@323: ./fixsvg $< igor@323: inkscape -E $@ $<-tmp.svg igor@323: rm $<-tmp.svg igor@323: igor@323: %.eps: %.dot igor@323: dot -Tps -o $@ $< igor@323: igor@323: examples: $(example-prereqs) examples/.run igor@323: igor@323: examples/.run: $(example-sources:%=examples/%.run) igor@323: touch examples/.run igor@323: igor@323: examples/%.run: examples/% examples/run-example igor@323: cd examples && ./run-example $(notdir $<) igor@323: igor@323: changelog := $(wildcard ../.hg/store/00changelog.[id]) igor@323: ifeq ($(changelog),) igor@323: changelog := $(wildcard ../.hg/00changelog.[id]) igor@323: endif igor@323: igor@323: build_id.tex: $(changelog) igor@323: echo -n '$(hg-id)' > build_id.tex igor@323: igor@323: hg_id.tex: $(hg) igor@323: echo -n '$(hg-version)' > hg_id.tex igor@323: igor@323: clean: igor@323: rm -rf dist html pdf \ igor@323: $(image-dot:%.dot=%.pdf) \ igor@323: $(image-dot:%.dot=%.png) \ igor@323: $(image-svg:%.svg=%.pdf) \ igor@323: $(image-svg:%.svg=%.png) \ igor@323: examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex igor@323: igor@323: install: pdf split $(dist-sources) igor@323: rm -rf dist igor@323: mkdir -p dist igor@323: cp pdf/hgbook.pdf dist igor@323: cp html/split/*.{css,html,png} dist igor@323: cp $(dist-sources) dist igor@323: igor@323: rsync: install igor@323: rsync -avz --delete dist sp.red-bean.com:public_html/hgbook