]>
Commit | Line | Data |
---|---|---|
1 | include /usr/share/dpkg/pkg-info.mk | |
2 | ||
3 | DGDIR=. | |
4 | ASCIIDOC_PMG=./asciidoc-pmg | |
5 | ||
6 | BUILDDIR ?= $(DEB_SOURCE)-$(DEB_VERSION) | |
7 | DSC=$(DEB_SOURCE)_$(DEB_VERSION).dsc | |
8 | ||
9 | GEN_PACKAGE=pmg-doc-generator | |
10 | DOC_PACKAGE=pmg-docs | |
11 | ||
12 | GEN_DEB=$(GEN_PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_all.deb | |
13 | DOC_DEB=$(DOC_PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_all.deb | |
14 | ||
15 | export SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp) | |
16 | SOURCE_DATE_HUMAN := $(shell date -d "@$(SOURCE_DATE_EPOCH)") | |
17 | ||
18 | ||
19 | all: index.html | |
20 | ||
21 | .PHONY: verify-images | |
22 | verify-images: png-verify.pl | |
23 | for i in ./images/screenshot/*.png; do ./png-verify.pl $$i; done | |
24 | for i in ./images/installer/*.png; do ./png-verify.pl $$i; done | |
25 | ||
26 | ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard *.adoc)) | |
27 | .pmg-doc-depends link-refs.json: $(ADOC_SOURCES_GUESS) scan-adoc-refs | |
28 | ./scan-adoc-refs *.adoc --depends .pmg-doc-depends.tmp > link-refs.json.tmp | |
29 | @cmp --quiet .pmg-doc-depends .pmg-doc-depends.tmp || mv .pmg-doc-depends.tmp .pmg-doc-depends | |
30 | @cmp --quiet link-refs.json link-refs.json.tmp || mv link-refs.json.tmp link-refs.json | |
31 | ||
32 | pmg-doc-generator.mk: .pmg-doc-depends pmg-doc-generator.mk.in | |
33 | cat pmg-doc-generator.mk.in .pmg-doc-depends > $@.tmp | |
34 | sed -i "s/@RELEASE@$$/$(DEB_VERSION_UPSTREAM)/" $@.tmp | |
35 | mv $@.tmp $@ | |
36 | ||
37 | -include ./pmg-doc-generator.mk | |
38 | ||
39 | GEN_DEB_SOURCES= \ | |
40 | pmg-doc-generator.mk \ | |
41 | $(MANUAL_SOURCES) \ | |
42 | docinfo.xml | |
43 | ||
44 | GEN_SCRIPTS= \ | |
45 | gen-cluster.conf.5-opts.pl \ | |
46 | gen-fetchmail.conf.5-opts.pl \ | |
47 | gen-ldap.conf.5-opts.pl \ | |
48 | gen-pmg.conf.5-opts.pl \ | |
49 | gen-user.conf.5-opts.pl | |
50 | ||
51 | API_VIEWER_FILES= \ | |
52 | api-viewer/apidata.js \ | |
53 | api-viewer/PMGAPI.js \ | |
54 | /usr/share/javascript/proxmox-widget-toolkit-dev/APIViewer.js | |
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_FILES) | |
143 | cat $(API_VIEWER_FILES) >$@.tmp | |
144 | mv $@.tmp $@ | |
145 | ||
146 | $(BUILDDIR): | |
147 | rm -rf $@ $@.tmp | |
148 | rsync -a * $@.tmp | |
149 | echo "git clone git://git.proxmox.com/git/pmg-docs.git\\ngit checkout $(shell git rev-parse HEAD)" > $@.tmp/debian/SOURCE | |
150 | mv $@.tmp $@ | |
151 | ||
152 | .PHONY: dinstall | |
153 | dinstall: $(GEN_DEB) $(DOC_DEB) | |
154 | dpkg -i $(GEN_DEB) $(DOC_DEB) | |
155 | ||
156 | .PHONY: dsc deb | |
157 | dsc: $(DSC) | |
158 | $(DSC): $(BUILDDIR) | |
159 | cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d | |
160 | lintian $(DSC) | |
161 | ||
162 | sbuild: $(DSC) | |
163 | sbuild $(DSC) | |
164 | ||
165 | deb: $(DOC_DEB) | |
166 | rm -f $(GEN_DEB) $(DOC_DEB) | |
167 | rm -rf $(BUILDDIR) | |
168 | $(MAKE) $(DOC_DEB) | |
169 | ||
170 | $(GEN_DEB): $(DOC_DEB) | |
171 | ||
172 | $(DOC_DEB): $(BUILDDIR) | |
173 | cd $(BUILDDIR); dpkg-buildpackage -b -us -uc | |
174 | lintian $(DOC_DEB) $(GEN_DEB) | |
175 | ||
176 | .PHONY: clean-build | |
177 | clean-build: | |
178 | rm -rf $(BUILDDIR) | |
179 | ||
180 | .PHONY: install | |
181 | install: gen-install doc-install | |
182 | ||
183 | .PHONY: gen-install | |
184 | gen-install: $(GEN_DEB_SOURCES) asciidoc-pmg | |
185 | install -dm755 $(DESTDIR)/usr/bin | |
186 | install -dm755 $(DESTDIR)/usr/share/$(GEN_PACKAGE) | |
187 | # install files | |
188 | install -m 0644 $(GEN_DEB_SOURCES) $(DESTDIR)/usr/share/$(GEN_PACKAGE) | |
189 | install -m 0755 $(GEN_SCRIPTS) $(DESTDIR)/usr/share/$(GEN_PACKAGE) | |
190 | # install asciidoc-pmg | |
191 | install -m 0755 asciidoc-pmg $(DESTDIR)/usr/bin/ | |
192 | install -dm755 $(DESTDIR)/usr/share/$(GEN_PACKAGE)/asciidoc/ | |
193 | install -m 0644 asciidoc/asciidoc-pmg.conf $(DESTDIR)/usr/share/$(GEN_PACKAGE)/asciidoc/ | |
194 | install -m 0644 asciidoc/pmg-html.conf $(DESTDIR)/usr/share/$(GEN_PACKAGE)/asciidoc/ | |
195 | ||
196 | .PHONY: doc-install | |
197 | doc-install: index.html $(API_VIEWER_SOURCES) verify-images | |
198 | # install files for pmgdocs package | |
199 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE) | |
200 | install -dm755 $(DESTDIR)/usr/share/doc/$(DOC_PACKAGE) | |
201 | install -m 0644 index.html $(INDEX_INCLUDES) $(DESTDIR)/usr/share/$(DOC_PACKAGE) | |
202 | # install screenshot images | |
203 | for d in screenshot installer; do \ | |
204 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE)/images/$$d; \ | |
205 | install -m 0644 images/$$d/*.png $(DESTDIR)/usr/share/$(DOC_PACKAGE)/images/$$d; \ | |
206 | done | |
207 | # install api doc viewer | |
208 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE)/api-viewer | |
209 | install -m 0644 $(API_VIEWER_SOURCES) $(DESTDIR)/usr/share/$(DOC_PACKAGE)/api-viewer | |
210 | ||
211 | .PHONY: upload | |
212 | upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION) | |
213 | upload: $(GEN_DEB) $(DOC_DEB) | |
214 | tar cf - $(GEN_DEB) $(DOC_DEB) | ssh -X repoman@repo.proxmox.com -- upload --product pmg --dist $(UPLOAD_DIST) | |
215 | ||
216 | .PHONY: update | |
217 | update: clean | |
218 | find . -regex '.*-\(opts\|synopsis\)\.adoc' -exec rm -f \{\} \; | |
219 | rm -f api-viewer/apidata.js | |
220 | make all | |
221 | ||
222 | clean: | |
223 | find . -name '*~' -exec rm {} ';' | |
224 | rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8 | |
225 | rm -f *.deb *dsc *.tar.* *.changes *.buildinfo *.build | |
226 | 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 | |
227 | rm -rf .pmg-doc-depends | |
228 | 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 | |
229 | rm -rf $(DEB_SOURCE)-[0-9]* |