[PATCHv2] tools.mk: Define CC if not set to 'default'

Submitted by Radostin Stoyanov on April 12, 2019, 8:04 a.m.

Details

Message ID 20190412080443.27177-1-rstoyanov1@gmail.com
State Accepted
Series "tools.mk: Define CC if not set to 'default'"
Commit 59930e5afb722491b58443fb2706b60882fdd8c7
Headers show

Commit Message

Radostin Stoyanov April 12, 2019, 8:04 a.m.
FOO ?= bar

is equivalent to

	ifeq ($(origin FOO), undefined)
	FOO = bar
	endif

However, when CC is not set its value is 'default' rather than
'undefined'.

From [1]:

'undefined': if variable was never defined.

'default': if variable has a default definition, as is usual with CC
and so on. See Variables Used by Implicit Rules. Note that if you have
redefined a default variable, the origin function will return the
origin of the later definition.

[1] https://www.gnu.org/software/make/manual/make.html

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 scripts/nmk/scripts/tools.mk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/nmk/scripts/tools.mk b/scripts/nmk/scripts/tools.mk
index d756358d5..8620ded7c 100644
--- a/scripts/nmk/scripts/tools.mk
+++ b/scripts/nmk/scripts/tools.mk
@@ -4,9 +4,13 @@  ifndef ____nmk_defined__tools
 # System tools shorthands
 RM		:= rm -f
 HOSTLD		?= ld
-LD		?= $(CROSS_COMPILE)$(HOSTLD)
+ifeq ($(origin LD), default)
+LD		:= $(CROSS_COMPILE)$(HOSTLD)
+endif
 HOSTCC		?= gcc
-CC		?= $(CROSS_COMPILE)$(HOSTCC)
+ifeq ($(origin CC), default)
+CC		:= $(CROSS_COMPILE)$(HOSTCC)
+endif
 CPP		:= $(CC) -E
 AS		:= $(CROSS_COMPILE)as
 AR		:= $(CROSS_COMPILE)ar

Comments

Zhang, Ning A April 12, 2019, 8:34 a.m.
Passes build with Android NDK/Clang in docker.

BR.
Ning.


在 2019-04-12五的 09:04 +0100,Radostin Stoyanov写道:
> 	FOO ?= bar
> 
> is equivalent to
> 
> 	ifeq ($(origin FOO), undefined)
> 	FOO = bar
> 	endif
> 
> However, when CC is not set its value is 'default' rather than
> 'undefined'.
> 
> From [1]:
> 
> 'undefined': if variable was never defined.
> 
> 'default': if variable has a default definition, as is usual with CC
> and so on. See Variables Used by Implicit Rules. Note that if you have
> redefined a default variable, the origin function will return the
> origin of the later definition.
> 
> [1] https://www.gnu.org/software/make/manual/make.html
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  scripts/nmk/scripts/tools.mk | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/nmk/scripts/tools.mk b/scripts/nmk/scripts/tools.mk
> index d756358d5..8620ded7c 100644
> --- a/scripts/nmk/scripts/tools.mk
> +++ b/scripts/nmk/scripts/tools.mk
> @@ -4,9 +4,13 @@ ifndef ____nmk_defined__tools
>  # System tools shorthands
>  RM		:= rm -f
>  HOSTLD		?= ld
> -LD		?= $(CROSS_COMPILE)$(HOSTLD)
> +ifeq ($(origin LD), default)
> +LD		:= $(CROSS_COMPILE)$(HOSTLD)
> +endif
>  HOSTCC		?= gcc
> -CC		?= $(CROSS_COMPILE)$(HOSTCC)
> +ifeq ($(origin CC), default)
> +CC		:= $(CROSS_COMPILE)$(HOSTCC)
> +endif
>  CPP		:= $(CC) -E
>  AS		:= $(CROSS_COMPILE)as
>  AR		:= $(CROSS_COMPILE)ar
Cyrill Gorcunov April 13, 2019, 7:44 a.m.
On Fri, Apr 12, 2019 at 09:04:43AM +0100, Radostin Stoyanov wrote:
> 	FOO ?= bar
> 
> is equivalent to
> 
> 	ifeq ($(origin FOO), undefined)
> 	FOO = bar
> 	endif
> 
> However, when CC is not set its value is 'default' rather than
> 'undefined'.
> 
> From [1]:
> 
> 'undefined': if variable was never defined.
> 
> 'default': if variable has a default definition, as is usual with CC
> and so on. See Variables Used by Implicit Rules. Note that if you have
> redefined a default variable, the origin function will return the
> origin of the later definition.
> 
> [1] https://www.gnu.org/software/make/manual/make.html
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Andrei Vagin April 18, 2019, 5:28 p.m.
What problem are you solving? Do we have a github issue for this?

On Fri, Apr 12, 2019 at 09:04:43AM +0100, Radostin Stoyanov wrote:
> 	FOO ?= bar
> 
> is equivalent to
> 
> 	ifeq ($(origin FOO), undefined)
> 	FOO = bar
> 	endif
> 
> However, when CC is not set its value is 'default' rather than
> 'undefined'.
> 
> From [1]:
> 
> 'undefined': if variable was never defined.
> 
> 'default': if variable has a default definition, as is usual with CC
> and so on. See Variables Used by Implicit Rules. Note that if you have
> redefined a default variable, the origin function will return the
> origin of the later definition.
> 
> [1] https://www.gnu.org/software/make/manual/make.html
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  scripts/nmk/scripts/tools.mk | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/nmk/scripts/tools.mk b/scripts/nmk/scripts/tools.mk
> index d756358d5..8620ded7c 100644
> --- a/scripts/nmk/scripts/tools.mk
> +++ b/scripts/nmk/scripts/tools.mk
> @@ -4,9 +4,13 @@ ifndef ____nmk_defined__tools
>  # System tools shorthands
>  RM		:= rm -f
>  HOSTLD		?= ld
> -LD		?= $(CROSS_COMPILE)$(HOSTLD)
> +ifeq ($(origin LD), default)
> +LD		:= $(CROSS_COMPILE)$(HOSTLD)
> +endif
>  HOSTCC		?= gcc
> -CC		?= $(CROSS_COMPILE)$(HOSTCC)
> +ifeq ($(origin CC), default)
> +CC		:= $(CROSS_COMPILE)$(HOSTCC)
> +endif
>  CPP		:= $(CC) -E
>  AS		:= $(CROSS_COMPILE)as
>  AR		:= $(CROSS_COMPILE)ar
> -- 
> 2.20.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
Radostin Stoyanov April 18, 2019, 7:29 p.m.
On 18/04/2019 18:28, Andrei Vagin wrote:
> What problem are you solving? Do we have a github issue for this?

$ sudo make install PREFIX=/usr
...
make: [Makefile.compel:73: compel/libcompel.so] Error 127 (ignored)
  CC       compel/arch/x86/src/lib/handle-elf.o
  CC       compel/src/lib/handle-elf.o
  CC       compel/src/main.o
  LINK     compel/built-in.o
  LINK     compel/compel
make: O2: Command not found
make: [Makefile.compel:66: compel/compel] Error 127 (ignored)
make[1]: *** No rule to make target 'compel/compel', needed by
'install'.  Stop.
make: *** [Makefile.install:44: install-compel] Error 2

No, I didn't open a github issue. The change in this patch is
complementary to commit

https://github.com/checkpoint-restore/criu/commit/7428b3794ac09cf6a546c0a51f92800f52b7daeb

Do you think that this information should have been included in the
commit message?

Thanks,
Radostin
Andrei Vagin April 20, 2019, 4:20 p.m.
Applied, thanks!

On Fri, Apr 12, 2019 at 09:04:43AM +0100, Radostin Stoyanov wrote:
> 	FOO ?= bar
> 
> is equivalent to
> 
> 	ifeq ($(origin FOO), undefined)
> 	FOO = bar
> 	endif
> 
> However, when CC is not set its value is 'default' rather than
> 'undefined'.
> 
> From [1]:
> 
> 'undefined': if variable was never defined.
> 
> 'default': if variable has a default definition, as is usual with CC
> and so on. See Variables Used by Implicit Rules. Note that if you have
> redefined a default variable, the origin function will return the
> origin of the later definition.
> 
> [1] https://www.gnu.org/software/make/manual/make.html
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  scripts/nmk/scripts/tools.mk | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/nmk/scripts/tools.mk b/scripts/nmk/scripts/tools.mk
> index d756358d5..8620ded7c 100644
> --- a/scripts/nmk/scripts/tools.mk
> +++ b/scripts/nmk/scripts/tools.mk
> @@ -4,9 +4,13 @@ ifndef ____nmk_defined__tools
>  # System tools shorthands
>  RM		:= rm -f
>  HOSTLD		?= ld
> -LD		?= $(CROSS_COMPILE)$(HOSTLD)
> +ifeq ($(origin LD), default)
> +LD		:= $(CROSS_COMPILE)$(HOSTLD)
> +endif
>  HOSTCC		?= gcc
> -CC		?= $(CROSS_COMPILE)$(HOSTCC)
> +ifeq ($(origin CC), default)
> +CC		:= $(CROSS_COMPILE)$(HOSTCC)
> +endif
>  CPP		:= $(CC) -E
>  AS		:= $(CROSS_COMPILE)as
>  AR		:= $(CROSS_COMPILE)ar
> -- 
> 2.20.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu