docs: sphinx-pre-install: improve dependency checks
Subsystems (3)
v3 cover docs: sphinx-pre-install: improve dependency checks
Hi all,
The Sphinx dependency checker currently does not provide useful installation guidance on macOS and only checks whether a make executable exists. This can leave macOS users without a clear setup path and allow an incompatible make implementation to pass the dependency check before the documentation build fails.
This series:
- documents the case-sensitive APFS volume needed for a kernel tree on macOS;
- adds macOS/Homebrew dependency handling, including command-line-only MacTeX support, required PDF font casks, and a PATH refresh hint;
- checks for GNU Make 4.0 or newer and honors an exported MAKE before preferring Homebrew gmake;
- teaches sphinx-build-wrapper to select a compatible GNU Make lazily for Info and Rust docs; and
- updates the zh_CN documentation in separate patches, including the APFS guidance in the contributor how-to.
Changes in v3:
- restore the PyYAML availability check on macOS, as the parser_yaml extension requires it regardless of how Sphinx is installed; and
- move GNU Make version parsing and command selection to the shared tools/lib/python/kdoc/gmake_detect.py module, used by both the dependency checker and Sphinx build wrapper.
Thanks,
Chen Miao
Chen Miao (6):
docs: kdoc: add GNU Make detection
docs: sphinx-pre-install: add macOS Homebrew support
docs: sphinx-pre-install: check GNU Make version
docs: sphinx-build-wrapper: prefer gmake docs/zh_CN: doc-guide: document macOS Sphinx setup docs/zh_CN: how-to: document case-sensitive APFS setup
Documentation/doc-guide/sphinx.rst | 20 +++ .../translations/zh_CN/doc-guide/sphinx.rst | 17 ++- Documentation/translations/zh_CN/how-to.rst | 8 ++ tools/docs/sphinx-build-wrapper | 23 +++- tools/docs/sphinx-pre-install | 120 +++++++++++++++++- tools/lib/python/kdoc/gmake_detect.py | 62 +++++++++ 6 files changed, 241 insertions(+), 9 deletions(-) create mode 100644 tools/lib/python/kdoc/gmake_detect.py
base-commit: 8492d4e6bb7b9b1e78f2d17c4dda5272f25ec118
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 1/6 docs: kdoc: add GNU Make detection
The Sphinx dependency checker and build wrapper need to select a GNU Make executable that meets the minimum supported version. Keep the version parsing and command selection in a common module so both tools use identical behavior.
--- tools/lib/python/kdoc/gmake_detect.py | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tools/lib/python/kdoc/gmake_detect.py
tools/lib/python/kdoc/gmake_detect.py new file +62 -0
@@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2026 Chen Miao <[email protected]> + +"""Detect a supported GNU Make executable.""" + +import re +import shutil +import subprocess +import sys + +from kdoc.python_version import PythonVersion + + +MIN_GMAKE_VERSION = PythonVersion("4.0").version + + +def get_gmake_version(cmd): + """Return the GNU Make version for *cmd*, or ``None`` otherwise.""" + if not cmd: + return None + + kwargs = {} + if sys.version_info < (3, 7): + kwargs["universal_newlines"] = True + else: + kwargs["text"] = True + + try: + result = subprocess.run( + [cmd, "--version"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=True, + **kwargs, + ) + except (OSError, subprocess.CalledProcessError): + return None + + match = re.search( + r"^GNU Make\s+([0-9]+(?:\.[0-9]+)*)", result.stdout, re.MULTILINE + ) + if not match: + return None + + return PythonVersion.parse_version(match.group(1)) + + +def find_gmake(make=None): + """Return the first GNU Make 4.0+ from MAKE, gmake, or make.""" + candidates = ( + make, + shutil.which("gmake"), + shutil.which("make"), + ) + + for cmd in candidates: + version = get_gmake_version(cmd) + if version and version >= MIN_GMAKE_VERSION: + return cmd + + return None
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 2/6 docs: sphinx-pre-install: add macOS Homebrew support
In reply to Chen MiaoThe dependency checker currently reports an unknown distribution on macOS and cannot provide installation hints.
Detect macOS and include its product version in the status output. Use Homebrew for formula dependencies and install the command-line-only MacTeX cask without sudo. Only require Homebrew when dependencies need to be installed, install the DejaVu and Noto CJK fonts needed for PDF output, and explain how to refresh PATH after installing MacTeX.
Keep PyYAML in the virtualenv requirements because Homebrew does not provide a PyYAML formula. Check the module even on macOS: it is required by the parser_yaml extension regardless of how Sphinx is installed. When it is missing, direct users to the default virtualenv mode.
--- Documentation/doc-guide/sphinx.rst | 18 +++++ tools/docs/sphinx-pre-install | 110 +++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+)
Documentation/doc-guide/sphinx.rst +18 -0
@@ -131,6 +131,24 @@ It supports two optional parameters: ``--no-virtualenv`` Use OS packaging for Sphinx instead of Python virtual environment. +macOS uses a case-insensitive APFS volume by default, but the kernel tree +contains file names that differ only in case. Before cloning the tree, use +``diskutil apfs list`` to find the APFS container identifier, replace +``diskX`` below with that identifier, and create an additional case-sensitive +volume with:: + + diskutil apfs addVolume diskX APFSX Linux + +On macOS, the script uses Homebrew for system dependencies. Homebrew +commands are printed without ``sudo``. The PDF toolchain is provided by the +``mactex-no-gui`` cask, while the required DejaVu and Noto CJK fonts are +installed from Homebrew font casks; use ``--no-pdf`` when only building HTML +documentation. After installing MacTeX, restart the terminal or run +``eval "$(/usr/libexec/path_helper)"`` so its command-line tools are visible. +The default virtualenv mode is recommended on macOS because PyYAML is +installed from ``Documentation/sphinx/requirements.txt`` rather than from a +Homebrew formula. + Installing Sphinx Minimal Version ---------------------------------
tools/docs/sphinx-pre-install +110 -0
134 lines not on this page · raw message
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 3/6 docs: sphinx-pre-install: check GNU Make version
In reply to Chen MiaoThe kernel documentation build requires GNU Make 4.0 or newer, but the Sphinx dependency checker only verifies that a make executable exists. This lets incompatible make implementations pass the check and fail later during the build.
Check the GNU Make version on all supported systems. Prefer a compatible gmake command, which is how Homebrew provides GNU Make on macOS, and fall back to make. Use the common kdoc detector so the dependency checker and build wrapper apply the same selection logic. Document the requirement and the macOS gmake invocation.
--- Documentation/doc-guide/sphinx.rst | 4 +++- tools/docs/sphinx-pre-install | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
Documentation/doc-guide/sphinx.rst +3 -1
@@ -147,7 +147,9 @@ documentation. After installing MacTeX, restart the terminal or run ``eval "$(/usr/libexec/path_helper)"`` so its command-line tools are visible. The default virtualenv mode is recommended on macOS because PyYAML is installed from ``Documentation/sphinx/requirements.txt`` rather than from a -Homebrew formula. +Homebrew formula. The script also checks for GNU Make 4.0 or newer; when +Homebrew provides it as ``gmake``, use ``gmake htmldocs`` instead of +``make htmldocs``. Installing Sphinx Minimal Version ---------------------------------
tools/docs/sphinx-pre-install +9 -1
@@ -37,6 +37,7 @@ import os.path src_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(src_dir, '../lib/python')) from kdoc.python_version import PythonVersion +from kdoc.gmake_detect import find_gmake RECOMMENDED_VERSION = PythonVersion("3.4.3").version MIN_PYTHON_VERSION = PythonVersion("3.7").version
@@ -308,6 +309,13 @@ class MissingCheckers(AncillaryMethods): return None + def check_make(self): + """Check for GNU Make 4.0 or newer.""" + if find_gmake(os.environ.get("MAKE")): + return + + self.deps.add_package("make", DepManager.SYSTEM_MANDATORY) + def check_perl_module(self, prog, dtype): """ Does perl have a dependency? Is it available?
@@ -1559,7 +1567,7 @@ class SphinxDependencyChecker(MissingCheckers): # Check for needed programs/tools self.check_perl_module("Pod::Usage", DepManager.SYSTEM_MANDATORY) - self.check_program("make", DepManager.SYSTEM_MANDATORY) + self.check_make() self.check_program("which", DepManager.SYSTEM_MANDATORY) self.check_program("dot", DepManager.SYSTEM_OPTIONAL)
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 4/6 docs: sphinx-build-wrapper: prefer gmake
In reply to Chen MiaoHomebrew installs GNU Make as gmake on macOS, but the Sphinx build wrapper invokes make directly when generating Info and Rust documentation. This can make the dependency check succeed while those documentation targets still use an incompatible make implementation.
Honor MAKE when it names a compatible GNU Make. Otherwise check gmake and then make, selecting the first GNU Make 4.0 or newer. Use the common kdoc detector to keep this selection consistent with sphinx-pre-install.
--- tools/docs/sphinx-build-wrapper | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
tools/docs/sphinx-build-wrapper +16 -7
@@ -63,6 +63,7 @@ SRC_DIR = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) from kdoc.python_version import PythonVersion +from kdoc.gmake_detect import find_gmake from kdoc.latex_fonts import LatexFontChecker from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401
@@ -97,6 +98,14 @@ class SphinxBuilder: with the Kernel. """ + def get_make(self): + """Select the first GNU Make 4.0 or newer in preference order.""" + make = find_gmake(self.env.get("MAKE")) + if make: + return make + + sys.exit("GNU Make 4.0 or newer is required") + def get_path(self, path, use_cwd=False, abs_path=False): """ Ancillary routine to handle patches the right way, as shell does.
@@ -569,9 +578,10 @@ class SphinxBuilder: texinfo directory. """ + make = self.get_make() for output_dir in output_dirs: try: - subprocess.run(["make", "info"], cwd=output_dir, check=True) + subprocess.run([make, "info"], cwd=output_dir, check=True) except subprocess.CalledProcessError as e: sys.exit(f"Error generating info docs: {e}")
@@ -787,12 +797,11 @@ class SphinxBuilder: if rustdoc and target in ["htmldocs", "epubdocs"]: print("Building rust docs") - if "MAKE" in self.env: - cmd = [self.env["MAKE"]] - else: - cmd = ["make", "LLVM=1"] - - cmd += [ "rustdoc"] + make = self.get_make() + cmd = [make] + if make != self.env.get("MAKE"): + cmd.append("LLVM=1") + cmd.append("rustdoc") if self.verbose: print(" ".join(cmd))
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 5/6 docs/zh_CN: doc-guide: document macOS Sphinx setup
In reply to Chen MiaoTranslate the macOS Sphinx dependency setup added to the English documentation. Keep the translation in a separate patch so translation status tooling can track the source change correctly.
--- .../translations/zh_CN/doc-guide/sphinx.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
Documentation/translations/zh_CN/doc-guide/sphinx.rst +16 -1
@@ -110,6 +110,22 @@ PDF和LaTeX构建 使用Sphinx的系统打包,而不是Python虚拟环境。 +macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。克隆源码前,请用 ``diskutil apfs list`` 找到 APFS 容器标识符, +将下面的 ``diskX`` 替换为该标识符,并创建一个额外的大小写敏感卷:: + + diskutil apfs addVolume diskX APFSX Linux + +在 macOS 上,该脚本使用 Homebrew 安装系统依赖,输出的 Homebrew 命令不需要 +``sudo``。PDF 工具链由 ``mactex-no-gui`` cask 提供,所需的 DejaVu 和 Noto CJK +字体则通过 Homebrew font cask 安装;如果只构建 HTML 文档,请使用 ``--no-pdf``。 +安装 MacTeX 后,请重新启动终端,或运行 +``eval "$(/usr/libexec/path_helper)"`` 使命令行工具可见。macOS 用户建议使用 +默认的 Python 虚拟环境,因为 PyYAML 会从 +``Documentation/sphinx/requirements.txt`` 安装,而不是通过 Homebrew 安装。 +该脚本还会检查 GNU Make 4.0 或更高版本;如果 Homebrew 将其安装为 +``gmake``,请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。 + Sphinx构建 ==========
@@ -409,4 +425,3 @@ Documentation/doc-guide/kernel-doc.rst 。 <line x1="180" y1="370" x2="500" y2="50" stroke="black" stroke-width="15px"/> <polygon points="585 0 525 25 585 50" transform="rotate(135 525 25)"/> </svg> -
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 6/6 docs/zh_CN: how-to: document case-sensitive APFS setup
In reply to Chen MiaoThe APFS volume used by macOS is case-insensitive by default, while the kernel tree contains file names that differ only in case. Document the diskutil commands needed to identify the APFS container and add a case-sensitive volume before cloning the tree.
--- Documentation/translations/zh_CN/how-to.rst | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/translations/zh_CN/how-to.rst +8 -0
@@ -102,6 +102,14 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议 您通过 pip/pypi 安装最新版本 Sphinx。 +macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。在执行 ``git clone`` 前,可在现有 APFS 容器中创建一个额外的大小写 +敏感卷(先用 ``diskutil apfs list`` 找到容器标识符,并将下面的 ``diskX`` 替换为该标识符):: + + diskutil apfs addVolume diskX APFSX Linux + +然后将内核源码克隆到新卷中。 + 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户 sphinx 虚拟环境,即只需要执行::
Signature · 1 line
2.50.1 (Apple Git-155)
Re: [PATCH v3 1/6] docs: kdoc: add GNU Make detection
In reply to Chen MiaoQuoted 19 lines · On Thu, 13 Aug 2026 02:23:18 +0800 Chen Miao <[email protected]> wrote:
The Sphinx dependency checker and build wrapper need to select a GNU Make executable that meets the minimum supported version. Keep the version parsing and command selection in a common module so both tools use identical behavior.
Signed-off-by Chen Miao <[email protected]>--- tools/lib/python/kdoc/gmake_detect.py | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tools/lib/python/kdoc/gmake_detect.pytools/lib/python/kdoc/gmake_detect.py new file +2
-0@@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later
tools/lib/python/kdoc/gmake_detect.py line 12
Quoted 10 lines
tools/lib/python/kdoc/gmake_detect.py new file +10
-0+# Copyright (c) 2026 Chen Miao <[email protected]> + +"""Detect a supported GNU Make executable.""" + +import re +import shutil +import subprocess +import sys + +from kdoc.python_version import PythonVersion
Did you test it? since python_version is at the same directory, I would expect it to be:
from python_version import PythonVersion
Quoted 40 lines
tools/lib/python/kdoc/gmake_detect.py new file +40
-0+ + +MIN_GMAKE_VERSION = PythonVersion("4.0").version + + +def get_gmake_version(cmd): + """Return the GNU Make version for *cmd*, or ``None`` otherwise.""" + if not cmd: + return None + + kwargs = {} + if sys.version_info < (3, 7): + kwargs["universal_newlines"] = True + else: + kwargs["text"] = True + + try: + result = subprocess.run( + [cmd, "--version"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=True, + **kwargs, + ) + except (OSError, subprocess.CalledProcessError): + return None + + match = re.search( + r"^GNU Make\s+([0-9]+(?:\.[0-9]+)*)", result.stdout, re.MULTILINE + ) + if not match: + return None + + return PythonVersion.parse_version(match.group(1)) + + +def find_gmake(make=None): + """Return the first GNU Make 4.0+ from MAKE, gmake, or make.""" + candidates = ( + make,
tools/lib/python/kdoc/gmake_detect.py line 62
Quoted 10 lines
tools/lib/python/kdoc/gmake_detect.py new file +10
-0+ shutil.which("gmake"), + shutil.which("make"), + ) + + for cmd in candidates: + version = get_gmake_version(cmd) + if version and version >= MIN_GMAKE_VERSION: + return cmd + + return None
Thanks,
Mauro
Re: [PATCH v3 2/6] docs: sphinx-pre-install: add macOS Homebrew support
In reply to Chen MiaoQuoted 9 lines · On Thu, 13 Aug 2026 02:23:19 +0800 Chen Miao <[email protected]> wrote:
The dependency checker currently reports an unknown distribution on macOS and cannot provide installation hints.
Detect macOS and include its product version in the status output. Use Homebrew for formula dependencies and install the command-line-only MacTeX cask without sudo. Only require Homebrew when dependencies need to be installed, install the DejaVu and Noto CJK fonts needed for PDF output, and explain how to refresh PATH after installing MacTeX.
Quoted 6 lines
Keep PyYAML in the virtualenv requirements because Homebrew does not provide a PyYAML formula. Check the module even on macOS: it is required by the
parser_yamlextension regardless of how Sphinx is installed. When it is missing, direct users to the default virtualenv mode.Signed-off-by Chen Miao <[email protected]>
I can't comment on macOS specifics, but the logic looks sane on my eyes.
Quoted 167 lines
--- Documentation/doc-guide/sphinx.rst | 18 +++++ tools/docs/sphinx-pre-install | 110 +++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+)Documentation/doc-guide/sphinx.rst +18
-0@@ -131,6 +131,24 @@ It supports two optional parameters: ``--no-virtualenv`` Use OS packaging for Sphinx instead of Python virtual environment. +macOS uses a case-insensitive APFS volume by default, but the kernel tree +contains file names that differ only in case. Before cloning the tree, use +``diskutil apfs list`` to find the APFS container identifier, replace +``diskX`` below with that identifier, and create an additional case-sensitive +volume with:: + + diskutil apfs addVolume diskX APFSX Linux + +On macOS, the script uses Homebrew for system dependencies. Homebrew +commands are printed without ``sudo``. The PDF toolchain is provided by the +``mactex-no-gui`` cask, while the required DejaVu and Noto CJK fonts are +installed from Homebrew font casks; use ``--no-pdf`` when only building HTML +documentation. After installing MacTeX, restart the terminal or run +``eval "$(/usr/libexec/path_helper)"`` so its command-line tools are visible. +The default virtualenv mode is recommended on macOS because PyYAML is +installed from ``Documentation/sphinx/requirements.txt`` rather than from a +Homebrew formula. + Installing Sphinx Minimal Version ---------------------------------tools/docs/sphinx-pre-install +107
-0@@ -518,6 +518,24 @@ class MissingCheckers(AncillaryMethods): a decent coverage. """ + if sys.platform == "darwin": + sw_vers = self.which("sw_vers") + if sw_vers: + try: + result = self.run( + [sw_vers, "-productVersion"], + capture_output=True, + text=True, + check=True, + ) + version = result.stdout.strip() + if version: + return f"macOS {version}" + except (subprocess.CalledProcessError, FileNotFoundError): + pass + + return "macOS" + system_release = "" if self.which("lsb_release"):@@ -716,6 +734,93 @@ class SphinxDependencyChecker(MissingCheckers): return self.get_install_progs(progs, "apt-get install") + def give_macos_hints(self): + """Provide package installation hints for macOS using Homebrew.""" + progs = { + "Pod::Usage": "perl", + "convert": "imagemagick", + "dot": "graphviz", + "ensurepip": "python", + "python-sphinx": "sphinx-doc", + "rsvg-convert": "librsvg", + "xelatex": "mactex-no-gui", + "latexmk": "mactex-no-gui", + } + + if self.pdf: + font_dirs = [ + os.path.expanduser("~/Library/Fonts"), + "/Library/Fonts", + "/System/Library/Fonts", + ] + pdf_fonts = { + "font-dejavu": ["DejaVuSans.ttf"], + "font-noto-sans-cjk": ["NotoSansCJK.ttc"], + } + + for package, names in pdf_fonts.items(): + files = [ + os.path.join(font_dir, name) + for font_dir in font_dirs + for name in names + ] + self.check_missing_file(files, package, DepManager.PDF_MANDATORY) + + install = self.deps.check_missing(progs) + + if self.verbose_warn_install: + self.deps.warn_install() + + if not install: + return None + + formulae = set() + casks = set() + notes = [] + for package in install.split(): + if package == "yaml": + notes.append( + "PyYAML is not provided as a Homebrew formula. Use the " + "default virtualenv mode so it is installed from " + "Documentation/sphinx/requirements.txt." + ) + continue + + if package == "mactex-no-gui" or package.startswith("font-"): + casks.add(package) + else: + formulae.add(package) + + commands = [] + if formulae: + commands.append("\tbrew install " + " ".join(sorted(formulae))) + if casks: + commands.append("\tbrew install --cask " + " ".join(sorted(casks))) + + if not commands: + self.distro_msg = "\n".join(notes) + return None + + if not self.which("brew"): + notes.append( + "Homebrew is needed to install the missing dependencies. " + "Install it from https://brew.sh/ and re-run this script." + ) + self.distro_msg = "\n".join(notes) + return None + + if "mactex-no-gui" in casks: + notes.append( + "After installing MacTeX, restart the terminal or run:\n" + "\teval \"$(/usr/libexec/path_helper)\"\n" + "before re-running this script." + ) + + if notes: + self.distro_msg = "\n".join(notes) + + return "\nYou should run:\n" + "\n".join(commands) + def give_redhat_hints(self): """ Provide package installation hints for RedHat-based distros@@ -1138,6 +1243,8 @@ class SphinxDependencyChecker(MissingCheckers): re.compile("Kali"): self.give_debian_hints, re.compile("Mint"): self.give_debian_hints, + re.compile("macOS"): self.give_macos_hints, + re.compile("openSUSE"): self.give_opensuse_hints, re.compile("Mageia"): self.give_mageia_hints,
tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 1573
Quoted 9 lines
tools/docs/sphinx-pre-install +3
-0@@ -1458,6 +1565,9 @@ class SphinxDependencyChecker(MissingCheckers): self.check_program("dot", DepManager.SYSTEM_OPTIONAL) self.check_program("convert", DepManager.SYSTEM_OPTIONAL) + # PyYAML is required by Documentation/sphinx/parser_yaml.py. The + # macOS installation hints explain that it is installed from the + # virtualenv requirements, rather than from a Homebrew formula. self.check_python_module("yaml") if self.pdf:
Thanks,
Mauro
Re: [PATCH v3 3/6] docs: sphinx-pre-install: check GNU Make version
In reply to Chen MiaoQuoted 10 lines · On Thu, 13 Aug 2026 02:23:20 +0800 Chen Miao <[email protected]> wrote:
The kernel documentation build requires GNU Make 4.0 or newer, but the Sphinx dependency checker only verifies that a make executable exists. This lets incompatible make implementations pass the check and fail later during the build.
Check the GNU Make version on all supported systems. Prefer a compatible gmake command, which is how Homebrew provides GNU Make on macOS, and fall back to make. Use the common kdoc detector so the dependency checker and build wrapper apply the same selection logic. Document the requirement and the macOS gmake invocation.
LGTM.
Quoted 49 lines
Signed-off-by Chen Miao <[email protected]>--- Documentation/doc-guide/sphinx.rst | 4 +++- tools/docs/sphinx-pre-install | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-)Documentation/doc-guide/sphinx.rst +3
-1@@ -147,7 +147,9 @@ documentation. After installing MacTeX, restart the terminal or run ``eval "$(/usr/libexec/path_helper)"`` so its command-line tools are visible. The default virtualenv mode is recommended on macOS because PyYAML is installed from ``Documentation/sphinx/requirements.txt`` rather than from a -Homebrew formula. +Homebrew formula. The script also checks for GNU Make 4.0 or newer; when +Homebrew provides it as ``gmake``, use ``gmake htmldocs`` instead of +``make htmldocs``. Installing Sphinx Minimal Version ---------------------------------tools/docs/sphinx-pre-install +8
-0@@ -37,6 +37,7 @@ import os.path src_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(src_dir, '../lib/python')) from kdoc.python_version import PythonVersion +from kdoc.gmake_detect import find_gmake RECOMMENDED_VERSION = PythonVersion("3.4.3").version MIN_PYTHON_VERSION = PythonVersion("3.7").version@@ -308,6 +309,13 @@ class MissingCheckers(AncillaryMethods): return None + def check_make(self): + """Check for GNU Make 4.0 or newer.""" + if find_gmake(os.environ.get("MAKE")): + return + + self.deps.add_package("make", DepManager.SYSTEM_MANDATORY) + def check_perl_module(self, prog, dtype): """ Does perl have a dependency? Is it available?
tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 1573
Quoted 8 lines
tools/docs/sphinx-pre-install +1
-1@@ -1559,7 +1567,7 @@ class SphinxDependencyChecker(MissingCheckers): # Check for needed programs/tools self.check_perl_module("Pod::Usage", DepManager.SYSTEM_MANDATORY) - self.check_program("make", DepManager.SYSTEM_MANDATORY) + self.check_make() self.check_program("which", DepManager.SYSTEM_MANDATORY) self.check_program("dot", DepManager.SYSTEM_OPTIONAL)
Thanks,
Mauro
Re: [PATCH v3 4/6] docs: sphinx-build-wrapper: prefer gmake
In reply to Chen MiaoQuoted 57 lines · On Thu, 13 Aug 2026 02:23:21 +0800 Chen Miao <[email protected]> wrote:
Homebrew installs GNU Make as gmake on macOS, but the Sphinx build wrapper invokes make directly when generating Info and Rust documentation. This can make the dependency check succeed while those documentation targets still use an incompatible make implementation.
Honor MAKE when it names a compatible GNU Make. Otherwise check gmake and then make, selecting the first GNU Make 4.0 or newer. Use the common kdoc detector to keep this selection consistent with sphinx-pre-install.
Signed-off-by Chen Miao <[email protected]>--- tools/docs/sphinx-build-wrapper | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)tools/docs/sphinx-build-wrapper +11
-1@@ -63,6 +63,7 @@ SRC_DIR = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) from kdoc.python_version import PythonVersion +from kdoc.gmake_detect import find_gmake from kdoc.latex_fonts import LatexFontChecker from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401@@ -97,6 +98,14 @@ class SphinxBuilder: with the Kernel. """ + def get_make(self): + """Select the first GNU Make 4.0 or newer in preference order.""" + make = find_gmake(self.env.get("MAKE")) + if make: + return make + + sys.exit("GNU Make 4.0 or newer is required") + def get_path(self, path, use_cwd=False, abs_path=False): """ Ancillary routine to handle patches the right way, as shell does.@@ -569,9 +578,10 @@ class SphinxBuilder: texinfo directory. """ + make = self.get_make() for output_dir in output_dirs: try: - subprocess.run(["make", "info"], cwd=output_dir, check=True) + subprocess.run([make, "info"], cwd=output_dir, check=True) except subprocess.CalledProcessError as e: sys.exit(f"Error generating info docs: {e}")@@ -787,12 +797,11 @@ class SphinxBuilder: if rustdoc and target in ["htmldocs", "epubdocs"]: print("Building rust docs")
tools/docs/sphinx-build-wrapper class SphinxBuilder: · line 803
Quoted 10 lines
tools/docs/sphinx-build-wrapper +4
-6- if "MAKE" in self.env: - cmd = [self.env["MAKE"]] - else: - cmd = ["make", "LLVM=1"] - - cmd += [ "rustdoc"] + make = self.get_make() + cmd = [make] + if make != self.env.get("MAKE"): + cmd.append("LLVM=1")
Did you test bulding documentation with CONFIG_RUST=y?
AFAIKT, building rust docs only work with LLVM, as GCC doesn't build Rust code yet(*). When the time comes and gcc starts supporting it, the code would likely need to check for gcc version as well.
(*) There is an experimental Rust support on gcc under development.
No idea about its current status. According with:
https://docs.kernel.org/rust/quick-start.html
"GCC also works for some configurations, but it is
very experimental".
Thanks,
Mauro
Re: [PATCH v3 1/6] docs: kdoc: add GNU Make detection
In reply to Mauro Carvalho ChehabQuoted 37 lines · Mauro Carvalho Chehab <[email protected]> 于2026年8月13日周四 04:13写道:
Quoted 19 lines · On Thu, 13 Aug 2026 02:23:18 +0800 Chen Miao <[email protected]> wrote:
The Sphinx dependency checker and build wrapper need to select a GNU Make executable that meets the minimum supported version. Keep the version parsing and command selection in a common module so both tools use identical behavior.
Signed-off-by Chen Miao <[email protected]>--- tools/lib/python/kdoc/gmake_detect.py | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tools/lib/python/kdoc/gmake_detect.pytools/lib/python/kdoc/gmake_detect.py new file +2
-0@@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-latertools/lib/python/kdoc/gmake_detect.py line 12
Quoted 10 lines
tools/lib/python/kdoc/gmake_detect.py new file +10
-0+# Copyright (c) 2026 Chen Miao <[email protected]> + +"""Detect a supported GNU Make executable.""" + +import re +import shutil +import subprocess +import sys + +from kdoc.python_version import PythonVersionDid you test it? since
python_versionis at the same directory, I would expect it to be:
Quoted 2 lines
from
python_versionimport PythonVersion
Yes, I tested the Sphinx documentation build.
The callers add tools/lib/python to sys.path, so kdoc is imported as a package. Therefore, from kdoc.python_version import PythonVersion is intentional. A plain from python_version import PythonVersion would rely on kdoc itself being added to sys.path.
Thanks,
Chen Miao
Quoted 56 lines
Quoted 41 lines
tools/lib/python/kdoc/gmake_detect.py new file +40
-0+ + +MIN_GMAKE_VERSION = PythonVersion("4.0").version + + +def get_gmake_version(cmd): + """Return the GNU Make version for *cmd*, or ``None`` otherwise.""" + if not cmd: + return None + + kwargs = {} + if sys.version_info < (3, 7): + kwargs["universal_newlines"] = True + else: + kwargs["text"] = True + + try: + result = subprocess.run( + [cmd, "--version"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=True, + **kwargs, + ) + except (OSError, subprocess.CalledProcessError): + return None + + match = re.search( + r"^GNU Make\s+([0-9]+(?:\.[0-9]+)*)", result.stdout, re.MULTILINE + ) + if not match: + return None + + return PythonVersion.parse_version(match.group(1)) + + +def find_gmake(make=None): + """Return the first GNU Make 4.0+ from MAKE, gmake, or make.""" + candidates = ( + make,tools/lib/python/kdoc/gmake_detect.py line 62
Quoted 10 lines
tools/lib/python/kdoc/gmake_detect.py new file +10
-0+ shutil.which("gmake"), + shutil.which("make"), + ) + + for cmd in candidates: + version = get_gmake_version(cmd) + if version and version >= MIN_GMAKE_VERSION: + return cmd + + return NoneThanks,
Mauro
Re: [PATCH v3 4/6] docs: sphinx-build-wrapper: prefer gmake
In reply to Mauro Carvalho ChehabQuoted 81 lines · Mauro Carvalho Chehab <[email protected]> 于2026年8月13日周四 04:23写道:
Quoted 57 lines · On Thu, 13 Aug 2026 02:23:21 +0800 Chen Miao <[email protected]> wrote:
Homebrew installs GNU Make as gmake on macOS, but the Sphinx build wrapper invokes make directly when generating Info and Rust documentation. This can make the dependency check succeed while those documentation targets still use an incompatible make implementation.
Honor MAKE when it names a compatible GNU Make. Otherwise check gmake and then make, selecting the first GNU Make 4.0 or newer. Use the common kdoc detector to keep this selection consistent with sphinx-pre-install.
Signed-off-by Chen Miao <[email protected]>--- tools/docs/sphinx-build-wrapper | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)tools/docs/sphinx-build-wrapper +11
-1@@ -63,6 +63,7 @@ SRC_DIR = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) from kdoc.python_version import PythonVersion +from kdoc.gmake_detect import find_gmake from kdoc.latex_fonts import LatexFontChecker from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401@@ -97,6 +98,14 @@ class SphinxBuilder: with the Kernel. """ + def get_make(self): + """Select the first GNU Make 4.0 or newer in preference order.""" + make = find_gmake(self.env.get("MAKE")) + if make: + return make + + sys.exit("GNU Make 4.0 or newer is required") + def get_path(self, path, use_cwd=False, abs_path=False): """ Ancillary routine to handle patches the right way, as shell does.@@ -569,9 +578,10 @@ class SphinxBuilder: texinfo directory. """ + make = self.get_make() for output_dir in output_dirs: try: - subprocess.run(["make", "info"], cwd=output_dir, check=True) + subprocess.run([make, "info"], cwd=output_dir, check=True) except subprocess.CalledProcessError as e: sys.exit(f"Error generating info docs: {e}")@@ -787,12 +797,11 @@ class SphinxBuilder: if rustdoc and target in ["htmldocs", "epubdocs"]: print("Building rust docs")tools/docs/sphinx-build-wrapper class SphinxBuilder: · line 803
Quoted 10 lines
tools/docs/sphinx-build-wrapper +4
-6- if "MAKE" in self.env: - cmd = [self.env["MAKE"]] - else: - cmd = ["make", "LLVM=1"] - - cmd += [ "rustdoc"] + make = self.get_make() + cmd = [make] + if make != self.env.get("MAKE"): + cmd.append("LLVM=1")Did you test bulding documentation with
CONFIG_RUST=y?AFAIKT, building rust docs only work with LLVM, as GCC doesn't build Rust code
yet(*). When the time comes and gcc starts supporting it, the code would likely need to check for gcc version as well.(*) There is an experimental Rust support on gcc under development.
No idea about its current status. According with:
Quoted 8 lines
https://docs.kernel.org/rust/quick-start.html
"GCC also works for some configurations, but it is
very experimental".Thanks,
Mauro
Yes, I tested it on macOS with CONFIG_RUST=y using:
make LLVM=1 SPHINXDIRS=rust htmldocs
The Rust documentation path was selected and the wrapper invoked rustdoc with the LLVM build configuration.
The initial build exposed a few macOS host-build portability issues unrelated to this series, including the lack of ELF headers required by host tools and GNU sed-specific uses in Rust-related build rules. After fixing those issues locally, the rustdoc build and the Sphinx HTML documentation build completed successfully.
Those fixes are outside the scope of this series. If macOS host-build support is useful, I can send them as a separate patch series.
Thanks,
Chen Miao
Re: [PATCH v3 5/6] docs/zh_CN: doc-guide: document macOS Sphinx setup
In reply to Chen MiaoQuoted 5 lines · Chen Miao
Translate the macOS Sphinx dependency setup added to the English documentation. Keep the translation in a separate patch so translation status tooling can track the source change correctly.
Signed-off-by Chen Miao <[email protected]>
Quoted 9 lines
--- .../translations/zh_CN/doc-guide/sphinx.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/doc-guide/sphinx.rst +0
-0
Documentation/translations/zh_CN/doc-guide/sphinx.rst PDF和LaTeX构建 · line 117
Quoted 8 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst +5
-0@@ -110,6 +110,22 @@ PDF和LaTeX构建 使用Sphinx的系统打包,而不是Python虚拟环境。 +macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。克隆源码前,请用 ``diskutil apfs list`` 找到 APFS 容器标识符, +将下面的 ``diskX`` 替换为该标识符,并创建一个额外的大小写敏感卷:: + + diskutil apfs addVolume diskX APFSX Linux
This CLI way definitely works, while the Disk Utility app also provides an easy way to do this. ;-) Shall we add more description or tips about it? But I'm also satisfied with the current situation, as some hackers who would read this may prefer CLI way.
Documentation/translations/zh_CN/doc-guide/sphinx.rst PDF和LaTeX构建 · line 127
Quoted 9 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst +9
-0+在 macOS 上,该脚本使用 Homebrew 安装系统依赖,输出的 Homebrew 命令不需要 +``sudo``。PDF 工具链由 ``mactex-no-gui`` cask 提供,所需的 DejaVu 和 Noto CJK +字体则通过 Homebrew font cask 安装;如果只构建 HTML 文档,请使用 ``--no-pdf``。 +安装 MacTeX 后,请重新启动终端,或运行 +``eval "$(/usr/libexec/path_helper)"`` 使命令行工具可见。macOS 用户建议使用 +默认的 Python 虚拟环境,因为 PyYAML 会从 +``Documentation/sphinx/requirements.txt`` 安装,而不是通过 Homebrew 安装。 +该脚本还会检查 GNU Make 4.0 或更高版本;如果 Homebrew 将其安装为 +``gmake``,请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。
Thanks for this, I like it.
Re: [PATCH v3 6/6] docs/zh_CN: how-to: document case-sensitive APFS setup
In reply to Chen MiaoQuoted 6 lines · Chen Miao
The APFS volume used by macOS is case-insensitive by default, while the kernel tree contains file names that differ only in case. Document the diskutil commands needed to identify the APFS container and add a case-sensitive volume before cloning the tree.
Signed-off-by Chen Miao <[email protected]>
Quoted 12 lines
--- Documentation/translations/zh_CN/how-to.rst | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/translations/zh_CN/how-to.rst +0
-0@@ -102,6 +102,14 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议 您通过 pip/pypi 安装最新版本 Sphinx。
Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 114
Quoted 10 lines
Documentation/translations/zh_CN/how-to.rst +8
-0+macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。在执行 ``git clone`` 前,可在现有 APFS 容器中创建一个额外的大小写 +敏感卷(先用 ``diskutil apfs list`` 找到容器标识符,并将下面的 ``diskX`` 替换为该标识符):: + + diskutil apfs addVolume diskX APFSX Linux + +然后将内核源码克隆到新卷中。 + 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户 sphinx 虚拟环境,即只需要执行::
Nit: In the subsequent content of this article, all commands use "make", not "gmake". So, is it necessary to mention the content of the patch [5/6] here? (Use gmake from Homebrew instead of make from Apple), like a cross-reference, to lead the macOS users to get more detailed info.
But I'm fine with currunt wordings. Because if you try to use 'make', you'll get
Makefile:15: *** GNU Make >= 4.0 is required. Your Make version is 3.81. Stop.
then, you should realize that Homebrew had told you that you should run 'gmake' instead of 'make'.
Thanks.
Re: [PATCH v3 5/6] docs/zh_CN: doc-guide: document macOS Sphinx setup
In reply to Weijie YuanQuoted 22 lines · Weijie Yuan <[email protected]> 于2026年8月13日周四 23:36写道:
Quoted 5 lines · Chen Miao
Translate the macOS Sphinx dependency setup added to the English documentation. Keep the translation in a separate patch so translation status tooling can track the source change correctly.
Signed-off-by Chen Miao <[email protected]>Acked-by Weijie Yuan <[email protected]>Quoted 12 lines
--- .../translations/zh_CN/doc-guide/sphinx.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/doc-guide/sphinx.rst +0
-0@@ -110,6 +110,22 @@ PDF和LaTeX构建 使用Sphinx的系统打包,而不是Python虚拟环境。
Quoted 11 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst PDF和LaTeX构建 · line 117
Quoted 5 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst +5
-0+macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。克隆源码前,请用 ``diskutil apfs list`` 找到 APFS 容器标识符, +将下面的 ``diskX`` 替换为该标识符,并创建一个额外的大小写敏感卷:: + + diskutil apfs addVolume diskX APFSX LinuxThis CLI way definitely works, while the Disk Utility app also provides an easy way to do this. ;-) Shall we add more description or tips about it? But I'm also satisfied with the current situation, as some hackers who would read this may prefer CLI way.
I don't think GUI instructions are necessary here. Readers who find diskutil unfamiliar can easily search for the equivalent steps in Disk Utility. The same operation can also be performed using Disk Utility.
Thanks,
Chen Miao
Quoted 12 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst PDF和LaTeX构建 · line 127
Quoted 10 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst +9
-0+在 macOS 上,该脚本使用 Homebrew 安装系统依赖,输出的 Homebrew 命令不需要 +``sudo``。PDF 工具链由 ``mactex-no-gui`` cask 提供,所需的 DejaVu 和 Noto CJK +字体则通过 Homebrew font cask 安装;如果只构建 HTML 文档,请使用 ``--no-pdf``。 +安装 MacTeX 后,请重新启动终端,或运行 +``eval "$(/usr/libexec/path_helper)"`` 使命令行工具可见。macOS 用户建议使用 +默认的 Python 虚拟环境,因为 PyYAML 会从 +``Documentation/sphinx/requirements.txt`` 安装,而不是通过 Homebrew 安装。 +该脚本还会检查 GNU Make 4.0 或更高版本;如果 Homebrew 将其安装为 +``gmake``,请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。Thanks for this, I like it.
Re: [PATCH v3 5/6] docs/zh_CN: doc-guide: document macOS Sphinx setup
Quoted 34 lines · Chen Miao
Quoted 22 lines · Weijie Yuan <[email protected]> 于2026年8月13日周四 23:36写道:
Quoted 5 lines · Chen Miao
Translate the macOS Sphinx dependency setup added to the English documentation. Keep the translation in a separate patch so translation status tooling can track the source change correctly.
Signed-off-by Chen Miao <[email protected]>Acked-by Weijie Yuan <[email protected]>Quoted 12 lines
--- .../translations/zh_CN/doc-guide/sphinx.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)Documentation/translations/zh_CN/doc-guide/sphinx.rst +0
-0@@ -110,6 +110,22 @@ PDF和LaTeX构建 使用Sphinx的系统打包,而不是Python虚拟环境。Quoted 11 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst PDF和LaTeX构建 · line 117
Quoted 5 lines
Documentation/translations/zh_CN/doc-guide/sphinx.rst +5
-0+macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。克隆源码前,请用 ``diskutil apfs list`` 找到 APFS 容器标识符, +将下面的 ``diskX`` 替换为该标识符,并创建一个额外的大小写敏感卷:: + + diskutil apfs addVolume diskX APFSX LinuxThis CLI way definitely works, while the Disk Utility app also provides an easy way to do this. ;-) Shall we add more description or tips about it? But I'm also satisfied with the current situation, as some hackers who would read this may prefer CLI way.
Quoted 3 lines
I don't think GUI instructions are necessary here. Readers who find diskutil unfamiliar can easily search for the equivalent steps in Disk Utility. The same operation can also be performed using Disk Utility.
Yeah, agreed. Thanks.
Re: [PATCH v3 6/6] docs/zh_CN: how-to: document case-sensitive APFS setup
In reply to Weijie YuanQuoted 42 lines · Weijie Yuan <[email protected]> 于2026年8月13日周四 23:46写道:
Quoted 6 lines · Chen Miao
The APFS volume used by macOS is case-insensitive by default, while the kernel tree contains file names that differ only in case. Document the diskutil commands needed to identify the APFS container and add a case-sensitive volume before cloning the tree.
Signed-off-by Chen Miao <[email protected]>Acked-by Weijie Yuan <[email protected]>Quoted 12 lines
--- Documentation/translations/zh_CN/how-to.rst | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/translations/zh_CN/how-to.rst +0
-0@@ -102,6 +102,14 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议 您通过 pip/pypi 安装最新版本 Sphinx。Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 114
Quoted 10 lines
Documentation/translations/zh_CN/how-to.rst +8
-0+macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。在执行 ``git clone`` 前,可在现有 APFS 容器中创建一个额外的大小写 +敏感卷(先用 ``diskutil apfs list`` 找到容器标识符,并将下面的 ``diskX`` 替换为该标识符):: + + diskutil apfs addVolume diskX APFSX Linux + +然后将内核源码克隆到新卷中。 + 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户 sphinx 虚拟环境,即只需要执行::Nit: In the subsequent content of this article, all commands use "make", not "gmake". So, is it necessary to mention the content of the patch [5/6] here? (Use gmake from Homebrew instead of make from Apple), like a cross-reference, to lead the macOS users to get more detailed info.
But I'm fine with currunt wordings. Because if you try to use 'make', you'll get
Quoted 7 lines
Makefile:15: *** GNU Make >= 4.0 is required. Your Make version is 3.81. Stop.
then, you should realize that Homebrew had told you that you should run 'gmake' instead of 'make'.
Thanks.
I don't think an additional cross-reference is necessary here. If users run into Apple's older make, the error message clearly states that GNU Make >= 4.0 is required. In addition, Homebrew's make formula already explains that GNU Make is installed as gmake:
$ brew install make
==> Would reinstall 1 formula:
make
...
GNU "make" has been installed as "gmake".Users can then retry the command with gmake, so I think the current wording is sufficient.
Thanks,
Chen Miao
Re: [PATCH v3 6/6] docs/zh_CN: how-to: document case-sensitive APFS setup
Quoted 55 lines · Chen Miao
Quoted 42 lines · Weijie Yuan <[email protected]> 于2026年8月13日周四 23:46写道:
Quoted 6 lines · Chen Miao
The APFS volume used by macOS is case-insensitive by default, while the kernel tree contains file names that differ only in case. Document the diskutil commands needed to identify the APFS container and add a case-sensitive volume before cloning the tree.
Signed-off-by Chen Miao <[email protected]>Acked-by Weijie Yuan <[email protected]>Quoted 12 lines
--- Documentation/translations/zh_CN/how-to.rst | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/translations/zh_CN/how-to.rst +0
-0@@ -102,6 +102,14 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议 您通过 pip/pypi 安装最新版本 Sphinx。Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 114
Quoted 10 lines
Documentation/translations/zh_CN/how-to.rst +8
-0+macOS 默认使用不区分文件名大小写的 APFS 卷,而内核源码树中存在仅大小写 +不同的文件。在执行 ``git clone`` 前,可在现有 APFS 容器中创建一个额外的大小写 +敏感卷(先用 ``diskutil apfs list`` 找到容器标识符,并将下面的 ``diskX`` 替换为该标识符):: + + diskutil apfs addVolume diskX APFSX Linux + +然后将内核源码克隆到新卷中。 + 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户 sphinx 虚拟环境,即只需要执行::Nit: In the subsequent content of this article, all commands use "make", not "gmake". So, is it necessary to mention the content of the patch [5/6] here? (Use gmake from Homebrew instead of make from Apple), like a cross-reference, to lead the macOS users to get more detailed info.
But I'm fine with currunt wordings. Because if you try to use 'make', you'll get
Quoted 7 lines
Makefile:15: *** GNU Make >= 4.0 is required. Your Make version is 3.81. Stop.
then, you should realize that Homebrew had told you that you should run 'gmake' instead of 'make'.
Thanks.
I don't think an additional cross-reference is necessary here. If users run into Apple's older
make, the error message clearly states that GNU Make >= 4.0 is required. In addition, Homebrew'smakeformula already explains that GNU Make is installed asgmake:
Quoted 8 lines
$ brew install make ==> Would reinstall 1 formula: make ... GNU "make" has been installed as "gmake".Users can then retry the command with
gmake, so I think the current wording is sufficient.
Yes, so it's not a big deal.
Thanks.
Re: [PATCH v3 4/6] docs: sphinx-build-wrapper: prefer gmake
In reply to Chen MiaoQuoted 87 lines · On Thu, 13 Aug 2026 17:38:59 +0800 Chen Miao <[email protected]> wrote:
Quoted 86 lines · Mauro Carvalho Chehab <[email protected]> 于2026年8月13日周四 04:23写道:
Quoted 57 lines · On Thu, 13 Aug 2026 02:23:21 +0800 Chen Miao <[email protected]> wrote:
Homebrew installs GNU Make as gmake on macOS, but the Sphinx build wrapper invokes make directly when generating Info and Rust documentation. This can make the dependency check succeed while those documentation targets still use an incompatible make implementation.
Honor MAKE when it names a compatible GNU Make. Otherwise check gmake and then make, selecting the first GNU Make 4.0 or newer. Use the common kdoc detector to keep this selection consistent with sphinx-pre-install.
Signed-off-by Chen Miao <[email protected]>--- tools/docs/sphinx-build-wrapper | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)tools/docs/sphinx-build-wrapper +11
-1@@ -63,6 +63,7 @@ SRC_DIR = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) from kdoc.python_version import PythonVersion +from kdoc.gmake_detect import find_gmake from kdoc.latex_fonts import LatexFontChecker from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401@@ -97,6 +98,14 @@ class SphinxBuilder: with the Kernel. """ + def get_make(self): + """Select the first GNU Make 4.0 or newer in preference order.""" + make = find_gmake(self.env.get("MAKE")) + if make: + return make + + sys.exit("GNU Make 4.0 or newer is required") + def get_path(self, path, use_cwd=False, abs_path=False): """ Ancillary routine to handle patches the right way, as shell does.@@ -569,9 +578,10 @@ class SphinxBuilder: texinfo directory. """ + make = self.get_make() for output_dir in output_dirs: try: - subprocess.run(["make", "info"], cwd=output_dir, check=True) + subprocess.run([make, "info"], cwd=output_dir, check=True) except subprocess.CalledProcessError as e: sys.exit(f"Error generating info docs: {e}")@@ -787,12 +797,11 @@ class SphinxBuilder: if rustdoc and target in ["htmldocs", "epubdocs"]: print("Building rust docs")tools/docs/sphinx-build-wrapper class SphinxBuilder: · line 803
Quoted 10 lines
tools/docs/sphinx-build-wrapper +4
-6- if "MAKE" in self.env: - cmd = [self.env["MAKE"]] - else: - cmd = ["make", "LLVM=1"] - - cmd += [ "rustdoc"] + make = self.get_make() + cmd = [make] + if make != self.env.get("MAKE"): + cmd.append("LLVM=1")Did you test bulding documentation with
CONFIG_RUST=y?AFAIKT, building rust docs only work with LLVM, as GCC doesn't build Rust code
yet(*). When the time comes and gcc starts supporting it, the code would likely need to check for gcc version as well.(*) There is an experimental Rust support on gcc under development.
No idea about its current status. According with:https://docs.kernel.org/rust/quick-start.html
"GCC also works for some configurations, but it is
very experimental".
Quoted 6 lines
Quoted 3 lines
Thanks,
MauroYes, I tested it on macOS with
CONFIG_RUST=yusing:make LLVM=1 SPHINXDIRS=rust htmldocs
No. I meant:
$ make LLVM=1 menuconfig # enable rust $ grep CONFIG_RUST .config # check if it was enabled $ make SPHINXDIRS=rust htmldocs
Quoted 10 lines
The Rust documentation path was selected and the wrapper invoked rustdoc with the LLVM build configuration.
The initial build exposed a few macOS host-build portability issues unrelated to this series, including the lack of ELF headers required by host tools and GNU sed-specific uses in Rust-related build rules. After fixing those issues locally, the rustdoc build and the Sphinx HTML documentation build completed successfully.
Quoted 5 lines
Those fixes are outside the scope of this series. If macOS host-build support is useful, I can send them as a separate patch series.
Thanks,
Chen Miao
Thanks,
Mauro
Re: [PATCH v3 4/6] docs: sphinx-build-wrapper: prefer gmake
Quoted 96 lines · Mauro Carvalho Chehab <[email protected]> 于2026年8月14日周五 05:36写道:
Quoted 92 lines · On Thu, 13 Aug 2026 17:38:59 +0800 Chen Miao <[email protected]> wrote:
Quoted 81 lines · Mauro Carvalho Chehab <[email protected]> 于2026年8月13日周四 04:23写道:
Quoted 57 lines · On Thu, 13 Aug 2026 02:23:21 +0800 Chen Miao <[email protected]> wrote:
Homebrew installs GNU Make as gmake on macOS, but the Sphinx build wrapper invokes make directly when generating Info and Rust documentation. This can make the dependency check succeed while those documentation targets still use an incompatible make implementation.
Honor MAKE when it names a compatible GNU Make. Otherwise check gmake and then make, selecting the first GNU Make 4.0 or newer. Use the common kdoc detector to keep this selection consistent with sphinx-pre-install.
Signed-off-by Chen Miao <[email protected]>--- tools/docs/sphinx-build-wrapper | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)tools/docs/sphinx-build-wrapper +11
-1@@ -63,6 +63,7 @@ SRC_DIR = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) from kdoc.python_version import PythonVersion +from kdoc.gmake_detect import find_gmake from kdoc.latex_fonts import LatexFontChecker from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401@@ -97,6 +98,14 @@ class SphinxBuilder: with the Kernel. """ + def get_make(self): + """Select the first GNU Make 4.0 or newer in preference order.""" + make = find_gmake(self.env.get("MAKE")) + if make: + return make + + sys.exit("GNU Make 4.0 or newer is required") + def get_path(self, path, use_cwd=False, abs_path=False): """ Ancillary routine to handle patches the right way, as shell does.@@ -569,9 +578,10 @@ class SphinxBuilder: texinfo directory. """ + make = self.get_make() for output_dir in output_dirs: try: - subprocess.run(["make", "info"], cwd=output_dir, check=True) + subprocess.run([make, "info"], cwd=output_dir, check=True) except subprocess.CalledProcessError as e: sys.exit(f"Error generating info docs: {e}")@@ -787,12 +797,11 @@ class SphinxBuilder: if rustdoc and target in ["htmldocs", "epubdocs"]: print("Building rust docs")tools/docs/sphinx-build-wrapper class SphinxBuilder: · line 803
Quoted 10 lines
tools/docs/sphinx-build-wrapper +4
-6- if "MAKE" in self.env: - cmd = [self.env["MAKE"]] - else: - cmd = ["make", "LLVM=1"] - - cmd += [ "rustdoc"] + make = self.get_make() + cmd = [make] + if make != self.env.get("MAKE"): + cmd.append("LLVM=1")Did you test bulding documentation with
CONFIG_RUST=y?AFAIKT, building rust docs only work with LLVM, as GCC doesn't build Rust code
yet(*). When the time comes and gcc starts supporting it, the code would likely need to check for gcc version as well.(*) There is an experimental Rust support on gcc under development.
No idea about its current status. According with:Quoted 8 lines
https://docs.kernel.org/rust/quick-start.html
"GCC also works for some configurations, but it is
very experimental".Thanks,
MauroYes, I tested it on macOS with
CONFIG_RUST=yusing:
Quoted 8 lines
Quoted 1 line
make LLVM=1 SPHINXDIRS=rust htmldocs
No. I meant:
$ make LLVM=1 menuconfig # enable rust $ grep CONFIG_RUST .config # check if it was enabled $ make SPHINXDIRS=rust htmldocs
Thanks for clarifying. I retested with CONFIG_RUST=y and then ran:
make SPHINXDIRS=rust htmldocs
Indeed, there is an issue: the wrapper invokes make rustdoc without LLVM=1, so the Rust documentation is not generated. I will update this and retest in v4.
Thanks,
Chen Miao
Quoted 21 lines
Quoted 11 lines
The Rust documentation path was selected and the wrapper invoked rustdoc with the LLVM build configuration.
The initial build exposed a few macOS host-build portability issues unrelated to this series, including the lack of ELF headers required by host tools and GNU sed-specific uses in Rust-related build rules. After fixing those issues locally, the rustdoc build and the Sphinx HTML documentation build completed successfully.
Quoted 5 lines
Those fixes are outside the scope of this series. If macOS host-build support is useful, I can send them as a separate patch series.
Thanks,
Chen MiaoThanks,
Mauro