Source

hgbook / fr / Makefile

Diff from to

fr/Makefile

 # This makefile requires GNU make.
 
-sources := \
-	00book.tex \
-	99book.bib \
-	99defs.tex \
-	build_id.tex \
-	branch.tex \
-	cmdref.tex \
-	collab.tex \
-	concepts.tex \
-	daily.tex \
-	filenames.tex \
-	hg_id.tex \
-	hgext.tex \
-	hook.tex \
-	intro.tex \
-	mq.tex \
-	mq-collab.tex \
-	mq-ref.tex \
-	preface.tex \
-	srcinstall.tex \
-	template.tex \
-	tour-basic.tex \
-	tour-merge.tex \
-	undo.tex
+image-sources := $(wildcard figs/*.dot figs/*.gif figs/*.png figs/*.svg)
 
-image-sources := \
-	feature-branches.dot \
-	filelog.svg \
-	kdiff3.png \
-	metadata.svg \
-	mq-stack.svg \
-	note.png \
-	revlog.svg \
-	snapshot.svg \
-	tour-history.svg \
-	tour-merge-conflict.svg \
-	tour-merge-merge.svg \
-	tour-merge-pull.svg \
-	tour-merge-sep-repos.svg \
-	undo-manual.dot \
-	undo-manual-merge.dot \
-	undo-non-tip.dot \
-	undo-simple.dot \
-	wdir.svg \
-	wdir-after-commit.svg \
-	wdir-branch.svg \
-	wdir-merge.svg \
-	wdir-pre-branch.svg
+xml-src-files := \
+	00book.xml \
+	app*.xml \
+	ch*.xml
 
 image-dot := $(filter %.dot,$(image-sources))
 image-svg := $(filter %.svg,$(image-sources))
-image-png := $(filter %.png,$(image-sources))
+image-oth := $(filter %.gif %.png,$(image-sources))
 
-image-pdf := $(image-dot:%.dot=%.pdf) $(image-svg:%.svg=%.pdf) $(image-png)
-image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
+obj-web := html
+obj-websup := $(obj-web)/support
+obj-web-read := $(obj-web)/read
 
-example-sources := \
+image-web := \
+	$(image-dot:%.dot=$(obj-web-read)/%.png) \
+	$(image-svg:%.svg=$(obj-web-read)/%.png) \
+	$(image-oth:%=$(obj-web-read)/%)
+
+example-sources-by-name := \
 	backout \
 	bisect \
 	branching \
 	filenames \
 	hook.msglen \
 	hook.simple \
-	hook.ws \
 	issue29 \
 	mq.guards \
 	mq.qinit-help \
 	tour \
 	tour-merge-conflict
 
+example-sources := \
+	$(example-sources-by-name:%=examples/%) \
+	$(wildcard examples/ch*/*)
+
+extras-web-base := \
+	$(obj-web)/index.html \
+	$(obj-web)/robots.txt \
+	$(obj-websup)/form-min.js \
+	$(obj-websup)/form.js \
+	$(obj-websup)/hsbook.js \
+	$(obj-websup)/jquery-min.js \
+	$(obj-websup)/jquery.js \
+	$(obj-websup)/styles.css
+
+extras-web := $(extras-web-base) $(extras-web-base:%=%.gz)
+
+xsltproc := xsltproc
+xsltproc-opts := --nonet --xinclude --path '$(xml-path)'
+
+xmllint := xmllint
+xmllint-opts := --noout --nonet --valid
+
+system-xsl-dir := $(firstword $(wildcard \
+	/usr/share/sgml/docbook/xsl-stylesheets \
+	/usr/share/xml/docbook/stylesheet/nwalsh \
+	))
+
+# Bletcherousness.
+
+ifneq ($(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*),)
+dtd-dir := $(wildcard /usr/share/sgml/docbook/xml-dtd-4.4-*)
+else
+ifneq ($(wildcard /usr/share/xml/docbook/schema/dtd/4.4),)
+dtd-dir := $(wildcard /usr/share/xml/docbook/schema/dtd/4.4)
+else
+$(error Do not know where to look for DocBook XML 4.4 DTD)
+endif
+endif
+
+ifeq ($(system-xsl-dir),)
+$(error add a suitable directory to system-xsl-dir)
+endif
+
 example-prereqs := \
 	/usr/bin/merge
 
 	../html/index.html.var \
 	../html/index.en.html
 
-latex-options = \
-	-interaction batchmode \
-	-output-directory $(dir $(1)) \
-	-jobname $(basename $(notdir $(1)))
-
 hg = $(shell which hg)
 
 hg-id = $(shell hg parents --template '{node|short}, dated {date|isodate},\n')
 hg-version = $(shell hg version -q | \
 		     sed 's,.*(version \(unknown\|[a-f0-9+]*\)),\1,')
 
-all: pdf html
+all: web complete.xml
 
-pdf: pdf/hgbook.pdf
+../stylesheets/system-xsl: $(system-xsl-dir)
+	ln -s $< $@
 
-define pdf
-	mkdir -p $(dir $@)
-	TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
-	cp 99book.bib $(dir $@)
-	cd $(dir $@) && bibtex $(basename $(notdir $@))
-	cd $(dir $@) && makeindex $(basename $(notdir $@))
-	TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
-	TEXINPUTS=$(dir $<): pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
-	if grep 'Reference.*undefined' $(@:.pdf=.log); then exit 1; fi
-endef
+web: ../stylesheets/system-xsl websup html
 
-pdf/hgbook.pdf: $(sources) examples $(image-pdf)
-	$(call pdf)
+html: $(obj-web-read)/index.html
 
-html: onepage split
+../web/index-read.html.in: ../web/genindex.py $(xml-src-files)
+	cd ../web && ./genindex.py
 
-onepage: $(htlatex) html/onepage/hgbook.html html/onepage/hgbook.css $(image-html:%=html/onepage/%)
+$(obj-web-read)/index.html: ../stylesheets/system-xsl .validated-00book.xml ../web/index-read.html.in
+	xsltproc $(xsltproc-opts) -o $(obj-web-read)/x ../stylesheets/chunk-stylesheet.xsl 00book.xml
+	python ../web/texpand.py ../web/index-read.html.in html/read/index.html
+	for i in $(obj-web-read)/*.html; do \
+	  gzip -9 -c $$i > $$i.gz; \
+	done
 
-html/onepage/%: %
-	cp $< $@
+websup: $(extras-web) $(image-web)
+	mkdir -p $(obj-websup)/figs $(obj-web-read)/figs
+	cp ../stylesheets/system-xsl/images/*.png $(obj-websup)/figs
+	cp -f ../web/icons/*.png $(obj-websup)/figs
 
-split: $(htlatex) html/split/hgbook.html html/split/hgbook.css $(image-html:%=html/split/%)
+complete.xml: .validated-00book.xml
+	$(xsltproc) $(xsltproc-opts) -o $@ ../stylesheets/dtd-profile.xsl 00book.xml
 
-html/split/%: %
-	cp $< $@
+all-ids.dat: ../stylesheets/all-ids.xsl $(xml-src-files)
+	$(xsltproc) $(xsltproc-opts) -o $@ ../stylesheets/all-ids.xsl 00book.xml
 
-# This is a horrible hack to work around the fact that the htlatex
-# command in tex4ht is itself a horrible hack.  I really don't want to
-# include verbatim the big wad of TeX that is repeated in that script,
-# but I've given up and run a hacked copy as htlatex.book here.
+web: websup
 
-define htlatex
-	mkdir -p $(dir $(1))
-	cp 99book.bib $(dir $(1))
-	TEXINPUTS=$(dir $(2)): ./htlatex.book $(2) "bookhtml,html4-uni,$(3)" " -cunihtf -utf8" "$(dir $(1))" "$(call latex-options,$(1))" || (rm -f $(1); exit 1)
-	cd $(dir $(1)) && tex4ht -f/$(basename $(notdir $(1))) -cvalidate -cunihtf
-	cd $(dir $(1)) && t4ht -f/$(basename $(notdir $(1)))
-	./fixhtml.py $(dir $(1))/*.html
-	rm $(dir $(1))/hgbook.css
-endef
+valid: .validated-00book.xml
 
-html/onepage/hgbook.html: $(sources) examples $(image-html) bookhtml.cfg
-	$(call htlatex,$@,$<)
-
-html/split/hgbook.html: $(sources) examples bookhtml.cfg
-	$(call htlatex,$@,$<,2)
+.validated-00book.xml: $(xml-src-files) examples/.run
+	$(xmllint) --path '$(dtd-dir):$(xml-path)' $(xmllint-opts) $<
+	touch $@
 
 # Produce 90dpi PNGs for the web.
 
-%.png: %.svg fixsvg
+$(obj-web-read)/figs/%.png: $(obj-web-read)/figs/%.svg fixsvg
+	mkdir -p $(dir $@)
 	./fixsvg $<
 	inkscape -D -e $@ $<-tmp.svg
 	rm $<-tmp.svg
 
-%.svg: %.dot
-	dot -Tsvg -o $@ $<
-
-# Produce eps & pdf for the pdf
-
-%.pdf: %.eps
-	epstopdf $<
-
-%.eps: %.svg
+$(obj-web-read)/figs/%.png: figs/%.svg fixsvg
+	mkdir -p $(dir $@)
 	./fixsvg $<
-	inkscape -E $@ $<-tmp.svg
+	inkscape -D -e $@ $<-tmp.svg
 	rm $<-tmp.svg
 
-%.eps: %.dot
-	dot -Tps -o $@ $<
+$(obj-web-read)/figs/%.gif: figs/%.gif
+	cp $< $@
+
+$(obj-web-read)/figs/%.png: figs/%.png
+	cp $< $@
+
+$(obj-web-read)/figs/%.svg: figs/%.dot
+	mkdir -p $(dir $@)
+	dot -Tsvg -o $@ $<
 
 examples: $(example-prereqs) examples/.run
 
-examples/.run: $(example-sources:%=examples/%.run)
-	touch examples/.run
+examples/.run: $(example-sources)
+	cd examples && ./run-example -a
 
 examples/%.run: examples/% examples/run-example
-	cd examples && ./run-example $(notdir $<)
-
-changelog := $(wildcard ../.hg/store/00changelog.[id])
-ifeq ($(changelog),)
-changelog := $(wildcard ../.hg/00changelog.[id])
-endif
-
-build_id.tex: $(changelog)
-	echo -n '$(hg-id)' > build_id.tex
-
-hg_id.tex: $(hg)
-	echo -n '$(hg-version)' > hg_id.tex
 
 clean:
-	rm -rf dist html pdf \
-		$(image-dot:%.dot=%.pdf) \
-		$(image-dot:%.dot=%.png) \
-		$(image-svg:%.svg=%.pdf) \
-		$(image-svg:%.svg=%.png) \
-		examples/*.{lxo,run} examples/.run build_id.tex hg_id.tex
+	-rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \
+	  $(image-svg:%.svg=%.png) examples/*.{lxo,run} examples/.run
 
-install: pdf split $(dist-sources)
+install: html $(dist-sources)
 	rm -rf dist
 	mkdir -p dist
-	cp pdf/hgbook.pdf dist
-	cp html/split/*.{css,html,png} dist
+	cp html/*.{css,html,png} dist
 	cp $(dist-sources) dist
 
 rsync: install
 	rsync -avz --delete dist sp.red-bean.com:public_html/hgbook
+
+vpath %.css ../web
+vpath %.html.in ../web
+vpath %.js ../web/javascript
+
+$(obj-websup)/%.css: %.css
+	@mkdir -p $(dir $@)
+	cp $< $@
+
+$(obj-websup)/%.jpg: %.jpg
+	@mkdir -p $(dir $@)
+	cp $< $@
+
+$(obj-websup)/%.js: %.js
+	@mkdir -p $(dir $@)
+	cp $< $@
+
+$(obj-web)/%: ../web/%
+	@mkdir -p $(dir $@)
+	cp $< $@
+
+$(obj-web)/%.html: %.html.in
+	@mkdir -p $(dir $@)
+	python ../web/texpand.py $< $@
+
+%.gz: %
+	gzip -9 -c $< > $@
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.