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