Relocatable SDK: preparatory changes
v11 cover Relocatable SDK: preparatory changes
Hi all,
Same series as v10, but with a typo fixed!
Sorry for the noise.
Regards,
Samuel
Samuel Martin (4):
core: split variables definition related to in/out-of-tree build from
O itself
core: reorder top-level Makefile and document things
core: re-enter make if $(CURDIR) or $(O) are not canonical paths
core: only remove O from MAKEOVERRIDES
Makefile | 81 ++++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 22 deletions(-)
--
2.10.0
PATCH v11 1/4 core: split variables definition related to in/out-of-tree build from O itself
This change uncorrolates the CONFIG_DIR and NEED_WRAPPER definition from the presence of the O variable in the command line.
Now, the condition used to set these variables is the value of O itself.
This change is a preparatory work since the O definition will need to be moved around when we will make Buildroot run with absolute canonical paths for both its root directory and the output location. This will be addressed in a follow-up patch.
---
changes v9->v10:
- update A/R/T tags
changes v8->v9:
- none
changes v7->v8:
- new patch
--- Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
Makefile +11 -3
@@ -109,10 +109,11 @@ endif # Include some helper macros and variables include support/misc/utils.mk +# Set O variable if not already done on the command line; +# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree +# build by preventing it from being forwarded to sub-make calls. ifneq ("$(origin O)", "command line") O := output -CONFIG_DIR := $(TOPDIR) -NEED_WRAPPER = else # other packages might also support Linux-style out of tree builds # with the O=<dir> syntax (E.G. BusyBox does). As make automatically
@@ -125,9 +126,16 @@ MAKEOVERRIDES = # Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+) # To really make O go away, we have to override it. override O := $(O) -CONFIG_DIR := $(O) # we need to pass O= everywhere we call back into the toplevel makefile EXTRAMAKEARGS = O=$(O) +endif + +# Set variables related to in-tree or out-of-tree build. +ifeq ($(O),output) +CONFIG_DIR := $(TOPDIR) +NEED_WRAPPER = +else +CONFIG_DIR := $(O) NEED_WRAPPER = y endif
Signature · 1 line
2.10.0
PATCH v11 2/4 core: reorder top-level Makefile and document things
In reply to Samuel MartinThis change only moves things around and comments what is done in the top-level Makefile file, in order to prepare the next changes.
Note that moving the definition of $(O) before or after re-entering make does not change anything on the buildroot behavior.
---
changes v10->v11:
- fix typos in umask variable
changes v9->v10:
- new patch (Arnout)
- s/:=/=/ in CUR_MASK assignation (Arnout)
--- Makefile | 57 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 25 deletions(-)
Makefile +32 -25
@@ -29,16 +29,44 @@ SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi; fi) -# Trick for always running with a fixed umask -UMASK = 0022 -ifneq ($(shell umask),$(UMASK)) +# Set O variable if not already done on the command line; +# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree +# build by preventing it from being forwarded to sub-make calls. +ifneq ("$(origin O)", "command line") +O := output +else +# Other packages might also support Linux-style out of tree builds +# with the O=<dir> syntax (E.G. BusyBox does). As make automatically +# forwards command line variable definitions those packages get very +# confused. Fix this by telling make to not do so. +MAKEOVERRIDES := +# Strangely enough O is still passed to submakes with MAKEOVERRIDES +# (with make 3.81 atleast), the only thing that changes is the output +# of the origin function (command line -> environment). +# Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+) +# To really make O go away, we have to override it. +override O := $(O) +endif + +# Check if the current Buildroot execution meets all the pre-requisites. +# If they are not met, Buildroot will actually do its job in a sub-make meeting +# its pre-requisites, which is: +# 1- Permissive enough umask: +# Wrong or too restrictive umask will prevent Buildroot and packages from +# creating files and directories. + +CUR_UMASK = $(shell umask) +REQ_UMASK = 0022 + +# Check Buildroot execution pre-requisites here. +ifneq ($(CUR_UMASK),$(REQ_UMASK)) .PHONY: _all $(MAKECMDGOALS) $(MAKECMDGOALS): _all @: _all: - @umask $(UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS) + @umask $(REQ_UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS) else # umask
@@ -109,27 +137,6 @@ endif # Include some helper macros and variables include support/misc/utils.mk -# Set O variable if not already done on the command line; -# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree -# build by preventing it from being forwarded to sub-make calls. -ifneq ("$(origin O)", "command line") -O := output -else -# other packages might also support Linux-style out of tree builds -# with the O=<dir> syntax (E.G. BusyBox does). As make automatically -# forwards command line variable definitions those packages get very -# confused. Fix this by telling make to not do so -MAKEOVERRIDES = -# strangely enough O is still passed to submakes with MAKEOVERRIDES -# (with make 3.81 atleast), the only thing that changes is the output -# of the origin function (command line -> environment). -# Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+) -# To really make O go away, we have to override it. -override O := $(O) -# we need to pass O= everywhere we call back into the toplevel makefile -EXTRAMAKEARGS = O=$(O) -endif - # Set variables related to in-tree or out-of-tree build. ifeq ($(O),output) CONFIG_DIR := $(TOPDIR)
Signature · 1 line
2.10.0
PATCH v11 3/4 core: re-enter make if $(CURDIR) or $(O) are not canonical paths
In reply to Samuel MartinWhen $(CURDIR) and/or $(O) contain symlinks in their paths, they can be resolved differently, depending on each package build-system (whether it uses the given paths or get the absolute canonical ones).
Using absolute canonical paths will help achieving reproducible builds and will make easier tracking down host machine paths leaking into the host, target or staging trees.
So, this change ensure the build takes place with the CURDIR and O variables are set to their absolute canonical paths.
In order to recall the toplevel makefile with absolute canonical paths for $(CURDIR) and $(O), we need to:
1- Compute the absolute canonical paths for $(CURDIR) and $(O) that will
be passed to the sub-make. This is achieved using the 'realpath' make primitive. However, some care must be taken when manipulating O:
- the out-of-tree makefile wrapper happens a trailing "/.", we need to strip this part away to not break the comparison driving the sub-make call;
- the user can leave a trailing '/' to $(O);
- according to [1,2], realpath returns an empty string in case of non-existing entry. So, to avoid passing an empty O= variable to sub-make, it is necessary to define the output directory and create it prior to call realpath on it (because on the first invocation, $(O) usually does not yet exists), hence the trick doing the mkdir right before calling realpath.
2- Update EXTRAMAKEARGS with the absolute canonical $(O) and use it
when call recalling the top-level makefile with umask and paths correctly set.
3- Lastly, update the condition for setting the CONFIG_DIR and
NEED_WRAPPER variables.
Note:
* This change takes care of the makefile wrapper installed in $(O) to avoid unneeded make recursion.
[1] https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html
[2] http://man7.org/linux/man-pages/man3/realpath.3.html
---
changes v9->v10:
- only keep what is about checking umask and canonical paths for CWD and O (Arnout)
- fix assignation (Arnout)
- remove the unrelated MAKEOVERRIDES cleanup (Arnout)
- fixes typos in commit log (Arnout)
changes v8->v9:
- none
changes v7->v8:
- keep @ at the beginning of the command (Yann)
- make ifneq condition easier to read/parsed (Yann)
- fix O definition before re-entering make (Reported by Matthew)
- use EXTRAMAKEARGS when re-entering make
- update the condition for CONFIG_DIR and NEED_WRAPPER
changes v6->v7:
- none
changes v5->v6:
- new patch
--- Makefile | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
Makefile +29 -8
@@ -33,7 +33,7 @@ SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ # or avoid confusing packages that can use the O=<dir> syntax for out-of-tree # build by preventing it from being forwarded to sub-make calls. ifneq ("$(origin O)", "command line") -O := output +O := $(CURDIR)/output else # Other packages might also support Linux-style out of tree builds # with the O=<dir> syntax (E.G. BusyBox does). As make automatically
@@ -50,25 +50,45 @@ endif # Check if the current Buildroot execution meets all the pre-requisites. # If they are not met, Buildroot will actually do its job in a sub-make meeting -# its pre-requisites, which is: +# its pre-requisites, which are: # 1- Permissive enough umask: # Wrong or too restrictive umask will prevent Buildroot and packages from # creating files and directories. +# 2- Absolute canonical CWD (i.e. $(CURDIR)): +# Otherwise, some packages will use CWD as-is, others will compute its +# absolute canonical path. This makes harder tracking and fixing host +# machine path leaks. +# 3- Absolute canonical output location (i.e. $(O)): +# For the same reason as the one for CWD. + +# Remove the trailing '/.' from $(O) as it can be added by the makefile wrapper +# installed in the $(O) directory. +# Also remove the trailing '/' the user can set when on the command line. +override O := $(patsubst %/,%,$(patsubst %.,%,$(O))) +CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O)) + +CANONICAL_CURDIR = $(realpath $(CURDIR)) CUR_UMASK = $(shell umask) REQ_UMASK = 0022 +# Make sure O= is passed (with its absolute canonical path) everywhere the +# toplevel makefile is called back. +EXTRAMAKEARGS := O=$(CANONICAL_O) + # Check Buildroot execution pre-requisites here. -ifneq ($(CUR_UMASK),$(REQ_UMASK)) +ifneq ($(CUR_UMASK):$(CURDIR):$(O),$(REQ_UMASK):$(CANONICAL_CURDIR):$(CANONICAL_O)) .PHONY: _all $(MAKECMDGOALS) $(MAKECMDGOALS): _all @: _all: - @umask $(REQ_UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS) + @umask $(REQ_UMASK) && \ + $(MAKE) -C $(CANONICAL_CURDIR) --no-print-directory \ + $(MAKECMDGOALS) $(EXTRAMAKEARGS) -else # umask +else # umask / $(CURDIR) / $(O) # This is our default rule, so must come first all:
@@ -138,8 +158,9 @@ endif include support/misc/utils.mk # Set variables related to in-tree or out-of-tree build. -ifeq ($(O),output) -CONFIG_DIR := $(TOPDIR) +# Here, both $(O) and $(CURDIR) are absolute canonical paths. +ifeq ($(O),$(CURDIR)/output) +CONFIG_DIR := $(CURDIR) NEED_WRAPPER = else CONFIG_DIR := $(O)
@@ -1036,4 +1057,4 @@ include docs/manual/manual.mk .PHONY: $(noconfig_targets) -endif #umask +endif #umask / $(CURDIR) / $(O)
Signature · 1 line
2.10.0
PATCH v11 4/4 core: only remove O from MAKEOVERRIDES
In reply to Samuel MartinFor no apparent reason, MAKEOVERRIDES is not treated the same way depending on whether O is set or not on the command line:
* when O is set on the command line (i.e. out-of-tree build): all variables were stripped away from MAKEOVERRIDES;
* when O is not set on the command line (i.e. in-Buildroot-source-tree build): all variables are kept and forwarded to the sub-make call.
This change cleans things up by only removing the relevant variables from MAKEOVERRIDES when appropriate (i.e. removing O from MAKEOVERRIDES when O is set on the command line) keeping all other variables as-is in the sub-make call; O is set on the sub-make call anyway.
---
changes v9->v10:
- new patch
--- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
@@ -38,8 +38,9 @@ else # Other packages might also support Linux-style out of tree builds # with the O=<dir> syntax (E.G. BusyBox does). As make automatically # forwards command line variable definitions those packages get very -# confused. Fix this by telling make to not do so. -MAKEOVERRIDES := +# confused. Fix this by telling make to not do so, only for O=..., but +# keep all others (such as BR2_EXTERNAL, BR2_DL_DIR, etc). +MAKEOVERRIDES := $(filter-out O=%,$(MAKEOVERRIDES)) # Strangely enough O is still passed to submakes with MAKEOVERRIDES # (with make 3.81 atleast), the only thing that changes is the output # of the origin function (command line -> environment).
Signature · 1 line
2.10.0
PATCH v11 2/4 core: reorder top-level Makefile and document things
In reply to Samuel MartinQuoted 2 lines · Samuel Martin
This change only moves things around and comments what is done in the top-level
Makefilefile, in order to prepare the next changes.
Well, you actually also missed something in the move (see below), you rename
UMASK to REQ_UMASK, and you introduce CUR_UMASK.
Quoted 50 lines
Note that moving the definition of $(O) before or after re-entering make does not change anything on the buildroot behavior.
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>Signed-off-by Samuel Martin <[email protected]>---
changesv10->v11:
- fix typos in umask variablechanges
v9->v10:
- new patch (Arnout)
- s/:=/=/ inCUR_MASKassignation (Arnout)--- Makefile | 57 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 25 deletions(-)Makefile +21
-3@@ -29,16 +29,44 @@ SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi; fi) -# Trick for always running with a fixed umask -UMASK = 0022 -ifneq ($(shell umask),$(UMASK)) +# Set O variable if not already done on the command line; +# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree +# build by preventing it from being forwarded to sub-make calls. +ifneq ("$(origin O)", "command line") +O := output +else +# Other packages might also support Linux-style out of tree builds +# with the O=<dir> syntax (E.G. BusyBox does). As make automatically +# forwards command line variable definitions those packages get very +# confused. Fix this by telling make to not do so. +MAKEOVERRIDES := +# Strangely enough O is still passed to submakes with MAKEOVERRIDES +# (with make 3.81 atleast), the only thing that changes is the output +# of the origin function (command line -> environment). +# Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+) +# To really make O go away, we have to override it. +override O := $(O) +endif + +# Check if the current Buildroot execution meets all the pre-requisites. +# If they are not met, Buildroot will actually do its job in a sub-make meeting
Makefile SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ · line 62
Quoted 10 lines
Makefile +10
-0+# its pre-requisites, which is: +# 1- Permissive enough umask: +# Wrong or too restrictive umask will prevent Buildroot and packages from +# creating files and directories. + +CUR_UMASK = $(shell umask) +REQ_UMASK = 0022 + +# Check Buildroot execution pre-requisites here. +ifneq ($(CUR_UMASK),$(REQ_UMASK))
I think I said it before: I don't like it when a variable (CUR_UMASK) is used
only once. IMHO it makes understanding the code more complicated, not simpler.
But I'll accept it this way too. So you can add my
after fixing up the commit message and the missed EXTRAMAKEARGS (see below), whether or not you change this CUR_UMASK. Or Thomas/Peter can do that while applying.
Quoted 24 lines
Makefile +1
-10.PHONY: _all $(MAKECMDGOALS) $(MAKECMDGOALS): _all @: _all: - @umask $(UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS) + @umask $(REQ_UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS) else # umask@@ -109,27 +137,6 @@ endif # Include some helper macros and variables include support/misc/utils.mk -# Set O variable if not already done on the command line; -# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree -# build by preventing it from being forwarded to sub-make calls. -ifneq ("$(origin O)", "command line") -O := output -else -# other packages might also support Linux-style out of tree builds -# with the O=<dir> syntax (E.G. BusyBox does). As make automatically -# forwards command line variable definitions those packages get very
Makefile endif · line 130
Quoted 10 lines
Makefile +0
-10-# confused. Fix this by telling make to not do so -MAKEOVERRIDES = -# strangely enough O is still passed to submakes with MAKEOVERRIDES -# (with make 3.81 atleast), the only thing that changes is the output -# of the origin function (command line -> environment). -# Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+) -# To really make O go away, we have to override it. -override O := $(O) -# we need to pass O= everywhere we call back into the toplevel makefile -EXTRAMAKEARGS = O=$(O)
This bit got removed. It is reintroduced in patch 3/4 that's why you didn't notice.
Regards,
Arnout
Quoted 6 lines
Makefile +0
-2-endif - # Set variables related to in-tree or out-of-tree build. ifeq ($(O),output) CONFIG_DIR := $(TOPDIR)
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH v11 3/4 core: re-enter make if $(CURDIR) or $(O) are not canonical paths
In reply to Samuel MartinQuoted 8 lines · Samuel Martin
When $(CURDIR) and/or $(O) contain symlinks in their paths, they can be resolved differently, depending on each package build-system (whether it uses the given paths or get the absolute canonical ones).
Using absolute canonical paths will help achieving reproducible builds and will make easier tracking down host machine paths leaking into the host, target or staging trees.
So, this change ensure the build takes place with the CURDIR and O
^s
Quoted 14 lines
variables are set to their absolute canonical paths.
In order to recall the toplevel makefile with absolute canonical paths for $(CURDIR) and $(O), we need to:
1- Compute the absolute canonical paths for $(CURDIR) and $(O) that will
be passed to the sub-make. This is achieved using the 'realpath' make primitive. However, some care must be taken when manipulating O:
- the out-of-tree makefile wrapper happens a trailing "/.", we need to strip this part away to not break the comparison driving the sub-make call;
- the user can leave a trailing '/' to $(O);
- according to [1,2], realpath returns an empty string in case of non-existing entry. So, to avoid passing an empty O= variable to sub-make, it is necessary to define the output directory and create
Quoted 8 lines
it prior to call realpath on it (because on the first invocation, $(O) usually does not yet exists), hence the trick doing the mkdir right before calling realpath.
2- Update EXTRAMAKEARGS with the absolute canonical $(O) and use it
when call recalling the top-level makefile with umask and paths correctly set.
3- Lastly, update the condition for setting theCONFIG_DIRand
NEED_WRAPPERvariables.
Actually for $(O) it is not strictly needed to re-enter make, but it just
simplifies things, right?
Quoted 5 lines
Note:
* This change takes care of the makefile wrapper installed in $(O) to avoid unneeded make recursion.
Quoted 8 lines
[1] https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html
[2] http://man7.org/linux/man-pages/man3/realpath.3.htmlReported-by Matthew Weber <[email protected]>Cc Matthew Weber <[email protected]>Cc "Yann E. MORIN" <[email protected]>Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>Signed-off-by Samuel Martin <[email protected]>
Small nit below but
I checked with a few combinations of umask and O= and symlinking to the output
dir. Even symnlinking <buildroot>/output to somewhere else and then running it with O=.../output works (i.e. the .config will be in the buildroot dir, not in the output dir).
Quoted 52 lines
---
changesv9->v10:
- only keep what is about checking umask and canonical paths for CWD and O (Arnout)
- fix assignation (Arnout)
- remove the unrelated MAKEOVERRIDES cleanup (Arnout)
- fixes typos in commit log (Arnout)changes
v8->v9:
- nonechanges
v7->v8:
- keep @ at the beginning of the command (Yann)
- make ifneq condition easier to read/parsed (Yann)
- fix O definition before re-entering make (Reported by Matthew)
- use EXTRAMAKEARGS when re-entering make
- update the condition forCONFIG_DIRandNEED_WRAPPERchanges
v6->v7:
- nonechanges
v5->v6:
- new patch--- Makefile | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)Makefile +4
-2@@ -33,7 +33,7 @@ SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ # or avoid confusing packages that can use the O=<dir> syntax for out-of-tree # build by preventing it from being forwarded to sub-make calls. ifneq ("$(origin O)", "command line") -O := output +O := $(CURDIR)/output else # Other packages might also support Linux-style out of tree builds # with the O=<dir> syntax (E.G. BusyBox does). As make automatically@@ -50,25 +50,45 @@ endif # Check if the current Buildroot execution meets all the pre-requisites. # If they are not met, Buildroot will actually do its job in a sub-make meeting -# its pre-requisites, which is: +# its pre-requisites, which are: # 1- Permissive enough umask: # Wrong or too restrictive umask will prevent Buildroot and packages from # creating files and directories. +# 2- Absolute canonical CWD (i.e. $(CURDIR)): +# Otherwise, some packages will use CWD as-is, others will compute its
Makefile endif · line 68
Quoted 10 lines
Makefile +10
-0+# absolute canonical path. This makes harder tracking and fixing host +# machine path leaks. +# 3- Absolute canonical output location (i.e. $(O)): +# For the same reason as the one for CWD. + +# Remove the trailing '/.' from $(O) as it can be added by the makefile wrapper +# installed in the $(O) directory. +# Also remove the trailing '/' the user can set when on the command line. +override O := $(patsubst %/,%,$(patsubst %.,%,$(O))) +CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))
This could use a comment why the mkdir is needed, but OK.
Regards,
Arnout
Quoted 48 lines
Makefile +15
-6+ +CANONICAL_CURDIR = $(realpath $(CURDIR)) CUR_UMASK = $(shell umask) REQ_UMASK = 0022 +# Make sure O= is passed (with its absolute canonical path) everywhere the +# toplevel makefile is called back. +EXTRAMAKEARGS := O=$(CANONICAL_O) + # Check Buildroot execution pre-requisites here. -ifneq ($(CUR_UMASK),$(REQ_UMASK)) +ifneq ($(CUR_UMASK):$(CURDIR):$(O),$(REQ_UMASK):$(CANONICAL_CURDIR):$(CANONICAL_O)) .PHONY: _all $(MAKECMDGOALS) $(MAKECMDGOALS): _all @: _all: - @umask $(REQ_UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS) + @umask $(REQ_UMASK) && \ + $(MAKE) -C $(CANONICAL_CURDIR) --no-print-directory \ + $(MAKECMDGOALS) $(EXTRAMAKEARGS) -else # umask +else # umask / $(CURDIR) / $(O) # This is our default rule, so must come first all:@@ -138,8 +158,9 @@ endif include support/misc/utils.mk # Set variables related to in-tree or out-of-tree build. -ifeq ($(O),output) -CONFIG_DIR := $(TOPDIR) +# Here, both $(O) and $(CURDIR) are absolute canonical paths. +ifeq ($(O),$(CURDIR)/output) +CONFIG_DIR := $(CURDIR) NEED_WRAPPER = else CONFIG_DIR := $(O)@@ -1036,4 +1057,4 @@ include docs/manual/manual.mk .PHONY: $(noconfig_targets) -endif #umask +endif #umask / $(CURDIR) / $(O)
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH v11 4/4 core: only remove O from MAKEOVERRIDES
In reply to Samuel MartinQuoted 11 lines · Samuel Martin
For no apparent reason, MAKEOVERRIDES is not treated the same way depending on whether O is set or not on the command line:
* when O is set on the command line (i.e. out-of-tree build): all variables were stripped away from MAKEOVERRIDES;
* when O is not set on the command line (i.e. in-Buildroot-source-tree build): all variables are kept and forwarded to the sub-make call.This change cleans things up by only removing the relevant variables from MAKEOVERRIDES when appropriate (i.e. removing O from MAKEOVERRIDES when O is set on the command line) keeping all other variables as-is in the sub-make call; O is set on the sub-make call anyway.
I'm not sure about this one. Clearing MAKEOVERRIDES makes sure that whatever we
set on the commandline of Buildroot's make will not get passed down to sub-makes. I don't see anything for which it would be useful to pass it down to sub-makes as commandline overrides.
Note that whatever we specify on the command line will be passed down in two
ways (unless it's overridden by the Makefile, like is done for O): it is passed in the environment, and it is passed in MAKEFLAGS in the environment. So even if we clear MAKEOVERRIDES, things still get passed down but just in the environment.
So, I don't see a good reason to apply this patch.
Regards,
Arnout
Quoted 28 lines
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>Signed-off-by Samuel Martin <[email protected]>---
changesv9->v10:
- new patch--- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Makefile +3
-2@@ -38,8 +38,9 @@ else # Other packages might also support Linux-style out of tree builds # with the O=<dir> syntax (E.G. BusyBox does). As make automatically # forwards command line variable definitions those packages get very -# confused. Fix this by telling make to not do so. -MAKEOVERRIDES := +# confused. Fix this by telling make to not do so, only for O=..., but +# keep all others (such as BR2_EXTERNAL, BR2_DL_DIR, etc). +MAKEOVERRIDES := $(filter-out O=%,$(MAKEOVERRIDES)) # Strangely enough O is still passed to submakes with MAKEOVERRIDES # (with make 3.81 atleast), the only thing that changes is the output # of the origin function (command line -> environment).
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH v11 4/4 core: only remove O from MAKEOVERRIDES
Quoted 20 lines · Arnout Vandecappelle
Quoted 11 lines · Samuel Martin
For no apparent reason, MAKEOVERRIDES is not treated the same way depending on whether O is set or not on the command line:
* when O is set on the command line (i.e. out-of-tree build): all variables were stripped away from MAKEOVERRIDES;
* when O is not set on the command line (i.e. in-Buildroot-source-tree build): all variables are kept and forwarded to the sub-make call.This change cleans things up by only removing the relevant variables from MAKEOVERRIDES when appropriate (i.e. removing O from MAKEOVERRIDES when O is set on the command line) keeping all other variables as-is in the sub-make call; O is set on the sub-make call anyway.
I'm not sure about this one. Clearing MAKEOVERRIDES makes sure that whatever we
set on the commandline of Buildroot's make will not get passed down to sub-makes. I don't see anything for which it would be useful to pass it down to sub-makes as commandline overrides.
Quoted 4 lines
Note that whatever we specify on the command line will be passed down in two
ways (unless it's overridden by theMakefile, like is done for O): it is passed in the environment, and it is passed in MAKEFLAGS in the environment. So even if we clear MAKEOVERRIDES, things still get passed down but just in the environment.
Interesting, I did not know that.
Quoted 2 lines
So, I don't see a good reason to apply this patch.
Fair enough.
Regards,
Signature · 1 line
Samuel
PATCH v11 3/4 core: re-enter make if $(CURDIR) or $(O) are not canonical paths
In reply to Arnout VandecappelleHi Arnout,
Quoted 36 lines · Arnout Vandecappelle
Quoted 8 lines · Samuel Martin
When $(CURDIR) and/or $(O) contain symlinks in their paths, they can be resolved differently, depending on each package build-system (whether it uses the given paths or get the absolute canonical ones).
Using absolute canonical paths will help achieving reproducible builds and will make easier tracking down host machine paths leaking into the host, target or staging trees.
So, this change ensure the build takes place with the CURDIR and O^sQuoted 14 lines
variables are set to their absolute canonical paths.
In order to recall the toplevel makefile with absolute canonical paths for $(CURDIR) and $(O), we need to:
1- Compute the absolute canonical paths for $(CURDIR) and $(O) that will
be passed to the sub-make. This is achieved using the 'realpath' make primitive. However, some care must be taken when manipulating O:
- the out-of-tree makefile wrapper happens a trailing "/.", we need to strip this part away to not break the comparison driving the sub-make call;
- the user can leave a trailing '/' to $(O);
- according to [1,2], realpath returns an empty string in case of non-existing entry. So, to avoid passing an empty O= variable to sub-make, it is necessary to define the output directory and createQuoted 8 lines
it prior to call realpath on it (because on the first invocation, $(O) usually does not yet exists), hence the trick doing the mkdir right before calling realpath.
2- Update EXTRAMAKEARGS with the absolute canonical $(O) and use it
when call recalling the top-level makefile with umask and paths correctly set.
3- Lastly, update the condition for setting theCONFIG_DIRand
NEED_WRAPPERvariables.
Quoted 2 lines
Actually for $(O) it is not strictly needed to re-enter make, but it just
simplifies things, right?
I think so.
Regards,
Signature · 1 line
Samuel