buildsys: not our job to handle editor files
[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 cat .git/refs/heads/master)
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
20 all: index.html
21
22 .PHONY: verify-images
23 verify-images:
24         for i in ./images/screenshot/*.png; do ./png-verify.pl $$i; done
25
26 ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard *.adoc))
27 .pve-doc-depends link-refs.json: ${ADOC_SOURCES_GUESS} scan-adoc-refs
28         ./scan-adoc-refs *.adoc --depends .pve-doc-depends.tmp > link-refs.json.tmp
29         @cmp --quiet .pve-doc-depends .pve-doc-depends.tmp || mv .pve-doc-depends.tmp .pve-doc-depends
30         @cmp --quiet link-refs.json link-refs.json.tmp || mv link-refs.json.tmp link-refs.json
31
32 pve-doc-generator.mk: .pve-doc-depends pve-doc-generator.mk.in
33         cat pve-doc-generator.mk.in .pve-doc-depends > $@.tmp
34         mv $@.tmp $@
35
36 include ./pve-doc-generator.mk
37
38 GEN_DEB_SOURCES=                                \
39         pve-doc-generator.mk                    \
40         ${MANUAL_SOURCES}                       \
41         pmxcfs.8-synopsis.adoc                  \
42         docinfo.xml
43
44 GEN_SCRIPTS=                                    \
45         gen-ha-groups-opts.pl                   \
46         gen-ha-resources-opts.pl                \
47         gen-datacenter.cfg.5-opts.pl            \
48         gen-pct.conf.5-opts.pl                  \
49         gen-pct-network-opts.pl                 \
50         gen-pct-mountpoint-opts.pl              \
51         gen-qm.conf.5-opts.pl                   \
52         gen-vzdump.conf.5-opts.pl               \
53         gen-pve-firewall-cluster-opts.pl        \
54         gen-pve-firewall-host-opts.pl           \
55         gen-pve-firewall-macros-adoc.pl         \
56         gen-pve-firewall-rules-opts.pl          \
57         gen-pve-firewall-vm-opts.pl
58
59 API_VIEWER_SOURCES=                             \
60         api-viewer/index.html                   \
61         api-viewer/apidoc.js
62
63 asciidoc-pve: asciidoc-pve.in link-refs.json
64         cat asciidoc-pve.in link-refs.json >asciidoc-pve.tmp
65         sed -e s/@RELEASE@/${DOCRELEASE}/ -i asciidoc-pve.tmp
66         chmod +x asciidoc-pve.tmp
67         mv asciidoc-pve.tmp asciidoc-pve
68
69 pve-docs-mediawiki-import: pve-docs-mediawiki-import.in link-refs.json
70         cat pve-docs-mediawiki-import.in link-refs.json >  pve-docs-mediawiki-import.tmp
71         chmod +x pve-docs-mediawiki-import.tmp
72         mv pve-docs-mediawiki-import.tmp pve-docs-mediawiki-import
73
74 INDEX_INCLUDES=                                                         \
75         pve-admin-guide.pdf                                             \
76         pve-admin-guide.epub                                            \
77         chapter-index-table.adoc                                        \
78         man1-index-table.adoc                                           \
79         man5-index-table.adoc                                           \
80         man8-index-table.adoc                                           \
81         $(sort $(addsuffix .html, ${MANUAL_PAGES}) ${CHAPTER_LIST})
82
83 ADOC_STDARG=-b $(shell pwd)/asciidoc/pve-html -f asciidoc/asciidoc-pve.conf -a icons -a data-uri -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}"
84
85 BROWSER?=xdg-open
86
87
88 %-nwdiag.svg: %.nwdiag
89         nwdiag -T svg $*.nwdiag -o $@;
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 pve-admin-guide.chunked
122         a2x -a docinfo -a docinfo1 -a icons -f chunked pve-admin-guide.adoc
123
124 PVE_DOCBOOK_CONF=-b $(shell pwd)/asciidoc/pve-docbook -f asciidoc/asciidoc-pve.conf
125
126 pve-admin-guide-docinfo.xml: pve-admin-guide-docinfo.xml.in
127         sed -e 's/@RELEASE@/${DOCRELEASE}/' <$< >$@
128
129 pve-admin-guide.pdf: ${PVE_ADMIN_GUIDE_ADOCDEPENDS} docinfo.xml pve-admin-guide-docinfo.xml
130         inkscape -z -D --export-pdf=proxmox-logo.pdf images/proxmox-logo.svg
131         inkscape -z -D --export-pdf=proxmox-ci-header.pdf images/proxmox-ci-header.svg
132         grep ">Release ${DOCRELEASE}<" pve-admin-guide-docinfo.xml || (echo "wrong release in  pve-admin-guide-docinfo.xml" && false);
133         a2x -a docinfo -a docinfo1 -f pdf -L --asciidoc-opts="${PVE_DOCBOOK_CONF}" --dblatex-opts "-p ./asciidoc/pve-dblatex.xsl -s asciidoc/dblatex-custom.sty" pve-admin-guide.adoc
134         rm proxmox-logo.pdf proxmox-ci-header.pdf
135
136 pve-admin-guide.epub: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
137         a2x -f epub --asciidoc-opts="${PVE_DOCBOOK_CONF}" pve-admin-guide.adoc
138
139 api-viewer/apidata.js: extractapi.pl
140         ./extractapi.pl >$@
141
142 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PVEAPI.js
143         cat api-viewer/apidata.js api-viewer/PVEAPI.js >$@
144
145 .PHONY: dinstall
146 dinstall: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
147         dpkg -i ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
148
149 .PHONY: deb
150 deb:
151         rm -f ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB};
152         make ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB};
153
154 ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}: index.html ${INDEX_INCLUDES} ${WIKI_IMPORTS} ${API_VIEWER_SOURCES} ${GEN_DEB_SOURCES} asciidoc-pve pve-docs-mediawiki-import asciidoc/mediawiki.conf verify-images
155         rm -rf build
156         mkdir build
157         rsync -a debian/ build/debian
158         cp pve-docs-mediawiki-import build/debian/tree/pve-docs-mediawiki/pve-docs-mediawiki-import
159         echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout ${GITVERSION}" > build/debian/SOURCE
160         # install files for pve-doc-generator package
161         mkdir -p build/usr/share/${GEN_PACKAGE}
162         mkdir -p build/usr/share/doc/${GEN_PACKAGE}
163         mkdir -p build/usr/bin
164         install -m 0644 ${GEN_DEB_SOURCES} build/usr/share/${GEN_PACKAGE}
165         install -m 0755 ${GEN_SCRIPTS} build/usr/share/${GEN_PACKAGE}
166         # install asciidoc-pve
167         install -m 0755 asciidoc-pve build/usr/bin/
168         install -D -m 0644 asciidoc/mediawiki.conf build/usr/share/${GEN_PACKAGE}/asciidoc/mediawiki.conf
169         install -m 0644 asciidoc/asciidoc-pve.conf build/usr/share/${GEN_PACKAGE}/asciidoc/
170         install -m 0644 asciidoc/pve-html.conf build/usr/share/${GEN_PACKAGE}/asciidoc/
171         # install files for pvedocs package
172         mkdir -p build/usr/share/${DOC_PACKAGE}
173         mkdir -p build/usr/share/doc/${DOC_PACKAGE}
174         install -m 0644 index.html ${INDEX_INCLUDES} build/usr/share/${DOC_PACKAGE}
175         install -m 0644 ${WIKI_IMPORTS} build/usr/share/${DOC_PACKAGE}
176         # install screenshot images
177         mkdir -p build/usr/share/${DOC_PACKAGE}/images/screenshot
178         install -m 0644 images/screenshot/*.png build/usr/share/${DOC_PACKAGE}/images/screenshot
179         # install api doc viewer
180         mkdir build/usr/share/${DOC_PACKAGE}/api-viewer
181         install -m 0644 ${API_VIEWER_SOURCES} build/usr/share/${DOC_PACKAGE}/api-viewer
182         # build Debian packages
183         cd build; dpkg-buildpackage -rfakeroot -b -us -uc
184         lintian ${GEN_DEB}
185         lintian ${DOC_DEB}
186         lintian ${MEDIAWIKI_DEB}
187
188 .PHONY: upload
189 upload: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
190         tar cf - ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB} | ssh repoman@repo.proxmox.com upload
191
192 .PHONY: update
193 update: clean
194         find . -regex '.*-\(opts\|synopsis\)\.adoc' -not -name pmxcfs.8-synopsis.adoc -exec rm -f \{\} \;
195         rm -f api-viewer/apidata.js
196         rm -f pve-firewall-macros.adoc pct-network-opts.adoc pct-mountpoint-opts.adoc
197         make all
198
199 clean: 
200         rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8 *.deb *.changes build 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 .pve-doc-depends 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