asciidoc-pve.in: add some real functionality
[pve-docs.git] / Makefile
1 DGDIR=.
2
3 include ./pve-doc-generator.mk
4
5 GEN_PACKAGE=pve-doc-generator
6 DOC_PACKAGE=pve-docs
7 MEDIAWIKI_PACKAGE=pve-docs-mediawiki
8
9 # also update debian/changelog
10 PKGREL=5
11
12 GITVERSION:=$(shell cat .git/refs/heads/master)
13
14 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
15
16 GEN_DEB=${GEN_PACKAGE}_${DOCRELEASE}-${PKGREL}_${ARCH}.deb
17 DOC_DEB=${DOC_PACKAGE}_${DOCRELEASE}-${PKGREL}_all.deb
18 MEDIAWIKI_DEB=${MEDIAWIKI_PACKAGE}_${DOCRELEASE}-${PKGREL}_all.deb
19
20 CHAPTER_LIST= \
21 pve-installation \
22 sysadmin \
23 pvecm \
24 pmxcfs \
25 pvesm \
26 qm \
27 pve-firewall \
28 pveum \
29 pct \
30 ha-manager \
31 vzdump \
32 pve-faq \
33 pve-bibliography
34
35 STORAGE_TYPES= \
36 dir \
37 glusterfs \
38 iscsi \
39 iscsidirect \
40 lvm \
41 lvmthin \
42 nfs \
43 rbd \
44 zfspool
45
46 COMMAND_LIST= \
47 pvesubscription \
48 pvecm \
49 qm \
50 qmrestore \
51 pveceph \
52 pct \
53 pveam \
54 pvesm \
55 pveum \
56 vzdump \
57 ha-manager \
58 pveperf
59
60 SERVICE_LIST= \
61 pve-firewall \
62 pve-ha-crm \
63 pve-ha-lrm \
64 pvestatd \
65 pmxcfs \
66 pveproxy \
67 spiceproxy \
68 pvedaemon
69
70 CONFIG_LIST=datacenter.cfg qm.conf pct.conf
71
72 GEN_DEB_SOURCES= \
73 pve-doc-generator.mk \
74 attributes.txt \
75 $(addsuffix .adoc, ${COMMAND_LIST}) \
76 $(addsuffix .adoc, ${SERVICE_LIST}) \
77 $(addsuffix .adoc, ${CONFIG_LIST}) \
78 pve-storage-dir.adoc \
79 pve-storage-glusterfs.adoc \
80 pve-storage-iscsi.adoc \
81 pve-storage-iscsidirect.adoc \
82 pve-storage-lvm.adoc \
83 pve-storage-lvmthin.adoc \
84 pve-storage-nfs.adoc \
85 pve-storage-rbd.adoc \
86 pve-storage-zfspool.adoc \
87 pmxcfs.8-cli.adoc \
88 pve-copyright.adoc \
89 docinfo.xml
90
91 GEN_SCRIPTS= \
92 gen-datacenter.cfg.5-opts.pl \
93 gen-pct.conf.5-opts.pl \
94 gen-pct-network-opts.pl \
95 gen-pct-mountpoint-opts.pl \
96 gen-qm.conf.5-opts.pl \
97 gen-vzdump.conf.5-opts.pl \
98 gen-pve-firewall-cluster-opts.pl \
99 gen-pve-firewall-host-opts.pl \
100 gen-pve-firewall-macros-adoc.pl \
101 gen-pve-firewall-rules-opts.pl \
102 gen-pve-firewall-vm-opts.pl
103
104 INSTALLATION_SOURCES= \
105 pve-usbstick.adoc \
106 pve-system-requirements.adoc \
107 pve-installation.adoc
108
109 SYSADMIN_PARTS= \
110 pve-network \
111 pve-package-repos \
112 system-software-updates \
113 pve-disk-health-monitoring \
114 local-lvm \
115 local-zfs
116
117 SYSADMIN_SOURCES= \
118 $(addsuffix .adoc, ${SYSADMIN_PARTS}) \
119 sysadmin.adoc
120
121 API_VIEWER_SOURCES= \
122 api-viewer/index.html \
123 api-viewer/apidoc.js
124
125 PVE_ADMIN_GUIDE_SOURCES= \
126 ${DATACENTER_CONF_MAN5_SOURCES} \
127 ${QM_CONF_MAN5_SOURCES} \
128 ${PCT_CONF_MAN5_SOURCES} \
129 ${SYSADMIN_SOURCES} \
130 pve-admin-guide.adoc \
131 pve-intro.adoc \
132 getting-help.adoc \
133 ${INSTALLATION_SOURCES} \
134 pmxcfs.adoc \
135 pmxcfs.8-cli.adoc \
136 pve-faq.adoc \
137 ${PVE_FIREWALL_MAN8_SOURCES} \
138 ${PVESM_MAN1_SOURCES} \
139 ${PCT_MAN1_SOURCES} \
140 ${PVECM_MAN1_SOURCES} \
141 ${PVEUM_MAN1_SOURCES} \
142 ${QM_MAN1_SOURCES} \
143 ${QMRESTORE_MAN1_SOURCES} \
144 ${HA_MANAGER_MAN1_SOURCES} \
145 ${PVESTATD_MAN8_SOURCES} \
146 ${PVEDAEMON_MAN8_SOURCES} \
147 ${PVEPROXY_MAN8_SOURCES} \
148 ${SPICEPROXY_MAN8_SOURCES} \
149 ${PVE_HA_CRM_MAN8_SOURCES} \
150 ${PVE_HA_LRM_MAN8_SOURCES} \
151 ${VZDUMP_MAN1_SOURCES} \
152 ${PVEAM_MAN1_SOURCES} \
153 ${PVESUBSCRIPTION_MAN1_SOURCES} \
154 ${PVECEPH_MAN1_SOURCES} \
155 ${PVEPERF_MAN1_SOURCES} \
156 pve-bibliography.adoc \
157 $(addsuffix .adoc, ${COMMAND_LIST}) \
158 $(addsuffix .adoc, ${SERVICE_LIST}) \
159 $(addsuffix .adoc, ${CONFIG_LIST}) \
160 GFDL.adoc \
161 attributes.txt
162
163 link-refs.json: scan-adoc-refs ${PVE_ADMIN_GUIDE_SOURCES}
164 ./scan-adoc-refs ${PVE_ADMIN_GUIDE_SOURCES} >link-refs.json
165
166 asciidoc-pve: asciidoc-pve.in link-refs.json
167 cat asciidoc-pve.in link-refs.json >asciidoc-pve.tmp
168 sed -e s/@RELEASE@/${DOCRELEASE}/ -i asciidoc-pve.tmp
169 chmod +x asciidoc-pve.tmp
170 mv asciidoc-pve.tmp asciidoc-pve
171
172 test: asciidoc-pve
173 ./asciidoc-pve compile-wiki-section pve-package-repos.adoc
174 #./asciidoc-pve compile-wiki-chapter ha-manager.adoc
175
176 WIKI_IMPORTS= \
177 section-pve-usbstick-plain.html \
178 section-getting-help-plain.html \
179 section-pve-system-requirements-plain.html \
180 $(addsuffix -plain.html, $(addprefix sysadmin-, ${SYSADMIN_PARTS})) \
181 $(addsuffix -plain.html, $(addprefix chapter-, ${CHAPTER_LIST})) \
182 $(addsuffix .5-plain.html, ${CONFIG_LIST}) \
183 $(addsuffix -plain.html, $(addprefix pve-storage-, ${STORAGE_TYPES}))
184
185 INDEX_INCLUDES= \
186 pve-admin-guide.pdf \
187 pve-admin-guide.html \
188 pve-admin-guide.epub \
189 $(addsuffix .1.html, ${COMMAND_LIST}) \
190 $(addsuffix .8.html, ${SERVICE_LIST}) \
191 $(addsuffix .5.html, ${CONFIG_LIST}) \
192 $(addsuffix .html, $(addprefix chapter-, ${CHAPTER_LIST}))
193
194 ADOC_STDARG= -a icons -a data-uri -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}"
195 ADOC_MAN1_HTML_ARGS=-a "manvolnum=1" ${ADOC_STDARG}
196 ADOC_MAN5_HTML_ARGS=-a "manvolnum=5" ${ADOC_STDARG}
197 ADOC_MAN8_HTML_ARGS=-a "manvolnum=8" ${ADOC_STDARG}
198
199 BROWSER?=xdg-open
200
201 all: index.html
202
203 %-nwdiag.svg: %.nwdiag
204 nwdiag -T svg $*.nwdiag -o $@;
205
206 sysadmin-%-plain.html: asciidoc-pve %.adoc
207 ./asciidoc-pve compile-wiki-section -o $@ $*.adoc
208
209 section-%-plain.html: asciidoc-pve %.adoc
210 ./asciidoc-pve compile-wiki-section -o $@ $*.adoc
211
212 chapter-sysadmin.html chapter-sysadmin-plain.html: ${SYSADMIN_SOURCES}
213
214 chapter-%.html: %.adoc ${PVE_COMMON_DOC_SOURCES}
215 asciidoc ${ADOC_STDARG} -a toc -o $@ $*.adoc
216
217 chapter-%-plain.html: %.adoc ${PVE_COMMON_DOC_SOURCES}
218 ./asciidoc-pve compile-wiki-chapter -o $@ $*.adoc
219
220 pve-storage-%-plain.html: pve-storage-%.adoc ${PVE_COMMON_DOC_SOURCES}
221 ./asciidoc-pve compile-wiki-section -o $@ pve-storage-$*.adoc
222
223 %.1.html: %.adoc %.1-synopsis.adoc ${PVE_COMMON_DOC_SOURCES}
224 asciidoc ${ADOC_MAN1_HTML_ARGS} -o $@ $*.adoc
225
226 pmxcfs.8.html: pmxcfs.adoc pmxcfs.8-cli.adoc ${PVE_COMMON_DOC_SOURCES}
227 asciidoc ${ADOC_MAN8_HTML_ARGS} -o $@ pmxcfs.adoc
228
229 %.8.html: %.adoc %.8-synopsis.adoc ${PVE_COMMON_DOC_SOURCES}
230 asciidoc ${ADOC_MAN8_HTML_ARGS} -o $@ $*.adoc
231
232 %.5.html: %.adoc %.5-opts.adoc ${PVE_COMMON_DOC_SOURCES}
233 asciidoc ${ADOC_MAN5_HTML_ARGS} -o $@ $*.adoc
234
235 %.5-plain.html: %.adoc %.5-opts.adoc ${PVE_COMMON_DOC_SOURCES}
236 asciidoc -s ${ADOC_MAN5_HTML_ARGS} -o $@ $*.adoc
237
238 README.html: README.adoc
239 asciidoc ${ADOC_STDARG} -o $@ $<
240
241 .PHONY: index
242 index: index.html
243 $(BROWSER) index.html &
244
245 index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES}
246 asciidoc -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}" index.adoc
247
248 pve-admin-guide.html: ${PVE_ADMIN_GUIDE_SOURCES}
249 asciidoc -a pvelogo -a "revnumber=${DOCRELEASE}" -a "date=$(shell date)" pve-admin-guide.adoc
250
251 pve-admin-guide.chunked: ${PVE_ADMIN_GUIDE_SOURCES}
252 rm -rf pve-admin-guide.chunked
253 a2x -a docinfo -a docinfo1 -a icons -f chunked pve-admin-guide.adoc
254
255 pve-admin-guide.pdf: ${PVE_ADMIN_GUIDE_SOURCES} docinfo.xml pve-admin-guide-docinfo.xml
256 inkscape -z -D --export-pdf=proxmox-logo.pdf images/proxmox-logo.svg
257 inkscape -z -D --export-pdf=proxmox-ci-header.pdf images/proxmox-ci-header.svg
258 grep ">Release ${DOCRELEASE}<" pve-admin-guide-docinfo.xml || (echo "wrong release in pve-admin-guide-docinfo.xml" && false);
259 a2x -a docinfo -a docinfo1 -f pdf -L --dblatex-opts "-P latex.output.revhistory=0" --dblatex-opts "-P latex.class.options=12pt" --dblatex-opts "-P doc.section.depth=2 -P toc.section.depth=2" --dblatex-opts "-P doc.publisher.show=0 -s asciidoc-dblatex-custom.sty" pve-admin-guide.adoc
260 rm proxmox-logo.pdf proxmox-ci-header.pdf
261
262 pve-admin-guide.epub: ${PVE_ADMIN_GUIDE_SOURCES}
263 a2x -f epub pve-admin-guide.adoc
264
265 api-viewer/apidata.js: extractapi.pl
266 ./extractapi.pl >$@
267
268 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PVEAPI.js
269 cat api-viewer/apidata.js api-viewer/PVEAPI.js >$@
270
271 .PHONY: dinstall
272 dinstall: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
273 dpkg -i ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
274
275 .PHONY: deb
276 deb:
277 rm -f ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB};
278 make ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB};
279
280 ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}: index.html ${INDEX_INCLUDES} ${WIKI_IMPORTS} ${API_VIEWER_SOURCES} ${GEN_DEB_SOURCES}
281 rm -rf build
282 mkdir build
283 rsync -a debian/ build/debian
284 echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout ${GITVERSION}" > build/debian/SOURCE
285 # install files for pve-doc-generator package
286 mkdir -p build/usr/share/${GEN_PACKAGE}
287 mkdir -p build/usr/share/doc/${GEN_PACKAGE}
288 install -m 0644 ${GEN_DEB_SOURCES} build/usr/share/${GEN_PACKAGE}
289 install -m 0755 ${GEN_SCRIPTS} build/usr/share/${GEN_PACKAGE}
290 # install files for pvedocs package
291 mkdir -p build/usr/share/${DOC_PACKAGE}
292 mkdir -p build/usr/share/doc/${DOC_PACKAGE}
293 install -m 0644 index.html ${INDEX_INCLUDES} build/usr/share/${DOC_PACKAGE}
294 install -m 0644 ${WIKI_IMPORTS} build/usr/share/${DOC_PACKAGE}
295 # install api doc viewer
296 mkdir build/usr/share/${DOC_PACKAGE}/api-viewer
297 install -m 0644 ${API_VIEWER_SOURCES} build/usr/share/${DOC_PACKAGE}/api-viewer
298 # build Debian packages
299 cd build; dpkg-buildpackage -rfakeroot -b -us -uc
300 lintian ${GEN_DEB}
301 lintian ${DOC_DEB}
302 lintian ${MEDIAWIKI_DEB}
303
304 .PHONY: upload
305 upload: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
306 tar cf - ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB} | ssh repoman@repo.proxmox.com upload
307
308 .PHONY: update
309 update: clean
310 rm -f *.5-opts.adoc *.1-synopsis.adoc *.8-synopsis.adoc
311 rm -f api-viewer/apidata.js
312 rm -f pve-firewall-macros.adoc pct-network-opts.adoc pct-mountpoint-opts.adoc
313 make all
314
315 clean:
316 rm -rf *.tmp.xml *.html *.pdf *.epub *.tmp *.1 *.5 *.8 *.deb *.changes build api-viewer/apidoc.js chapter-*.html chapter-*-plain.html chapter-*.html pve-admin-guide.chunked asciidoc-pve link-refs.json .asciidoc-pve-tmp_*
317 find . -name '*~' -exec rm {} ';'