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