]> git.proxmox.com Git - pmg-docs.git/blob - Makefile
bsys: refactor build process
[pmg-docs.git] / Makefile
1 DGDIR=.
2 ASCIIDOC_PMG=./asciidoc-pmg
3
4 GEN_PACKAGE=pmg-doc-generator
5 DOC_PACKAGE=pmg-docs
6
7 # also update debian/changelog
8 PKGREL=4
9
10 GITVERSION:=$(shell git rev-parse HEAD)
11
12 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
13
14 GEN_DEB=${GEN_PACKAGE}_${DOCRELEASE}-${PKGREL}_${ARCH}.deb
15 DOC_DEB=${DOC_PACKAGE}_${DOCRELEASE}-${PKGREL}_all.deb
16
17
18 all: index.html
19
20 .PHONY: verify-images
21 verify-images: png-verify.pl
22 for i in ./images/screenshot/*.png; do ./png-verify.pl $$i; done
23
24 ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard *.adoc))
25 .pmg-doc-depends link-refs.json: ${ADOC_SOURCES_GUESS} scan-adoc-refs
26 ./scan-adoc-refs *.adoc --depends .pmg-doc-depends.tmp > link-refs.json.tmp
27 @cmp --quiet .pmg-doc-depends .pmg-doc-depends.tmp || mv .pmg-doc-depends.tmp .pmg-doc-depends
28 @cmp --quiet link-refs.json link-refs.json.tmp || mv link-refs.json.tmp link-refs.json
29
30 pmg-doc-generator.mk: .pmg-doc-depends pmg-doc-generator.mk.in
31 cat pmg-doc-generator.mk.in .pmg-doc-depends > $@.tmp
32 mv $@.tmp $@
33
34 -include ./pmg-doc-generator.mk
35
36 GEN_DEB_SOURCES= \
37 pmg-doc-generator.mk \
38 ${MANUAL_SOURCES} \
39 docinfo.xml
40
41 GEN_SCRIPTS= \
42 gen-cluster.conf.5-opts.pl \
43 gen-fetchmail.conf.5-opts.pl \
44 gen-ldap.conf.5-opts.pl \
45 gen-pmg.conf.5-opts.pl \
46 gen-user.conf.5-opts.pl
47
48 API_VIEWER_SOURCES= \
49 api-viewer/index.html \
50 api-viewer/apidoc.js
51
52 asciidoc-pmg: asciidoc-pmg.in link-refs.json
53 cat asciidoc-pmg.in link-refs.json >asciidoc-pmg.tmp
54 sed -e s/@RELEASE@/${DOCRELEASE}/ -i asciidoc-pmg.tmp
55 chmod +x asciidoc-pmg.tmp
56 mv asciidoc-pmg.tmp asciidoc-pmg
57
58 INDEX_INCLUDES= \
59 pmg-admin-guide.pdf \
60 pmg-admin-guide.epub \
61 chapter-index-table.adoc \
62 man1-index-table.adoc \
63 man5-index-table.adoc \
64 man8-index-table.adoc \
65 $(sort $(addsuffix .html, ${MANUAL_PAGES}) ${CHAPTER_LIST})
66
67 ADOC_STDARG=-b $(shell pwd)/asciidoc/pmg-html -f asciidoc/asciidoc-pmg.conf -a icons -a data-uri -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}"
68
69 BROWSER?=xdg-open
70
71
72 README.html: README.adoc
73 asciidoc -a toc ${ADOC_STDARG} -o $@ $<
74
75 .PHONY: index
76 index: index.html
77 $(BROWSER) index.html &
78
79 chapter-index-table.adoc: asciidoc-pmg
80 ./asciidoc-pmg chapter-table >$@.tmp
81 mv $@.tmp $@
82
83 man1-index-table.adoc: asciidoc-pmg
84 ./asciidoc-pmg man1page-table >$@.tmp
85 mv $@.tmp $@
86
87 man5-index-table.adoc: asciidoc-pmg
88 ./asciidoc-pmg man5page-table >$@.tmp
89 mv $@.tmp $@
90
91 man8-index-table.adoc: asciidoc-pmg
92 ./asciidoc-pmg man8page-table >$@.tmp
93 mv $@.tmp $@
94
95 index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES}
96 asciidoc ${ADOC_STDARG} -o $@ index.adoc
97
98 pmg-admin-guide.html: ${PMG_ADMIN_GUIDE_ADOCDEPENDS}
99 asciidoc -a pmglogo ${ADOC_STDARG} -o $@ pmg-admin-guide.adoc
100
101 pmg-admin-guide.chunked: ${PMG_ADMIN_GUIDE_ADOCDEPENDS}
102 rm -rf pmg-admin-guide.chunked
103 a2x -a docinfo -a docinfo1 -a icons -f chunked pmg-admin-guide.adoc
104
105 PMG_DOCBOOK_CONF=-b $(shell pwd)/asciidoc/pmg-docbook -f asciidoc/asciidoc-pmg.conf
106 PMG_DBLATEX_OPTS='-p ./asciidoc/pmg-dblatex.xsl -s asciidoc/dblatex-custom.sty -c asciidoc/dblatex-export.conf'
107
108 pmg-admin-guide-docinfo.xml: pmg-admin-guide-docinfo.xml.in
109 sed -e 's/@RELEASE@/${DOCRELEASE}/' <$< >$@
110
111 pmg-admin-guide.pdf: ${PMG_ADMIN_GUIDE_ADOCDEPENDS} docinfo.xml pmg-admin-guide-docinfo.xml
112 rsvg-convert -f pdf -o proxmox-logo.pdf images/proxmox-logo.svg
113 rsvg-convert -f pdf -o proxmox-ci-header.pdf images/proxmox-ci-header.svg
114 grep ">Release ${DOCRELEASE}<" pmg-admin-guide-docinfo.xml || (echo "wrong release in pmg-admin-guide-docinfo.xml" && false);
115 a2x -a docinfo -a docinfo1 -f pdf -L --asciidoc-opts="${PMG_DOCBOOK_CONF}" --dblatex-opts ${PMG_DBLATEX_OPTS} pmg-admin-guide.adoc
116 rm proxmox-logo.pdf proxmox-ci-header.pdf
117
118 pmg-admin-guide.epub: ${PMG_ADMIN_GUIDE_ADOCDEPENDS}
119 a2x -f epub --asciidoc-opts="${PMG_DOCBOOK_CONF}" pmg-admin-guide.adoc
120
121 api-viewer/apidata.js: extractapi.pl
122 ./extractapi.pl >$@
123
124 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PMGAPI.js
125 cat api-viewer/apidata.js api-viewer/PMGAPI.js >$@
126
127 .PHONY: dinstall
128 dinstall: ${GEN_DEB} ${DOC_DEB}
129 dpkg -i ${GEN_DEB} ${DOC_DEB}
130
131 .PHONY: deb
132 deb: ${DOC_DEB}
133
134 ${GEN_DEB}: ${DOC_DEB}
135
136 ${DOC_DEB}:
137 rm -f ${GEN_DEB} ${DOC_DEB}
138 rm -rf build
139 rsync -a * build/
140 echo "git clone git://git.proxmox.com/git/pmg-docs.git\\ngit checkout ${GITVERSION}" > build/debian/SOURCE
141 cd build; dpkg-buildpackage -b -us -uc
142 lintian $(DOC_DEB) $(GEN_DEB)
143
144 .PHONY: clean-build
145 clean-build:
146 rm -rf build
147
148 .PHONY: install
149 install: gen-install doc-install
150
151 .PHONY: gen-install
152 gen-install: $(GEN_DEB_SOURCES) asciidoc-pmg
153 install -dm755 ${DESTDIR}/usr/bin
154 install -dm755 $(DESTDIR)/usr/share/${GEN_PACKAGE}
155 # install files
156 install -m 0644 ${GEN_DEB_SOURCES} $(DESTDIR)/usr/share/${GEN_PACKAGE}
157 install -m 0755 ${GEN_SCRIPTS} $(DESTDIR)/usr/share/${GEN_PACKAGE}
158 # install asciidoc-pmg
159 install -m 0755 asciidoc-pmg $(DESTDIR)/usr/bin/
160 install -dm755 $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
161 install -m 0644 asciidoc/asciidoc-pmg.conf $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
162 install -m 0644 asciidoc/pmg-html.conf $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
163
164 .PHONY: doc-install
165 doc-install: index.html $(API_VIEWER_SOURCES) verify-images
166 # install files for pmgdocs package
167 install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}
168 install -dm755 $(DESTDIR)/usr/share/doc/${DOC_PACKAGE}
169 install -m 0644 index.html ${INDEX_INCLUDES} $(DESTDIR)/usr/share/${DOC_PACKAGE}
170 # install screenshot images
171 install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}/images/screenshot
172 install -m 0644 images/screenshot/*.png $(DESTDIR)/usr/share/${DOC_PACKAGE}/images/screenshot
173 # install api doc viewer
174 install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}/api-viewer
175 install -m 0644 ${API_VIEWER_SOURCES} $(DESTDIR)/usr/share/${DOC_PACKAGE}/api-viewer
176
177 .PHONY: upload
178 upload: ${GEN_DEB} ${DOC_DEB}
179 tar cf - ${GEN_DEB} ${DOC_DEB} | ssh -X repoman@repo.proxmox.com -- upload --product pmg --dist stretch
180
181 .PHONY: update
182 update: clean
183 find . -regex '.*-\(opts\|synopsis\)\.adoc' -exec rm -f \{\} \;
184 rm -f api-viewer/apidata.js
185 make all
186
187 clean:
188 find . -name '*~' -exec rm {} ';'
189 rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8
190 rm -f *.deb *.changes *.buildinfo
191 rm -f api-viewer/apidoc.js chapter-*.html *-plain.html chapter-*.html pmg-admin-guide.chunked asciidoc-pmg link-refs.json .asciidoc-pmg-tmp_* pmg-smtp-filter.8-synopsis.adoc pmgpolicy.8-synopsis.adoc pmgsh.1-synopsis.adoc
192 rm -rf .pmg-doc-depends
193 rm -f pmg-doc-generator.mk chapter-index-table.adoc man1-index-table.adoc man5-index-table.adoc man8-index-table.adoc pmg-admin-guide-docinfo.xml
194 rm -rf build*