help-make
[Top][All Lists]
Advanced

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

Re: why isn't command expansion deferred?? (stupid question probably)


From: Paul Smith
Subject: Re: why isn't command expansion deferred?? (stupid question probably)
Date: Sun, 31 Jan 2010 20:01:33 -0500

On Sun, 2010-01-31 at 03:31 -0800, Mark Galeck (CW) wrote:
> Hello,  the manual says, that commands are always expanded deferred.
> OK, I have this makefile
> 
> foobar:
>               touch foobar
>               echo $(wildcard foobar)
> 
> Then why is this:
> 
> C:\Temp>del foobar
> 
> C:\Temp>make foobar
> touch foobar
> echo
> ECHO is off. 
> 
> I was expecting it would echo foobar!  How do I make $(wildcard...)
> evaluate when it is being called from a command?

Hi Mark.  Please start a new thread when asking a new question, rather
than replying to an existing, unrelated thread.  Thanks!

The expansion of variables and functions in a recipe is deferred...
until the recipe is invoked.  The entire recipe, including all lines, is
expanded when make decides to run the rule.

Therefore, when make expands the recipe, "foobar" doesn't exist yet and
so the wildcard gets nothing back.

To do things like this you need to use shell commands, not make
commands.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist





reply via email to

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