help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: export does not export to $(shell ...


From: Martin d'Anjou
Subject: Re: export does not export to $(shell ...
Date: Fri, 25 Nov 2005 08:11:30 -0500 (EST)

John wrote:
>Martin d'Anjou wrote:
>> How do I convince export to export variables to $(shell ...)?
>>
>> l:=$(shell echo $$USER)
>> $(warning $(l))
>> export VAR=Hi
>> l:=$(shell echo VAR $$VAR)
>> $(warning $(l))
>>
>> all:
>>       echo $$VAR
>>
>> Is this a bug? I use 3.81beta3
>
>The code handling $(shell) (func_shell in function.c) uses the parent
>environment (from environ) for the sub-shell.  Hence GNU Make's export
>directive will not put GNU Make variables into the $(shell) environment.
>
>You could have this like this:
>
>     export FOO=fooey
>     ORIGINAL := $(shell echo 1: $$FOO)
>     HACKED := $(shell export FOO=$(FOO) ; echo 2: $$FOO)
>
>     all:
>         @echo Original: $(ORIGINAL)
>         @echo Hacked:   $(HACKED)
>
>John.

How annoying. I can kind of almost see why, but not quite. Consider this:

l:=$(shell echo $$VAR)
$(warning VAR=$(VAR))
export VAR=10
l:=$(shell echo $$VAR)
$(warning VAR=$(VAR))

make

Makefile:2: VAR=
Makefile:5: VAR=10

Why would VAR be defined for $(shell) just like it is for $(warning) for 
example? Without export, ok, but with export, why not?

Martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]