Whamcloud - gitweb
LUDOC-13 render diff of html manual to enhance reviewability.
[doc/manual.git] / Makefile
1 SRC_XML=$(wildcard *.xml)
2 SRC_IMG=$(wildcard figures/*.png)
3 SRCS=$(SRC_XML) $(SRC_IMG)
4 TEMP=/tmp
5
6 TGT_BASE=lustre_manual
7 MASTER_URL=http://build.whamcloud.com/job/lustre-manual/lastSuccessfulBuild/
8 MASTER_XHTML=$(MASTER_URL)/artifact/_out/$(TGT_BASE).xhtml
9 TGT_MASTER=$(TEMP)/mastermanual
10
11
12 RNG_LIN=/usr/share/xml/docbook/schema/rng/5.0/docbookxi.rng
13 RNG_MAC=/opt/local/share/xml/docbook/5.0/rng/docbookxi.rng
14 RNG=$(or $(shell ls $(RNG_LIN) 2> /dev/null), \
15          $(shell ls $(RNG_MAC) 2> /dev/null))
16 XSL_LIN=/usr/share/xml/docbook/stylesheet/docbook-xsl-ns
17 XSL_MAC=/opt/local/share/xsl/docbook-xsl
18 XSL=$(or $(shell ls -d $(XSL_LIN) 2> /dev/null), \
19          $(shell ls -d $(XSL_MAC) 2> /dev/null))
20
21 .PHONY: check
22 check: $(SRC_XML)
23         xmllint --noout --xinclude --noent --relaxng $(RNG) ./index.xml
24
25 # Note: can't use "suffix" instead of "subst", because it keeps the '.'
26 $(TGT_BASE).html $(TGT_BASE).xhtml $(TGT_BASE).fo: $(SRCS)
27         xsltproc --stringparam fop1.extensions  1 \
28                 --stringparam section.label.includes.component.label 1 \
29                 --stringparam section.autolabel 1 \
30                 --stringparam chapter.autolabel 1 \
31                 --stringparam appendix.autolabel 1 \
32                 --xinclude -o $@ $(XSL)/$(subst $(TGT_BASE).,,$@)/docbook.xsl ./index.xml
33
34 $(TGT_BASE).pdf: $(TGT_BASE).fo
35                 fop $< $@
36
37 .PHONY: html
38 html: $(TGT_BASE).html
39
40 .PHONY: xhtml
41 xhtml: $(TGT_BASE).xhtml
42
43 .PHONY: pdf
44 pdf: $(TGT_BASE).pdf
45
46 # get the git hash for the last successful build of the manual
47 .PHONY: mastermanual.revision
48 mastermanual.revision:
49         wget -O mastermanual.index $(MASTER_URL)
50         awk '/Revision/ { print $$NF }' mastermanual.index > mastermanual.revision
51
52 # only fetch the full manual if we don't have it or the manual changed
53 $(TGT_MASTER).xhtml: mastermanual.revision
54         if ! cmp -s mastermanual.revision $(TGT_MASTER).revision ; then\
55                 wget -O $(TGT_MASTER).xhtml $(MASTER_XHTML) && \
56                 mv mastermanual.revision $(TGT_MASTER).revision;\
57         fi
58
59 .PHONY: diff
60 diff: $(TGT_BASE).xhtml $(TGT_MASTER).xhtml
61         ./tools/diff.py $(TGT_MASTER).xhtml $(TGT_BASE).xhtml > $(TGT_BASE).diff
62
63
64 .PHONY: push
65 push:
66         git push ssh://review.whamcloud.com:29418/doc/manual HEAD:refs/for/master
67
68 .PHONY: clean
69 clean:
70         rm $(TGT_BASE).html $(TGT_BASE).xhtml $(TGT_BASE).pdf