Makefile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Minimal makefile for Sphinx documentation
  2. #
  3. # You can set these variables from the command line, and also
  4. # from the environment for the first two.
  5. SPHINXOPTS ?= -W --keep-going -j auto
  6. SPHINXBUILD ?= sphinx-build
  7. # Release notes are excluded because they contain contributor names and commit messages which can't be modified
  8. VALEOPTS ?= --no-wrap --glob '!migration-guides/release-notes-*.rst'
  9. VALEDOCS ?= .
  10. SOURCEDIR = .
  11. IMAGEDIRS = */svg
  12. BUILDDIR = _build
  13. DESTDIR = final
  14. SVG2PNG = inkscape
  15. SVG2PDF = inkscape
  16. ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
  17. $(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed")
  18. endif
  19. # Put it first so that "make" without argument is like "make help".
  20. help:
  21. @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  22. .PHONY: all help Makefile clean stylecheck publish epub latexpdf
  23. publish: Makefile html singlehtml
  24. rm -rf $(BUILDDIR)/$(DESTDIR)/
  25. mkdir -p $(BUILDDIR)/$(DESTDIR)/
  26. cp -r $(BUILDDIR)/html/* $(BUILDDIR)/$(DESTDIR)/
  27. cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
  28. sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
  29. # Build a list of SVG files to convert to PDFs
  30. PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
  31. # Build a list of SVG files to convert to PNGs
  32. PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
  33. # Pattern rule for converting SVG to PDF
  34. %.pdf : %.svg
  35. $(SVG2PDF) --export-filename=$@ $<
  36. # Pattern rule for converting SVG to PNG
  37. %.png : %.svg
  38. $(SVG2PNG) --export-filename=$@ $<
  39. clean:
  40. @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js
  41. stylecheck:
  42. vale sync
  43. vale $(VALEOPTS) $(VALEDOCS)
  44. epub: $(PNGs)
  45. $(SOURCEDIR)/set_versions.py
  46. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  47. latexpdf: $(PDFs)
  48. $(SOURCEDIR)/set_versions.py
  49. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  50. all: html epub latexpdf
  51. # Catch-all target: route all unknown targets to Sphinx using the new
  52. # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
  53. %:
  54. $(SOURCEDIR)/set_versions.py
  55. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)