help-make
[Top][All Lists]
Advanced

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

Re: variable expansion in pattern rule prerequisites


From: Boris Kolpackov
Subject: Re: variable expansion in pattern rule prerequisites
Date: Tue, 17 Aug 2004 22:09:13 +0000 (UTC)
User-agent: nn/6.6.5+RFC1522

Nathan Straz <address@hidden> writes:

> I have a makefile like this:
> ------------------------------
> $(LIBBAR): ../lib/libbar.a
>       $(MAKE) -C ../lib libbar.a
> $(LIBFAR): ../lib/libfar.a
>       $(MAKE) -C ../lib libfar.a
> 
> LIBS_foo := $(LIBBAR)
> LIBS_boo := $(LIBFAR)
> 
> %: %.c $(LIBS_%)
>       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) $(LIBS_$@)
> ------------------------------

You cannot do (at least not in mainline GNU make):

%: %.c $(LIBS_%)

The $(LIBS_%) expansion happens when makefile is read and stem (%) 
substitution happens later when the rule is tried.


> Can this be done with pattern rules?

Why don't you just tell make directly what you want:

foo: $(LIBBAR)
boo: $(LIBFAR)

%: %.c
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^

-boris





reply via email to

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