blob: c930d2d28045d924234be785047ad17ced6b779e [file] [log] [blame]
Andrew Geisslerf0343792020-11-18 10:42:21 -06001# Minimal makefile for Sphinx documentation
Andrew Geissler4ed12e12020-06-05 18:00:41 -05002#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003
Andrew Geisslerf0343792020-11-18 10:42:21 -06004# You can set these variables from the command line, and also
5# from the environment for the first two.
Andrew Geissler09036742021-06-25 14:25:14 -05006SPHINXOPTS ?= -W --keep-going -j auto
Andrew Geisslerf0343792020-11-18 10:42:21 -06007SPHINXBUILD ?= sphinx-build
Patrick Williams03514f12024-04-05 07:04:11 -05008# Release notes are excluded because they contain contributor names and commit messages which can't be modified
9VALEOPTS ?= --no-wrap --glob '!migration-guides/release-notes-*.rst'
10VALEDOCS ?= .
Andrew Geisslerf0343792020-11-18 10:42:21 -060011SOURCEDIR = .
Andrew Geisslereff27472021-10-29 15:35:00 -050012IMAGEDIRS = */svg
Andrew Geisslerf0343792020-11-18 10:42:21 -060013BUILDDIR = _build
14DESTDIR = final
Andrew Geisslereff27472021-10-29 15:35:00 -050015SVG2PNG = inkscape
16SVG2PDF = inkscape
Brad Bishop316dfdd2018-06-25 12:45:53 -040017
Andrew Geisslerf0343792020-11-18 10:42:21 -060018ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
19$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed")
Brad Bishop316dfdd2018-06-25 12:45:53 -040020endif
21
Andrew Geisslerf0343792020-11-18 10:42:21 -060022# Put it first so that "make" without argument is like "make help".
23help:
24 @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Brad Bishop316dfdd2018-06-25 12:45:53 -040025
Patrick Williams03514f12024-04-05 07:04:11 -050026.PHONY: all help Makefile clean stylecheck publish epub latexpdf
Brad Bishop316dfdd2018-06-25 12:45:53 -040027
Andrew Geisslerf0343792020-11-18 10:42:21 -060028publish: Makefile html singlehtml
29 rm -rf $(BUILDDIR)/$(DESTDIR)/
30 mkdir -p $(BUILDDIR)/$(DESTDIR)/
31 cp -r $(BUILDDIR)/html/* $(BUILDDIR)/$(DESTDIR)/
32 cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
33 sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034
Andrew Geisslereff27472021-10-29 15:35:00 -050035# Build a list of SVG files to convert to PDFs
36PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
37
38# Build a list of SVG files to convert to PNGs
39PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
40
41# Pattern rule for converting SVG to PDF
42%.pdf : %.svg
43 $(SVG2PDF) --export-filename=$@ $<
44
45# Pattern rule for converting SVG to PNG
46%.png : %.svg
47 $(SVG2PNG) --export-filename=$@ $<
48
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049clean:
Patrick Williams03514f12024-04-05 07:04:11 -050050 @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js releases.rst
51
52stylecheck:
53 vale sync
54 vale $(VALEOPTS) $(VALEDOCS)
55
56stylecheck:
57 vale sync
58 vale $(VALEOPTS) $(VALEDOCS)
Andrew Geisslereff27472021-10-29 15:35:00 -050059
60epub: $(PNGs)
Andrew Geisslerd5838332022-05-27 11:33:10 -050061 $(SOURCEDIR)/set_versions.py
Andrew Geisslereff27472021-10-29 15:35:00 -050062 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
63
64latexpdf: $(PDFs)
Andrew Geisslerd5838332022-05-27 11:33:10 -050065 $(SOURCEDIR)/set_versions.py
Andrew Geisslereff27472021-10-29 15:35:00 -050066 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
67
68all: html epub latexpdf
Andrew Geisslerf0343792020-11-18 10:42:21 -060069
70# Catch-all target: route all unknown targets to Sphinx using the new
71# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Andrew Geisslereff27472021-10-29 15:35:00 -050072%:
Andrew Geissler9aee5002022-03-30 16:27:02 +000073 $(SOURCEDIR)/set_versions.py
Andrew Geisslerf0343792020-11-18 10:42:21 -060074 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)