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

Submitted by Radostin Stoyanov on April 11, 2019, 9:21 a.m.

Details

Message ID 20190411092137.16437-1-rstoyanov1@gmail.com
State New
Series "tools.mk: Define CC if not set to 'default'"
Headers show

Commit Message

Radostin Stoyanov April 11, 2019, 9:21 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'.

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

Patch hide | download patch | download mbox

diff --git a/scripts/nmk/scripts/tools.mk b/scripts/nmk/scripts/tools.mk
index d756358d5..e62172dd9 100644
--- a/scripts/nmk/scripts/tools.mk
+++ b/scripts/nmk/scripts/tools.mk
@@ -6,7 +6,9 @@  RM		:= rm -f
 HOSTLD		?= ld
 LD		?= $(CROSS_COMPILE)$(HOSTLD)
 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

Cyrill Gorcunov April 11, 2019, 9:28 a.m.
On Thu, Apr 11, 2019 at 10:21:37AM +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'.
>

Who set this value to "default"? This patch looks pretty wrong.
Radostin Stoyanov April 11, 2019, 9:54 a.m.
On 11/04/2019 10:28, Cyrill Gorcunov wrote:
> On Thu, Apr 11, 2019 at 10:21:37AM +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'.
>>
> Who set this value to "default"? This patch looks pretty wrong.
'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.


https://www.gnu.org/software/make/manual/make.html
Cyrill Gorcunov April 11, 2019, 10:11 a.m.
On Thu, Apr 11, 2019 at 10:54:43AM +0100, Radostin Stoyanov wrote:
> > Who set this value to "default"? This patch looks pretty wrong.
> '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.

Will take a look at evening, thanks!
Cyrill Gorcunov April 11, 2019, 5:17 p.m.
On Thu, Apr 11, 2019 at 10:21:37AM +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'.
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Zhang, Ning A April 12, 2019, 1:29 a.m.
Build passes with Cross compile using Android NDK/Clang.

w/o this patch, CC is default value, so does LD?

apply same change to LD? 

BR.
Ning.

在 2019-04-11四的 10:21 +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'.
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  scripts/nmk/scripts/tools.mk | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/nmk/scripts/tools.mk b/scripts/nmk/scripts/tools.mk
> index d756358d5..e62172dd9 100644
> --- a/scripts/nmk/scripts/tools.mk
> +++ b/scripts/nmk/scripts/tools.mk
> @@ -6,7 +6,9 @@ RM		:= rm -f
>  HOSTLD		?= ld
>  LD		?= $(CROSS_COMPILE)$(HOSTLD)
>  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