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