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 |
Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame^] | 8 | # Release notes are excluded because they contain contributor names and commit messages which can't be modified |
| 9 | VALEOPTS ?= --no-wrap --glob '!migration-guides/release-notes-*.rst' |
| 10 | VALEDOCS ?= . |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 11 | SOURCEDIR = . |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 12 | IMAGEDIRS = */svg |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 13 | BUILDDIR = _build |
| 14 | DESTDIR = final |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 15 | SVG2PNG = inkscape |
| 16 | SVG2PDF = inkscape |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 17 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 18 | ifeq ($(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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | endif |
| 21 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 22 | # Put it first so that "make" without argument is like "make help". |
| 23 | help: |
| 24 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | |
Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame^] | 26 | .PHONY: all help Makefile clean stylecheck publish epub latexpdf |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 27 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 28 | publish: 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 35 | # Build a list of SVG files to convert to PDFs |
| 36 | PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg))) |
| 37 | |
| 38 | # Build a list of SVG files to convert to PNGs |
| 39 | PNGs := $(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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | clean: |
Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame^] | 50 | @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js releases.rst |
| 51 | |
| 52 | stylecheck: |
| 53 | vale sync |
| 54 | vale $(VALEOPTS) $(VALEDOCS) |
| 55 | |
| 56 | stylecheck: |
| 57 | vale sync |
| 58 | vale $(VALEOPTS) $(VALEDOCS) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 59 | |
| 60 | epub: $(PNGs) |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 61 | $(SOURCEDIR)/set_versions.py |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 62 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 63 | |
| 64 | latexpdf: $(PDFs) |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 65 | $(SOURCEDIR)/set_versions.py |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 66 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 67 | |
| 68 | all: html epub latexpdf |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 69 | |
| 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 Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 72 | %: |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 73 | $(SOURCEDIR)/set_versions.py |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 74 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |