1# -*- makefile -*- 2# Makefile for Sphinx documentation 3# 4 5# for cleaning 6subdir- := devicetree/bindings 7 8ifneq ($(MAKECMDGOALS),cleandocs) 9# Check for broken documentation file references 10ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y) 11$(shell $(srctree)/scripts/documentation-file-ref-check --warn) 12endif 13 14# Check for broken ABI files 15ifeq ($(CONFIG_WARN_ABI_ERRORS),y) 16$(shell $(srctree)/scripts/get_abi.py --dir $(srctree)/Documentation/ABI validate) 17endif 18endif 19 20# You can set these variables from the command line. 21SPHINXBUILD = sphinx-build 22SPHINXOPTS = 23SPHINXDIRS = . 24DOCS_THEME = 25DOCS_CSS = 26SPHINX_CONF = conf.py 27PAPER = 28BUILDDIR = $(obj)/output 29PDFLATEX = xelatex 30LATEXOPTS = -interaction=batchmode -no-shell-escape 31 32PYTHONPYCACHEPREFIX ?= $(abspath $(BUILDDIR)/__pycache__) 33 34# Wrapper for sphinx-build 35 36BUILD_WRAPPER = $(srctree)/tools/docs/sphinx-build-wrapper 37 38# For denylisting "variable font" files 39# Can be overridden by setting as an env variable 40FONTS_CONF_DENY_VF ?= $(HOME)/deny-vf 41 42# User-friendly check for sphinx-build 43HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi) 44 45ifeq ($(HAVE_SPHINX),0) 46 47.DEFAULT: 48 $(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.) 49 @echo 50 @$(srctree)/tools/docs/sphinx-pre-install 51 @echo " SKIP Sphinx $@ target." 52 53else # HAVE_SPHINX 54 55# Common documentation targets 56infodocs texinfodocs latexdocs epubdocs xmldocs pdfdocs linkcheckdocs: 57 $(Q)@$(srctree)/tools/docs/sphinx-pre-install --version-check 58 +$(Q)$(PYTHON3) $(BUILD_WRAPPER) $@ \ 59 --sphinxdirs="$(SPHINXDIRS)" --conf="$(SPHINX_CONF)" \ 60 --builddir="$(BUILDDIR)" --deny-vf=$(FONTS_CONF_DENY_VF) \ 61 --theme=$(DOCS_THEME) --css=$(DOCS_CSS) --paper=$(PAPER) 62 63# Special handling for pdfdocs 64ifneq ($(shell which $(PDFLATEX) >/dev/null 2>&1; echo $$?),0) 65pdfdocs: 66 $(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.) 67 @echo " SKIP Sphinx $@ target." 68endif 69 70htmldocs-redirects: $(srctree)/Documentation/.renames.txt 71 @tools/docs/gen-redirects.py --output $(BUILDDIR) < $< 72 73# HTML main logic is identical to other targets. However, if rust is enabled, 74# an extra step at the end is required to generate rustdoc. 75htmldocs: 76 $(Q)@$(srctree)/tools/docs/sphinx-pre-install --version-check 77 +$(Q)$(PYTHON3) $(BUILD_WRAPPER) $@ \ 78 --sphinxdirs="$(SPHINXDIRS)" --conf="$(SPHINX_CONF)" \ 79 --builddir="$(BUILDDIR)" \ 80 --theme=$(DOCS_THEME) --css=$(DOCS_CSS) --paper=$(PAPER) 81# If Rust support is available and .config exists, add rustdoc generated contents. 82# If there are any, the errors from this make rustdoc will be displayed but 83# won't stop the execution of htmldocs 84 85ifneq ($(wildcard $(srctree)/.config),) 86ifeq ($(CONFIG_RUST),y) 87 $(Q)$(MAKE) rustdoc || true 88endif 89endif 90 91endif # HAVE_SPHINX 92 93# The following targets are independent of HAVE_SPHINX, and the rules should 94# work or silently pass without Sphinx. 95 96refcheckdocs: 97 $(Q)cd $(srctree);scripts/documentation-file-ref-check 98 99cleandocs: 100 $(Q)rm -rf $(BUILDDIR) 101 102# Used only on help 103_SPHINXDIRS = $(sort $(patsubst $(srctree)/Documentation/%/index.rst,%,$(wildcard $(srctree)/Documentation/*/index.rst))) 104 105dochelp: 106 @echo ' Linux kernel internal documentation in different formats from ReST:' 107 @echo ' htmldocs - HTML' 108 @echo ' htmldocs-redirects - generate HTML redirects for moved pages' 109 @echo ' texinfodocs - Texinfo' 110 @echo ' infodocs - Info' 111 @echo ' latexdocs - LaTeX' 112 @echo ' pdfdocs - PDF' 113 @echo ' epubdocs - EPUB' 114 @echo ' xmldocs - XML' 115 @echo ' linkcheckdocs - check for broken external links' 116 @echo ' (will connect to external hosts)' 117 @echo ' refcheckdocs - check for references to non-existing files under' 118 @echo ' Documentation' 119 @echo ' cleandocs - clean all generated files' 120 @echo 121 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2' 122 @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)' 123 @echo 124 @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build' 125 @echo ' configuration. This is e.g. useful to build with nit-picking config.' 126 @echo 127 @echo ' make DOCS_THEME={sphinx-theme} selects a different Sphinx theme.' 128 @echo 129 @echo ' make DOCS_CSS={a .css file} adds a DOCS_CSS override file for html/epub output.' 130 @echo 131 @echo ' make PAPER={a4|letter} Specifies the paper size used for LaTeX/PDF output.' 132 @echo 133 @echo ' make FONTS_CONF_DENY_VF={path} sets a deny list to block variable Noto CJK fonts' 134 @echo ' for PDF build. See tools/docs/lib/latex_fonts.py for more details' 135 @echo 136 @echo ' Default location for the generated documents is Documentation/output' 137