help-gnu-utils
[Top][All Lists]
Advanced

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

How do I reference target name when defining target-specific variable?


From: fixin
Subject: How do I reference target name when defining target-specific variable?
Date: 25 Aug 2005 10:21:09 -0700
User-agent: G2/0.2

I'm looking for a way to reference a target when defining a
target-specific variable.

The problem: a bunch of files (.prc files below) all depend on the
same set of object files, but the object files must be rebuilt for
each one knowing the name of the .prc file they'll eventually be
linked into.  (The name's passed in via a -D option to the compiler.)
In effect I need to figure out how to set the make variable PRC_NAME
below.

%.o :
        $(CC) -DPRC_NAME=$(PRC_NAME) $< -o $@
%.prc : a.o b.o c.o
        $(BUILDPRC) $^ -o $@

>From the manual, it looks as if target-specific variables are the
answer.  Something like this should work:

%.prc : PRC_NAME := $@
%.prc : a.o b.o c.o
        $(BUILDPRC) $^ -o $@

except that $@ is undefined at that point.  The manual suggests that
$$@ should work, but it doesn't.  It also says that there are other
ways to do the same thing.  Does anybody know what they are?

I'm using GNU Make 2.80 via cygwin and on GNU/Linux.

Thanks,

--Eric House



reply via email to

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