340eba482ffc20e5176ea1133101a57f9841f051
[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
8 # also update debian/changelog
9 GEN_PKGREL=3
10 # also update doc-debian/changelog
11 DOC_PKGREL=4
12
13 GITVERSION:=$(shell cat .git/refs/heads/master)
14
15 GEN_DEB=${GEN_PACKAGE}_${DOCRELEASE}-${GEN_PKGREL}_amd64.deb
16 DOC_DEB=${DOC_PACKAGE}_${DOCRELEASE}-${DOC_PKGREL}_all.deb
17
18 CHAPTER_LIST=           \
19         sysadmin        \
20         pvecm           \
21         pmxcfs          \
22         pvesm           \
23         qm              \
24         pve-firewall    \
25         pveum           \
26         pct             \
27         ha-manager      \
28         vzdump          \
29         pve-faq         \
30         pve-bibliography
31
32 STORAGE_TYPES=          \
33         dir             \
34         glusterfs       \
35         iscsi           \
36         iscsidirect     \
37         lvm             \
38         lvmthin         \
39         nfs             \
40         rbd             \
41         zfspool
42
43 COMMAND_LIST=           \
44         pvesubscription \
45         pvecm           \
46         qm              \
47         qmrestore       \
48         pveceph         \
49         pct             \
50         pveam           \
51         pvesm           \
52         pveum           \
53         vzdump          \
54         ha-manager
55
56 SERVICE_LIST=           \
57         pve-firewall    \
58         pve-ha-crm      \
59         pve-ha-lrm      \
60         pvestatd        \
61         pmxcfs          \
62         pveproxy        \
63         spiceproxy      \
64         pvedaemon
65
66 CONFIG_LIST=datacenter.cfg qm.conf pct.conf
67
68 GEN_DEB_SOURCES=                                \
69         pve-doc-generator.mk                    \
70         attributes.txt                          \
71         $(addsuffix .adoc, ${COMMAND_LIST})     \
72         $(addsuffix .adoc, ${SERVICE_LIST})     \
73         $(addsuffix .adoc, ${CONFIG_LIST})      \
74         pve-storage-dir.adoc                    \
75         pve-storage-glusterfs.adoc              \
76         pve-storage-iscsi.adoc                  \
77         pve-storage-iscsidirect.adoc            \
78         pve-storage-lvm.adoc                    \
79         pve-storage-nfs.adoc                    \
80         pve-storage-rbd.adoc                    \
81         pve-storage-zfspool.adoc                \
82         pmxcfs.8-cli.adoc                       \
83         pve-copyright.adoc                      \
84         docinfo.xml
85
86 GEN_SCRIPTS=                                    \
87         gen-datacenter.cfg.5-opts.pl            \
88         gen-pct.conf.5-opts.pl                  \
89         gen-pct-network-opts.pl                 \
90         gen-pct-mountpoint-opts.pl              \
91         gen-qm.conf.5-opts.pl                   \
92         gen-vzdump.conf.5-opts.pl               \
93         gen-pve-firewall-cluster-opts.pl        \
94         gen-pve-firewall-host-opts.pl           \
95         gen-pve-firewall-macros-adoc.pl         \
96         gen-pve-firewall-rules-opts.pl          \
97         gen-pve-firewall-vm-opts.pl
98
99 SYSADMIN_SOURCES=                               \
100         getting-help.adoc                       \
101         pve-package-repos.adoc                  \
102         pve-installation.adoc                   \
103         system-software-updates.adoc            \
104         sysadmin.adoc
105
106 API_VIEWER_SOURCES=                             \
107         api-viewer/index.html                   \
108         api-viewer/apidoc.js
109
110 PVE_ADMIN_GUIDE_SOURCES=                        \
111         ${DATACENTER_CONF_MAN5_SOURCES}         \
112         ${QM_CONF_MAN5_SOURCES}                 \
113         ${PCT_CONF_MAN5_SOURCES}                \
114         ${SYSADMIN_SOURCES}                     \
115         pve-admin-guide.adoc                    \
116         pve-intro.adoc                          \
117         pmxcfs.adoc                             \
118         pmxcfs.8-cli.adoc                       \
119         pve-faq.adoc                            \
120         ${PVE_FIREWALL_MAN8_SOURCES}            \
121         ${PVESM_MAN1_SOURCES}                   \
122         ${PCT_MAN1_SOURCES}                     \
123         ${PVECM_MAN1_SOURCES}                   \
124         ${PVEUM_MAN1_SOURCES}                   \
125         ${QM_MAN1_SOURCES}                      \
126         ${QMRESTORE_MAN1_SOURCES}               \
127         ${HA_MANAGER_MAN1_SOURCES}              \
128         ${PVESTATD_MAN8_SOURCES}                \
129         ${PVEDAEMON_MAN8_SOURCES}               \
130         ${PVEPROXY_MAN8_SOURCES}                \
131         ${SPICEPROXY_MAN8_SOURCES}              \
132         ${PVE_HA_CRM_MAN8_SOURCES}              \
133         ${PVE_HA_LRM_MAN8_SOURCES}              \
134         ${VZDUMP_MAN1_SOURCES}                  \
135         ${PVEAM_MAN1_SOURCES}                   \
136         ${PVESUBSCRIPTION_MAN1_SOURCES}         \
137         ${PVECEPH_MAN1_SOURCES}                 \
138         pve-bibliography.adoc                   \
139         $(addsuffix .adoc, ${COMMAND_LIST})     \
140         $(addsuffix .adoc, ${SERVICE_LIST})     \
141         $(addsuffix .adoc, ${CONFIG_LIST})      \
142         GFDL.adoc                               \
143         attributes.txt
144
145 WIKI_IMPORTS=                                                           \
146         $(addsuffix -plain.html, $(addprefix chapter-, ${CHAPTER_LIST}))\
147         $(addsuffix .5-plain.html, ${CONFIG_LIST})                      \
148         $(addsuffix -plain.html, $(addprefix pve-storage-, ${STORAGE_TYPES}))
149
150 INDEX_INCLUDES=                                                         \
151         pve-admin-guide.pdf                                             \
152         pve-admin-guide.html                                            \
153         pve-admin-guide.epub                                            \
154         $(addsuffix .1.html, ${COMMAND_LIST})                           \
155         $(addsuffix .8.html, ${SERVICE_LIST})                           \
156         $(addsuffix .5.html, ${CONFIG_LIST})                            \
157         $(addsuffix .html, $(addprefix chapter-, ${CHAPTER_LIST}))
158
159 ADOC_STDARG= -a icons -a data-uri -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}"
160 ADOC_MAN1_HTML_ARGS=-a "manvolnum=1" ${ADOC_STDARG}
161 ADOC_MAN5_HTML_ARGS=-a "manvolnum=5" ${ADOC_STDARG}
162 ADOC_MAN8_HTML_ARGS=-a "manvolnum=8" ${ADOC_STDARG}
163
164 BROWSER?=xdg-open
165
166 all: index.html
167
168 %-nwdiag.svg: %.nwdiag
169         nwdiag -T svg $*.nwdiag -o $@;
170
171 chapter-%.html: %.adoc ${PVE_COMMON_DOC_SOURCES}
172         asciidoc ${ADOC_STDARG} -a toc -o $@ $*.adoc
173
174 chapter-%-plain.html: %.adoc ${PVE_COMMON_DOC_SOURCES}
175         asciidoc -s -a wiki ${ADOC_STDARG} -o $@ $*.adoc
176
177 pve-storage-%-plain.html: pve-storage-%.adoc ${PVE_COMMON_DOC_SOURCES}
178         asciidoc -s -a wiki -a 'leveloffset=-1' ${ADOC_STDARG} -o $@ pve-storage-$*.adoc
179
180 %.1.html: %.adoc %.1-synopsis.adoc ${PVE_COMMON_DOC_SOURCES}
181         asciidoc ${ADOC_MAN1_HTML_ARGS} -o $@ $*.adoc
182
183 pmxcfs.8.html: pmxcfs.adoc pmxcfs.8-cli.adoc ${PVE_COMMON_DOC_SOURCES}
184         asciidoc ${ADOC_MAN8_HTML_ARGS} -o $@ pmxcfs.adoc
185
186 %.8.html: %.adoc %.8-synopsis.adoc ${PVE_COMMON_DOC_SOURCES}
187         asciidoc ${ADOC_MAN8_HTML_ARGS} -o $@ $*.adoc
188
189 %.5.html: %.adoc %.5-opts.adoc ${PVE_COMMON_DOC_SOURCES}
190         asciidoc ${ADOC_MAN5_HTML_ARGS} -o $@ $*.adoc
191
192 %.5-plain.html: %.adoc %.5-opts.adoc ${PVE_COMMON_DOC_SOURCES}
193         asciidoc -s ${ADOC_MAN5_HTML_ARGS} -o $@ $*.adoc
194
195 .PHONY: index
196 index: index.html
197         $(BROWSER) index.html &
198
199 index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES} 
200         asciidoc -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}" index.adoc
201
202 pve-admin-guide.html: ${PVE_ADMIN_GUIDE_SOURCES}
203         asciidoc -a "revnumber=${DOCRELEASE}" -a "date=$(shell date)" pve-admin-guide.adoc
204
205 pve-admin-guide.chunked: ${PVE_ADMIN_GUIDE_SOURCES}
206         rm -rf pve-admin-guide.chunked
207         a2x -a docinfo -a docinfo1 -a icons -f chunked pve-admin-guide.adoc
208
209 pve-admin-guide.pdf: ${PVE_ADMIN_GUIDE_SOURCES} docinfo.xml pve-admin-guide-docinfo.xml
210         grep ">Release ${DOCRELEASE}<" pve-admin-guide-docinfo.xml || (echo "wrong release in  pve-admin-guide-docinfo.xml" && false);
211         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" pve-admin-guide.adoc
212
213 pve-admin-guide.epub: ${PVE_ADMIN_GUIDE_SOURCES}
214         a2x -f epub pve-admin-guide.adoc
215
216 api-viewer/apidata.js: extractapi.pl
217         ./extractapi.pl >$@
218
219 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PVEAPI.js
220         cat api-viewer/apidata.js api-viewer/PVEAPI.js >$@
221
222 .PHONY: dinstall
223 dinstall: ${GEN_DEB} ${DOC_DEB}
224         dpkg -i ${GEN_DEB} ${DOC_DEB}
225
226 .PHONY: deb
227 deb:
228         rm -f ${GEN_DEB} ${DOC_DEB};
229         make ${GEN_DEB};
230         make ${DOC_DEB};
231
232 ${DOC_DEB}: index.html ${INDEX_INCLUDES} ${WIKI_IMPORTS} ${API_VIEWER_SOURCES}
233         rm -rf build
234         mkdir build
235         rsync -a doc-debian/ build/debian
236         mkdir -p build/usr/share/${DOC_PACKAGE}
237         mkdir -p build/usr/share/doc/${DOC_PACKAGE}
238         echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout ${GITVERSION}" > build/usr/share/doc/${DOC_PACKAGE}/SOURCE
239         # install doc files
240         install -m 0644 index.html ${INDEX_INCLUDES} build/usr/share/${DOC_PACKAGE}
241         install -m 0644 ${WIKI_IMPORTS} build/usr/share/${DOC_PACKAGE}
242         # install api doc viewer
243         mkdir build/usr/share/${DOC_PACKAGE}/api-viewer
244         install -m 0644 ${API_VIEWER_SOURCES} build/usr/share/${DOC_PACKAGE}/api-viewer
245         cd build; dpkg-buildpackage -rfakeroot -b -us -uc
246         lintian ${DOC_DEB}
247
248 ${GEN_DEB}: ${GEN_DEB_SOURCES}
249         rm -rf build
250         mkdir build
251         rsync -a debian/ build/debian
252         mkdir -p build/usr/share/${GEN_PACKAGE}
253         mkdir -p build/usr/share/doc/${GEN_PACKAGE}
254         echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout ${GITVERSION}" > build/usr/share/doc/${GEN_PACKAGE}/SOURCE
255         install -m 0644 ${GEN_DEB_SOURCES} build/usr/share/${GEN_PACKAGE}
256         install -m 0755 ${GEN_SCRIPTS} build/usr/share/${GEN_PACKAGE}
257         cd build; dpkg-buildpackage -rfakeroot -b -us -uc
258         lintian ${GEN_DEB}
259
260 .PHONY: upload
261 upload: ${GEN_DEB} ${DOC_DEB}
262         umount /pve/${DOCRELEASE}; mount /pve/${DOCRELEASE} -o rw
263         mkdir -p /pve/${DOCRELEASE}/extra
264         rm -f /pve/${DOCRELEASE}/extra/${GEN_PACKAGE}_*.deb
265         rm -f /pve/${DOCRELEASE}/extra/${DOC_PACKAGE}_*.deb
266         rm -f /pve/${DOCRELEASE}/extra/Packages*
267         cp ${GEN_DEB} ${DOC_DEB} /pve/${DOCRELEASE}/extra
268         cd /pve/${DOCRELEASE}/extra; dpkg-scanpackages . /dev/null > Packages; gzip -9c Packages > Packages.gz
269         umount /pve/${DOCRELEASE}; mount /pve/${DOCRELEASE} -o ro
270
271 .PHONY: update
272 update: clean
273         rm -f *.5-opts.adoc *.1-synopsis.adoc *.8-synopsis.adoc
274         rm -f api-viewer/apidata.js
275         rm -f pve-firewall-macros.adoc pct-network-opts.adoc pct-mountpoint-opts.adoc
276         make all
277
278 clean:
279         rm -rf *.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
280         find . -name '*~' -exec rm {} ';'