2 # Makefile for Sphinx documentation
5 subdir-y
:= devicetree
/bindings
/
7 # Check for broken documentation file references
8 ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS
),y
)
9 $(shell $(srctree
)/scripts
/documentation-file-ref-check
--warn
)
12 # You can set these variables from the command line.
13 SPHINXBUILD
= sphinx-build
16 _SPHINXDIRS
= $(patsubst $(srctree
)/Documentation
/%/index.rst
,%,$(wildcard $(srctree
)/Documentation
/*/index.rst
))
19 BUILDDIR
= $(obj
)/output
21 LATEXOPTS
= -interaction
=batchmode
23 # User-friendly check for sphinx-build
24 HAVE_SPHINX
:= $(shell if which
$(SPHINXBUILD
) >/dev
/null
2>&1; then echo
1; else echo
0; fi
)
26 ifeq ($(HAVE_SPHINX
),0)
29 $(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.
)
31 @
$(srctree
)/scripts
/sphinx-pre-install
32 @echo
" SKIP Sphinx $@ target."
36 # User-friendly check for pdflatex and latexmk
37 HAVE_PDFLATEX
:= $(shell if which
$(PDFLATEX
) >/dev
/null
2>&1; then echo
1; else echo
0; fi
)
38 HAVE_LATEXMK
:= $(shell if which latexmk
>/dev
/null
2>&1; then echo
1; else echo
0; fi
)
40 ifeq ($(HAVE_LATEXMK
),1)
41 PDFLATEX
:= latexmk
-$(PDFLATEX
)
45 PAPEROPT_a4
= -D latex_paper_size
=a4
46 PAPEROPT_letter
= -D latex_paper_size
=letter
47 KERNELDOC
= $(srctree
)/scripts
/kernel-doc
48 KERNELDOC_CONF
= -D kerneldoc_srctree
=$(srctree
) -D kerneldoc_bin
=$(KERNELDOC
)
49 ALLSPHINXOPTS
= $(KERNELDOC_CONF
) $(PAPEROPT_
$(PAPER
)) $(SPHINXOPTS
)
50 # the i18n builder cannot share the environment and doctrees with the others
51 I18NSPHINXOPTS
= $(PAPEROPT_
$(PAPER
)) $(SPHINXOPTS
) .
53 # commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
54 loop_cmd
= $(echo-cmd
) $(cmd_
$(1)) || exit
;
56 # $2 sphinx builder e.g. "html"
57 # $3 name of the build subfolder / e.g. "media", used as:
58 # * dest folder relative to $(BUILDDIR) and
59 # * cache folder relative to $(BUILDDIR)/.doctrees
60 # $4 dest subfolder e.g. "man" for man pages at media/man
61 # $5 reST source folder relative to $(srctree)/$(src),
62 # e.g. "media" for the linux-tv book-set at ./Documentation/media
64 quiet_cmd_sphinx
= SPHINX
$@
--> file
://$(abspath
$(BUILDDIR
)/$3/$4)
65 cmd_sphinx
= $(MAKE
) BUILDDIR
=$(abspath
$(BUILDDIR
)) $(build
)=Documentation
/media
$2 && \
66 PYTHONDONTWRITEBYTECODE
=1 \
67 BUILDDIR
=$(abspath
$(BUILDDIR
)) SPHINX_CONF
=$(abspath
$(srctree
)/$(src
)/$5/$(SPHINX_CONF
)) \
68 $(PYTHON
) $(srctree
)/scripts
/jobserver-exec \
69 $(SHELL
) $(srctree
)/Documentation
/sphinx
/parallel-wrapper.sh \
72 -c
$(abspath
$(srctree
)/$(src
)) \
73 -d
$(abspath
$(BUILDDIR
)/.doctrees
/$3) \
74 -D version
=$(KERNELVERSION
) -D release
=$(KERNELRELEASE
) \
76 $(abspath
$(srctree
)/$(src
)/$5) \
77 $(abspath
$(BUILDDIR
)/$3/$4)
80 @
$(srctree
)/scripts
/sphinx-pre-install
--version-check
81 @
+$(foreach var
,$(SPHINXDIRS
),$(call loop_cmd
,sphinx
,html
,$(var
),,$(var
)))
84 @
$(foreach var
,$(SPHINXDIRS
),$(call loop_cmd
,sphinx
,linkcheck
,$(var
),,$(var
)))
87 @
$(srctree
)/scripts
/sphinx-pre-install
--version-check
88 @
+$(foreach var
,$(SPHINXDIRS
),$(call loop_cmd
,sphinx
,latex
,$(var
),latex
,$(var
)))
90 ifeq ($(HAVE_PDFLATEX
),0)
93 $(warning The
'$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.
)
94 @echo
" SKIP Sphinx $@ target."
99 @
$(srctree
)/scripts
/sphinx-pre-install
--version-check
100 $(foreach var
,$(SPHINXDIRS
), $(MAKE
) PDFLATEX
="$(PDFLATEX)" LATEXOPTS
="$(LATEXOPTS)" -C
$(BUILDDIR
)/$(var
)/latex || exit
;)
102 endif # HAVE_PDFLATEX
105 @
$(srctree
)/scripts
/sphinx-pre-install
--version-check
106 @
+$(foreach var
,$(SPHINXDIRS
),$(call loop_cmd
,sphinx
,epub
,$(var
),epub
,$(var
)))
109 @
$(srctree
)/scripts
/sphinx-pre-install
--version-check
110 @
+$(foreach var
,$(SPHINXDIRS
),$(call loop_cmd
,sphinx
,xml
,$(var
),xml
,$(var
)))
114 # The following targets are independent of HAVE_SPHINX, and the rules should
115 # work or silently pass without Sphinx.
118 $(Q
)cd
$(srctree
);scripts
/documentation-file-ref-check
121 $(Q
)rm -rf
$(BUILDDIR
)
122 $(Q
)$(MAKE
) BUILDDIR
=$(abspath
$(BUILDDIR
)) $(build
)=Documentation
/media
clean
125 @echo
' Linux kernel internal documentation in different formats from ReST:'
126 @echo
' htmldocs - HTML'
127 @echo
' latexdocs - LaTeX'
128 @echo
' pdfdocs - PDF'
129 @echo
' epubdocs - EPUB'
130 @echo
' xmldocs - XML'
131 @echo
' linkcheckdocs - check for broken external links'
132 @echo
' (will connect to external hosts)'
133 @echo
' refcheckdocs - check for references to non-existing files under'
134 @echo
' Documentation'
135 @echo
' cleandocs - clean all generated files'
137 @echo
' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
138 @echo
' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
140 @echo
' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
141 @echo
' configuration. This is e.g. useful to build with nit-picking config.'
143 @echo
' Default location for the generated documents is Documentation/output'