blob: f04f381bd2569c258bb79e38970a223a97e85ac4 [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:
Andrew Geisslereff27472021-10-29 15:35:00 -050047 @rm -rf $(BUILDDIR) $(PNGs) $(PDFs)
48
49epub: $(PNGs)
50 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
51
52latexpdf: $(PDFs)
53 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
54
55all: html epub latexpdf
Andrew Geisslerf0343792020-11-18 10:42:21 -060056
57# Catch-all target: route all unknown targets to Sphinx using the new
58# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Andrew Geisslereff27472021-10-29 15:35:00 -050059%:
Andrew Geisslerf0343792020-11-18 10:42:21 -060060 @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)