help-make
[Top][All Lists]
Advanced

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

Re: is there any way to get at prerequisites of "current" rule


From: Philip Guenther
Subject: Re: is there any way to get at prerequisites of "current" rule
Date: Wed, 30 May 2012 15:36:26 -0700

On Wed, May 30, 2012 at 3:05 PM, Mark Galeck (CW) <address@hidden> wrote:
> Frequently there is this
>
> target: <some prerequisites>
>                <recipe involving $^>
>
> And then someone adds
>
> target: <remaining prerequisites>
>
> and now the first recipe breaks.  Is there a way to get at the prerequisites 
> of the "current" rule, rather than "all" prerequisites.

$^ is the complete list of prereq's for the target.  If the recipe
wants to process a subset of those, it should either
a) use $(filter) or $(filter-out) to select the ones it wants, or
b) put the subset that it wants to process into a variable and then
reference that variable in both the prereq line
   and in the commands.

As an example of the former, I've written this sort of rule a number of times:
----
%.a:
        rm -f $@
        ${AR} ${ARFLAGS} $@ $(filter %.o,$^)
----

Where the actual libfoo.a ends up depending on several .o files and a
.direxists file that guarantees the target directory is created before
the above rule is run.


Philip Guenther



reply via email to

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