Makefile 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 = rsvg-convert
  16. SVG2PDF = rsvg-convert
  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 epub latexpdf html singlehtml
  25. rm -rf $(BUILDDIR)/$(DESTDIR)/
  26. mkdir -p $(BUILDDIR)/$(DESTDIR)/
  27. cp -r $(BUILDDIR)/html/* $(BUILDDIR)/$(DESTDIR)/
  28. mkdir -p $(BUILDDIR)/$(DESTDIR)/_static
  29. cp $(BUILDDIR)/epub/TheYoctoProject.epub $(BUILDDIR)/latex/theyoctoproject.pdf $(BUILDDIR)/$(DESTDIR)/_static/
  30. cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
  31. sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
  32. # Build a list of SVG files to convert to PDFs
  33. PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
  34. # Build a list of SVG files to convert to PNGs
  35. PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
  36. # Pattern rule for converting SVG to PDF
  37. %.pdf : %.svg
  38. $(SVG2PDF) --format=Pdf --output=$@ $<
  39. # Pattern rule for converting SVG to PNG
  40. %.png : %.svg
  41. $(SVG2PNG) --format=Png --output=$@ $<
  42. clean:
  43. @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js releases.rst
  44. stylecheck:
  45. vale sync
  46. vale $(VALEOPTS) $(VALEDOCS)
  47. sphinx-lint:
  48. sphinx-lint $(SPHINXLINTDOCS)
  49. epub: $(PNGs)
  50. $(SOURCEDIR)/set_versions.py
  51. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  52. # Note: we need to pass buf_size here (which is also configurable from
  53. # texmf.cnf), to avoid following error:
  54. # Unable to read an entire line---bufsize=200000. Please increase buf_size in texmf.cnf.
  55. latexpdf: $(PDFs)
  56. $(SOURCEDIR)/set_versions.py
  57. buf_size=10000000 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
  58. all: html epub latexpdf
  59. # Catch-all target: route all unknown targets to Sphinx using the new
  60. # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
  61. %:
  62. $(SOURCEDIR)/set_versions.py
  63. @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)