执行make htmldocs输出如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

Documentation/Makefile:39: The 'sphinx-build' 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 'sphinx-build' executable.

Detected OS: Ubuntu 20.04.1 LTS.
Warning: better to also install "convert".
Warning: better to also install "dot".
Warning: better to also install "dvipng".
ERROR: please install "ensurepip", otherwise, build won't work.
Warning: better to also install "latexmk".
Warning: better to also install "rsvg-convert".
Warning: better to also install "xelatex".
You should run:

	sudo apt-get install imagemagick graphviz dvipng python3-venv latexmk librsvg2-bin texlive-xetex
Warning: It is recommended at least Sphinx version 1.7.9.
         If you want pdf, you need at least 2.4.4.
Note: It is recommended at least Sphinx version 2.4.4 if you need PDF support.
	/usr/bin/python3 -m venv sphinx_2.4.4
	. sphinx_2.4.4/bin/activate
	pip install -r ./Documentation/sphinx/requirements.txt

If you want to exit the virtualenv, you can use:
	deactivate

Can't build as 2 mandatory dependencies are missing at ./scripts/sphinx-pre-install line 855.
Documentation/Makefile:39: The 'sphinx-build' 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 'sphinx-build' executable.

Detected OS: Ubuntu 20.04.1 LTS.
Warning: better to also install "convert".
Warning: better to also install "dot".
Warning: better to also install "dvipng".
ERROR: please install "ensurepip", otherwise, build won't work.
Warning: better to also install "latexmk".
Warning: better to also install "rsvg-convert".
Warning: better to also install "xelatex".
You should run:

	sudo apt-get install imagemagick graphviz dvipng python3-venv latexmk librsvg2-bin texlive-xetex
Warning: It is recommended at least Sphinx version 1.7.9.
         If you want pdf, you need at least 2.4.4.
Note: It is recommended at least Sphinx version 2.4.4 if you need PDF support.
	/usr/bin/python3 -m venv sphinx_2.4.4
	. sphinx_2.4.4/bin/activate
	pip install -r ./Documentation/sphinx/requirements.txt

If you want to exit the virtualenv, you can use:
	deactivate

Can't build as 2 mandatory dependencies are missing at ./scripts/sphinx-pre-install line 855.
make[1]: *** [Documentation/Makefile:41:htmldocs] 错误 2
make: *** [Makefile:1669:htmldocs] 错误 2

安装依赖

1
sudo apt-get install imagemagick graphviz dvipng python3-venv latexmk librsvg2-bin texlive-xetex

再次尝试执行make htmldocs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Documentation/Makefile:39: The 'sphinx-build' 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 'sphinx-build' executable.

Detected OS: Ubuntu 20.04.1 LTS.
Warning: It is recommended at least Sphinx version 1.7.9.
         If you want pdf, you need at least 2.4.4.
Note: It is recommended at least Sphinx version 2.4.4 if you need PDF support.
	/usr/bin/python3 -m venv sphinx_2.4.4
	. sphinx_2.4.4/bin/activate
	pip install -r ./Documentation/sphinx/requirements.txt

If you want to exit the virtualenv, you can use:
	deactivate

All optional dependencies are met.
Can't build as 1 mandatory dependency is missing at ./scripts/sphinx-pre-install line 853.

处理python依赖

1
2
3
4
sudo apt install python3-pip
/usr/bin/python3 -m venv sphinx_2.4.4
. sphinx_2.4.4/bin/activate
pip3 install -r ./Documentation/sphinx/requirements.txt   -i https://pypi.douban.com/simple 

再次执行make htmldocs

看一下Makefile中怎么定义htmldocs目标的:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
htmldocs:                      
        @$(srctree)/scripts/sphinx-pre-install --version-check
        @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) 
        
# commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;

# cmd_$(1) => cmd_sphinx

# scripts/Kbuild.include
# echo command.
# Short version is used, if $(quiet) equals `quiet_', otherwise full one.                                                                                                           
echo-cmd = $(if $($(quiet)cmd_$(1)),\
        echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)



# $2 sphinx builder e.g. "html"
# $3 name of the build subfolder / e.g. "userspace-api/media", used as:
#    * dest folder relative to $(BUILDDIR) and
#    * cache folder relative to $(BUILDDIR)/.doctrees
# $4 dest subfolder e.g. "man" for man pages at userspace-api/media/man
# $5 reST source folder relative to $(srctree)/$(src),
#    e.g. "userspace-api/media" for the linux-tv book-set at ./Documentation/userspace-api/media

quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
# SPHINX  htmldocs --> file:///home/myye/linux/Documentation/output
# BUILDDIR      = $(obj)/output

      cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media $2 && \                               
        PYTHONDONTWRITEBYTECODE=1 \
        BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
        $(PYTHON) $(srctree)/scripts/jobserver-exec \
        $(SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \
        $(SPHINXBUILD) \
        -b $2 \
        -c $(abspath $(srctree)/$(src)) \
        -d $(abspath $(BUILDDIR)/.doctrees/$3) \
        -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
        $(ALLSPHINXOPTS) \
        $(abspath $(srctree)/$(src)/$5) \
        $(abspath $(BUILDDIR)/$3/$4)

补充阅读:

https://blog.csdn.net/yanlaifan/article/details/71402771 makefile foreach函数

https://blog.csdn.net/ly890700/article/details/52800734 makefile call函数