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