[PATCH v2 2/5] docs: sphinx-pre-install: check GNU Make version
Chen Miao <[email protected]>
| Newsgroups | org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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. Document the requirement and the macOS gmake invocation. Signed-off-by: Chen Miao <[email protected]> --- Documentation/doc-guide/sphinx.rst | 4 ++- tools/docs/sphinx-pre-install | 41 +++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Documentation/doc-guide/sphinx.rst b/Documentation/doc-guide/sphinx.rst index 1e105542a..4fb716e77 100644 --- a/Documentation/doc-guide/sphinx.rst +++ b/Documentation/doc-guide/sphinx.rst @@ -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 --------------------------------- diff --git a/tools/docs/sphinx-pre-install b/tools/docs/sphinx-pre-install index 1b9d77ec3..54f36c3b8 100755 --- a/tools/docs/sphinx-pre-install +++ b/tools/docs/sphinx-pre-install @@ -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,44 @@ 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 (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 check_make(self): + """Check for GNU Make 4.0 or newer.""" + candidates = ( + os.environ.get("MAKE"), + self.which("gmake"), + self.which("make"), + ) + + for make in candidates: + version = self.get_make_version(make) + if version and version >= MIN_MAKE_VERSION: + 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 +1598,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) -- 2.50.1 (Apple Git-155)