Makefile: update - do not delete file pmxcfs.8-synopsis.adoc
[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=10
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 all: index.html
20
21 .pve-doc-depends link-refs.json: $(wildcard *.adoc) scan-adoc-refs
22         ./scan-adoc-refs *.adoc --depends .pve-doc-depends > link-refs.json
23
24 pve-doc-generator.mk: .pve-doc-depends pve-doc-generator.mk.in
25         cat pve-doc-generator.mk.in .pve-doc-depends > $@.tmp
26         mv $@.tmp $@
27
28 include ./pve-doc-generator.mk
29
30 GEN_DEB_SOURCES=                                \
31         pve-doc-generator.mk                    \
32         ${MANUAL_SOURCES}                       \
33         pmxcfs.8-synopsis.adoc                  \
34         docinfo.xml
35
36 GEN_SCRIPTS=                                    \
37         gen-datacenter.cfg.5-opts.pl            \
38         gen-pct.conf.5-opts.pl                  \
39         gen-pct-network-opts.pl                 \
40         gen-pct-mountpoint-opts.pl              \
41         gen-qm.conf.5-opts.pl                   \
42         gen-vzdump.conf.5-opts.pl               \
43         gen-pve-firewall-cluster-opts.pl        \
44         gen-pve-firewall-host-opts.pl           \
45         gen-pve-firewall-macros-adoc.pl         \
46         gen-pve-firewall-rules-opts.pl          \
47         gen-pve-firewall-vm-opts.pl
48
49 API_VIEWER_SOURCES=                             \
50         api-viewer/index.html                   \
51         api-viewer/apidoc.js
52
53 asciidoc-pve: asciidoc-pve.in link-refs.json
54         cat asciidoc-pve.in link-refs.json >asciidoc-pve.tmp
55         sed -e s/@RELEASE@/${DOCRELEASE}/ -i asciidoc-pve.tmp
56         chmod +x asciidoc-pve.tmp
57         mv asciidoc-pve.tmp asciidoc-pve
58
59 pve-docs-mediawiki-import: pve-docs-mediawiki-import.in link-refs.json
60         cat pve-docs-mediawiki-import.in link-refs.json >  pve-docs-mediawiki-import.tmp
61         chmod +x pve-docs-mediawiki-import.tmp
62         mv pve-docs-mediawiki-import.tmp pve-docs-mediawiki-import
63
64 INDEX_INCLUDES=                                                         \
65         pve-admin-guide.pdf                                             \
66         pve-admin-guide.epub                                            \
67         $(sort $(addsuffix .html, ${MANUAL_PAGES}) ${CHAPTER_LIST})
68
69 ADOC_STDARG= -a icons -a data-uri -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}"
70
71 BROWSER?=xdg-open
72
73
74 %-nwdiag.svg: %.nwdiag
75         nwdiag -T svg $*.nwdiag -o $@;
76
77 README.html: README.adoc
78         asciidoc ${ADOC_STDARG} -o $@ $<
79
80 .PHONY: index
81 index: index.html
82         $(BROWSER) index.html &
83
84 index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES} 
85         asciidoc -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}" index.adoc
86
87 pve-admin-guide.html: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
88         asciidoc -a pvelogo -a "revnumber=${DOCRELEASE}" -a "date=$(shell date)" pve-admin-guide.adoc
89
90 pve-admin-guide.chunked: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
91         rm -rf pve-admin-guide.chunked
92         a2x -a docinfo -a docinfo1 -a icons -f chunked pve-admin-guide.adoc
93
94 pve-admin-guide.pdf: ${PVE_ADMIN_GUIDE_ADOCDEPENDS} docinfo.xml pve-admin-guide-docinfo.xml
95         inkscape -z -D --export-pdf=proxmox-logo.pdf images/proxmox-logo.svg
96         inkscape -z -D --export-pdf=proxmox-ci-header.pdf images/proxmox-ci-header.svg
97         grep ">Release ${DOCRELEASE}<" pve-admin-guide-docinfo.xml || (echo "wrong release in  pve-admin-guide-docinfo.xml" && false);
98         a2x -a docinfo -a docinfo1 -f pdf -L --dblatex-opts "-P latex.output.revhistory=0" --dblatex-opts "-P latex.class.options=12pt" --dblatex-opts "-P doc.section.depth=2 -P toc.section.depth=2" --dblatex-opts "-P doc.publisher.show=0 -s asciidoc-dblatex-custom.sty" pve-admin-guide.adoc
99         rm proxmox-logo.pdf proxmox-ci-header.pdf
100
101 pve-admin-guide.epub: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
102         a2x -f epub pve-admin-guide.adoc
103
104 api-viewer/apidata.js: extractapi.pl
105         ./extractapi.pl >$@
106
107 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PVEAPI.js
108         cat api-viewer/apidata.js api-viewer/PVEAPI.js >$@
109
110 .PHONY: dinstall
111 dinstall: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
112         dpkg -i ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
113
114 .PHONY: deb
115 deb:
116         rm -f ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB};
117         make ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB};
118
119 ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}: index.html ${INDEX_INCLUDES} ${WIKI_IMPORTS} ${API_VIEWER_SOURCES} ${GEN_DEB_SOURCES} asciidoc-pve pve-docs-mediawiki-import
120         rm -rf build
121         mkdir build
122         rsync -a debian/ build/debian
123         cp pve-docs-mediawiki-import build/debian/tree/pve-docs-mediawiki/pve-docs-mediawiki-import
124         echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout ${GITVERSION}" > build/debian/SOURCE
125         # install files for pve-doc-generator package
126         mkdir -p build/usr/share/${GEN_PACKAGE}
127         mkdir -p build/usr/share/doc/${GEN_PACKAGE}
128         mkdir -p build/usr/bin
129         install -m 0644 ${GEN_DEB_SOURCES} build/usr/share/${GEN_PACKAGE}
130         install -m 0755 ${GEN_SCRIPTS} build/usr/share/${GEN_PACKAGE}
131         install -m 0755 asciidoc-pve build/usr/bin/
132         # install files for pvedocs package
133         mkdir -p build/usr/share/${DOC_PACKAGE}
134         mkdir -p build/usr/share/doc/${DOC_PACKAGE}
135         install -m 0644 index.html ${INDEX_INCLUDES} build/usr/share/${DOC_PACKAGE}
136         install -m 0644 ${WIKI_IMPORTS} build/usr/share/${DOC_PACKAGE}
137         # install api doc viewer
138         mkdir build/usr/share/${DOC_PACKAGE}/api-viewer
139         install -m 0644 ${API_VIEWER_SOURCES} build/usr/share/${DOC_PACKAGE}/api-viewer
140         # build Debian packages
141         cd build; dpkg-buildpackage -rfakeroot -b -us -uc
142         lintian ${GEN_DEB}
143         lintian ${DOC_DEB}
144         lintian ${MEDIAWIKI_DEB}
145
146 .PHONY: upload
147 upload: ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB}
148         tar cf - ${GEN_DEB} ${DOC_DEB} ${MEDIAWIKI_DEB} | ssh repoman@repo.proxmox.com upload
149
150 .PHONY: update
151 update: clean
152         find . -regex '.*-\(opts\|synopsis\)\.adoc' -not -name pmxcfs.8-synopsis.adoc -exec rm -f \{\} \;
153         rm -f api-viewer/apidata.js
154         rm -f pve-firewall-macros.adoc pct-network-opts.adoc pct-mountpoint-opts.adoc
155         make all
156
157 clean: 
158         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
159         find . -name '*~' -exec rm {} ';'