xref: /linux/Documentation/Makefile (revision 683dd3f79a3140e11d2e6f4a5320f3ea42e63878)
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      =
26RUSTDOC       =
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
45ifneq ($(wildcard $(srctree)/.config),)
46ifeq ($(CONFIG_RUST),y)
47	RUSTDOC=--rustdoc
48endif
49endif
50
51ifeq ($(HAVE_SPHINX),0)
52
53.DEFAULT:
54	$(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.)
55	@echo
56	@$(srctree)/tools/docs/sphinx-pre-install
57	@echo "  SKIP    Sphinx $@ target."
58
59else # HAVE_SPHINX
60
61# Common documentation targets
62htmldocs mandocs infodocs texinfodocs latexdocs epubdocs xmldocs pdfdocs linkcheckdocs:
63	$(Q)@$(srctree)/tools/docs/sphinx-pre-install --version-check
64	+$(Q)$(PYTHON3) $(BUILD_WRAPPER) $@ \
65		--sphinxdirs="$(SPHINXDIRS)" $(RUSTDOC) \
66		--builddir="$(BUILDDIR)" --deny-vf=$(FONTS_CONF_DENY_VF) \
67		--theme=$(DOCS_THEME) --css=$(DOCS_CSS) --paper=$(PAPER)
68
69# Special handling for pdfdocs
70ifneq ($(shell which $(PDFLATEX) >/dev/null 2>&1; echo $$?),0)
71pdfdocs:
72	$(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
73	@echo "  SKIP    Sphinx $@ target."
74endif
75
76htmldocs-redirects: $(srctree)/Documentation/.renames.txt
77	@tools/docs/gen-redirects.py --output $(BUILDDIR) < $<
78endif # HAVE_SPHINX
79
80# The following targets are independent of HAVE_SPHINX, and the rules should
81# work or silently pass without Sphinx.
82
83refcheckdocs:
84	$(Q)cd $(srctree);scripts/documentation-file-ref-check
85
86cleandocs:
87	$(Q)rm -rf $(BUILDDIR)
88
89# Used only on help
90_SPHINXDIRS   = $(sort $(patsubst $(srctree)/Documentation/%/index.rst,%,$(wildcard $(srctree)/Documentation/*/index.rst)))
91
92dochelp:
93	@echo  ' Linux kernel internal documentation in different formats from ReST:'
94	@echo  '  htmldocs        - HTML'
95	@echo  '  htmldocs-redirects - generate HTML redirects for moved pages'
96	@echo  '  texinfodocs     - Texinfo'
97	@echo  '  infodocs        - Info'
98	@echo  '  mandocs         - Man pages'
99	@echo  '  latexdocs       - LaTeX'
100	@echo  '  pdfdocs         - PDF'
101	@echo  '  epubdocs        - EPUB'
102	@echo  '  xmldocs         - XML'
103	@echo  '  linkcheckdocs   - check for broken external links'
104	@echo  '                    (will connect to external hosts)'
105	@echo  '  refcheckdocs    - check for references to non-existing files under'
106	@echo  '                    Documentation'
107	@echo  '  cleandocs       - clean all generated files'
108	@echo
109	@echo  '  make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
110	@echo  '  valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
111	@echo
112	@echo  '  make DOCS_THEME={sphinx-theme} selects a different Sphinx theme.'
113	@echo
114	@echo  '  make DOCS_CSS={a .css file} adds a DOCS_CSS override file for html/epub output.'
115	@echo
116	@echo  '  make PAPER={a4|letter} Specifies the paper size used for LaTeX/PDF output.'
117	@echo
118	@echo  '  make FONTS_CONF_DENY_VF={path} sets a deny list to block variable Noto CJK fonts'
119	@echo  '  for PDF build. See tools/docs/lib/latex_fonts.py for more details'
120	@echo
121	@echo  '  Default location for the generated documents is Documentation/output'
122