fixup: s/devies/devices/
[pve-docs.git] / Makefile
1 DGDIR=.
2 ASCIIDOC_PVE=./asciidoc-pve
3
4 GEN_PACKAGE=pve-doc-generator
5 DOC_PACKAGE=pve-docs
6 MEDIAWIKI_PACKAGE=pve-docs-mediawiki
7
8 # also update debian/changelog
9 PKGREL=3
10
11 GITVERSION:=$(shell git rev-parse HEAD)
12
13 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
14
15 GEN_DEB=${GEN_PACKAGE}_${DOCRELEASE}-${PKGREL}_${ARCH}.deb
16 DOC_DEB=${DOC_PACKAGE}_${DOCRELEASE}-${PKGREL}_all.deb
17 MEDIAWIKI_DEB=${MEDIAWIKI_PACKAGE}_${DOCRELEASE}-${PKGREL}_all.deb
18
19 export SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp)
20 SOURCE_DATE_HUMAN := $(shell date -d "@${SOURCE_DATE_EPOCH}")
21
22 all: index.html
23
24 .PHONY: verify-images
25 verify-images:
26         for i in ./images/screenshot/*.png; do ./png-verify.pl $$i; done
27
28 ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard *.adoc))
29 .pve-doc-depends link-refs.json: ${ADOC_SOURCES_GUESS} scan-adoc-refs
30         ./scan-adoc-refs *.adoc --depends .pve-doc-depends.tmp > link-refs.json.tmp
31         @cmp --quiet .pve-doc-depends .pve-doc-depends.tmp || mv .pve-doc-depends.tmp .pve-doc-depends
32         @cmp --quiet link-refs.json link-refs.json.tmp || mv link-refs.json.tmp link-refs.json
33
34 pve-doc-generator.mk: .pve-doc-depends pve-doc-generator.mk.in
35         cat pve-doc-generator.mk.in .pve-doc-depends > $@.tmp
36         mv $@.tmp $@
37
38 -include ./pve-doc-generator.mk
39
40 GEN_DEB_SOURCES=                                \
41         pve-doc-generator.mk                    \
42         ${MANUAL_SOURCES}                       \
43         pmxcfs.8-synopsis.adoc                  \
44         qmeventd.8-synopsis.adoc                \
45         docinfo.xml
46
47 GEN_SCRIPTS=                                    \
48         gen-ha-groups-opts.pl                   \
49         gen-ha-resources-opts.pl                \
50         gen-datacenter.cfg.5-opts.pl            \
51         gen-pct.conf.5-opts.pl                  \
52         gen-pct-network-opts.pl                 \
53         gen-pct-mountpoint-opts.pl              \
54         gen-qm.conf.5-opts.pl                   \
55         gen-qm-cloud-init-opts.pl               \
56         gen-vzdump.conf.5-opts.pl               \
57         gen-pve-firewall-cluster-opts.pl        \
58         gen-pve-firewall-host-opts.pl           \
59         gen-pve-firewall-macros-adoc.pl         \
60         gen-pve-firewall-rules-opts.pl          \
61         gen-pve-firewall-vm-opts.pl             \
62         gen-output-format-opts.pl
63
64 API_VIEWER_SOURCES=                             \
65         api-viewer/index.html                   \
66         api-viewer/apidoc.js
67
68 asciidoc-pve: asciidoc-pve.in link-refs.json
69         cat asciidoc-pve.in link-refs.json >asciidoc-pve.tmp
70         sed -e s/@RELEASE@/${DOCRELEASE}/ -i asciidoc-pve.tmp
71         chmod +x asciidoc-pve.tmp
72         mv asciidoc-pve.tmp asciidoc-pve
73
74 pve-docs-mediawiki-import: pve-docs-mediawiki-import.in link-refs.json
75         cat pve-docs-mediawiki-import.in link-refs.json >  pve-docs-mediawiki-import.tmp
76         chmod +x pve-docs-mediawiki-import.tmp
77         mv pve-docs-mediawiki-import.tmp pve-docs-mediawiki-import
78
79 INDEX_INCLUDES=                                                         \
80         pve-admin-guide.pdf                                             \
81         pve-admin-guide.epub                                            \
82         chapter-index-table.adoc                                        \
83         man1-index-table.adoc                                           \
84         man5-index-table.adoc                                           \
85         man8-index-table.adoc                                           \
86         $(sort $(addsuffix .html, ${MANUAL_PAGES}) ${CHAPTER_LIST})
87
88 ADOC_STDARG=-b $(shell pwd)/asciidoc/pve-html -f asciidoc/asciidoc-pve.conf -a icons -a data-uri -a "date=${SOURCE_DATE_HUMAN}" -a "revnumber=${DOCRELEASE}" -a footer-style=revdate
89
90 BROWSER?=xdg-open
91
92 README.html: README.adoc
93         asciidoc -a toc ${ADOC_STDARG} -o $@ $<
94
95 .PHONY: index
96 index: index.html
97         $(BROWSER) index.html &
98
99 chapter-index-table.adoc: asciidoc-pve
100         ./asciidoc-pve chapter-table >$@.tmp
101         mv $@.tmp $@
102
103 man1-index-table.adoc: asciidoc-pve
104         ./asciidoc-pve man1page-table >$@.tmp
105         mv $@.tmp $@
106
107 man5-index-table.adoc: asciidoc-pve
108         ./asciidoc-pve man5page-table >$@.tmp
109         mv $@.tmp $@
110
111 man8-index-table.adoc: asciidoc-pve
112         ./asciidoc-pve man8page-table >$@.tmp
113         mv $@.tmp $@
114
115 index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES}
116         asciidoc ${ADOC_STDARG} -o $@ index.adoc
117
118 pve-admin-guide.html: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
119         asciidoc -a pvelogo ${ADOC_STDARG} -o $@ pve-admin-guide.adoc
120
121 pve-admin-guide.chunked: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
122         rm -rf $@.tmp $@
123         mkdir $@.tmp
124         a2x -D $@.tmp -a docinfo -a docinfo1 -a icons -f chunked pve-admin-guide.adoc
125         mv $@.tmp/$@ $@
126
127 PVE_DOCBOOK_CONF=-b $(shell pwd)/asciidoc/pve-docbook -f asciidoc/asciidoc-pve.conf
128 PVE_DBLATEX_OPTS='-p ./asciidoc/pve-dblatex.xsl -s asciidoc/dblatex-custom.sty -c asciidoc/dblatex-export.conf'
129
130 YEAR:=$(shell date '+%Y')
131 pve-admin-guide-docinfo.xml: pve-admin-guide-docinfo.xml.in
132         sed -e 's/@RELEASE@/${DOCRELEASE}/' -e 's/@YEAR@/${YEAR}/' <$< >$@
133
134 pve-admin-guide.pdf: ${PVE_ADMIN_GUIDE_ADOCDEPENDS} docinfo.xml pve-admin-guide-docinfo.xml
135         rsvg-convert -f pdf -o proxmox-logo.pdf images/proxmox-logo.svg
136         rsvg-convert -f pdf -o proxmox-ci-header.pdf images/proxmox-ci-header.svg
137         grep ">Release ${DOCRELEASE}<" pve-admin-guide-docinfo.xml || (echo "wrong release in  pve-admin-guide-docinfo.xml" && false);
138         a2x -a docinfo -a docinfo1 -f pdf -L --asciidoc-opts="${PVE_DOCBOOK_CONF}" --dblatex-opts ${PVE_DBLATEX_OPTS} pve-admin-guide.adoc
139         rm proxmox-logo.pdf proxmox-ci-header.pdf
140
141 pve-admin-guide.epub: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
142         rm -rf $@.tmp $@
143         mkdir $@.tmp
144         a2x -D $@.tmp -f epub --asciidoc-opts="${PVE_DOCBOOK_CONF}" pve-admin-guide.adoc
145         mv $@.tmp/$@ $@
146
147 api-viewer/apidata.js: extractapi.pl
148         ./extractapi.pl >$@
149
150 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PVEAPI.js
151         cat api-viewer/apidata.js api-viewer/PVEAPI.js >$@
152
153 .PHONY: dinstall
154 dinstall: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
155         dpkg -i ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
156
157 .PHONY: deb
158 deb: $(DOC_DEB)
159 $(MEDIAWIKI_DEB) $(GEN_DEB): $(DOC_DEB)
160 $(DOC_DEB):
161         rm -f ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
162         rm -rf build
163         rsync -a * build/
164         echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout ${GITVERSION}" > build/debian/SOURCE
165         cd build; dpkg-buildpackage -b -us -uc
166         lintian $(DOC_DEB) $(GEN_DEB) $(MEDIAWIKI_DEB)
167
168 .PHONY: clean-build
169 clean-build:
170         rm -rf build
171
172 .PHONY: install
173 install: gen-install doc-install mediawiki-install
174
175 .PHONY: gen-install
176 gen-install: $(GEN_DEB_SOURCES) asciidoc-pve asciidoc/mediawiki.conf
177         install -dm755 $(DESTDIR)/usr/share/$(GEN_PACKAGE)
178         install -dm755 $(DESTDIR)/usr/share/doc/$(GEN_PACKAGE)
179         install -dm755 $(DESTDIR)/usr/bin
180         # install files
181         install -m 0644 ${GEN_DEB_SOURCES} $(DESTDIR)/usr/share/${GEN_PACKAGE}
182         install -m 0755 ${GEN_SCRIPTS} $(DESTDIR)/usr/share/${GEN_PACKAGE}
183         # install asciidoc-pve
184         install -m 0755 asciidoc-pve $(DESTDIR)/usr/bin/
185         install -D -m 0644 asciidoc/mediawiki.conf $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/mediawiki.conf
186         install -m 0644 asciidoc/asciidoc-pve.conf $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
187         install -m 0644 asciidoc/pve-html.conf $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
188
189 .PHONY: doc-install
190 doc-install: index.html $(WIKI_IMPORTS) $(API_VIEWER_SOURCES) verify-images examples
191         install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE)
192         install -dm755 $(DESTDIR)/usr/share/doc/$(DOC_PACKAGE)
193         # install files for pvedocs package
194         install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}
195         install -dm755 $(DESTDIR)/usr/share/doc/${DOC_PACKAGE}
196         install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}/examples/
197         install -m 755 examples/guest-example-hookscript.pl $(DESTDIR)/usr/share/${DOC_PACKAGE}/examples/
198         install -m 0644 index.html ${INDEX_INCLUDES} $(DESTDIR)/usr/share/${DOC_PACKAGE}
199         install -m 0644 ${WIKI_IMPORTS} $(DESTDIR)/usr/share/${DOC_PACKAGE}
200         # install images
201         make -C images install
202         # install screenshot images
203         install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}/images/screenshot
204         install -m 0644 images/screenshot/*.png $(DESTDIR)/usr/share/${DOC_PACKAGE}/images/screenshot
205         # install api doc viewer
206         install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}/api-viewer
207         install -m 0644 ${API_VIEWER_SOURCES} $(DESTDIR)/usr/share/${DOC_PACKAGE}/api-viewer
208
209 .PHONY: mediawiki-install
210 mediawiki-install: pve-docs-mediawiki-import
211         install -dm755 $(DESTDIR)/usr/share/$(MEDIAWIKI_PACKAGE)
212         install -dm755 $(DESTDIR)/usr/share/doc/$(MEDIAWIKI_PACKAGE)
213         install -dm755 $(DESTDIR)/usr/bin
214         install -dm755 $(DESTDIR)/usr/share/$(MEDIAWIKI_PACKAGE)
215         install -dm755 $(DESTDIR)/usr/share/doc/$(MEDIAWIKI_PACKAGE)
216         install -m 0755 pve-docs-mediawiki-import $(DESTDIR)/usr/bin/
217
218 .PHONY: upload
219 upload: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
220         tar cf - ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB} | ssh -X repoman@repo.proxmox.com -- upload --product pve --dist stretch
221
222 .PHONY: update
223 update:
224         make clean clean-static
225         make update-static
226         make all
227
228 .PHONY: update-static
229 update-static:
230         make clean-static
231         make $(filter %-synopsis.adoc %-opts.adoc, ${PVE_ADMIN_GUIDE_ADOCDEPENDS}) pve-firewall-macros.adoc api-viewer/apidata.js
232
233 .PHONY: clean-static
234 clean-static:
235         find . -regex '.*-\(opts\|synopsis\)\.adoc' -not -name pmxcfs.8-synopsis.adoc -not -name qmeventd.8-synopsis.adoc -exec rm -f \{\} \;
236         rm -f api-viewer/apidata.js
237         rm -f pve-firewall-macros.adoc pct-network-opts.adoc pct-mountpoint-opts.adoc
238
239 clean:
240         rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8
241         rm -f *.deb *.changes *.buildinfo
242         rm -f api-viewer/apidoc.js chapter-*.html *-plain.html chapter-*.html pve-admin-guide.chunked asciidoc-pve link-refs.json .asciidoc-pve-tmp_* pve-docs-mediawiki-import
243         rm -rf .pve-doc-depends
244         rm -f pve-doc-generator.mk chapter-index-table.adoc man1-index-table.adoc man5-index-table.adoc man8-index-table.adoc pve-admin-guide-docinfo.xml
245         rm -rf build