On Mon, Sep 3, 2018 at 5:23 AM Marc Espie <[email protected]> wrote:

> Our make is perfectly happy generating several targets with one rule.
>
> The only thing we're actually missing wrt % is suffixes rules with
> multiple results.
>
> See any Makefile that generates .h and .c file from .y, for instance
> lib/libkeynote/Makefile
>
> a line like:
>
> k.tab.c k.tab.h: keynote.y keynote.h signature.h
>         $(YACC.y) $(YACCFLAGS) ${.CURDIR}/keynote.y
>
> looks exactly like what you want.
>

Classically, a rule like that doesn't mean one invocation will generate
both targets, but rather that the same recipe can be invoked for each
target (with different values for $@, etc).  In default single-job mode (no
-jN) this works out fine as after the first invocation 'make' will notice
the second file is already up-to-date, but with -jN some makes could decide
to build both of the targets at the same time and invoke yacc twice,
possibly resulting in truncated/corrupted output files.

Does our make have some logic in the -jN handling to detect and prevent
that, Marc?

Otherwise, the workaround has been as Geoff noted: have all the target
files depend on a timestamp file which has the real recipe and
prerequisites.  That's still recommended for GNU make users when there's no
reasonable set of patterns that can match the generated files.  People
occasionally pine for the SunOS 4.x 'make' feature of "targ1 + targ2 [+
targN...]" functionality, but it's not a great syntax and no one has done
the work.


Philip Guenther

Reply via email to