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