]> git.proxmox.com Git - pve-docs.git/blob - Makefile
add graphviz picture for our default bonded network setup
[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=8
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 DOC_BUILDDEPS := asciidoc-dblatex, source-highlight, librsvg2-bin
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 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
93 %-nwdiag.svg: %.nwdiag
94 nwdiag -T svg $*.nwdiag -o $@;
95
96 README.html: README.adoc
97 asciidoc -a toc ${ADOC_STDARG} -o $@ $<
98
99 .PHONY: index
100 index: index.html
101 $(BROWSER) index.html &
102
103 chapter-index-table.adoc: asciidoc-pve
104 ./asciidoc-pve chapter-table >$@.tmp
105 mv $@.tmp $@
106
107 man1-index-table.adoc: asciidoc-pve
108 ./asciidoc-pve man1page-table >$@.tmp
109 mv $@.tmp $@
110
111 man5-index-table.adoc: asciidoc-pve
112 ./asciidoc-pve man5page-table >$@.tmp
113 mv $@.tmp $@
114
115 man8-index-table.adoc: asciidoc-pve
116 ./asciidoc-pve man8page-table >$@.tmp
117 mv $@.tmp $@
118
119 index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES}
120 asciidoc ${ADOC_STDARG} -o $@ index.adoc
121
122 pve-admin-guide.html: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
123 asciidoc -a pvelogo ${ADOC_STDARG} -o $@ pve-admin-guide.adoc
124
125 pve-admin-guide.chunked: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
126 rm -rf pve-admin-guide.chunked
127 a2x -a docinfo -a docinfo1 -a icons -f chunked pve-admin-guide.adoc
128
129 PVE_DOCBOOK_CONF=-b $(shell pwd)/asciidoc/pve-docbook -f asciidoc/asciidoc-pve.conf
130 PVE_DBLATEX_OPTS='-p ./asciidoc/pve-dblatex.xsl -s asciidoc/dblatex-custom.sty -c asciidoc/dblatex-export.conf'
131
132 pve-admin-guide-docinfo.xml: pve-admin-guide-docinfo.xml.in
133 sed -e 's/@RELEASE@/${DOCRELEASE}/' <$< >$@
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 a2x -f epub --asciidoc-opts="${PVE_DOCBOOK_CONF}" pve-admin-guide.adoc
144
145 api-viewer/apidata.js: extractapi.pl
146 ./extractapi.pl >$@
147
148 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PVEAPI.js
149 cat api-viewer/apidata.js api-viewer/PVEAPI.js >$@
150
151 .PHONY: dinstall
152 dinstall: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
153 dpkg -i ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
154
155 .PHONY: deb
156 deb:
157 rm -f ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
158 make all-debs
159
160 .PHONY: all-debs
161 all-debs: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
162
163 .PHONY: clean-build
164 clean-build:
165 rm -rf build
166
167 define prepare_build
168 rm -rf build-$1
169 mkdir build-$1
170 cp -a debian build-$1/debian
171 mv build-$1/debian/control.in build-$1/debian/control
172 echo >> build-$1/debian/control
173 cat debian/$1.control >> build-$1/debian/control
174 echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout ${GITVERSION}" > build-$1/debian/SOURCE
175 install -dm755 build-$1/usr/share/$1
176 install -dm755 build-$1/usr/share/doc/$1
177 endef
178
179 .PHONY: gen-deb
180 gen-deb: $(GEN_DEB)
181 $(GEN_DEB): $(GEN_DEB_SOURCES) asciidoc-pve asciidoc/mediawiki.conf
182 $(call prepare_build,$(GEN_PACKAGE))
183 install -dm755 build-$(GEN_PACKAGE)/usr/bin
184 # install files
185 install -m 0644 ${GEN_DEB_SOURCES} build-$(GEN_PACKAGE)/usr/share/${GEN_PACKAGE}
186 install -m 0755 ${GEN_SCRIPTS} build-$(GEN_PACKAGE)/usr/share/${GEN_PACKAGE}
187 # install asciidoc-pve
188 install -m 0755 asciidoc-pve build-$(GEN_PACKAGE)/usr/bin/
189 install -D -m 0644 asciidoc/mediawiki.conf build-$(GEN_PACKAGE)/usr/share/${GEN_PACKAGE}/asciidoc/mediawiki.conf
190 install -m 0644 asciidoc/asciidoc-pve.conf build-$(GEN_PACKAGE)/usr/share/${GEN_PACKAGE}/asciidoc/
191 install -m 0644 asciidoc/pve-html.conf build-$(GEN_PACKAGE)/usr/share/${GEN_PACKAGE}/asciidoc/
192 cd build-$(GEN_PACKAGE) && dpkg-buildpackage -rfakeroot -b -us -uc
193 lintian ${GEN_DEB}
194
195 .PHONY: doc-deb
196 doc-deb: $(DOC_DEB)
197 $(DOC_DEB): index.html $(WIKI_IMPORTS) $(API_VIEWER_SOURCES) verify-images
198 $(call prepare_build,$(DOC_PACKAGE))
199 sed -i -e '/^Build-Depends/{s/$$/, $(DOC_BUILDDEPS)/}' build-$(DOC_PACKAGE)/debian/control
200 # install files for pvedocs package
201 install -dm755 build-$(DOC_PACKAGE)/usr/share/${DOC_PACKAGE}
202 install -dm755 build-$(DOC_PACKAGE)/usr/share/doc/${DOC_PACKAGE}
203 install -m 0644 index.html ${INDEX_INCLUDES} build-$(DOC_PACKAGE)/usr/share/${DOC_PACKAGE}
204 install -m 0644 ${WIKI_IMPORTS} build-$(DOC_PACKAGE)/usr/share/${DOC_PACKAGE}
205 # install screenshot images
206 install -dm755 build-$(DOC_PACKAGE)/usr/share/${DOC_PACKAGE}/images/screenshot
207 install -m 0644 images/screenshot/*.png build-$(DOC_PACKAGE)/usr/share/${DOC_PACKAGE}/images/screenshot
208 # install api doc viewer
209 install -dm755 build-$(DOC_PACKAGE)/usr/share/${DOC_PACKAGE}/api-viewer
210 install -m 0644 ${API_VIEWER_SOURCES} build-$(DOC_PACKAGE)/usr/share/${DOC_PACKAGE}/api-viewer
211 cd build-$(DOC_PACKAGE) && dpkg-buildpackage -rfakeroot -b -us -uc
212 lintian ${DOC_DEB}
213
214 .PHONY: mediawiki-deb
215 mediawiki-deb: $(MEDIAWIKI_DEB)
216 $(MEDIAWIKI_DEB): pve-docs-mediawiki-import
217 $(call prepare_build,$(MEDIAWIKI_PACKAGE))
218 cp pve-docs-mediawiki-import build-$(MEDIAWIKI_PACKAGE)/debian/tree/pve-docs-mediawiki/pve-docs-mediawiki-import
219 cd build-$(MEDIAWIKI_PACKAGE) && dpkg-buildpackage -rfakeroot -b -us -uc
220 lintian ${MEDIAWIKI_DEB}
221
222 .PHONY: upload
223 upload: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
224 tar cf - ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB} | ssh -X repoman@repo.proxmox.com -- upload --product pve --dist stretch
225
226 .PHONY: update
227 update:
228 make clean clean-static
229 make update-static
230 make all
231
232 .PHONY: update-static
233 update-static:
234 make clean-static
235 make $(filter %-synopsis.adoc %-opts.adoc, ${PVE_ADMIN_GUIDE_ADOCDEPENDS}) pve-firewall-macros.adoc api-viewer/apidata.js
236
237 .PHONY: clean-static
238 clean-static:
239 find . -regex '.*-\(opts\|synopsis\)\.adoc' -not -name pmxcfs.8-synopsis.adoc -exec rm -f \{\} \;
240 rm -f api-viewer/apidata.js
241 rm -f pve-firewall-macros.adoc pct-network-opts.adoc pct-mountpoint-opts.adoc
242
243 clean:
244 rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8
245 rm -f *.deb *.changes *.buildinfo
246 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
247 rm -rf .pve-doc-depends
248 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
249 rm -rf build-*