Makefile: identify silent make via firstword findstring
PATCH 1/1 Makefile: identify silent make via firstword findstring
Make recommends using this technique for identifying short options.
From make NEWS for upcoming version 4.4:
Previously only simple (one-letter) options were added to the MAKEFLAGS variable that was visible while parsing makefiles. Now, all options are available in MAKEFLAGS. If you want to check MAKEFLAGS for a one-letter option, expanding "$(firstword -$(MAKEFLAGS))" is a reliable way to return the set of one-letter options which can be examined via findstring, etc.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -434,7 +434,7 @@ PACKAGES := PACKAGES_ALL := # silent mode requested? -QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q) +QUIET := $(if $(findstring s,$(firstword -$(MAKEFLAGS))),-q) # Strip off the annoying quoting ARCH := $(call qstrip,$(BR2_ARCH))
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello James,
Quoted 1 line · On Fri, 14 Oct 2022 17:09:05 -0600 James Hilliard <[email protected]>…
+QUIET := $(if $(findstring s,$(firstword -$(MAKEFLAGS))),-q)
I must be missing something, but why is -$(MAKEFLAGS) used and not just $(MAKEFLAGS) ?
Indeed, with "make -s --debug -k", $(MAKEFLAGS) is "ks --debug=all", and therefore $(firstword $(MAKEFLAGS)) is ks, which is good enough for the findstring s, no? Why is adding a - in front needed?
Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 6 lines · Thomas Petazzoni
Hello James,
On Fri, 14 Oct 2022 17:09:05 -0600
James Hilliard <[email protected]> wrote:
Quoted 8 lines
Quoted 1 line
+QUIET := $(if $(findstring s,$(firstword -$(MAKEFLAGS))),-q)
I must be missing something, but why is -$(MAKEFLAGS) used and not just $(MAKEFLAGS) ?
Indeed, with "make -s --debug -k", $(MAKEFLAGS) is "ks --debug=all", and therefore $(firstword $(MAKEFLAGS)) is ks, which is good enough for the findstring s, no? Why is adding a - in front needed?
I think so that if $(MAKEFLAGS) doesn't have any short options that it won't accidentally match on a long option.
For example if $(MAKEFLAGS) is " --shuffle=none" the - in front ensures that we don't match the s in a long option like shuffle.
Quoted 8 lines
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 17 lines · James Hilliard
Quoted 6 lines · Thomas Petazzoni
Hello James,
On Fri, 14 Oct 2022 17:09:05 -0600
James Hilliard <[email protected]> wrote:Quoted 8 lines
Quoted 1 line
+QUIET := $(if $(findstring s,$(firstword -$(MAKEFLAGS))),-q)
I must be missing something, but why is -$(MAKEFLAGS) used and not just $(MAKEFLAGS) ?
Indeed, with "make -s --debug -k", $(MAKEFLAGS) is "ks --debug=all", and therefore $(firstword $(MAKEFLAGS)) is ks, which is good enough for the findstring s, no? Why is adding a - in front needed?
Quoted 5 lines
I think so that if $(MAKEFLAGS) doesn't have any short options that it won't accidentally match on a long option.
For example if $(MAKEFLAGS) is " --shuffle=none" the - in front ensures that we don't match the s in a long option like shuffle.
Exactly right.
However, the firstword approach doesn't work with GNU make 3.81. For example,
the following invocation:
make --no-print-directory -s
will set MAKEFLAGS to " --no-print-directory -s", so the firstword approach *doesn't* find the -s, but the filter-out approach does.
Therefore, I marked this patch as Rejected.
Regards,
Arnout
Quoted 9 lines
Quoted 9 lines
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com
Quoted 4 lines
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot