Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. SOURCEDIR = .
  10. VALEDOCS ?= $(SOURCEDIR)
  11. SPHINXLINTDOCS ?= $(SOURCEDIR)
  12. IMAGEDIRS = */svg
  13. BUILDDIR = _build
  14. DESTDIR = final
  15. SVG2PNG = inkscape
  16. SVG2PDF = inkscape
  17. ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
  18. $(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed")
  19. endif
  20. # Put it first so that "make" without argument is like "make help".
  21. help:
  22. @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  23. .PHONY: all help Makefile clean stylecheck publish epub latexpdf
  24. publish: Makefile html singlehtml
  25. rm -rf $(BUILDDIR)/$(DESTDIR)/
  26. mkdir -p $(BUILDDIR)/$(DESTDIR)/
  27. cp -r $(BUILDDIR)/html/* $(BUILDDIR)/$(DESTDIR)/
  28. cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
  29. sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
  30. # Build a list of SVG files to convert to PDFs
  31. PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
  32. # Build a list of SVG files to convert to PNGs
  33. PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
  34. # Pattern rule for converting SVG to PDF
  35. %.pdf : %.svg
  36. $(SVG2PDF) --export-filename=$@ $<
  37. # Pattern rule for converting SVG to PNG
  38. %.png : %.svg
  39. $(SVG2PNG) --export-filename=$@ $<
  40. clean:
  41. @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js
  42. stylecheck:
  43. vale sync
  44. vale $(VALEOPTS) $(VALEDOCS)
  45. sphinx-lint:
  46. sphinx-lint $(SPHINXLINTDOCS)
  47. epub: $(PNGs)
  48. $(SOURCEDIR)/set_versions.py
  49. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  50. latexpdf: $(PDFs)
  51. $(SOURCEDIR)/set_versions.py
  52. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  53. all: html epub latexpdf
  54. # Catch-all target: route all unknown targets to Sphinx using the new
  55. # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
  56. %:
  57. $(SOURCEDIR)/set_versions.py
  58. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)