6ca6e8
commit f42d871b22f7eb5330e77ed9bccbb447c44e7101
6ca6e8
Author: Sergei Trofimovich <slyich@gmail.com>
6ca6e8
Date:   Tue Sep 13 13:39:13 2022 -0400
6ca6e8
6ca6e8
    Makerules: fix MAKEFLAGS assignment for upcoming make-4.4 [BZ# 29564]
6ca6e8
    
6ca6e8
    make-4.4 will add long flags to MAKEFLAGS variable:
6ca6e8
    
6ca6e8
        * WARNING: Backward-incompatibility!
6ca6e8
          Previously only simple (one-letter) options were added to the MAKEFLAGS
6ca6e8
          variable that was visible while parsing makefiles.  Now, all options
6ca6e8
          are available in MAKEFLAGS.
6ca6e8
    
6ca6e8
    This causes locale builds to fail when long options are used:
6ca6e8
    
6ca6e8
        $ make --shuffle
6ca6e8
        ...
6ca6e8
        make  -C localedata install-locales
6ca6e8
        make: invalid shuffle mode: '1662724426r'
6ca6e8
    
6ca6e8
    The change fixes it by passing eash option via whitespace and dashes.
6ca6e8
    That way option is appended to both single-word form and whitespace
6ca6e8
    separated form.
6ca6e8
    
6ca6e8
    While at it fixed --silent mode detection in $(MAKEFLAGS) by filtering
6ca6e8
    out --long-options. Otherwise options like --shuffle flag enable silent
6ca6e8
    mode unintentionally. $(silent-make) variable consolidates the checks.
6ca6e8
    
6ca6e8
    Resolves: BZ# 29564
6ca6e8
    
6ca6e8
    CC: Paul Smith <psmith@gnu.org>
6ca6e8
    CC: Siddhesh Poyarekar <siddhesh@gotplt.org>
6ca6e8
    Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
6ca6e8
    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
6ca6e8
    (cherry picked from commit 2d7ed98add14f75041499ac189696c9bd3d757fe)
6ca6e8
6ca6e8
diff --git a/Makeconfig b/Makeconfig
6ca6e8
index 99898a632a64be91..4e04dafb76a1e1a1 100644
6ca6e8
--- a/Makeconfig
6ca6e8
+++ b/Makeconfig
6ca6e8
@@ -43,6 +43,22 @@ else
6ca6e8
 $(error objdir must be defined by the build-directory Makefile)
6ca6e8
 endif
6ca6e8
 
6ca6e8
+# Did we request 'make -s' run? "yes" or "no".
6ca6e8
+# Starting from make-4.4 MAKEFLAGS now contains long
6ca6e8
+# options like '--shuffle'. To detect presence of 's'
6ca6e8
+# we pick first word with short options. Long options
6ca6e8
+# are guaranteed to come after whitespace. We use '-'
6ca6e8
+# prefix to always have a word before long options
6ca6e8
+# even if no short options were passed.
6ca6e8
+# Typical MAKEFLAGS values to watch for:
6ca6e8
+#   "rs --shuffle=42" (silent)
6ca6e8
+#   " --shuffle" (not silent)
6ca6e8
+ifeq ($(findstring s, $(firstword -$(MAKEFLAGS))),)
6ca6e8
+silent-make := no
6ca6e8
+else
6ca6e8
+silent-make := yes
6ca6e8
+endif
6ca6e8
+
6ca6e8
 # Root of the sysdeps tree.
6ca6e8
 sysdep_dir := $(..)sysdeps
6ca6e8
 export sysdep_dir := $(sysdep_dir)
6ca6e8
@@ -918,7 +934,7 @@ endif
6ca6e8
 # umpteen zillion filenames along with it (we use `...' instead)
6ca6e8
 # but we don't want this echoing done when the user has said
6ca6e8
 # he doesn't want to see commands echoed by using -s.
6ca6e8
-ifneq	"$(findstring s,$(MAKEFLAGS))" ""	# if -s
6ca6e8
+ifeq ($(silent-make),yes)			# if -s
6ca6e8
 +cmdecho	:= echo >/dev/null
6ca6e8
 else						# not -s
6ca6e8
 +cmdecho	:= echo
6ca6e8
diff --git a/Makerules b/Makerules
6ca6e8
index 7fbe85719aacc230..e5916f29fa0d4593 100644
6ca6e8
--- a/Makerules
6ca6e8
+++ b/Makerules
6ca6e8
@@ -810,7 +810,7 @@ endif
6ca6e8
 # Maximize efficiency by minimizing the number of rules.
6ca6e8
 .SUFFIXES:	# Clear the suffix list.  We don't use suffix rules.
6ca6e8
 # Don't define any builtin rules.
6ca6e8
-MAKEFLAGS := $(MAKEFLAGS)r
6ca6e8
+MAKEFLAGS := $(MAKEFLAGS) -r
6ca6e8
 
6ca6e8
 # Generic rule for making directories.
6ca6e8
 %/:
6ca6e8
@@ -827,7 +827,7 @@ MAKEFLAGS := $(MAKEFLAGS)r
6ca6e8
 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
6ca6e8
 
6ca6e8
 # Use the verbose option of ar and tar when not running silently.
6ca6e8
-ifeq	"$(findstring s,$(MAKEFLAGS))" ""	# if not -s
6ca6e8
+ifeq ($(silent-make),no)			# if not -s
6ca6e8
 verbose := v
6ca6e8
 else	   					# -s
6ca6e8
 verbose	:=
6ca6e8
diff --git a/elf/rtld-Rules b/elf/rtld-Rules
6ca6e8
index 10de81918c07670f..a452536d39b5c198 100644
6ca6e8
--- a/elf/rtld-Rules
6ca6e8
+++ b/elf/rtld-Rules
6ca6e8
@@ -52,7 +52,7 @@ $(objpfx)rtld-libc.a: $(foreach dir,$(rtld-subdirs),\
6ca6e8
 	mv -f $@T $@
6ca6e8
 
6ca6e8
 # Use the verbose option of ar and tar when not running silently.
6ca6e8
-ifeq	"$(findstring s,$(MAKEFLAGS))" ""	# if not -s
6ca6e8
+ifeq ($(silent-make),no)			# if not -s
6ca6e8
 verbose := v
6ca6e8
 else						# -s
6ca6e8
 verbose	:=