hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/Documentation/Makefile
....@@ -2,18 +2,33 @@
22 # Makefile for Sphinx documentation
33 #
44
5
-subdir-y :=
5
+# for cleaning
6
+subdir- := devicetree/bindings
7
+
8
+# Check for broken documentation file references
9
+ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
10
+$(shell $(srctree)/scripts/documentation-file-ref-check --warn)
11
+endif
12
+
13
+# Check for broken ABI files
14
+ifeq ($(CONFIG_WARN_ABI_ERRORS),y)
15
+$(shell $(srctree)/scripts/get_abi.pl validate --dir $(srctree)/Documentation/ABI)
16
+endif
617
718 # You can set these variables from the command line.
819 SPHINXBUILD = sphinx-build
920 SPHINXOPTS =
1021 SPHINXDIRS = .
11
-_SPHINXDIRS = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py))
22
+_SPHINXDIRS = $(sort $(patsubst $(srctree)/Documentation/%/index.rst,%,$(wildcard $(srctree)/Documentation/*/index.rst)))
1223 SPHINX_CONF = conf.py
1324 PAPER =
1425 BUILDDIR = $(obj)/output
1526 PDFLATEX = xelatex
1627 LATEXOPTS = -interaction=batchmode
28
+
29
+ifeq ($(KBUILD_VERBOSE),0)
30
+SPHINXOPTS += "-q"
31
+endif
1732
1833 # User-friendly check for sphinx-build
1934 HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
....@@ -23,13 +38,18 @@
2338 .DEFAULT:
2439 $(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.)
2540 @echo
26
- @./scripts/sphinx-pre-install
41
+ @$(srctree)/scripts/sphinx-pre-install
2742 @echo " SKIP Sphinx $@ target."
2843
2944 else # HAVE_SPHINX
3045
31
-# User-friendly check for pdflatex
46
+# User-friendly check for pdflatex and latexmk
3247 HAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi)
48
+HAVE_LATEXMK := $(shell if which latexmk >/dev/null 2>&1; then echo 1; else echo 0; fi)
49
+
50
+ifeq ($(HAVE_LATEXMK),1)
51
+ PDFLATEX := latexmk -$(PDFLATEX)
52
+endif #HAVE_LATEXMK
3353
3454 # Internal variables.
3555 PAPEROPT_a4 = -D latex_paper_size=a4
....@@ -44,17 +64,19 @@
4464 loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
4565
4666 # $2 sphinx builder e.g. "html"
47
-# $3 name of the build subfolder / e.g. "media", used as:
67
+# $3 name of the build subfolder / e.g. "userspace-api/media", used as:
4868 # * dest folder relative to $(BUILDDIR) and
4969 # * cache folder relative to $(BUILDDIR)/.doctrees
50
-# $4 dest subfolder e.g. "man" for man pages at media/man
70
+# $4 dest subfolder e.g. "man" for man pages at userspace-api/media/man
5171 # $5 reST source folder relative to $(srctree)/$(src),
52
-# e.g. "media" for the linux-tv book-set at ./Documentation/media
72
+# e.g. "userspace-api/media" for the linux-tv book-set at ./Documentation/userspace-api/media
5373
5474 quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
55
- cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media $2 && \
75
+ cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media $2 && \
5676 PYTHONDONTWRITEBYTECODE=1 \
5777 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
78
+ $(PYTHON) $(srctree)/scripts/jobserver-exec \
79
+ $(SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \
5880 $(SPHINXBUILD) \
5981 -b $2 \
6082 -c $(abspath $(srctree)/$(src)) \
....@@ -65,12 +87,14 @@
6587 $(abspath $(BUILDDIR)/$3/$4)
6688
6789 htmldocs:
90
+ @$(srctree)/scripts/sphinx-pre-install --version-check
6891 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
6992
7093 linkcheckdocs:
7194 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
7295
7396 latexdocs:
97
+ @$(srctree)/scripts/sphinx-pre-install --version-check
7498 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
7599
76100 ifeq ($(HAVE_PDFLATEX),0)
....@@ -82,14 +106,21 @@
82106 else # HAVE_PDFLATEX
83107
84108 pdfdocs: latexdocs
85
- $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit;)
109
+ @$(srctree)/scripts/sphinx-pre-install --version-check
110
+ $(foreach var,$(SPHINXDIRS), \
111
+ $(MAKE) PDFLATEX="$(PDFLATEX)" LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit; \
112
+ mkdir -p $(BUILDDIR)/$(var)/pdf; \
113
+ mv $(subst .tex,.pdf,$(wildcard $(BUILDDIR)/$(var)/latex/*.tex)) $(BUILDDIR)/$(var)/pdf/; \
114
+ )
86115
87116 endif # HAVE_PDFLATEX
88117
89118 epubdocs:
119
+ @$(srctree)/scripts/sphinx-pre-install --version-check
90120 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
91121
92122 xmldocs:
123
+ @$(srctree)/scripts/sphinx-pre-install --version-check
93124 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
94125
95126 endif # HAVE_SPHINX
....@@ -102,7 +133,7 @@
102133
103134 cleandocs:
104135 $(Q)rm -rf $(BUILDDIR)
105
- $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media clean
136
+ $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media clean
106137
107138 dochelp:
108139 @echo ' Linux kernel internal documentation in different formats from ReST:'
....@@ -111,8 +142,10 @@
111142 @echo ' pdfdocs - PDF'
112143 @echo ' epubdocs - EPUB'
113144 @echo ' xmldocs - XML'
114
- @echo ' linkcheckdocs - check for broken external links (will connect to external hosts)'
115
- @echo ' refcheckdocs - check for references to non-existing files under Documentation'
145
+ @echo ' linkcheckdocs - check for broken external links'
146
+ @echo ' (will connect to external hosts)'
147
+ @echo ' refcheckdocs - check for references to non-existing files under'
148
+ @echo ' Documentation'
116149 @echo ' cleandocs - clean all generated files'
117150 @echo
118151 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'