| 1 | include /usr/share/dpkg/pkg-info.mk |
| 2 | |
| 3 | # overwriting below ensures that we can build without full PVE installed |
| 4 | DGDIR=. |
| 5 | ASCIIDOC_PVE=./asciidoc-pve |
| 6 | |
| 7 | BUILDDIR ?= $(DEB_SOURCE)-$(DEB_VERSION) |
| 8 | DSC=$(DEB_SOURCE)_$(DEB_VERSION).dsc |
| 9 | |
| 10 | GEN_PACKAGE=pve-doc-generator |
| 11 | DOC_PACKAGE=pve-docs |
| 12 | MEDIAWIKI_PACKAGE=pve-docs-mediawiki |
| 13 | |
| 14 | GITVERSION:=$(shell git rev-parse HEAD) |
| 15 | |
| 16 | GEN_DEB=$(GEN_PACKAGE)_$(DEB_VERSION)_all.deb |
| 17 | DOC_DEB=$(DOC_PACKAGE)_$(DEB_VERSION)_all.deb |
| 18 | MEDIAWIKI_DEB=$(MEDIAWIKI_PACKAGE)_$(DEB_VERSION)_all.deb |
| 19 | |
| 20 | export SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp) |
| 21 | SOURCE_DATE_HUMAN := $(shell date -d "@$(SOURCE_DATE_EPOCH)") |
| 22 | |
| 23 | all: index.html |
| 24 | |
| 25 | .PHONY: verify-images |
| 26 | verify-images: |
| 27 | for i in ./images/screenshot/*.png; do ./png-verify.pl $$i; done |
| 28 | |
| 29 | ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard *.adoc)) |
| 30 | .pve-doc-depends link-refs.json: $(ADOC_SOURCES_GUESS) scan-adoc-refs |
| 31 | ./scan-adoc-refs *.adoc --depends .pve-doc-depends.tmp > link-refs.json.tmp |
| 32 | @cmp --quiet .pve-doc-depends .pve-doc-depends.tmp || mv .pve-doc-depends.tmp .pve-doc-depends |
| 33 | @cmp --quiet link-refs.json link-refs.json.tmp || mv link-refs.json.tmp link-refs.json |
| 34 | |
| 35 | pve-doc-generator.mk: .pve-doc-depends pve-doc-generator.mk.in |
| 36 | cat pve-doc-generator.mk.in .pve-doc-depends > $@.tmp |
| 37 | sed -i "s/@RELEASE@$$/$(DEB_VERSION_UPSTREAM)/" $@.tmp |
| 38 | mv $@.tmp $@ |
| 39 | |
| 40 | -include ./pve-doc-generator.mk |
| 41 | |
| 42 | GEN_DEB_SOURCES= \ |
| 43 | pve-doc-generator.mk \ |
| 44 | $(MANUAL_SOURCES) \ |
| 45 | pmxcfs.8-synopsis.adoc \ |
| 46 | qmeventd.8-synopsis.adoc \ |
| 47 | docinfo.xml |
| 48 | |
| 49 | GEN_SCRIPTS= \ |
| 50 | gen-ha-groups-opts.pl \ |
| 51 | gen-ha-resources-opts.pl \ |
| 52 | gen-datacenter.cfg.5-opts.pl \ |
| 53 | gen-pct.conf.5-opts.pl \ |
| 54 | gen-pct-network-opts.pl \ |
| 55 | gen-pct-mountpoint-opts.pl \ |
| 56 | gen-qm.conf.5-opts.pl \ |
| 57 | gen-cpu-models.conf.5-opts.pl \ |
| 58 | gen-qm-cloud-init-opts.pl \ |
| 59 | gen-vzdump.conf.5-opts.pl \ |
| 60 | gen-pve-firewall-cluster-opts.pl \ |
| 61 | gen-pve-firewall-host-opts.pl \ |
| 62 | gen-pve-firewall-macros-adoc.pl \ |
| 63 | gen-pve-firewall-rules-opts.pl \ |
| 64 | gen-pve-firewall-vm-opts.pl \ |
| 65 | gen-output-format-opts.pl |
| 66 | |
| 67 | API_VIEWER_FILES= \ |
| 68 | api-viewer/apidata.js \ |
| 69 | api-viewer/PVEAPI.js \ |
| 70 | /usr/share/javascript/proxmox-widget-toolkit-dev/APIViewer.js |
| 71 | |
| 72 | API_VIEWER_SOURCES= \ |
| 73 | api-viewer/index.html \ |
| 74 | api-viewer/apidoc.js |
| 75 | |
| 76 | asciidoc-pve: asciidoc-pve.in link-refs.json |
| 77 | cat asciidoc-pve.in link-refs.json >asciidoc-pve.tmp |
| 78 | sed -e s/@RELEASE@/$(DOCRELEASE)/ -i asciidoc-pve.tmp |
| 79 | chmod +x asciidoc-pve.tmp |
| 80 | mv asciidoc-pve.tmp asciidoc-pve |
| 81 | |
| 82 | pve-docs-mediawiki-import: pve-docs-mediawiki-import.in link-refs.json |
| 83 | cat pve-docs-mediawiki-import.in link-refs.json > pve-docs-mediawiki-import.tmp |
| 84 | chmod +x pve-docs-mediawiki-import.tmp |
| 85 | mv pve-docs-mediawiki-import.tmp pve-docs-mediawiki-import |
| 86 | |
| 87 | INDEX_INCLUDES= \ |
| 88 | pve-admin-guide.pdf \ |
| 89 | pve-admin-guide.epub \ |
| 90 | chapter-index-table.adoc \ |
| 91 | man1-index-table.adoc \ |
| 92 | man5-index-table.adoc \ |
| 93 | man8-index-table.adoc \ |
| 94 | $(sort $(addsuffix .html, $(MANUAL_PAGES)) $(CHAPTER_LIST)) |
| 95 | |
| 96 | ADOC_STDARG=-b $(shell pwd)/asciidoc/pve-html -f asciidoc/asciidoc-pve.conf -a icons -a data-uri -a "date=$(SOURCE_DATE_HUMAN)" -a "revnumber=$(DOCRELEASE)" -a footer-style=revdate |
| 97 | |
| 98 | README.html: README.adoc |
| 99 | asciidoc -a toc $(ADOC_STDARG) -o $@ $< |
| 100 | |
| 101 | chapter-index-table.adoc: asciidoc-pve |
| 102 | ./asciidoc-pve chapter-table >$@.tmp |
| 103 | mv $@.tmp $@ |
| 104 | |
| 105 | man1-index-table.adoc: asciidoc-pve |
| 106 | ./asciidoc-pve man1page-table >$@.tmp |
| 107 | mv $@.tmp $@ |
| 108 | |
| 109 | man5-index-table.adoc: asciidoc-pve |
| 110 | ./asciidoc-pve man5page-table >$@.tmp |
| 111 | mv $@.tmp $@ |
| 112 | |
| 113 | man8-index-table.adoc: asciidoc-pve |
| 114 | ./asciidoc-pve man8page-table >$@.tmp |
| 115 | mv $@.tmp $@ |
| 116 | |
| 117 | index.html: index.adoc $(API_VIEWER_SOURCES) $(INDEX_INCLUDES) |
| 118 | asciidoc $(ADOC_STDARG) -o $@ index.adoc |
| 119 | |
| 120 | pve-admin-guide.html: $(PVE_ADMIN_GUIDE_ADOCDEPENDS) |
| 121 | asciidoc -a pvelogo $(ADOC_STDARG) -o $@ pve-admin-guide.adoc |
| 122 | |
| 123 | pve-admin-guide.chunked: $(PVE_ADMIN_GUIDE_ADOCDEPENDS) |
| 124 | rm -rf $@.tmp $@ |
| 125 | mkdir $@.tmp |
| 126 | a2x -D $@.tmp -a docinfo -a docinfo1 -a icons -f chunked pve-admin-guide.adoc |
| 127 | mv $@.tmp/$@ $@ |
| 128 | |
| 129 | PVE_DOCBOOK_CONF=-b $(shell pwd)/asciidoc/pve-docbook -f asciidoc/asciidoc-pve.conf |
| 130 | PVE_DBLATEX_OPTS='-p ./asciidoc/pve-dblatex.xsl -s asciidoc/dblatex-custom.sty -c asciidoc/dblatex-export.conf' |
| 131 | |
| 132 | YEAR:=$(shell date '+%Y') |
| 133 | pve-admin-guide-docinfo.xml: pve-admin-guide-docinfo.xml.in |
| 134 | sed -e 's/@RELEASE@/$(DOCRELEASE)/' -e 's/@YEAR@/$(YEAR)/' <$< >$@ |
| 135 | |
| 136 | pve-admin-guide.pdf: $(PVE_ADMIN_GUIDE_ADOCDEPENDS) docinfo.xml pve-admin-guide-docinfo.xml |
| 137 | rsvg-convert -f pdf -o proxmox-logo.pdf images/proxmox-logo.svg |
| 138 | rsvg-convert -f pdf -o proxmox-ci-header.pdf images/proxmox-ci-header.svg |
| 139 | grep ">Release $(DOCRELEASE)<" pve-admin-guide-docinfo.xml || (echo "wrong release in pve-admin-guide-docinfo.xml" && false); |
| 140 | a2x -a docinfo -a docinfo1 -f pdf -L --asciidoc-opts="$(PVE_DOCBOOK_CONF)" --dblatex-opts $(PVE_DBLATEX_OPTS) pve-admin-guide.adoc |
| 141 | rm proxmox-logo.pdf proxmox-ci-header.pdf |
| 142 | |
| 143 | pve-admin-guide.epub: $(PVE_ADMIN_GUIDE_ADOCDEPENDS) |
| 144 | rm -rf $@.tmp $@ |
| 145 | mkdir $@.tmp |
| 146 | a2x -D $@.tmp -f epub --asciidoc-opts="$(PVE_DOCBOOK_CONF)" pve-admin-guide.adoc |
| 147 | mv $@.tmp/$@ $@ |
| 148 | |
| 149 | api-viewer/apidata.js: extractapi.pl |
| 150 | ./extractapi.pl >$@ |
| 151 | |
| 152 | api-viewer/apidoc.js: $(API_VIEWER_FILES) |
| 153 | cat $(API_VIEWER_FILES) >$@.tmp |
| 154 | mv $@.tmp $@ |
| 155 | |
| 156 | $(BUILDDIR): |
| 157 | rm -rf $@ $@.tmp |
| 158 | rsync -a * $@.tmp/ |
| 159 | echo "git clone git://git.proxmox.com/git/pve-docs.git\\ngit checkout $(GITVERSION)" > $@.tmp/debian/SOURCE |
| 160 | mv $@.tmp $@ |
| 161 | |
| 162 | .PHONY: dsc deb |
| 163 | dsc: $(DSC) |
| 164 | $(DSC): $(BUILDDIR) |
| 165 | cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d |
| 166 | lintian $(DSC) |
| 167 | |
| 168 | sbuild: $(DSC) |
| 169 | sbuild $(DSC) |
| 170 | |
| 171 | deb: |
| 172 | rm -f $(GEN_DEB) $(DOC_DEB) $(MEDIAWIKI_DEB) |
| 173 | rm -rf $(BUILDDIR) |
| 174 | $(MAKE) $(DOC_DEB) |
| 175 | |
| 176 | $(MEDIAWIKI_DEB) $(GEN_DEB): $(DOC_DEB) |
| 177 | $(DOC_DEB): $(BUILDDIR) |
| 178 | cd $(BUILDDIR); dpkg-buildpackage -b -us -uc |
| 179 | lintian $(DOC_DEB) $(GEN_DEB) $(MEDIAWIKI_DEB) |
| 180 | |
| 181 | .PHONY: dinstall |
| 182 | dinstall: $(GEN_DEB) $(DOC_DEB) $(MEDIAWIKI_DEB) |
| 183 | dpkg -i $(GEN_DEB) $(DOC_DEB) # $(MEDIAWIKI_DEB) |
| 184 | |
| 185 | .PHONY: clean-build |
| 186 | clean-build: |
| 187 | rm -rf build |
| 188 | |
| 189 | .PHONY: install |
| 190 | install: gen-install doc-install mediawiki-install |
| 191 | |
| 192 | .PHONY: gen-install |
| 193 | gen-install: $(GEN_DEB_SOURCES) asciidoc-pve asciidoc/mediawiki.conf |
| 194 | install -dm755 $(DESTDIR)/usr/share/$(GEN_PACKAGE) |
| 195 | install -dm755 $(DESTDIR)/usr/share/doc/$(GEN_PACKAGE) |
| 196 | install -dm755 $(DESTDIR)/usr/bin |
| 197 | # install files |
| 198 | install -m 0644 $(GEN_DEB_SOURCES) $(DESTDIR)/usr/share/$(GEN_PACKAGE) |
| 199 | install -m 0755 $(GEN_SCRIPTS) $(DESTDIR)/usr/share/$(GEN_PACKAGE) |
| 200 | # install asciidoc-pve |
| 201 | install -m 0755 asciidoc-pve $(DESTDIR)/usr/bin/ |
| 202 | install -D -m 0644 asciidoc/mediawiki.conf $(DESTDIR)/usr/share/$(GEN_PACKAGE)/asciidoc/mediawiki.conf |
| 203 | install -m 0644 asciidoc/asciidoc-pve.conf $(DESTDIR)/usr/share/$(GEN_PACKAGE)/asciidoc/ |
| 204 | install -m 0644 asciidoc/pve-html.conf $(DESTDIR)/usr/share/$(GEN_PACKAGE)/asciidoc/ |
| 205 | |
| 206 | .PHONY: doc-install |
| 207 | doc-install: index.html $(WIKI_IMPORTS) $(API_VIEWER_SOURCES) verify-images examples |
| 208 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE) |
| 209 | install -dm755 $(DESTDIR)/usr/share/doc/$(DOC_PACKAGE) |
| 210 | # install files for pvedocs package |
| 211 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE) |
| 212 | install -dm755 $(DESTDIR)/usr/share/doc/$(DOC_PACKAGE) |
| 213 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE)/examples/ |
| 214 | install -m 755 examples/guest-example-hookscript.pl $(DESTDIR)/usr/share/$(DOC_PACKAGE)/examples/ |
| 215 | install -m 0644 index.html $(INDEX_INCLUDES) $(DESTDIR)/usr/share/$(DOC_PACKAGE) |
| 216 | install -m 0644 $(WIKI_IMPORTS) $(DESTDIR)/usr/share/$(DOC_PACKAGE) |
| 217 | # install images |
| 218 | make -C images install |
| 219 | # install screenshot images |
| 220 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE)/images/screenshot |
| 221 | install -m 0644 images/screenshot/*.png $(DESTDIR)/usr/share/$(DOC_PACKAGE)/images/screenshot |
| 222 | # install api doc viewer |
| 223 | install -dm755 $(DESTDIR)/usr/share/$(DOC_PACKAGE)/api-viewer |
| 224 | install -m 0644 $(API_VIEWER_SOURCES) $(DESTDIR)/usr/share/$(DOC_PACKAGE)/api-viewer |
| 225 | |
| 226 | .PHONY: mediawiki-install |
| 227 | mediawiki-install: pve-docs-mediawiki-import |
| 228 | install -dm755 $(DESTDIR)/usr/share/$(MEDIAWIKI_PACKAGE) |
| 229 | install -dm755 $(DESTDIR)/usr/share/doc/$(MEDIAWIKI_PACKAGE) |
| 230 | install -dm755 $(DESTDIR)/usr/bin |
| 231 | install -dm755 $(DESTDIR)/usr/share/$(MEDIAWIKI_PACKAGE) |
| 232 | install -dm755 $(DESTDIR)/usr/share/doc/$(MEDIAWIKI_PACKAGE) |
| 233 | install -m 0755 pve-docs-mediawiki-import $(DESTDIR)/usr/bin/ |
| 234 | |
| 235 | .PHONY: upload |
| 236 | upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION) |
| 237 | upload: $(GEN_DEB) $(DOC_DEB) $(MEDIAWIKI_DEB) |
| 238 | tar cf - $(GEN_DEB) $(DOC_DEB) $(MEDIAWIKI_DEB) | ssh -X repoman@repo.proxmox.com -- upload --product pve --dist $(UPLOAD_DIST) |
| 239 | |
| 240 | .PHONY: update |
| 241 | update: |
| 242 | make clean clean-static |
| 243 | make update-static |
| 244 | make all |
| 245 | |
| 246 | .PHONY: update-static |
| 247 | update-static: |
| 248 | make clean-static |
| 249 | make $(filter %-synopsis.adoc %-opts.adoc, $(PVE_ADMIN_GUIDE_ADOCDEPENDS)) pve-firewall-macros.adoc api-viewer/apidata.js |
| 250 | |
| 251 | .PHONY: clean-static |
| 252 | clean-static: |
| 253 | find . -regex '.*-\(opts\|synopsis\)\.adoc' -not -name pmxcfs.8-synopsis.adoc -not -name qmeventd.8-synopsis.adoc -exec rm -f \{\} \; |
| 254 | rm -f api-viewer/apidata.js |
| 255 | rm -f pve-firewall-macros.adoc pct-network-opts.adoc pct-mountpoint-opts.adoc |
| 256 | |
| 257 | clean: |
| 258 | rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8 |
| 259 | rm -f *.deb *.dsc *.tar.* *.changes *.buildinfo *.build |
| 260 | rm -f 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 |
| 261 | rm -rf .pve-doc-depends |
| 262 | rm -f pve-doc-generator.mk chapter-index-table.adoc man1-index-table.adoc man5-index-table.adoc man8-index-table.adoc pve-admin-guide-docinfo.xml |
| 263 | rm -rf $(DEB_SOURCE)-[0-9]*/ |