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