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