help-make
[Top][All Lists]
Advanced

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

clarification of deferred function expansion


From: Asperheim, Eric
Subject: clarification of deferred function expansion
Date: Thu, 4 Apr 2002 14:43:52 -0800

All,

I've read the gmake v3.79.1 doc (p. 14) about deferred "Expansion of
deferred construct is not performed until either the construct appears later
in an immediate context, or until the second phase" of gmake's operation.
Given that the shell command

$(shell echo $$ENV_VAR)

expansion was deferred since it's part of a define directive, I was
expecting this to work. I'm setting an environment var ENV_VAR (using bash
shell) and then trying to use that env var in the next command. But, this
doesn't work. Note, I tried to use the gmake var $(ENV_VAR). But, this
doesn't work either since the value of $(ENV_VAR) is the value of the env
var at gmake invocation - which is not what I want.

Initially - ENV_VAR is set to "0"

Makefile
--------------------------------
define cmd
  ENV_VAR=1; \
  export ENV_VAR; \
  set TCL_VAR {$(shell echo $$ENV_VAR)};
endef

default : 
        @ $(cmd)
--------------------------------

When I use "gmake -n" to see what I'll get, I get this

fhc2349:easperhe gmake -n
ENV_VAR=1; export ENV_VAR; set TCL_VAR {0};


Is this the expected behavior? Or, is there a bug in gmake. If this is the
intended behavior, is there anyway to do what I want to do?

Thanks,

Eric


Eric Asperheim  -  CSE Design Automation
phone: (916) 356-4624 
Intel Corporation, FM6-81
fax: (916) 356-3051 
1900 Prairie City Rd, Folsom, CA 95630
address@hidden
----------------------------------------------------------------------------
--------------------------------- 





reply via email to

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