]> git.proxmox.com Git - pmg-docs.git/blob - Makefile
installation: fix codeblock rendering in zfs performance tips section
[pmg-docs.git] / Makefile
1 include /usr/share/dpkg/pkg-info.mk
2
3 DGDIR=.
4 ASCIIDOC_PMG=./asciidoc-pmg
5
6 GEN_PACKAGE=pmg-doc-generator
7 DOC_PACKAGE=pmg-docs
8 WEB_PACKAGE=pmg-docs-apache
9
10 # also update debian/changelog
11 PKGREL=1
12
13 GITVERSION:=$(shell git rev-parse HEAD)
14
15 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
16
17 GEN_DEB=${GEN_PACKAGE}_${DEB_VERSION_UPSTREAM_REVISION}_${ARCH}.deb
18 DOC_DEB=${DOC_PACKAGE}_${DEB_VERSION_UPSTREAM_REVISION}_all.deb
19 WEB_DEB=${WEB_PACKAGE}_${DEB_VERSION_UPSTREAM_REVISION}_all.deb
20
21 export SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp)
22 SOURCE_DATE_HUMAN := $(shell date -d "@${SOURCE_DATE_EPOCH}")
23
24
25 all: index.html
26
27 .PHONY: verify-images
28 verify-images: png-verify.pl
29 for i in ./images/screenshot/*.png; do ./png-verify.pl $$i; done
30
31 ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard *.adoc))
32 .pmg-doc-depends link-refs.json: ${ADOC_SOURCES_GUESS} scan-adoc-refs
33 ./scan-adoc-refs *.adoc --depends .pmg-doc-depends.tmp > link-refs.json.tmp
34 @cmp --quiet .pmg-doc-depends .pmg-doc-depends.tmp || mv .pmg-doc-depends.tmp .pmg-doc-depends
35 @cmp --quiet link-refs.json link-refs.json.tmp || mv link-refs.json.tmp link-refs.json
36
37 pmg-doc-generator.mk: .pmg-doc-depends pmg-doc-generator.mk.in
38 cat pmg-doc-generator.mk.in .pmg-doc-depends > $@.tmp
39 sed -i "s/@RELEASE@$$/${DEB_VERSION_UPSTREAM}/" $@.tmp
40 mv $@.tmp $@
41
42 -include ./pmg-doc-generator.mk
43
44 GEN_DEB_SOURCES= \
45 pmg-doc-generator.mk \
46 ${MANUAL_SOURCES} \
47 docinfo.xml
48
49 GEN_SCRIPTS= \
50 gen-cluster.conf.5-opts.pl \
51 gen-fetchmail.conf.5-opts.pl \
52 gen-ldap.conf.5-opts.pl \
53 gen-pmg.conf.5-opts.pl \
54 gen-user.conf.5-opts.pl
55
56 API_VIEWER_SOURCES= \
57 api-viewer/index.html \
58 api-viewer/apidoc.js
59
60 asciidoc-pmg: asciidoc-pmg.in link-refs.json
61 cat asciidoc-pmg.in link-refs.json >asciidoc-pmg.tmp
62 sed -e s/@RELEASE@/${DOCRELEASE}/ -i asciidoc-pmg.tmp
63 chmod +x asciidoc-pmg.tmp
64 mv asciidoc-pmg.tmp asciidoc-pmg
65
66 INDEX_INCLUDES= \
67 pmg-admin-guide.pdf \
68 pmg-admin-guide.epub \
69 chapter-index-table.adoc \
70 man1-index-table.adoc \
71 man5-index-table.adoc \
72 man8-index-table.adoc \
73 $(sort $(addsuffix .html, ${MANUAL_PAGES}) ${CHAPTER_LIST})
74
75 ADOC_STDARG=-b $(shell pwd)/asciidoc/pmg-html -f asciidoc/asciidoc-pmg.conf -a icons -a data-uri -a "date=${SOURCE_DATE_HUMAN}" -a "revnumber=${DOCRELEASE}"
76
77 BROWSER?=xdg-open
78
79
80 README.html: README.adoc
81 asciidoc -a toc ${ADOC_STDARG} -o $@ $<
82
83 .PHONY: index
84 index: index.html
85 $(BROWSER) index.html &
86
87 chapter-index-table.adoc: asciidoc-pmg
88 ./asciidoc-pmg chapter-table >$@.tmp
89 mv $@.tmp $@
90
91 man1-index-table.adoc: asciidoc-pmg
92 ./asciidoc-pmg man1page-table >$@.tmp
93 mv $@.tmp $@
94
95 man5-index-table.adoc: asciidoc-pmg
96 ./asciidoc-pmg man5page-table >$@.tmp
97 mv $@.tmp $@
98
99 man8-index-table.adoc: asciidoc-pmg
100 ./asciidoc-pmg man8page-table >$@.tmp
101 mv $@.tmp $@
102
103 index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES}
104 asciidoc ${ADOC_STDARG} -o $@ index.adoc
105
106 pmg-admin-guide.html: ${PMG_ADMIN_GUIDE_ADOCDEPENDS}
107 asciidoc -a pmglogo ${ADOC_STDARG} -o $@ pmg-admin-guide.adoc
108
109 pmg-admin-guide.chunked: ${PMG_ADMIN_GUIDE_ADOCDEPENDS}
110 rm -rf $@.tmp $@
111 mkdir $@.tmp
112 a2x -D $@.tmp -a docinfo -a docinfo1 -a icons -f chunked pmg-admin-guide.adoc
113 mv $@.tmp/$@ $@
114
115 PMG_DOCBOOK_CONF=-b $(shell pwd)/asciidoc/pmg-docbook -f asciidoc/asciidoc-pmg.conf
116 PMG_DBLATEX_OPTS='-p ./asciidoc/pmg-dblatex.xsl -s asciidoc/dblatex-custom.sty -c asciidoc/dblatex-export.conf'
117
118 YEAR:=$(shell date "+%Y")
119
120 pmg-admin-guide-docinfo.xml: pmg-admin-guide-docinfo.xml.in
121 sed -e 's/@RELEASE@/${DOCRELEASE}/' -e 's/@YEAR@/${YEAR}/' <$< >$@
122
123 pmg-copyright.adoc: pmg-copyright.adoc.in
124 sed -e 's/@YEAR@/${YEAR}/' <$< >$@
125
126 pmg-admin-guide.pdf: ${PMG_ADMIN_GUIDE_ADOCDEPENDS} docinfo.xml pmg-admin-guide-docinfo.xml
127 rsvg-convert -f pdf -o proxmox-logo.pdf images/proxmox-logo.svg
128 rsvg-convert -f pdf -o proxmox-ci-header.pdf images/proxmox-ci-header.svg
129 grep ">Release ${DOCRELEASE}<" pmg-admin-guide-docinfo.xml || (echo "wrong release in pmg-admin-guide-docinfo.xml" && false);
130 a2x -a docinfo -a docinfo1 -f pdf -L --asciidoc-opts="${PMG_DOCBOOK_CONF}" --dblatex-opts ${PMG_DBLATEX_OPTS} pmg-admin-guide.adoc
131 rm proxmox-logo.pdf proxmox-ci-header.pdf
132
133 pmg-admin-guide.epub: ${PMG_ADMIN_GUIDE_ADOCDEPENDS}
134 rm -rf $@.tmp $@
135 mkdir $@.tmp
136 a2x -D $@.tmp -f epub --asciidoc-opts="${PMG_DOCBOOK_CONF}" pmg-admin-guide.adoc
137 mv $@.tmp/$@ $@
138
139 api-viewer/apidata.js: extractapi.pl
140 ./extractapi.pl >$@
141
142 api-viewer/apidoc.js: api-viewer/apidata.js api-viewer/PMGAPI.js
143 cat api-viewer/apidata.js api-viewer/PMGAPI.js >$@
144
145 .PHONY: dinstall
146 dinstall: ${GEN_DEB} ${DOC_DEB}
147 dpkg -i ${GEN_DEB} ${DOC_DEB}
148
149 .PHONY: deb
150 deb: ${DOC_DEB}
151
152 ${WEB_DEB} ${GEN_DEB}: ${DOC_DEB}
153
154 ${DOC_DEB}:
155 rm -f ${GEN_DEB} ${DOC_DEB}
156 rm -rf build
157 rsync -a * build/
158 echo "git clone git://git.proxmox.com/git/pmg-docs.git\\ngit checkout ${GITVERSION}" > build/debian/SOURCE
159 cd build; dpkg-buildpackage -b -us -uc
160 lintian $(DOC_DEB) $(GEN_DEB) $(WEB_DEB)
161
162 .PHONY: clean-build
163 clean-build:
164 rm -rf build
165
166 .PHONY: install
167 install: gen-install doc-install
168
169 .PHONY: gen-install
170 gen-install: $(GEN_DEB_SOURCES) asciidoc-pmg
171 install -dm755 ${DESTDIR}/usr/bin
172 install -dm755 $(DESTDIR)/usr/share/${GEN_PACKAGE}
173 # install files
174 install -m 0644 ${GEN_DEB_SOURCES} $(DESTDIR)/usr/share/${GEN_PACKAGE}
175 install -m 0755 ${GEN_SCRIPTS} $(DESTDIR)/usr/share/${GEN_PACKAGE}
176 # install asciidoc-pmg
177 install -m 0755 asciidoc-pmg $(DESTDIR)/usr/bin/
178 install -dm755 $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
179 install -m 0644 asciidoc/asciidoc-pmg.conf $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
180 install -m 0644 asciidoc/pmg-html.conf $(DESTDIR)/usr/share/${GEN_PACKAGE}/asciidoc/
181
182 .PHONY: doc-install
183 doc-install: index.html $(API_VIEWER_SOURCES) verify-images
184 # install files for pmgdocs package
185 install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}
186 install -dm755 $(DESTDIR)/usr/share/doc/${DOC_PACKAGE}
187 install -m 0644 index.html ${INDEX_INCLUDES} $(DESTDIR)/usr/share/${DOC_PACKAGE}
188 # install screenshot images
189 install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}/images/screenshot
190 install -m 0644 images/screenshot/*.png $(DESTDIR)/usr/share/${DOC_PACKAGE}/images/screenshot
191 # install api doc viewer
192 install -dm755 $(DESTDIR)/usr/share/${DOC_PACKAGE}/api-viewer
193 install -m 0644 ${API_VIEWER_SOURCES} $(DESTDIR)/usr/share/${DOC_PACKAGE}/api-viewer
194
195 .PHONY: upload
196 upload: ${WEB_DEB} ${GEN_DEB} ${DOC_DEB}
197 tar cf - ${WEB_DEB} ${GEN_DEB} ${DOC_DEB} | ssh -X repoman@repo.proxmox.com -- upload --product pmg --dist stretch
198
199 .PHONY: update
200 update: clean
201 find . -regex '.*-\(opts\|synopsis\)\.adoc' -exec rm -f \{\} \;
202 rm -f api-viewer/apidata.js
203 make all
204
205 clean:
206 find . -name '*~' -exec rm {} ';'
207 rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8
208 rm -f *.deb *.changes *.buildinfo
209 rm -f api-viewer/apidoc.js chapter-*.html *-plain.html chapter-*.html pmg-admin-guide.chunked asciidoc-pmg link-refs.json .asciidoc-pmg-tmp_* pmg-smtp-filter.8-synopsis.adoc pmgpolicy.8-synopsis.adoc pmgsh.1-synopsis.adoc
210 rm -rf .pmg-doc-depends
211 rm -f pmg-doc-generator.mk chapter-index-table.adoc man1-index-table.adoc man5-index-table.adoc man8-index-table.adoc pmg-admin-guide-docinfo.xml pmg-copyright.adoc
212 rm -rf build*