RHEL/CentOS 7, a popular distribution that installs GNU Make 3.82,
reached EOM/EOL on June 30, 2024. While you may get extended support,
it is a good time to raise the minimum GNU Make version.

The new requirement, GNU Make 4.0, was released in October, 2013.

This follows Linux commit 5f99665ee8f4 ("kbuild: raise the minimum
GNU Make requirement to 4.0"). Raise the enforced minimum to 4.0 and
drop the now-unreachable compatibility code for older versions:

- Add an explicit "GNU Make >= 4.0 is required" version-check gate.
- Simplify the "make -s" (silent mode) detection to a single
  unconditional check instead of branching on make-4 vs make-3.8x.
  This also changes behaviour on Make 4.x: the old check matched only
  when 's' was the last single-letter flag in MAKEFLAGS, whereas the
  new check matches 's' among them, as in Linux.
- Drop the GNU Make 3.x sub-make workaround, which is now dead code.
- Document the minimum GNU Make version in doc/build/gcc.rst.

Signed-off-by: Suraj Kakade <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
---
 Makefile          | 20 +++++---------------
 doc/build/gcc.rst |  3 +++
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index 6303a0cca6a..5abd0a7ce04 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,10 @@ NAME =
 # Comments in this file are targeted only to the developer, do not
 # expect to learn how to build the kernel reading this file.
 
+ifeq ($(filter output-sync,$(.FEATURES)),)
+$(error GNU Make >= 4.0 is required. Your Make version is $(MAKE_VERSION))
+endif
+
 $(if $(filter __%, $(MAKECMDGOALS)), \
        $(error targets prefixed with '__' are only for internal use))
 
@@ -93,15 +97,9 @@ endif
 
 # If the user is running make -s (silent mode), suppress echoing of
 # commands
-ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
-ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
-  quiet=silent_
-endif
-else                                   # make-3.8x
-ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
+ifneq ($(findstring s,$(firstword -$(MAKEFLAGS))),)
   quiet=silent_
 endif
-endif
 
 export quiet Q KBUILD_VERBOSE
 
@@ -166,14 +164,6 @@ ifneq ($(abs_srctree),$(abs_objtree))
 MAKEFLAGS += --include-dir=$(abs_srctree)
 endif
 
-ifneq ($(filter 3.%,$(MAKE_VERSION)),)
-# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
-# We need to invoke sub-make to avoid implicit rules in the top Makefile.
-need-sub-make := 1
-# Cancel implicit rules for this Makefile.
-$(this-makefile): ;
-endif
-
 export abs_srctree abs_objtree
 export sub_make_done := 1
 
diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst
index 1fef718ceec..16afe292899 100644
--- a/doc/build/gcc.rst
+++ b/doc/build/gcc.rst
@@ -7,6 +7,9 @@ Dependencies
 For building U-Boot you need a GCC compiler for your host platform. If you
 are not building on the target platform you further need  a GCC cross compiler.
 
+GNU Make 4.0 or later is required to build U-Boot. Older versions are rejected
+with an error at the start of the build.
+
 Debian based
 ~~~~~~~~~~~~
 
-- 
2.43.7

Reply via email to