blob: 9fb6814c8f837322c8eb33f1f8e0c006a3272cab [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
8SOURCEDIR = .
Andrew Geisslereff27472021-10-29 15:35:00 -05009IMAGEDIRS = */svg
Andrew Geisslerf0343792020-11-18 10:42:21 -060010BUILDDIR = _build
11DESTDIR = final
Andrew Geisslereff27472021-10-29 15:35:00 -050012SVG2PNG = inkscape
13SVG2PDF = inkscape
Brad Bishop316dfdd2018-06-25 12:45:53 -040014
Andrew Geisslerf0343792020-11-18 10:42:21 -060015ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
16$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed")
Brad Bishop316dfdd2018-06-25 12:45:53 -040017endif
18
Andrew Geisslerf0343792020-11-18 10:42:21 -060019# Put it first so that "make" without argument is like "make help".
20help:
21 @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Brad Bishop316dfdd2018-06-25 12:45:53 -040022
Andrew Geisslereff27472021-10-29 15:35:00 -050023.PHONY: all help Makefile clean publish epub latexpdf
Brad Bishop316dfdd2018-06-25 12:45:53 -040024
Andrew Geisslerf0343792020-11-18 10:42:21 -060025publish: Makefile html singlehtml
26 rm -rf $(BUILDDIR)/$(DESTDIR)/
27 mkdir -p $(BUILDDIR)/$(DESTDIR)/
28 cp -r $(BUILDDIR)/html/* $(BUILDDIR)/$(DESTDIR)/
29 cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
30 sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031
Andrew Geisslereff27472021-10-29 15:35:00 -050032# Build a list of SVG files to convert to PDFs
33PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
34
35# Build a list of SVG files to convert to PNGs
36PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
37
38# Pattern rule for converting SVG to PDF
39%.pdf : %.svg
40 $(SVG2PDF) --export-filename=$@ $<
41
42# Pattern rule for converting SVG to PNG
43%.png : %.svg
44 $(SVG2PNG) --export-filename=$@ $<
45
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046clean:
Patrick Williams45852732022-04-02 08:58:32 -050047 @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js
Andrew Geisslereff27472021-10-29 15:35:00 -050048
49epub: $(PNGs)
Andrew Geisslerd5838332022-05-27 11:33:10 -050050 $(SOURCEDIR)/set_versions.py
Andrew Geisslereff27472021-10-29 15:35:00 -050051 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
52
53latexpdf: $(PDFs)
Andrew Geisslerd5838332022-05-27 11:33:10 -050054 $(SOURCEDIR)/set_versions.py
Andrew Geisslereff27472021-10-29 15:35:00 -050055 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
56
57all: html epub latexpdf
Andrew Geisslerf0343792020-11-18 10:42:21 -060058
59# Catch-all target: route all unknown targets to Sphinx using the new
60# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Andrew Geisslereff27472021-10-29 15:35:00 -050061%:
Andrew Geissler9aee5002022-03-30 16:27:02 +000062 $(SOURCEDIR)/set_versions.py
Andrew Geisslerf0343792020-11-18 10:42:21 -060063 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)