help-make
[Top][All Lists]
Advanced

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

Commands with multiple output files


From: Peter Eisentraut
Subject: Commands with multiple output files
Date: Wed, 6 Feb 2002 15:31:38 -0500 (EST)

What is a good way to write rules that contain commands with multiple
output files?

For instance, yacc -d creates two output files: y.tab.c and y.tab.h.
Both of these may be prerequisites for other targets, so they have to be
mentioned.  The naive way to write the rules was like this:

y.tab.c y.tab.h: input.y
        $(YACC) -d $<

But that is inappropriate because it really says

y.tab.c: input.y
        $(YACC) -d $<

y.tab.h: input.y
        $(YACC) -d $<

So in a parellel make, these two rules may be run on top of each other,
creating busted output files.  (Maybe yacc is reasonably careful about
that, but just imagine more complex commands in the rule that cannot be
run concurrently with themselves.)

One workaround that we've found is like this:

y.tab.h: y.tab.c

y.tab.c: input.y
        $(YACC) -d $<

But that is abuse.

Any ideas?

-- 
Peter Eisentraut   address@hidden




reply via email to

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