[Top][All Lists]

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

Question about pattern rule with multiple targets

From: Tom Varga
Subject: Question about pattern rule with multiple targets
Date: Fri, 27 Jun 2014 14:24:45 -0400

On page 120 of the gnumake manual, it mentions support for pattern
rules with multiple targets.

This pattern rule has two targets:
%.tab.c %.tab.h: %.y
bison -d $<

So, if I have a simple rule that looks like:

%.bar1 %.bar2 : %.foo
touch $(*F).bar1
touch $(*F).bar2

and then do:

> touch a.foo
> make a.bar1
touch a.bar1
touch a.bar2
> make a.bar1
make: 'a.bar1' is up to date.
> rm a.bar2
> make a.bar1
make: 'a.bar1' is up to date.
> make a.bar2
touch a.bar1
touch a.bar2

What I was really hoping is that make would consider both a.bar1 and
a.bar2 to be required outputs of the rule and if one of them is
deleted, then both the .bar1 and .bar2 targets should be considered
out-of-date.  But when I manually remove the a.bar2 file, the a.bar1
file is still considered to be up-to-date.  Yet, when I then ask to
build the a.bar2 target, both the a.bar1 and a.bar2 targets are

Is there any way to code a rule so that all targets must always be
considered to have been built simultaneously.  More so, if after the
deletion of the a.bar2 file, some other rule that depends on a.bar1
file would cause make to consider both the a.bar1 and a.bar2 files to
be out-of-date.

I really hope there is some way to support my need for a recipe to
build all specified targets and have subsequent rules that depends on
any one or more of those targets thus force the re-build of said
targets if any of them are missing.


reply via email to

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