|
From: | Brendan Bridgford |
Subject: | Re: "no rule to make target" when target is a variable |
Date: | Tue, 5 Dec 2006 22:22:22 -0500 |
On Tue, 2006-12-05 at 20:19 -0500, Brendan Bridgford wrote:
> I'm trying to use a variable as a target without much luck.
> .PHONY = foobar
> foobar : a = foo
> foobar : b = bar
> c=$(a)$(b)
>
> When I invoke
> >make foobar
>
> ... it returns:
> make: *** No rule to make target `foobar'. Stop.
Indeed.
> Why isn't it working when I use the variable $(c) as a target? I'm
> using GNU Make 3.80 for i686-pc-cygwin.
The synaxt "target : variable = value" defines a target-specific
variable. That means that the variable only has this value in the
context of that target: for example inside the command scripts for that
target.
You are trying to set a and b as variables in the context of the foobar
target, but then use them (in c) in the global scope, outside of the
scope of the target foobar. That can't work.
If you do this:
a = foo
b = bar
c = $(a)$(b)
$(c): ; @echo $@
it will work as you expect.
--
-------------------------------------------------------------------------------
Paul D. Smith < address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
[Prev in Thread] | Current Thread | [Next in Thread] |