Makefile: don't depend on the umask
authorGuido Martínez <guido@vanguardiasur.com.ar>
Fri, 21 Nov 2014 16:19:00 +0000 (13:19 -0300)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 13 Jul 2015 10:57:58 +0000 (12:57 +0200)
Some packages and BR itself create files and directories on the target
with cp/mkdir/etc which depend on the umask at the time of building.

To fix this, use a trick inside the Makefile which wraps all rules when
the umask is not 0022. This sets the umask at the top level, and then
the building process continues as usual.

[Thomas: add --no-print-directory, as suggested by Arnout.]

Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>
Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tested-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Makefile

index daf692e59105fa2c5c27959c62bf1c6e5183ba68..55b1d457867e4b8e696cd8e17aae48ca5bfd2da9 100644 (file)
--- a/Makefile
+++ b/Makefile
 # You shouldn't need to mess with anything beyond this point...
 #--------------------------------------------------------------
 
+# Trick for always running with a fixed umask
+UMASK=0022
+ifneq ($(shell umask),$(UMASK))
+.PHONY: all $(MAKECMDGOALS)
+
+all:
+       @umask $(UMASK) && $(MAKE) --no-print-directory
+
+$(MAKECMDGOALS):
+       @umask $(UMASK) && $(MAKE) --no-print-directory $@
+
+else # umask
+
 # This is our default rule, so must come first
 all:
 
@@ -937,3 +950,5 @@ include docs/manual/manual.mk
 -include $(BR2_EXTERNAL)/docs/*/*.mk
 
 .PHONY: $(noconfig_targets)
+
+endif #umask