[Buildroot] [PATCH] Makefile: optimize umask setting

Guido Martínez guido at vanguardiasur.com.ar
Thu Jul 16 21:55:17 UTC 2015


When using make to build multiple targets ("make a b ..."), the makefile
would get called individually for each target, making the build a lot
slower since every Makefile in BR's tree was parsed each time.

Fix this by making every invoked target depend on an "_all" rule, and
doing the real work there, only one time. This is similar to the logic
used in the generated makefile (support/scripts/mkmakefile).

Signed-off-by: Guido Martínez <guido at vanguardiasur.com.ar>
---
 Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 531ac5d..f50f767 100644
--- a/Makefile
+++ b/Makefile
@@ -27,13 +27,13 @@
 # Trick for always running with a fixed umask
 UMASK=0022
 ifneq ($(shell umask),$(UMASK))
-.PHONY: all $(MAKECMDGOALS)
+.PHONY: _all
 
-all:
-	@umask $(UMASK) && $(MAKE) --no-print-directory
+$(MAKECMDGOALS): _all
+	@:
 
-$(MAKECMDGOALS):
-	@umask $(UMASK) && $(MAKE) --no-print-directory $@
+_all:
+	@umask $(UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS)
 
 else # umask
 
-- 
2.1.4




More information about the buildroot mailing list