blob: f5de65e92782236c2f7a4282a5669d354f50287c [file] [log] [blame]
Mario Six78a88f72018-07-10 08:40:17 +02001# -*- makefile -*-
2# Makefile for Sphinx documentation
3#
4
5subdir-y :=
6
7# You can set these variables from the command line.
8SPHINXBUILD = sphinx-build
Heinrich Schuchardt89a5fbb2021-08-01 22:11:39 +02009SPHINXOPTS = -W
Mario Six78a88f72018-07-10 08:40:17 +020010SPHINXDIRS = .
Breno Matheus Lima656d8da2019-06-05 18:18:30 +000011_SPHINXDIRS = $(patsubst $(srctree)/doc/%/conf.py,%,$(wildcard $(srctree)/doc/*/conf.py))
Mario Six78a88f72018-07-10 08:40:17 +020012SPHINX_CONF = conf.py
13PAPER =
14BUILDDIR = $(obj)/output
15PDFLATEX = xelatex
16LATEXOPTS = -interaction=batchmode
17
18# User-friendly check for sphinx-build
19HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
20
21ifeq ($(HAVE_SPHINX),0)
22
23.DEFAULT:
24 $(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.)
25 @echo
26 @./scripts/sphinx-pre-install
27 @echo " SKIP Sphinx $@ target."
28
29else # HAVE_SPHINX
30
31# User-friendly check for pdflatex
32HAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi)
33
34# Internal variables.
35PAPEROPT_a4 = -D latex_paper_size=a4
36PAPEROPT_letter = -D latex_paper_size=letter
37KERNELDOC = $(srctree)/scripts/kernel-doc
38KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
39ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
40# the i18n builder cannot share the environment and doctrees with the others
41I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
42
43# commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
44loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
45
46# $2 sphinx builder e.g. "html"
47# $3 name of the build subfolder / e.g. "media", used as:
48# * dest folder relative to $(BUILDDIR) and
49# * cache folder relative to $(BUILDDIR)/.doctrees
50# $4 dest subfolder e.g. "man" for man pages at media/man
51# $5 reST source folder relative to $(srctree)/$(src),
Breno Matheus Lima656d8da2019-06-05 18:18:30 +000052# e.g. "media" for the linux-tv book-set at ./doc/media
Mario Six78a88f72018-07-10 08:40:17 +020053
54quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
Breno Matheus Lima656d8da2019-06-05 18:18:30 +000055 cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=doc/media $2 && \
Mario Six78a88f72018-07-10 08:40:17 +020056 PYTHONDONTWRITEBYTECODE=1 \
57 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
58 $(SPHINXBUILD) \
Simon Glass7d6fade2022-08-07 16:33:26 -060059 -j$(shell nproc) \
Mario Six78a88f72018-07-10 08:40:17 +020060 -b $2 \
Simon Glass5e730d92022-08-13 11:40:40 -060061 -j auto \
Mario Six78a88f72018-07-10 08:40:17 +020062 -c $(abspath $(srctree)/$(src)) \
63 -d $(abspath $(BUILDDIR)/.doctrees/$3) \
64 -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
65 $(ALLSPHINXOPTS) \
66 $(abspath $(srctree)/$(src)/$5) \
67 $(abspath $(BUILDDIR)/$3/$4)
68
69htmldocs:
70 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
71
72linkcheckdocs:
73 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
74
75latexdocs:
76 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
77
78ifeq ($(HAVE_PDFLATEX),0)
79
80pdfdocs:
81 $(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
82 @echo " SKIP Sphinx $@ target."
83
84else # HAVE_PDFLATEX
85
86pdfdocs: latexdocs
87 $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit;)
88
89endif # HAVE_PDFLATEX
90
91epubdocs:
92 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
93
94xmldocs:
95 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
96
97endif # HAVE_SPHINX
98
99# The following targets are independent of HAVE_SPHINX, and the rules should
100# work or silently pass without Sphinx.
101
102refcheckdocs:
103 $(Q)cd $(srctree);scripts/documentation-file-ref-check
104
105cleandocs:
106 $(Q)rm -rf $(BUILDDIR)
Breno Matheus Lima656d8da2019-06-05 18:18:30 +0000107 $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=doc/media clean
Mario Six78a88f72018-07-10 08:40:17 +0200108
109dochelp:
Patrick Delaunay91539242021-01-14 12:04:04 +0100110 @echo ' U-Boot documentation in different formats from ReST:'
Mario Six78a88f72018-07-10 08:40:17 +0200111 @echo ' htmldocs - HTML'
112 @echo ' latexdocs - LaTeX'
113 @echo ' pdfdocs - PDF'
114 @echo ' epubdocs - EPUB'
115 @echo ' xmldocs - XML'
116 @echo ' linkcheckdocs - check for broken external links (will connect to external hosts)'
117 @echo ' refcheckdocs - check for references to non-existing files under Documentation'
118 @echo ' cleandocs - clean all generated files'
119 @echo
120 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
121 @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
122 @echo
123 @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
124 @echo ' configuration. This is e.g. useful to build with nit-picking config.'
125 @echo
Breno Matheus Lima656d8da2019-06-05 18:18:30 +0000126 @echo ' Default location for the generated documents is doc/output'