Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 1 | # Minimal makefile for Sphinx documentation |
Andrew Geissler | 4ed12e1 | 2020-06-05 18:00:41 -0500 | [diff] [blame] | 2 | # |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 4 | # You can set these variables from the command line, and also |
| 5 | # from the environment for the first two. |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 6 | SPHINXOPTS ?= -W --keep-going -j auto |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 7 | SPHINXBUILD ?= sphinx-build |
| 8 | SOURCEDIR = . |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 9 | IMAGEDIRS = */svg |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 10 | BUILDDIR = _build |
| 11 | DESTDIR = final |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 12 | SVG2PNG = inkscape |
| 13 | SVG2PDF = inkscape |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 15 | ifeq ($(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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 17 | endif |
| 18 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 19 | # Put it first so that "make" without argument is like "make help". |
| 20 | help: |
| 21 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 23 | .PHONY: all help Makefile clean publish epub latexpdf |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 24 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 25 | publish: 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 32 | # Build a list of SVG files to convert to PDFs |
| 33 | PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg))) |
| 34 | |
| 35 | # Build a list of SVG files to convert to PNGs |
| 36 | PNGs := $(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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | clean: |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 47 | @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 48 | |
| 49 | epub: $(PNGs) |
| 50 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 51 | |
| 52 | latexpdf: $(PDFs) |
| 53 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 54 | |
| 55 | all: html epub latexpdf |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 56 | |
| 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 Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 59 | %: |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 60 | $(SOURCEDIR)/set_versions.py |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 61 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |