On Thu, Dec 1, 2022 at 8:18 AM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote: > > On Wed, Nov 30, 2022 at 2:10 AM Dmitry Goncharov > <dgoncharov@xxxxxxxxxxxx> wrote: > > > > Port silent mode detection to the future (post make-4.4) versions of gnu make. > > > > Makefile contains the following piece of make code to detect if option -s is > > specified on the command line. > > > > ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) > > > > > > This code is executed by make at parse time and assumes that MAKEFLAGS > > does not contain command line variable definitions. > > Currently if the user defines a=s on the command line, then at build only > > time MAKEFLAGS contains " -- a=s". > > However, starting with commit dc2d963989b96161472b2cd38cef5d1f4851ea34 > > MAKEFLAGS contains command line definitions at both parse time and > > build time. > > > > This '-s' detection code then confuses a command line variable > > definition which contains letter 's' with option -s. > > > > E.g. > > $ # old make > > $ make net/wireless/ocb.o a=s > > CALL scripts/checksyscalls.sh > > DESCEND objtool > > $ # this a new make which defines makeflags at parse time > > $ ~/src/gmake/make/l64/make net/wireless/ocb.o a=s > > $ > > > > We can see here that the letter 's' from 'a=s' was confused with -s. > > > > This patch checks for presence of -s using a method recommended by the > > make manual here > > https://www.gnu.org/software/make/manual/make.html#Testing-Flags. > > > > > The GNU Make manual is written with the latest Make version in mind. > > > "Recall that MAKEFLAGS will put all single-letter options (such as ‘-t’) > into the first word, and that word will be empty if no single-letter > options were given." > > This statement is not true for GNU Make 3.82, which the kbuild supports. > > > > > $ git show 6f0fa58 > commit 6f0fa58e459642b16901521cc58ac474b787ec5b > Author: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> > Date: Fri May 19 20:42:30 2017 +0900 > > kbuild: simplify silent build (-s) detection > > > [snip] > > Test cases: > > [1] command line input: make --silent > -> MAKEFLAGS for Make 3.8x: s > -> MAKEFLAGS for Make 4.x : s > > [2] command line input: make -srR > -> MAKEFLAGS for Make 3.8x: sRr > -> MAKEFLAGS for Make 4.x : rRs > > [3] command line input: make -s -rR --warn-undefined-variables > -> MAKEFLAGS for Make 3.8x: --warn-undefined-variables -sRr > -> MAKEFLAGS for Make 4.x : rRs --warn-undefined-variables > > > > > > > > > As this commit description says, Make 3.8x puts long > options before the collection of single letter options. > > So, this patch does not work for Make 3.82. > I think the following code will work for 3.82, 4.x, and future releases. diff --git a/Makefile b/Makefile index 78525ebea876..58dfd7475448 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ endif # If the user is running make -s (silent mode), suppress echoing of # commands -ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) +ifneq ($(findstring s,$(filter-out --%,$(filter -%,-$(MAKEFLAGS)))),) quiet=silent_ KBUILD_VERBOSE = 0 endif -- Best Regards Masahiro Yamada