Skip to contentSkip to conversation

docs: sphinx-pre-install: improve dependency checks

PATCH Superseded Chen Miao 5 participants 13 messages Aug 9 – Aug 10

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Chen Miao

author
#0 lore raw

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:

- adds macOS/Homebrew dependency handling, including MacTeX cask support;
- checks for GNU Make 4.0 or newer and recognizes Homebrew's ``gmake``; and
- avoids printing an empty installation command when only PyYAML is missing.

Thanks,

Chen Miao

Chen Miao (2):
docs: sphinx-pre-install: add macOS Homebrew support
docs: sphinx-pre-install: check GNU Make version

 Documentation/doc-guide/sphinx.rst            |   9 ++
 .../translations/zh_CN/doc-guide/sphinx.rst   |   7 +
 Documentation/translations/zh_CN/how-to.rst   |   7 +
 tools/docs/sphinx-pre-install                 | 141 +++++++++++++++++-
 4 files changed, 162 insertions(+), 2 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)
author
#1 lore raw

PATCH 1/2 docs: sphinx-pre-install: add macOS Homebrew support

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 MacTeX as a cask without sudo. Keep PyYAML in the virtual environment requirements because Homebrew does not provide a PyYAML formula.

Document the macOS setup and the --no-pdf option.

---
 Documentation/doc-guide/sphinx.rst            |  7 ++
 .../translations/zh_CN/doc-guide/sphinx.rst   |  5 ++
 Documentation/translations/zh_CN/how-to.rst   |  6 ++
 tools/docs/sphinx-pre-install                 | 89 ++++++++++++++++++-
 4 files changed, 106 insertions(+), 1 deletion(-)
Documentation/doc-guide/sphinx.rst +7 -0
index 51c370260..62aca56b8 100644
@@ -131,6 +131,13 @@ It supports two optional parameters:
 ``--no-virtualenv``
 	Use OS packaging for Sphinx instead of Python virtual environment.
 
+On macOS, the script uses Homebrew for system dependencies. Homebrew
+commands are printed without ``sudo``. The PDF dependencies are provided by
+the ``mactex`` cask; use ``--no-pdf`` when only building HTML documentation.
+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
 ---------------------------------
 
Documentation/translations/zh_CN/doc-guide/sphinx.rst +5 -0
index 3375c6f3a..154142318 100644
@@ -110,6 +110,11 @@ PDF和LaTeX构建
 
 	使用Sphinx的系统打包,而不是Python虚拟环境。
 
+在 macOS 上,该脚本使用 Homebrew 安装系统依赖,输出的 Homebrew 命令不需要
+``sudo``。PDF 依赖通过 ``mactex`` cask 提供;如果只构建 HTML 文档,请使用
+``--no-pdf``。macOS 用户建议使用默认的 Python 虚拟环境,因为 PyYAML 会从
+``Documentation/sphinx/requirements.txt`` 安装,而不是通过 Homebrew 安装。
+
 Sphinx构建
 ==========
 
Documentation/translations/zh_CN/how-to.rst +6 -0
index 9ec2384e1..e8c91d81a 100644
@@ -102,6 +102,12 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
 开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议
 您通过 pip/pypi 安装最新版本 Sphinx。
 
+如果您使用 macOS,脚本会使用 Homebrew 输出安装命令,Homebrew 命令不需要
+sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
+可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
+的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
+安装,而不是通过 Homebrew 安装。
+
 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户
 sphinx 虚拟环境,即只需要执行::
 
tools/docs/sphinx-pre-install +88 -1

113 lines not on this page · raw message

Signature · 1 line
2.50.1 (Apple Git-155)
#2 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

Hi Miao,

Quoted 17 lines · Chen Miao

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 MacTeX as a cask without sudo. Keep PyYAML in the virtual environment requirements because Homebrew does not provide a PyYAML formula.

Document the macOS setup and the --no-pdf option.

---
 Documentation/doc-guide/sphinx.rst            |  7 ++
 .../translations/zh_CN/doc-guide/sphinx.rst   |  5 ++
 Documentation/translations/zh_CN/how-to.rst   |  6 ++
 tools/docs/sphinx-pre-install                 | 89 ++++++++++++++++++-
 4 files changed, 106 insertions(+), 1 deletion(-)

[...]

Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 109

Quoted 13 lines
Documentation/translations/zh_CN/how-to.rst +5 -0
index 9ec2384e1..e8c91d81a 100644
@@ -102,6 +102,12 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
 开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议
 您通过 pip/pypi 安装最新版本 Sphinx。
 
+如果您使用 macOS,脚本会使用 Homebrew 输出安装命令,Homebrew 命令不需要
+sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
+可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
+的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
+安装,而不是通过 Homebrew 安装。

My question is perhaps quite stupid. (I'm not familiar with this part)

How can you make "git clone xxx/linux.git" done on your mac? I've tried this before, but it seems that there's some format issue? macOS's default APFS is case-insensitive.., so I guess you did some extra settings? (like 'git clone --sparse' or 'git clone --filter=blob:none'?) But my intuition and experience tell me that it won't be convenient ;-)

If so, an additional description for macOS users might be more user-friendly, I guess? Since the how-to file aims to lower the threshold of the process of translation. (While I don't know how many macOS users are potential contributors.)

And another thing is that zh_CN would prefer splitting zh_CN translations apart from the original English one in your patch. Because there's a script to monitor the translation status.
(Better confirm this with zh_CN maintainers)

Thanks.

I haven't read this script carefully. Please feel free to ignore my incorrect comments below.

Quoted 31 lines
tools/docs/sphinx-pre-install +18 -0
index 965c9b093..51a296cc7 100755
@@ -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,69 @@ class SphinxDependencyChecker(MissingCheckers):
 

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 744

Quoted 10 lines
tools/docs/sphinx-pre-install +8 -0
         return self.get_install_progs(progs, "apt-get install")
 
+    def give_macos_hints(self):
+        """
+        Provide package installation hints for macOS using Homebrew.
+
+        Homebrew formulae and casks must not be installed with sudo. MacTeX
+        is a cask, while the other dependencies are formulae.
+        """
+        if not self.which("brew"):

Homebrew seems to be treated as a build dependency here, rather than as the package manager used to provide installation hints.

If all actual documentation dependencies are already installed on a macOS system without Homebrew, this adds Homebrew as SYSTEM_MANDATORY, increments self.deps.need, and eventually makes the script exit with Can't build as 1 mandatory dependency is missing, even though the documentation can actually be built.

Could we first check whether there are any missing dependencies and only complain about a missing brew when an installation hint is actually needed? I don't think Homebrew itself should be added to self.deps.

Quoted 8 lines
tools/docs/sphinx-pre-install +8 -0
+            if not self.distro_msg:
+                self.deps.add_package("Homebrew", DepManager.SYSTEM_MANDATORY)
+                self.deps.check_missing({})
+                self.deps.warn_install()
+                self.distro_msg = \
+                    "Homebrew is required for macOS support. Install it from " \
+                    "https://brew.sh/ and re-run this script."
+            return None

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 762

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+
+        progs = {
+            "Pod::Usage":    "perl",
+            "convert":       "imagemagick",
+            "dot":           "graphviz",
+            "ensurepip":     "python",
+            "python-sphinx": "sphinx-doc",
+            "rsvg-convert":   "librsvg",
+            "xelatex":        "mactex",
+            "latexmk":        "mactex",

Nit & Non-blocking:

Btw, would 'mactex-no-gui' be a better fit here?

The documentation build only needs the TeX command-line tools, while the regular mactex cask also installs the GUI applications (I forget whether GUI is big or not, but I guess <1GB). mactex-no-gui still provides the full TeX Live distribution, so it may avoid installing software that is not needed for kernel documentation builds.

Not a blocker.

Quoted 21 lines
tools/docs/sphinx-pre-install +21 -0
+        }
+
+        install = self.deps.check_missing(progs)
+
+        if self.verbose_warn_install:
+            self.deps.warn_install()
+
+        if not install:
+            return None
+
+        formulae = set()
+        casks = set()
+        for prog in self.deps.missing:
+            if prog == "yaml":
+                self.distro_msg = \
+                    "PyYAML is not provided as a Homebrew formula. Use the " \
+                    "default virtualenv mode so it is installed from " \
+                    "Documentation/sphinx/requirements.txt."
+                continue
+
+            package = progs.get(prog, prog)

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 793

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+            if package == "mactex":
+                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)))

One more thing about the MacTeX hint: after installing the mactex cask, its command-line tools may not become visible in the current shell immediately. Homebrew's cask notes say that the terminal needs to be restarted, or eval "$(/usr/libexec/path_helper)" (Is it?) should be run.

Otherwise, a user who immediately re-runs sphinx-pre-install after following this suggestion may still see xelatex and latexmk reported as missing.

Would it make sense to mention this in the macOS installation hint?

Quoted 21 lines
tools/docs/sphinx-pre-install +8 -0
+
+        if not commands:
+            return None
+
+        return "\nYou should run:\n" + "\n".join(commands)
+
     def give_redhat_hints(self):
         """
         Provide package installation hints for RedHat-based distros
@@ -1138,6 +1219,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,
@@ -1458,7 +1541,11 @@ class SphinxDependencyChecker(MissingCheckers):
         self.check_program("dot", DepManager.SYSTEM_OPTIONAL)
         self.check_program("convert", DepManager.SYSTEM_OPTIONAL)

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 1551

Quoted 10 lines
tools/docs/sphinx-pre-install +5 -1
 
-        self.check_python_module("yaml")
+        # PyYAML is installed from Documentation/sphinx/requirements.txt in
+        # the virtualenv recommended on macOS. Homebrew does not provide a
+        # PyYAML formula, so do not ask for a nonexistent brew package here.
+        if not (sys.platform == "darwin" and self.virtualenv and self.need_pip):
+            self.check_python_module("yaml")
 
         if self.pdf:
             self.check_program("xelatex", DepManager.PDF_MANDATORY)

Thanks.

reviewer
#3 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

Quoted 36 lines · Weijie Yuan

Hi Miao,

Quoted 17 lines · Chen Miao

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 MacTeX as a cask without sudo. Keep PyYAML in the virtual environment requirements because Homebrew does not provide a PyYAML formula.

Document the macOS setup and the --no-pdf option.

---
  Documentation/doc-guide/sphinx.rst            |  7 ++
  .../translations/zh_CN/doc-guide/sphinx.rst   |  5 ++
  Documentation/translations/zh_CN/how-to.rst   |  6 ++
  tools/docs/sphinx-pre-install                 | 89 ++++++++++++++++++-
  4 files changed, 106 insertions(+), 1 deletion(-)

[...]

Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 109

Quoted 13 lines
Documentation/translations/zh_CN/how-to.rst +5 -0
index 9ec2384e1..e8c91d81a 100644
@@ -102,6 +102,12 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
  开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议
  您通过 pip/pypi 安装最新版本 Sphinx。
 
+如果您使用 macOS,脚本会使用 Homebrew 输出安装命令,Homebrew 命令不需要
+sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
+可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
+的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
+安装,而不是通过 Homebrew 安装。

My question is perhaps quite stupid. (I'm not familiar with this part)

Quoted 5 lines

How can you make "git clone xxx/linux.git" done on your mac? I've tried this before, but it seems that there's some format issue? macOS's default APFS is case-insensitive.., so I guess you did some extra settings? (like 'git clone --sparse' or 'git clone --filter=blob:none'?) But my intuition and experience tell me that it won't be convenient ;-)

For Mac OSX, you need to first establish a Case-sensitive APFS Volume, and in this volume you can execute thse commands.

Quoted 5 lines

If so, an additional description for macOS users might be more user-friendly, I guess? Since the how-to file aims to lower the threshold of the process of translation. (While I don't know how many macOS users are potential contributors.)

I don't prefer to add many description about "how to start kernel development on Mac OS X". Some key parts should be enough.

Quoted 5 lines

And another thing is that zh_CN would prefer splitting zh_CN translations apart from the original English one in your patch. Because there's a script to monitor the translation status.
(Better confirm this with zh_CN maintainers)

This is a good suggestion. However, many minor changes of documentation contains EN and zh_CN in the same patch :(

For the script, l will comment in another email.

Quoted 165 lines

Thanks.

I haven't read this script carefully. Please feel free to ignore my incorrect comments below.

Quoted 31 lines
tools/docs/sphinx-pre-install +18 -0
index 965c9b093..51a296cc7 100755
@@ -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,69 @@ class SphinxDependencyChecker(MissingCheckers):
 

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 744

Quoted 10 lines
tools/docs/sphinx-pre-install +8 -0
          return self.get_install_progs(progs, "apt-get install")
 
+    def give_macos_hints(self):
+        """
+        Provide package installation hints for macOS using Homebrew.
+
+        Homebrew formulae and casks must not be installed with sudo. MacTeX
+        is a cask, while the other dependencies are formulae.
+        """
+        if not self.which("brew"):

Homebrew seems to be treated as a build dependency here, rather than as the package manager used to provide installation hints.

If all actual documentation dependencies are already installed on a macOS system without Homebrew, this adds Homebrew as SYSTEM_MANDATORY, increments self.deps.need, and eventually makes the script exit with Can't build as 1 mandatory dependency is missing, even though the documentation can actually be built.

Could we first check whether there are any missing dependencies and only complain about a missing brew when an installation hint is actually needed? I don't think Homebrew itself should be added to self.deps.

Quoted 8 lines
tools/docs/sphinx-pre-install +8 -0
+            if not self.distro_msg:
+                self.deps.add_package("Homebrew", DepManager.SYSTEM_MANDATORY)
+                self.deps.check_missing({})
+                self.deps.warn_install()
+                self.distro_msg = \
+                    "Homebrew is required for macOS support. Install it from " \
+                    "https://brew.sh/ and re-run this script."
+            return None

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 762

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+
+        progs = {
+            "Pod::Usage":    "perl",
+            "convert":       "imagemagick",
+            "dot":           "graphviz",
+            "ensurepip":     "python",
+            "python-sphinx": "sphinx-doc",
+            "rsvg-convert":   "librsvg",
+            "xelatex":        "mactex",
+            "latexmk":        "mactex",

Nit & Non-blocking:

Btw, would 'mactex-no-gui' be a better fit here?

The documentation build only needs the TeX command-line tools, while the regular mactex cask also installs the GUI applications (I forget whether GUI is big or not, but I guess <1GB). mactex-no-gui still provides the full TeX Live distribution, so it may avoid installing software that is not needed for kernel documentation builds.

Not a blocker.

Quoted 21 lines
tools/docs/sphinx-pre-install +21 -0
+        }
+
+        install = self.deps.check_missing(progs)
+
+        if self.verbose_warn_install:
+            self.deps.warn_install()
+
+        if not install:
+            return None
+
+        formulae = set()
+        casks = set()
+        for prog in self.deps.missing:
+            if prog == "yaml":
+                self.distro_msg = \
+                    "PyYAML is not provided as a Homebrew formula. Use the " \
+                    "default virtualenv mode so it is installed from " \
+                    "Documentation/sphinx/requirements.txt."
+                continue
+
+            package = progs.get(prog, prog)

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 793

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+            if package == "mactex":
+                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)))

One more thing about the MacTeX hint: after installing the mactex cask, its command-line tools may not become visible in the current shell immediately. Homebrew's cask notes say that the terminal needs to be restarted, or eval "$(/usr/libexec/path_helper)" (Is it?) should be run.

Otherwise, a user who immediately re-runs sphinx-pre-install after following this suggestion may still see xelatex and latexmk reported as missing.

Would it make sense to mention this in the macOS installation hint?

Quoted 21 lines
tools/docs/sphinx-pre-install +8 -0
+
+        if not commands:
+            return None
+
+        return "\nYou should run:\n" + "\n".join(commands)
+
      def give_redhat_hints(self):
          """
          Provide package installation hints for RedHat-based distros
@@ -1138,6 +1219,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,
@@ -1458,7 +1541,11 @@ class SphinxDependencyChecker(MissingCheckers):
          self.check_program("dot", DepManager.SYSTEM_OPTIONAL)
          self.check_program("convert", DepManager.SYSTEM_OPTIONAL)

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 1551

Quoted 10 lines
tools/docs/sphinx-pre-install +5 -1
 
-        self.check_python_module("yaml")
+        # PyYAML is installed from Documentation/sphinx/requirements.txt in
+        # the virtualenv recommended on macOS. Homebrew does not provide a
+        # PyYAML formula, so do not ask for a nonexistent brew package here.
+        if not (sys.platform == "darwin" and self.virtualenv and self.need_pip):
+            self.check_python_module("yaml")
 
          if self.pdf:
              self.check_program("xelatex", DepManager.PDF_MANDATORY)

Thanks.

#4 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

Quoted 37 lines · Dongliang Mu
Quoted 35 lines · Weijie Yuan

Hi Miao,

Quoted 17 lines · Chen Miao

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 MacTeX as a cask without sudo. Keep PyYAML in the virtual environment requirements because Homebrew does not provide a PyYAML formula.

Document the macOS setup and the --no-pdf option.

---
  Documentation/doc-guide/sphinx.rst            |  7 ++
  .../translations/zh_CN/doc-guide/sphinx.rst   |  5 ++
  Documentation/translations/zh_CN/how-to.rst   |  6 ++
  tools/docs/sphinx-pre-install                 | 89 ++++++++++++++++++-
  4 files changed, 106 insertions(+), 1 deletion(-)

[...]

Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 108

Quoted 12 lines
Documentation/translations/zh_CN/how-to.rst +5 -0
index 9ec2384e1..e8c91d81a 100644
@@ -102,6 +102,12 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
  开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议
  您通过 pip/pypi 安装最新版本 Sphinx。
+如果您使用 macOS,脚本会使用 Homebrew 输出安装命令,Homebrew 命令不需要
+sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
+可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
+的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
+安装,而不是通过 Homebrew 安装。

My question is perhaps quite stupid. (I'm not familiar with this part)

Quoted 8 lines
Quoted 5 lines

How can you make "git clone xxx/linux.git" done on your mac? I've tried this before, but it seems that there's some format issue? macOS's default APFS is case-insensitive.., so I guess you did some extra settings? (like 'git clone --sparse' or 'git clone --filter=blob:none'?) But my intuition and experience tell me that it won't be convenient ;-)

For Mac OSX, you need to first establish a Case-sensitive APFS Volume, and in this volume you can execute thse commands.

Yes. So what I mean is: for documentation that tries to keep the barrier to entry for new contributors as low as possible, if we are going to introduce macOS-specific instructions here, would it be worth mentioning this as well (i.e. the case-sensitivity issue)?

That said, if someone is already doing this kind of work, they probably do not need much explanation about it anyway.

Quoted 7 lines
Quoted 4 lines

If so, an additional description for macOS users might be more user-friendly, I guess? Since the how-to file aims to lower the threshold of the process of translation. (While I don't know how many macOS users are potential contributors.)

I don't prefer to add many description about "how to start kernel development on Mac OS X". Some key parts should be enough.

Yes. Agreed.

Quoted 7 lines
Quoted 4 lines

And another thing is that zh_CN would prefer splitting zh_CN translations apart from the original English one in your patch. Because there's a script to monitor the translation status.
(Better confirm this with zh_CN maintainers)

This is a good suggestion. However, many minor changes of documentation contains EN and zh_CN in the same patch :(

Then I guess we'll just have to wait for the next patch adding a new translation to verify the statistics produced by the script.

Thanks.

author
#5 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

Quoted 61 lines · Weijie Yuan <[email protected]> 于2026年8月9日周日 22:12写道:
Quoted 37 lines · Dongliang Mu
Quoted 35 lines · Weijie Yuan

Hi Miao,

Quoted 17 lines · Chen Miao

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 MacTeX as a cask without sudo. Keep PyYAML in the virtual environment requirements because Homebrew does not provide a PyYAML formula.

Document the macOS setup and the --no-pdf option.

---
  Documentation/doc-guide/sphinx.rst            |  7 ++
  .../translations/zh_CN/doc-guide/sphinx.rst   |  5 ++
  Documentation/translations/zh_CN/how-to.rst   |  6 ++
  tools/docs/sphinx-pre-install                 | 89 ++++++++++++++++++-
  4 files changed, 106 insertions(+), 1 deletion(-)

[...]

Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 108

Quoted 12 lines
Documentation/translations/zh_CN/how-to.rst +5 -0
index 9ec2384e1..e8c91d81a 100644
@@ -102,6 +102,12 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
  开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议
  您通过 pip/pypi 安装最新版本 Sphinx。
+如果您使用 macOS,脚本会使用 Homebrew 输出安装命令,Homebrew 命令不需要
+sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
+可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
+的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
+安装,而不是通过 Homebrew 安装。

My question is perhaps quite stupid. (I'm not familiar with this part)

Quoted 8 lines
Quoted 5 lines

How can you make "git clone xxx/linux.git" done on your mac? I've tried this before, but it seems that there's some format issue? macOS's default APFS is case-insensitive.., so I guess you did some extra settings? (like 'git clone --sparse' or 'git clone --filter=blob:none'?) But my intuition and experience tell me that it won't be convenient ;-)

For Mac OSX, you need to first establish a Case-sensitive APFS Volume, and in this volume you can execute thse commands.

Yes. So what I mean is: for documentation that tries to keep the barrier to entry for new contributors as low as possible, if we are going to introduce macOS-specific instructions here, would it be worth mentioning this as well (i.e. the case-sensitivity issue)?

That said, if someone is already doing this kind of work, they probably do not need much explanation about it anyway.

Quoted 5 lines
Quoted 4 lines

If so, an additional description for macOS users might be more user-friendly, I guess? Since the how-to file aims to lower the threshold of the process of translation. (While I don't know how many macOS users are potential contributors.)

Quoted 5 lines
Quoted 2 lines

I don't prefer to add many description about "how to start kernel development on Mac OS X". Some key parts should be enough.

Yes. Agreed.

Thanks for the clarification. I'll first check whether the kernel documentation already has something like a "macOS kernel development guide." If not, I think it might be worth documenting this.

In particular, macOS uses a case-insensitive APFS volume by default, which can cause unexpected problems for newcomers working with the Linux kernel source tree. It would be unfortunate if there were no documentation covering the things developers need to be aware of when doing kernel development on macOS. That said, I suspect this would be better handled in a separate patch series.

Of course, if such documentation already exists, then that's even better, and there would be no need to add another one.

My main concern is that, if there are currently no macOS-specific notes in the kernel documentation, some important details may remain implicit knowledge among experienced macOS users rather than being documented for newcomers.

Thanks,
Chen Miao

Quoted 13 lines
Quoted 8 lines
Quoted 5 lines

And another thing is that zh_CN would prefer splitting zh_CN translations apart from the original English one in your patch. Because there's a script to monitor the translation status.
(Better confirm this with zh_CN maintainers)

This is a good suggestion. However, many minor changes of documentation contains EN and zh_CN in the same patch :(

Then I guess we'll just have to wait for the next patch adding a new translation to verify the statistics produced by the script.

Thanks.

maintainer
#6 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

Quoted 4 lines · Chen Miao

Thanks for the clarification. I'll first check whether the kernel documentation already has something like a "macOS kernel development guide." If not, I think it might be worth documenting this.

Quoted 8 lines

In particular, macOS uses a case-insensitive APFS volume by default, which can cause unexpected problems for newcomers working with the Linux kernel source tree. It would be unfortunate if there were no documentation covering the things developers need to be aware of when doing kernel development on macOS. That said, I suspect this would be better handled in a separate patch series.

Of course, if such documentation already exists, then that's even better, and there would be no need to add another one.

There is no such guide now.

Correct me if I'm wrong, but I *think* that absence reflects the fact that Linux kernel development is mostly done on Linux systems?

We can certainly add such a guide if somebody is willing to write it, and if it would be useful to people.

Thanks,

jon

#7 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

Quoted 12 lines · Jonathan Corbet
Quoted 10 lines · Chen Miao

Thanks for the clarification. I'll first check whether the kernel documentation already has something like a "macOS kernel development guide." If not, I think it might be worth documenting this.

In particular, macOS uses a case-insensitive APFS volume by default, which can cause unexpected problems for newcomers working with the Linux kernel source tree. It would be unfortunate if there were no documentation covering the things developers need to be aware of when doing kernel development on macOS. That said, I suspect this would be better handled in a separate patch series.

Quoted 7 lines
Quoted 2 lines

Of course, if such documentation already exists, then that's even better, and there would be no need to add another one.

There is no such guide now.

Correct me if I'm wrong, but I *think* that absence reflects the fact that Linux kernel development is mostly done on Linux systems?

Yes, I think so. But while macOS is not a common platform for kernel development itself, it might still be worthwhile to make things a little easier for people who want to contribute to the kernel *documentation* from macOS.

That said, I don't have any data on how many people would actually want to work on the documentation from macOS. In my own case, though, there have been a few times when I only had an Apple machine available and still needed to get some work done.

So overall, if supporting that use case is not too complicated and does not create much of a maintenance burden, having one more option available does not seem like a bad thing.

Thanks.

Quoted 2 lines

We can certainly add such a guide if somebody is willing to write it, and if it would be useful to people.

author
#8 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

Quoted 32 lines · Weijie Yuan <[email protected]> 于2026年8月10日周一 11:48写道:
Quoted 12 lines · Jonathan Corbet
Quoted 10 lines · Chen Miao

Thanks for the clarification. I'll first check whether the kernel documentation already has something like a "macOS kernel development guide." If not, I think it might be worth documenting this.

In particular, macOS uses a case-insensitive APFS volume by default, which can cause unexpected problems for newcomers working with the Linux kernel source tree. It would be unfortunate if there were no documentation covering the things developers need to be aware of when doing kernel development on macOS. That said, I suspect this would be better handled in a separate patch series.

Quoted 7 lines
Quoted 2 lines

Of course, if such documentation already exists, then that's even better, and there would be no need to add another one.

There is no such guide now.

Correct me if I'm wrong, but I *think* that absence reflects the fact that Linux kernel development is mostly done on Linux systems?

Yes, I think so. But while macOS is not a common platform for kernel development itself, it might still be worthwhile to make things a little easier for people who want to contribute to the kernel *documentation* from macOS.

That said, I don't have any data on how many people would actually want to work on the documentation from macOS. In my own case, though, there have been a few times when I only had an Apple machine available and still needed to get some work done.

Quoted 5 lines

So overall, if supporting that use case is not too complicated and does not create much of a maintenance burden, having one more option available does not seem like a bad thing.

Thanks.

Thanks for the discussion. My takeaway is that support for macOS *development* is still limited.

For v2, I’ll limit the change to kernel *documentation*: I’ll add a note to how-to.rst for macOS users about APFS being case-insensitive by default and the resulting issue. I won’t try to document a broader macOS development setup in this series; that would need more established guidance first.

Unless there are objections, I’ll proceed on that basis for v2.

Thanks.

Quoted 3 lines
Quoted 3 lines

We can certainly add such a guide if somebody is willing to write it, and if it would be useful to people.

author
#9 lore raw

Re: [PATCH v1 1/2] docs: sphinx-pre-install: add macOS Homebrew support

In reply to Weijie Yuan
Quoted 49 lines · Weijie Yuan <[email protected]> 于2026年8月9日周日 21:02写道:

Hi Miao,

Quoted 17 lines · Chen Miao

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 MacTeX as a cask without sudo. Keep PyYAML in the virtual environment requirements because Homebrew does not provide a PyYAML formula.

Document the macOS setup and the --no-pdf option.

---
 Documentation/doc-guide/sphinx.rst            |  7 ++
 .../translations/zh_CN/doc-guide/sphinx.rst   |  5 ++
 Documentation/translations/zh_CN/how-to.rst   |  6 ++
 tools/docs/sphinx-pre-install                 | 89 ++++++++++++++++++-
 4 files changed, 106 insertions(+), 1 deletion(-)

[...]

Documentation/translations/zh_CN/how-to.rst Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了 · line 109

Quoted 13 lines
Documentation/translations/zh_CN/how-to.rst +5 -0
index 9ec2384e1..e8c91d81a 100644
@@ -102,6 +102,12 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
 开头的命令。**请注意**,最新版本 Sphinx 的文档编译速度有极大提升,强烈建议
 您通过 pip/pypi 安装最新版本 Sphinx。
 
+如果您使用 macOS,脚本会使用 Homebrew 输出安装命令,Homebrew 命令不需要
+sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
+可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
+的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
+安装,而不是通过 Homebrew 安装。

My question is perhaps quite stupid. (I'm not familiar with this part)

How can you make "git clone xxx/linux.git" done on your mac? I've tried this before, but it seems that there's some format issue? macOS's default APFS is case-insensitive.., so I guess you did some extra settings? (like 'git clone --sparse' or 'git clone --filter=blob:none'?) But my intuition and experience tell me that it won't be convenient ;-)

If so, an additional description for macOS users might be more user-friendly, I guess? Since the how-to file aims to lower the threshold of the process of translation. (While I don't know how many macOS users are potential contributors.)

Quoted 7 lines

And another thing is that zh_CN would prefer splitting zh_CN translations apart from the original English one in your patch. Because there's a script to monitor the translation status.
(Better confirm this with zh_CN maintainers)

Thanks.

Regarding APFS, I'll reply to that together in response to your latest email. I see that you and the other reviewer have reached a consensus.

In the next revision of the patch, I'll split the English and Chinese versions into separate patches. I agree that this would indeed be better.

Quoted 55 lines

I haven't read this script carefully. Please feel free to ignore my incorrect comments below.

Quoted 31 lines
tools/docs/sphinx-pre-install +18 -0
index 965c9b093..51a296cc7 100755
@@ -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,69 @@ class SphinxDependencyChecker(MissingCheckers):
 

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 744

Quoted 10 lines
tools/docs/sphinx-pre-install +8 -0
         return self.get_install_progs(progs, "apt-get install")
 
+    def give_macos_hints(self):
+        """
+        Provide package installation hints for macOS using Homebrew.
+
+        Homebrew formulae and casks must not be installed with sudo. MacTeX
+        is a cask, while the other dependencies are formulae.
+        """
+        if not self.which("brew"):

Homebrew seems to be treated as a build dependency here, rather than as the package manager used to provide installation hints.

If all actual documentation dependencies are already installed on a macOS system without Homebrew, this adds Homebrew as SYSTEM_MANDATORY, increments self.deps.need, and eventually makes the script exit with Can't build as 1 mandatory dependency is missing, even though the documentation can actually be built.

Quoted 4 lines

Could we first check whether there are any missing dependencies and only complain about a missing brew when an installation hint is actually needed? I don't think Homebrew itself should be added to self.deps.

I think you're right — Homebrew is not a required dependency. We should only suggest using brew to install the necessary dependencies when we detect that they are missing.

Quoted 22 lines
Quoted 9 lines
tools/docs/sphinx-pre-install +8 -0
+            if not self.distro_msg:
+                self.deps.add_package("Homebrew", DepManager.SYSTEM_MANDATORY)
+                self.deps.check_missing({})
+                self.deps.warn_install()
+                self.distro_msg = \
+                    "Homebrew is required for macOS support. Install it from " \
+                    "https://brew.sh/ and re-run this script."
+            return None

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 762

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+
+        progs = {
+            "Pod::Usage":    "perl",
+            "convert":       "imagemagick",
+            "dot":           "graphviz",
+            "ensurepip":     "python",
+            "python-sphinx": "sphinx-doc",
+            "rsvg-convert":   "librsvg",
+            "xelatex":        "mactex",
+            "latexmk":        "mactex",

Nit & Non-blocking:

Quoted 8 lines

Btw, would 'mactex-no-gui' be a better fit here?

The documentation build only needs the TeX command-line tools, while the regular mactex cask also installs the GUI applications (I forget whether GUI is big or not, but I guess <1GB). mactex-no-gui still provides the full TeX Live distribution, so it may avoid installing software that is not needed for kernel documentation builds.

Agree.

Quoted 40 lines

Not a blocker.

Quoted 21 lines
tools/docs/sphinx-pre-install +21 -0
+        }
+
+        install = self.deps.check_missing(progs)
+
+        if self.verbose_warn_install:
+            self.deps.warn_install()
+
+        if not install:
+            return None
+
+        formulae = set()
+        casks = set()
+        for prog in self.deps.missing:
+            if prog == "yaml":
+                self.distro_msg = \
+                    "PyYAML is not provided as a Homebrew formula. Use the " \
+                    "default virtualenv mode so it is installed from " \
+                    "Documentation/sphinx/requirements.txt."
+                continue
+
+            package = progs.get(prog, prog)

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 793

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+            if package == "mactex":
+                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)))

One more thing about the MacTeX hint: after installing the mactex cask, its command-line tools may not become visible in the current shell immediately. Homebrew's cask notes say that the terminal needs to be restarted, or eval "$(/usr/libexec/path_helper)" (Is it?) should be run.

Quoted 6 lines

Otherwise, a user who immediately re-runs sphinx-pre-install after following this suggestion may still see xelatex and latexmk reported as missing.

Would it make sense to mention this in the macOS installation hint?

Sure, nice tips.

Thanks,
Chen Miao

Quoted 34 lines
Quoted 22 lines
tools/docs/sphinx-pre-install +8 -0
+
+        if not commands:
+            return None
+
+        return "\nYou should run:\n" + "\n".join(commands)
+
     def give_redhat_hints(self):
         """
         Provide package installation hints for RedHat-based distros
@@ -1138,6 +1219,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,
@@ -1458,7 +1541,11 @@ class SphinxDependencyChecker(MissingCheckers):
         self.check_program("dot", DepManager.SYSTEM_OPTIONAL)
         self.check_program("convert", DepManager.SYSTEM_OPTIONAL)

tools/docs/sphinx-pre-install class SphinxDependencyChecker(MissingCheckers): · line 1551

Quoted 10 lines
tools/docs/sphinx-pre-install +5 -1
 
-        self.check_python_module("yaml")
+        # PyYAML is installed from Documentation/sphinx/requirements.txt in
+        # the virtualenv recommended on macOS. Homebrew does not provide a
+        # PyYAML formula, so do not ask for a nonexistent brew package here.
+        if not (sys.platform == "darwin" and self.virtualenv and self.need_pip):
+            self.check_python_module("yaml")
 
         if self.pdf:
             self.check_program("xelatex", DepManager.PDF_MANDATORY)

Thanks.

author
#10 lore raw

PATCH 2/2 docs: sphinx-pre-install: check GNU Make version

In reply to Chen Miao

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. If make is missing or too old, report it as a missing dependency. Also accept a compatible gmake command, which is how Homebrew provides GNU Make on macOS.

Document the requirement and the macOS gmake fallback.

---
 Documentation/doc-guide/sphinx.rst            |  4 +-
 .../translations/zh_CN/doc-guide/sphinx.rst   |  2 +
 Documentation/translations/zh_CN/how-to.rst   |  3 +-
 tools/docs/sphinx-pre-install                 | 52 ++++++++++++++++++-
 4 files changed, 58 insertions(+), 3 deletions(-)
Documentation/doc-guide/sphinx.rst +3 -1
index 62aca56b8..d9b9e025f 100644
@@ -136,7 +136,9 @@ commands are printed without ``sudo``. The PDF dependencies are provided by
 the ``mactex`` cask; use ``--no-pdf`` when only building HTML documentation.
 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
 ---------------------------------
Documentation/translations/zh_CN/doc-guide/sphinx.rst +2 -0
index 154142318..93f27d35a 100644
@@ -114,6 +114,8 @@ PDF和LaTeX构建
 ``sudo``。PDF 依赖通过 ``mactex`` cask 提供;如果只构建 HTML 文档,请使用
 ``--no-pdf``。macOS 用户建议使用默认的 Python 虚拟环境,因为 PyYAML 会从
 ``Documentation/sphinx/requirements.txt`` 安装,而不是通过 Homebrew 安装。
+脚本还会检查 GNU Make 4.0 或更高版本;如果 Homebrew 将其安装为 ``gmake``,
+请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。
 
 Sphinx构建
 ==========
Documentation/translations/zh_CN/how-to.rst +2 -1
index e8c91d81a..84f277124 100644
@@ -106,7 +106,8 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
 sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
 可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
 的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
-安装,而不是通过 Homebrew 安装。
+安装,而不是通过 Homebrew 安装。脚本还会检查 GNU Make 4.0 或更高版本;如果
+Homebrew 将其安装为 ``gmake``,请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。
 
 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户
 sphinx 虚拟环境,即只需要执行::
tools/docs/sphinx-pre-install +51 -1

70 lines not on this page · raw message

Signature · 1 line
2.50.1 (Apple Git-155)
#11 lore raw

Re: [PATCH v1 2/2] docs: sphinx-pre-install: check GNU Make version

Quoted 94 lines · On Sun, 9 Aug 2026 18:19:21 +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. If make is missing or too old, report it as a missing dependency. Also accept a compatible gmake command, which is how Homebrew provides GNU Make on macOS.

Document the requirement and the macOS gmake fallback.

---
 Documentation/doc-guide/sphinx.rst            |  4 +-
 .../translations/zh_CN/doc-guide/sphinx.rst   |  2 +
 Documentation/translations/zh_CN/how-to.rst   |  3 +-
 tools/docs/sphinx-pre-install                 | 52 ++++++++++++++++++-
 4 files changed, 58 insertions(+), 3 deletions(-)
Documentation/doc-guide/sphinx.rst +3 -1
index 62aca56b8..d9b9e025f 100644
@@ -136,7 +136,9 @@ commands are printed without ``sudo``. The PDF dependencies are provided by
 the ``mactex`` cask; use ``--no-pdf`` when only building HTML documentation.
 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
 ---------------------------------
Documentation/translations/zh_CN/doc-guide/sphinx.rst +2 -0
index 154142318..93f27d35a 100644
@@ -114,6 +114,8 @@ PDF和LaTeX构建
 ``sudo``。PDF 依赖通过 ``mactex`` cask 提供;如果只构建 HTML 文档,请使用
 ``--no-pdf``。macOS 用户建议使用默认的 Python 虚拟环境,因为 PyYAML 会从
 ``Documentation/sphinx/requirements.txt`` 安装,而不是通过 Homebrew 安装。
+脚本还会检查 GNU Make 4.0 或更高版本;如果 Homebrew 将其安装为 ``gmake``,
+请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。
 
 Sphinx构建
 ==========
Documentation/translations/zh_CN/how-to.rst +2 -1
index e8c91d81a..84f277124 100644
@@ -106,7 +106,8 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
 sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
 可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
 的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
-安装,而不是通过 Homebrew 安装。
+安装,而不是通过 Homebrew 安装。脚本还会检查 GNU Make 4.0 或更高版本;如果
+Homebrew 将其安装为 ``gmake``,请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。
 
 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户
 sphinx 虚拟环境,即只需要执行::
tools/docs/sphinx-pre-install +18 -0
index 51a296cc7..079655078 100755
@@ -40,6 +40,7 @@ from kdoc.python_version import PythonVersion
 
 RECOMMENDED_VERSION = PythonVersion("3.4.3").version
 MIN_PYTHON_VERSION = PythonVersion("3.7").version
+MIN_MAKE_VERSION = PythonVersion("4.0").version
 
 
 class DepManager:
@@ -308,6 +309,55 @@ class MissingCheckers(AncillaryMethods):
 
         return None
 
+    def get_make_version(self, cmd):
+        """Get the GNU Make version, or None if cmd is not GNU Make."""
+        if not cmd:
+            return None
+
+        try:
+            result = self.run(
+                [cmd, "--version"],
+                capture_output=True,
+                text=True,
+                check=True,
+            )
+        except (subprocess.CalledProcessError, FileNotFoundError):
+            return None
+
+        match = re.search(
+            r"^GNU Make\s+([0-9]+(?:\.[0-9]+)*)", result.stdout, re.MULTILINE

tools/docs/sphinx-pre-install class MissingCheckers(AncillaryMethods): · line 338

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+        )
+        if not match:
+            return None
+
+        return PythonVersion.parse_version(match.group(1))
+
+    def check_make(self):
+        """Check for GNU Make 4.0 or newer."""
+        make = self.which("make")
+        version = self.get_make_version(make)

I would invert the check: test first for "gmake", and then for "make".

Lots of Linux distros have an alias for gmake, like on Fedora:

	lrwxrwxrwx 1 root root        4 Apr 24 21:33 /usr/bin/gmake -> make
	-rwxr-xr-x 1 root root   287384 Apr 24 21:33 /usr/bin/make

Yet, I would do it on a different way:

make = self.which("gmake")
if not make:
make = self.which("make")

version = self.get_make_version(make)

This should simplify the code a little bit.

Quoted 9 lines
tools/docs/sphinx-pre-install +9 -0
+
+        if version and version >= MIN_MAKE_VERSION:
+            return
+
+        # macOS commonly has an incompatible /usr/bin/make, while Homebrew
+        # installs GNU Make as gmake. Also accept gmake on other systems when
+        # it is the only compatible command available.
+        gmake = self.which("gmake")
+        gmake_version = self.get_make_version(gmake)

tools/docs/sphinx-pre-install class MissingCheckers(AncillaryMethods): · line 357

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+        if gmake_version and gmake_version >= MIN_MAKE_VERSION:
+            make_name = os.path.basename(make) if make else "make"
+            gmake_name = os.path.basename(gmake)
+            make_ver = PythonVersion.ver_str(version) if version else "unknown"
+            gmake_ver = PythonVersion.ver_str(gmake_version)
+            print(
+                f"Note: {make_name} ({make_ver}) does not meet the GNU Make "
+                f"requirement; use {gmake_name} ({gmake_ver}) instead."
+            )
+            return

With that, you probably can remove most of the above.

Btw, you likely need to teach tools/docs/sphinx-build-wrapper to also consider gmake binary, as it can run make internally to generate info and Rust docs.

Thanks,
Mauro

author
#12 lore raw

Re: [PATCH v1 2/2] docs: sphinx-pre-install: check GNU Make version

Quoted 118 lines · Mauro Carvalho Chehab <[email protected]> 于2026年8月10日周一 01:18写道:
Quoted 94 lines · On Sun, 9 Aug 2026 18:19:21 +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. If make is missing or too old, report it as a missing dependency. Also accept a compatible gmake command, which is how Homebrew provides GNU Make on macOS.

Document the requirement and the macOS gmake fallback.

---
 Documentation/doc-guide/sphinx.rst            |  4 +-
 .../translations/zh_CN/doc-guide/sphinx.rst   |  2 +
 Documentation/translations/zh_CN/how-to.rst   |  3 +-
 tools/docs/sphinx-pre-install                 | 52 ++++++++++++++++++-
 4 files changed, 58 insertions(+), 3 deletions(-)
Documentation/doc-guide/sphinx.rst +3 -1
index 62aca56b8..d9b9e025f 100644
@@ -136,7 +136,9 @@ commands are printed without ``sudo``. The PDF dependencies are provided by
 the ``mactex`` cask; use ``--no-pdf`` when only building HTML documentation.
 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
 ---------------------------------
Documentation/translations/zh_CN/doc-guide/sphinx.rst +2 -0
index 154142318..93f27d35a 100644
@@ -114,6 +114,8 @@ PDF和LaTeX构建
 ``sudo``。PDF 依赖通过 ``mactex`` cask 提供;如果只构建 HTML 文档,请使用
 ``--no-pdf``。macOS 用户建议使用默认的 Python 虚拟环境,因为 PyYAML 会从
 ``Documentation/sphinx/requirements.txt`` 安装,而不是通过 Homebrew 安装。
+脚本还会检查 GNU Make 4.0 或更高版本;如果 Homebrew 将其安装为 ``gmake``,
+请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。
 
 Sphinx构建
 ==========
Documentation/translations/zh_CN/how-to.rst +2 -1
index e8c91d81a..84f277124 100644
@@ -106,7 +106,8 @@ Linux 发行版和简单地使用 Linux 命令行,那么可以迅速开始了
 sudo。PDF 构建所需的 MacTeX 通过 Homebrew cask 安装;如果只构建 HTML 文档,
 可以执行 ``./tools/docs/sphinx-pre-install --no-pdf``。macOS 用户建议使用默认
 的 Python 虚拟环境,因为 PyYAML 会从 ``Documentation/sphinx/requirements.txt``
-安装,而不是通过 Homebrew 安装。
+安装,而不是通过 Homebrew 安装。脚本还会检查 GNU Make 4.0 或更高版本;如果
+Homebrew 将其安装为 ``gmake``,请使用 ``gmake htmldocs``,而不是 ``make htmldocs``。
 
 如果您处于一个多用户环境中,为了避免对其他人造成影响,建议您配置单用户
 sphinx 虚拟环境,即只需要执行::
tools/docs/sphinx-pre-install +18 -0
index 51a296cc7..079655078 100755
@@ -40,6 +40,7 @@ from kdoc.python_version import PythonVersion
 
 RECOMMENDED_VERSION = PythonVersion("3.4.3").version
 MIN_PYTHON_VERSION = PythonVersion("3.7").version
+MIN_MAKE_VERSION = PythonVersion("4.0").version
 
 
 class DepManager:
@@ -308,6 +309,55 @@ class MissingCheckers(AncillaryMethods):
 
         return None
 
+    def get_make_version(self, cmd):
+        """Get the GNU Make version, or None if cmd is not GNU Make."""
+        if not cmd:
+            return None
+
+        try:
+            result = self.run(
+                [cmd, "--version"],
+                capture_output=True,
+                text=True,
+                check=True,
+            )
+        except (subprocess.CalledProcessError, FileNotFoundError):
+            return None
+
+        match = re.search(
+            r"^GNU Make\s+([0-9]+(?:\.[0-9]+)*)", result.stdout, re.MULTILINE

tools/docs/sphinx-pre-install class MissingCheckers(AncillaryMethods): · line 338

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+        )
+        if not match:
+            return None
+
+        return PythonVersion.parse_version(match.group(1))
+
+    def check_make(self):
+        """Check for GNU Make 4.0 or newer."""
+        make = self.which("make")
+        version = self.get_make_version(make)

I would invert the check: test first for "gmake", and then for "make".

Lots of Linux distros have an alias for gmake, like on Fedora:

        lrwxrwxrwx 1 root root        4 Apr 24 21:33 /usr/bin/gmake -> make
        -rwxr-xr-x 1 root root   287384 Apr 24 21:33 /usr/bin/make

Yet, I would do it on a different way:

Quoted 8 lines

make = self.which("gmake")
if not make:
make = self.which("make")

version = self.get_make_version(make)

This should simplify the code a little bit.

Yes, I overlooked that. I'll fix it in the next revision.

Quoted 23 lines
Quoted 10 lines
tools/docs/sphinx-pre-install +9 -0
+
+        if version and version >= MIN_MAKE_VERSION:
+            return
+
+        # macOS commonly has an incompatible /usr/bin/make, while Homebrew
+        # installs GNU Make as gmake. Also accept gmake on other systems when
+        # it is the only compatible command available.
+        gmake = self.which("gmake")
+        gmake_version = self.get_make_version(gmake)

tools/docs/sphinx-pre-install class MissingCheckers(AncillaryMethods): · line 357

Quoted 10 lines
tools/docs/sphinx-pre-install +10 -0
+        if gmake_version and gmake_version >= MIN_MAKE_VERSION:
+            make_name = os.path.basename(make) if make else "make"
+            gmake_name = os.path.basename(gmake)
+            make_ver = PythonVersion.ver_str(version) if version else "unknown"
+            gmake_ver = PythonVersion.ver_str(gmake_version)
+            print(
+                f"Note: {make_name} ({make_ver}) does not meet the GNU Make "
+                f"requirement; use {gmake_name} ({gmake_ver}) instead."
+            )
+            return

With that, you probably can remove most of the above.

Quoted 7 lines

Btw, you likely need to teach tools/docs/sphinx-build-wrapper to also consider gmake binary, as it can run make internally to generate info and Rust docs.

Thanks,
Mauro

I'll add a separate patch in the next series to handle tools/docs/sphinx-build-wrapper.

Thanks,
Chen Miao