Thanks Paul. I understand now why this doesn't work but I may have mislead you on my end goal. Is there a way to set a global variable from the context of a target?
Here's a fuller picture of what I'm trying to do (pretend for a moment that my syntax works): .PHONY = foobar foobar : a = foo foobar : b = bar .PHONY = poobar poobar : a = poo poobar : b = bar c=$(a)$(b) $(c) : echo $(a)rules I want to apply essentially the same rules to multiple targets without explicitly listing each target (i.e. a variable target name), while retaining control over what gets made (i.e. I don't want "c = foobar poobar"). Is there a better way of going about this? Thx, --Brendan On 12/5/06, Paul Smith <[EMAIL PROTECTED]> wrote:
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 <[EMAIL PROTECTED]> 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
_______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
