help-make
[Top][All Lists]
Advanced

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

RE: Multiple expansion works in rules, but not in actions


From: Dave Korn
Subject: RE: Multiple expansion works in rules, but not in actions
Date: Mon, 29 Oct 2007 19:24:40 -0000

On 29 October 2007 17:01, Alexander Kriegisch wrote:

> Forgive me, I sent the wrong example and it is not really about multiple
> expansion but about changing values:
> 
> FOO:=bla
> 
> $(FOO):
>       @echo "## $(FOO) ##"
> 
> FOO:=
> 
> The target name $(FOO) is expanded to "bla", but $(FOO) is expanded to
> nothing inside the action. I studied the manual of GNU make 3.81, but
> found no explanation for this effect. Can you point me to the section I
> should read in order to unserstand how changing values affect actions?

  Variables in rules don't get expanded until the rule is brought into action.
So at the time the rule is parsed and defined, when FOO is "bla", make sees:

bla:
        @echo "## $(FOO) ##"

but by the time make comes to invoke the rule, which is only after make has
finished reading and parsing the entire makefile and started walking the
dependency graph, FOO is now empty.

  See the "5.1.2 Using variables in Commands" section of the docs:

"The other way in which `make' processes commands is by expanding any
variable references in them (*note Basics of Variable References:
Reference.).  This occurs after make has finished reading all the
makefiles and the target is determined to be out of date; so, the
commands for targets which are not rebuilt are never expanded."


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....





reply via email to

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