2 # Makefile for Sphinx documentation
5 # You can set these variables from the command line.
6 SPHINXBUILD = sphinx-build
9 _SPHINXDIRS = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py))
12 BUILDDIR = $(obj)/output
14 # User-friendly check for sphinx-build
15 HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
17 ifeq ($(HAVE_SPHINX),0)
20 $(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.)
21 @echo " SKIP Sphinx $@ target."
23 else ifneq ($(DOCBOOKS),)
25 # Skip Sphinx build if the user explicitly requested DOCBOOKS.
27 @echo " SKIP Sphinx $@ target (DOCBOOKS specified)."
31 # User-friendly check for pdflatex
32 HAVE_PDFLATEX := $(shell if which xelatex >/dev/null 2>&1; then echo 1; else echo 0; fi)
35 PAPEROPT_a4 = -D latex_paper_size=a4
36 PAPEROPT_letter = -D latex_paper_size=letter
37 KERNELDOC = $(srctree)/scripts/kernel-doc
38 KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
39 ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
40 # the i18n builder cannot share the environment and doctrees with the others
41 I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
43 # commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
44 loop_cmd = $(echo-cmd) $(cmd_$(1))
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),
52 # e.g. "media" for the linux-tv book-set at ./Documentation/media
54 quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4);
55 cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media all;\
56 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
59 -c $(abspath $(srctree)/$(src)) \
60 -d $(abspath $(BUILDDIR)/.doctrees/$3) \
61 -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
63 $(abspath $(srctree)/$(src)/$5) \
64 $(abspath $(BUILDDIR)/$3/$4);
67 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
70 ifeq ($(HAVE_PDFLATEX),0)
71 $(warning The 'xelatex' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
72 @echo " SKIP Sphinx $@ target."
74 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
78 ifneq ($(HAVE_PDFLATEX),0)
79 $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=xelatex LATEXOPTS="-interaction=nonstopmode" -C $(BUILDDIR)/$(var)/latex)
83 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
86 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
88 # no-ops for the Sphinx toolchain
95 $(Q)rm -rf $(BUILDDIR)
100 @echo ' Linux kernel internal documentation in different formats (Sphinx):'
101 @echo ' htmldocs - HTML'
102 @echo ' latexdocs - LaTeX'
103 @echo ' pdfdocs - PDF'
104 @echo ' epubdocs - EPUB'
105 @echo ' xmldocs - XML'
106 @echo ' cleandocs - clean all generated files'
108 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
109 @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
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.'