Whamcloud - gitweb
LUDOC-321 style: ensure ID attributes are unique.
[doc/manual.git] / Makefile
1 SRC_XML=$(wildcard *.xml)
2 SRC_IMG=$(wildcard figures/*.png)
3 SRCS=$(SRC_XML) $(SRC_IMG)
4 TMP?=/tmp
5
6 TGT_BASE=lustre_manual
7 MASTER_URL=http://build.whamcloud.com/job/lustre-manual/lastSuccessfulBuild/
8 MASTER_URL_LAB=http://build.lab.whamcloud.com:8080/job/lustre-manual/lastSuccessfulBuild/
9 MASTER_XHTML=$(MASTER_URL)/artifact/$(TGT_BASE).xhtml
10 MASTER_XHTML_LAB=$(MASTER_URL_LAB)/artifact/$(TGT_BASE).xhtml
11 TGT_MASTER=$(TMP)/mastermanual
12 CHUNKED_HTML=chunked-html
13
14
15 RNG_UBN=/usr/share/xml/docbook/schema/rng/5.0/docbookxi.rng
16 RNG_REL=/usr/share/xml/docbook5/schema/rng/5.0/docbookxi.rng
17 RNG_MAC=/opt/local/share/xml/docbook/5.0/rng/docbookxi.rng
18 RNG=$(or $(shell ls $(RNG_UBN) 2> /dev/null), \
19          $(shell ls $(RNG_REL) 2> /dev/null), \
20          $(shell ls $(RNG_MAC) 2> /dev/null))
21 XSL_UBN=/usr/share/xml/docbook/stylesheet/docbook-xsl-ns
22 XSL_REL=/usr/share/sgml/docbook/xsl-ns-stylesheets-1.75.2
23 XSL_F16=/usr/share/sgml/docbook/xsl-ns-stylesheets
24 XSL_SLE=/usr/share/xml/docbook/stylesheet/nwalsh5/current
25 XSL_MAC=/opt/local/share/xsl/docbook-xsl
26 XSL=$(or $(shell ls -d $(XSL_UBN) 2> /dev/null), \
27          $(shell ls -d $(XSL_REL) 2> /dev/null), \
28          $(shell ls -d $(XSL_F16) 2> /dev/null), \
29          $(shell ls -d $(XSL_SLE) 2> /dev/null), \
30          $(shell ls -d $(XSL_MAC) 2> /dev/null))
31 PRIMARYXSL=$(XSL)/$(subst $(TGT_BASE).,,$@)/docbook.xsl
32 PRIMARYCHUNKXSL=$(XSL)/html/chunkfast.xsl
33
34 .PHONY: all
35 all: clean check xhtml html chunked-html pdf epub
36
37 .PHONY: check
38 check: $(SRC_XML)
39         xmllint --noout --xinclude --noent --relaxng $(RNG) ./index.xml
40
41 # Note: can't use "suffix" instead of "subst", because it keeps the '.'
42 # Note: xsl:import is resolved at compile time, so the primary xsl
43 #   is substituted into the custom xsl with sed before compliation.
44 $(CHUNKED_HTML)/%.html: $(SRCS)
45         sed -e 's;PRIMARYXSL;${PRIMARYCHUNKXSL};' ./style/customstyle.xsl | \
46         xsltproc --xinclude -o ${CHUNKED_HTML}/ - ./index.xml
47
48 $(TGT_BASE).html $(TGT_BASE).xhtml $(TGT_BASE).epub: $(SRCS)
49         sed -e 's;PRIMARYXSL;${PRIMARYXSL};' ./style/customstyle.xsl | \
50         xsltproc --xinclude -o $@ - ./index.xml
51
52 $(TGT_BASE).fo: $(SRCS)
53         sed -e 's;PRIMARYXSL;${PRIMARYXSL};' ./style/customstyle_fo.xsl | \
54         xsltproc --xinclude -o $@ - ./index.xml
55
56
57 $(TGT_BASE).pdf: $(TGT_BASE).fo
58                 fop $< $@
59
60 .PHONY: html
61 html: $(TGT_BASE).html
62
63 .PHONY: xhtml
64 xhtml: $(TGT_BASE).xhtml
65
66 .PHONY: pdf
67 pdf: $(TGT_BASE).pdf
68
69 .PHONY: epub
70 epub: $(TGT_BASE).epub
71         echo "application/epub+zip" > mimetype
72         cp -r ./figures ./OEBPS/
73         mkdir ./OEBPS/style
74         cp ./style/manual.css ./OEBPS/style/
75         zip -0Xq $(TGT_BASE).epub mimetype
76         zip -Xr9D $(TGT_BASE).epub OEBPS/*
77         zip -Xr9D $(TGT_BASE).epub META-INF/*
78
79 .PHONY: chunked-html
80 chunked-html: $(CHUNKED_HTML)/%.html
81         cp -r ./figures ./${CHUNKED_HTML}
82
83
84 # get the git hash for the last successful build of the manual
85 .PHONY: mastermanual.revision
86 mastermanual.revision:
87         wget -O mastermanual.index $(MASTER_URL) || wget -O mastermanual.index $(MASTER_URL_LAB)
88         awk '/Revision/ { print $$NF }' mastermanual.index > mastermanual.revision
89
90 # only fetch the full manual if we don't have it or the manual changed
91 $(TGT_MASTER).xhtml: mastermanual.revision
92         if ! cmp -s mastermanual.revision $(TGT_MASTER).revision ; then\
93                 (wget -O $(TGT_MASTER).xhtml $(MASTER_XHTML) || \
94                 wget -O $(TGT_MASTER).xhtml $(MASTER_XHTML_LAB)) && \
95                 mv mastermanual.revision $(TGT_MASTER).revision;\
96         fi
97
98 .PHONY: diff
99 diff: $(TGT_BASE).xhtml $(TGT_MASTER).xhtml
100         ./tools/diff.py $(TGT_MASTER).xhtml $(TGT_BASE).xhtml > $(TGT_BASE).diff.html
101
102
103 .PHONY: push
104 push:
105         git push ssh://review.hpdd.intel.com:29418/doc/manual HEAD:refs/for/master
106
107 .PHONY: clean
108 clean:
109         rm -f $(TGT_BASE).html $(TGT_BASE).xhtml $(TGT_BASE).pdf\
110                 mastermanual.revision mastermanual.index mimetype\
111                 $(TGT_BASE).diff.html $(TGT_BASE).epub $(TGT_BASE).fo
112         rm -rf ./META-INF ./OEBPS ./$(TGT_BASE)