Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # -*- makefile -*-
  2. # Makefile for Sphinx documentation
  3. #
  4. # for cleaning
  5. subdir- := devicetree/bindings
  6. ifneq ($(MAKECMDGOALS),cleandocs)
  7. # Check for broken documentation file references
  8. ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
  9. $(shell $(srctree)/tools/docs/documentation-file-ref-check --warn)
  10. endif
  11. # Check for broken ABI files
  12. ifeq ($(CONFIG_WARN_ABI_ERRORS),y)
  13. $(shell $(srctree)/tools/docs/get_abi.py --dir $(srctree)/Documentation/ABI validate)
  14. endif
  15. endif
  16. # You can set these variables from the command line.
  17. SPHINXBUILD = sphinx-build
  18. SPHINXOPTS =
  19. SPHINXDIRS = .
  20. DOCS_THEME =
  21. DOCS_CSS =
  22. RUSTDOC =
  23. PAPER =
  24. BUILDDIR = $(obj)/output
  25. PDFLATEX = xelatex
  26. LATEXOPTS = -interaction=batchmode -no-shell-escape
  27. PYTHONPYCACHEPREFIX ?= $(abspath $(BUILDDIR)/__pycache__)
  28. # Wrapper for sphinx-build
  29. BUILD_WRAPPER = $(srctree)/tools/docs/sphinx-build-wrapper
  30. # For denylisting "variable font" files
  31. # Can be overridden by setting as an env variable
  32. FONTS_CONF_DENY_VF ?= $(HOME)/deny-vf
  33. # User-friendly check for sphinx-build
  34. HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
  35. ifeq ($(HAVE_SPHINX),0)
  36. .DEFAULT:
  37. $(warning The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed and in PATH, or set the SPHINXBUILD make variable to point to the full path of the '$(SPHINXBUILD)' executable.)
  38. @echo
  39. @$(srctree)/tools/docs/sphinx-pre-install
  40. @echo " SKIP Sphinx $@ target."
  41. else # HAVE_SPHINX
  42. # Common documentation targets
  43. htmldocs mandocs infodocs texinfodocs latexdocs epubdocs xmldocs pdfdocs linkcheckdocs:
  44. $(Q)PYTHONPYCACHEPREFIX="$(PYTHONPYCACHEPREFIX)" \
  45. $(srctree)/tools/docs/sphinx-pre-install --version-check
  46. +$(Q)PYTHONPYCACHEPREFIX="$(PYTHONPYCACHEPREFIX)" \
  47. $(PYTHON3) $(BUILD_WRAPPER) $@ \
  48. --sphinxdirs="$(SPHINXDIRS)" $(RUSTDOC) \
  49. --builddir="$(BUILDDIR)" --deny-vf=$(FONTS_CONF_DENY_VF) \
  50. --theme=$(DOCS_THEME) --css=$(DOCS_CSS) --paper=$(PAPER)
  51. endif
  52. # The following targets are independent of HAVE_SPHINX, and the rules should
  53. # work or silently pass without Sphinx.
  54. htmldocs-redirects: $(srctree)/Documentation/.renames.txt
  55. @tools/docs/gen-redirects.py --output $(BUILDDIR) < $<
  56. refcheckdocs:
  57. $(Q)cd $(srctree); tools/docs/documentation-file-ref-check
  58. cleandocs:
  59. $(Q)rm -rf $(BUILDDIR)
  60. # Used only on help
  61. _SPHINXDIRS = $(shell printf "%s\n" $(patsubst $(srctree)/Documentation/%/index.rst,%,$(wildcard $(srctree)/Documentation/*/index.rst)) | sort -f)
  62. dochelp:
  63. @echo ' Linux kernel internal documentation in different formats from ReST:'
  64. @echo ' htmldocs - HTML'
  65. @echo ' htmldocs-redirects - generate HTML redirects for moved pages'
  66. @echo ' texinfodocs - Texinfo'
  67. @echo ' infodocs - Info'
  68. @echo ' mandocs - Man pages'
  69. @echo ' latexdocs - LaTeX'
  70. @echo ' pdfdocs - PDF'
  71. @echo ' epubdocs - EPUB'
  72. @echo ' xmldocs - XML'
  73. @echo ' linkcheckdocs - check for broken external links'
  74. @echo ' (will connect to external hosts)'
  75. @echo ' refcheckdocs - check for references to non-existing files under'
  76. @echo ' Documentation'
  77. @echo ' cleandocs - clean all generated files'
  78. @echo
  79. @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
  80. @echo ' top level values for SPHINXDIRS are:'
  81. @echo '$(_SPHINXDIRS)' | fmt -s -w 75 -g 75 | sed 's/^/ /'
  82. @echo ' you may also use a subdirectory like SPHINXDIRS=userspace-api/media,'
  83. @echo ' provided that there is an index.rst file at the subdirectory.'
  84. @echo
  85. @echo ' make DOCS_THEME={sphinx-theme} selects a different Sphinx theme.'
  86. @echo
  87. @echo ' make DOCS_CSS={a .css file} adds a DOCS_CSS override file for html/epub output.'
  88. @echo
  89. @echo ' make PAPER={a4|letter} Specifies the paper size used for LaTeX/PDF output.'
  90. @echo
  91. @echo ' make FONTS_CONF_DENY_VF={path} sets a deny list to block variable Noto CJK fonts'
  92. @echo ' for PDF build. See tools/lib/python/kdoc/latex_fonts.py for more details'
  93. @echo
  94. @echo ' Default location for the generated documents is Documentation/output'