Exported vs command line variables

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Exported vs command line variables

Pietro
Hi,

I have noticed that there is a difference between the two scenarios
listed below:

i) make  CC=arm-linux-gnueabihf-gcc CPPFLAGS=[..]

ii) export CPPFLAGS=[..] [RET]
    make CC=arm-linux-gnueabihf-gcc


I have read over internet that the latter is used when appending
instead of replacing/setting the variable's value.

What is exactly the difference ? Is there a page in the Make manual
explaining that ?


Thanks a lot,
P.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: Exported vs command line variables

Rakesh Sharma-6
There is no difference between the two. They both declare environment variables for make.


________________________________
From: Help-make <help-make-bounces+sharma__r=[hidden email]> on behalf of Pietro <[hidden email]>
Sent: Monday, September 19, 2016 9:32 AM
To: [hidden email]
Subject: Exported vs command line variables

Hi,

I have noticed that there is a difference between the two scenarios
listed below:

i) make  CC=arm-linux-gnueabihf-gcc CPPFLAGS=[..]

ii) export CPPFLAGS=[..] [RET]
    make CC=arm-linux-gnueabihf-gcc


I have read over internet that the latter is used when appending
instead of replacing/setting the variable's value.

What is exactly the difference ? Is there a page in the Make manual
explaining that ?


Thanks a lot,
P.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Help-make -- Users list for the GNU implementation of make<https://lists.gnu.org/mailman/listinfo/help-make>
lists.gnu.org
Help-make -- Users list for the GNU implementation of make About Help-make



_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

AW: Exported vs command line variables

Warlich, Christof
> There is no difference between the two. They both declare environment variables for make.

That's not entirely true, at least not for (admittedly rather ancient) GNU Make V3.81.
E.g., consider this Makefile:

var := $(shell echo "echo hi" >say_hi.sh; chmod +x say_hi.sh; say_hi.sh)
all: ; @echo $(var)

Calling make with the PATH environment variable either way yiedls:

$ make PATH=$PATH:.
/bin/sh: 1: say_hi.sh: not found

$ PATH=$PATH:. make
hi

I'm not sure though if this is intended behavior or just a bug and if a more recent version of GNU Make does the same. But considering that GNU Make V3.81 is the standard in e.g. Ubuntu LTS 14.04, it may still matter.

Cheers,

Chris

-----Urspr√ľngliche Nachricht-----
Von: Help-make [mailto:help-make-bounces+christof.warlich=[hidden email]] Im Auftrag von Rakesh Sharma
Gesendet: Dienstag, 20. September 2016 06:35
An: Pietro; [hidden email]
Betreff: Re: Exported vs command line variables

There is no difference between the two. They both declare environment variables for make.


________________________________
From: Help-make <help-make-bounces+sharma__r=[hidden email]> on behalf of Pietro <[hidden email]>
Sent: Monday, September 19, 2016 9:32 AM
To: [hidden email]
Subject: Exported vs command line variables

Hi,

I have noticed that there is a difference between the two scenarios
listed below:

i) make  CC=arm-linux-gnueabihf-gcc CPPFLAGS=[..]

ii) export CPPFLAGS=[..] [RET]
    make CC=arm-linux-gnueabihf-gcc


I have read over internet that the latter is used when appending
instead of replacing/setting the variable's value.

What is exactly the difference ? Is there a page in the Make manual
explaining that ?


Thanks a lot,
P.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Help-make -- Users list for the GNU implementation of make<https://lists.gnu.org/mailman/listinfo/help-make>
lists.gnu.org
Help-make -- Users list for the GNU implementation of make About Help-make



_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: AW: Exported vs command line variables

Pietro
"Warlich, Christof" <[hidden email]> writes:

>> There is no difference between the two. They both declare environment variables for make.
>
> That's not entirely true, at least not for (admittedly rather ancient) GNU Make V3.81.
> E.g., consider this Makefile:
>
> var := $(shell echo "echo hi" >say_hi.sh; chmod +x say_hi.sh; say_hi.sh)
> all: ; @echo $(var)
>
> Calling make with the PATH environment variable either way yiedls:
>
> $ make PATH=$PATH:.
> /bin/sh: 1: say_hi.sh: not found
>
> $ PATH=$PATH:. make
> hi
>
> I'm not sure though if this is intended behavior or just a bug and if
> a more recent version of GNU Make does the same. But considering that
> GNU Make V3.81 is the standard in e.g. Ubuntu LTS 14.04, it may still
> matter.
>
> Cheers,
>
> Chris
>

Well, actually I am using version 4.1 and I do see the difference, are
you sure it is not working as intended ? I can't find anything on the
manual but I am quite curious.



_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

AW: AW: Exported vs command line variables

Warlich, Christof
> > I'm not sure though if this is intended behavior or just a bug

> Well, actually I am using version 4.1 and I do see the difference, are
> you sure it is not working as intended ?

Well, as I said above, I'm definitely not sure. I would most likely consider it being a bug.
Nevertheless, it's a rather contrived example, so I would not bother too much ...

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: AW: AW: Exported vs command line variables

Pietro
"Warlich, Christof" <[hidden email]> writes:

>> > I'm not sure though if this is intended behavior or just a bug
>
>> Well, actually I am using version 4.1 and I do see the difference, are
>> you sure it is not working as intended ?
>
> Well, as I said above, I'm definitely not sure. I would most likely consider it being a bug.
> Nevertheless, it's a rather contrived example, so I would not bother too much ...
Your it is, but mine isn't and it is common to cross-compile stuff givin
flags as command line through *FLAGS implicit variables.

Is there a Make bug report where I could try to raise a bug ? If it
isn't it would be rejected :-)

P.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: Exported vs command line variables

Brian Vandenberg-2
In reply to this post by Pietro
This makefile example should help clear things up:

$ cat makefile
SHELL := bash
.RECIPEPREFIX := >
blah1 := test1
blah2 := test2
export blah2
# blah2 & blah3 should have identical results
export blah3 := test3

default:
>@$(foreach x,blah1 blah2 blah3 blah4 blah5,echo "${x}: (origin = $(origin
${x}), flavor = $(flavor ${x}), make value = ${${x}}, shell value:
$${${x}:-not set})";)

$ make --version
GNU Make 4.1
(...)

$ blah5=test5 make -f makefile blah4=test4
blah1: (origin = file, flavor = simple, make value = test1, shell value:
not set)
blah2: (origin = file, flavor = simple, make value = test2, shell value:
test2)
blah3: (origin = file, flavor = simple, make value = test3, shell value:
test3)
blah4: (origin = command line, flavor = recursive, make value = test4,
shell value: test4)
blah5: (origin = environment, flavor = recursive, make value = test5, shell
value: test5)

This is identical to:

$ export blah5=test5
$ make -f makefile blah4=test4
blah1: (origin = file, flavor = simple, make value = test1, shell value:
not set)
blah2: (origin = file, flavor = simple, make value = test2, shell value:
test2)
blah3: (origin = file, flavor = simple, make value = test3, shell value:
test3)
blah4: (origin = command line, flavor = recursive, make value = test4,
shell value: test4)
blah5: (origin = environment, flavor = recursive, make value = test5, shell
value: test5)

I was a little surprised to discover that variables passed on the
command-line to make get marked for export.

-brian
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

AW: AW: AW: Exported vs command line variables

Warlich, Christof
In reply to this post by Pietro
> Is there a Make bug report where I could try to raise a bug ?

See http://lmgtfy.com/?q=gnu+make+bug+reports :-)

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make