On Wed, May 30, 2012 at 3:05 PM, Mark Galeck (CW) <[email protected]> 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

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to