Makefile: fix out-of-tree builds with multiple targets with 'all'
PATCH 1/1 Makefile: fix out-of-tree builds with multiple targets with 'all'
From: "Yann E. MORIN" <[email protected]>
For out-of-tree builds, this use-case fails to build:
$ make clean all
This is because 'all' is filtered-out in the Makefile wrapper, since the wrapper itself has a 'all' target.
The 'all' target is just the usual naming for the default target in a Makefile. In fact, the first target is the default one, so we can name it whatever we want.
Rename the Makefile wrapper 'all' target to avoid name-clashing.
Fixes #6644.
---
Changes v2->v3:
- add bug reference (Ryan)
Changes v1->v2
- fix one missed 'all' occurence
--- support/scripts/mkmakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
support/scripts/mkmakefile +4 -4
@@ -32,16 +32,16 @@ MAKEFLAGS += --no-print-directory .PHONY: all \$(MAKECMDGOALS) -all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) +all := \$(filter-out Makefile,\$(MAKECMDGOALS)) -all: +_all: \$(MAKE) \$(MAKEARGS) \$(all) Makefile:; -\$(all): all +\$(all): _all @: -%/: all +%/: _all @: EOF
Signature · 1 line
1.8.1.2
PATCH 1/1 Makefile: fix out-of-tree builds with multiple targets with 'all'
Quoted 56 lines · Yann E. MORIN
From: "Yann E. MORIN" <[email protected]>
For out-of-tree builds, this use-case fails to build:
$ make clean allThis is because 'all' is filtered-out in the
Makefilewrapper, since the wrapper itself has a 'all' target.The 'all' target is just the usual naming for the default target in a
Makefile. In fact, the first target is the default one, so we can name it whatever we want.Rename the
Makefilewrapper 'all' target to avoid name-clashing.Fixes #6644.
Reported-by Ryan Barnett <[email protected]>Signed-off-by "Yann E. MORIN" <[email protected]>Cc Ryan Barnett <[email protected]>Cc Thomas Petazzoni <[email protected]>Tested-by Ryan Barnett <[email protected]>---
Changesv2->v3:
- add bug reference (Ryan)Changes
v1->v2
- fix one missed 'all' occurence---
support/scripts/mkmakefile | 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)support/scripts/mkmakefile +4
-4@@ -32,16 +32,16 @@ MAKEFLAGS += --no-print-directory .PHONY: all \$(MAKECMDGOALS) -all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) +all := \$(filter-out Makefile,\$(MAKECMDGOALS)) -all: +_all: \$(MAKE) \$(MAKEARGS) \$(all) Makefile:; -\$(all): all +\$(all): _all @: -%/: all +%/: _all @:
Quoted 1 line
EOF
Just curious: if you now type 'make all', which of the above rules gets executed? Can you explain what is going on here?
Thanks,
Thomas
PATCH 1/1 Makefile: fix out-of-tree builds with multiple targets with 'all'
Thomas DS, All,
On 2013-11-05 19:39 +0100, Thomas De Schampheleire spake thusly:
Quoted 6 lines
Quoted 5 lines · Yann E. MORIN
From: "Yann E. MORIN" <[email protected]>
For out-of-tree builds, this use-case fails to build:
$ make clean all
Quoted 8 lines
Quoted 8 lines
This is because 'all' is filtered-out in the
Makefilewrapper, since the wrapper itself has a 'all' target.The 'all' target is just the usual naming for the default target in a
Makefile. In fact, the first target is the default one, so we can name it whatever we want.Rename the
Makefilewrapper 'all' target to avoid name-clashing.
[moved the question here, it's easier to answer below]
Quoted 2 lines
Just curious: if you now type 'make all', which of the above rules gets executed? Can you explain what is going on here?
Please, follow the numbers, below:
Quoted 10 lines
support/scripts/mkmakefile MAKEFLAGS += --no-print-directory · line 35
Quoted 10 lines
support/scripts/mkmakefile +1
-1@@ -32,16 +32,16 @@ MAKEFLAGS += --no-print-directory .PHONY: all \$(MAKECMDGOALS) -all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) +all := \$(filter-out Makefile,\$(MAKECMDGOALS))
(1)
With 'make all', the variable $(MAKECMDGOALS) is the string "all" (without the quotes). So the variable $(all) is assigned the string "all" (still without quotes).
Quoted 4 lines
support/scripts/mkmakefile MAKEFLAGS += --no-print-directory · line 38
Quoted 4 lines
support/scripts/mkmakefile +1
-1-all: +_all: \$(MAKE) \$(MAKEARGS) \$(all)
(3)
And finally here, the rulle is:
make -C /path/to/buildroot O=$(pwd) all
`----------------------------' `-'
$(MAKEARGS) $(all)Quoted 6 lines
support/scripts/mkmakefile MAKEFLAGS += --no-print-directory · line 42
Quoted 6 lines
support/scripts/mkmakefile +1
-1Makefile:; -\$(all): all +\$(all): _all
(2)
And here the variable $(all) ix expanded, and as it depends on _all, the rulle _all above is executed
Quoted 7 lines
Quoted 6 lines
support/scripts/mkmakefile +1
-1@: -%/: all +%/: _all @:EOF
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'