bug-gnu-utils
[Top][All Lists]
Advanced

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

express multiple output files in gnu make


From: Wayne Throop
Subject: express multiple output files in gnu make
Date: Fri, 07 Jun 2002 00:57:49 GMT

Not exactly a bug, but an odd behavior.
Consider these (expected) behaviors:

    sh-2.04$ cat makefile
    x.c x.h: x.src; : building $@
    sh-2.04$ make x.c x.h
    : building x.c
    : building x.h

    sh-2.04$ cat makefile
    %.c %.h: %.src; : building $@
    sh-2.04$ make x.c x.h
    : building x.c
    make: Nothing to be done for `x.h'.

So the question is, how to express an action that produces multiple
output files?  If they are related by a stem, then you can use a pattern
rule as in the second case above; but what if they aren't? 

Suppose "cmd" produces files "foo" and "bar".
How to express it in gnu make.  One might suppose

    foo: bar
    bar: baz; cmd

would work, but that turns out not to be the case.
What happens is that dependents of foo don't get triggered
appropriately in the same run where the action for bar is triggered.

The intersting variant

    foo: bar;
    bar: baz; cmd

DOES work (well... close enough for all concrete-minded cetacians)
though it's not something one would immediately figure out 
(or rather... I didn't immediately figure it out).

Hence the questions:

     1 is there a better way to express it that would have
       the same semantics as the "%.x %.y: %.z; cmd" case,
       but unrelated filenames, and

     2 is the above a well-known and widely used idiom,
       and I shoulda knowed it before?

Fishing around in google groups and the gnu make info file
yielded no joy.  If it's already there, just point me to it.
If it isn't, maybe it a syntax for it could be recommended
in the info file?


Wayne Throop   address@hidden   http://sheol.org/throopw



reply via email to

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