help-make
[Top][All Lists]
Advanced

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

producing more than one target? (was: prerequisites of targets are not


From: ale-make
Subject: producing more than one target? (was: prerequisites of targets are not made?|?
Date: Wed, 01 Dec 2004 14:42:33 +0100

I wrote:
>    comp%:
>       rm -f $(filter %.u,$^)
>       $(MAKE)

Besides being counter-intuitive, that hack does not work.
The sub-make will call itself again forever.

Looking in make manual, the only case where one rule produces more targets
is that exemplified in 
<http://www.gnu.org/software/make/manual/html_node/make_106.html>:

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

Writing the same in a regular rule, i.e. `a.tab.c a.tab.h: a.y',
runs bison twice.

Questions:
Is there a generic mechanism for simultaneously producing more than one target?
If not, does GNU make deserve one? Shall we discuss that here?

Although this need arises from compiling Java (see
<http://lists.gnu.org/archive/html/help-make/2004-11/msg00051.html>)
I don't think that producing more than one target is peculiar to that language.

Thank you for your attention
Ale

(I leave my previous response below, for I had not received it from 
address@hidden yet)
-------- Original Message --------
Message-ID: <address@hidden>
Date: Wed, 01 Dec 2004 01:53:15 +0100
From: Alessandro Vesely <address@hidden>
To: "Paul D. Smith" <address@hidden>
CC: address@hidden
Subject: Re: prerequisites of targets are not made?|?
References: <address@hidden> <address@hidden>

Hi Paul,

"Paul D. Smith" wrote:
> 
> %% Alessandro Vesely <address@hidden> writes:
> 
>   av> is that a bug or a feature?
> 
> It's a bug... in your makefile :-).

I felt that, but really couldn't see why...

>   av> all: all_targets
> 
>   av> %.u:
>   av>   touch $@
> 
>   av> an.u: source1
>   av> comp1: an.u
>   av> an.u: comp2
>   av> another.u: source2
>   av> comp2: another.u
> 
>   av> all_targets:  an.u another.u
> 
> I don't see how you expect that to happen.  The another.u target doesn't
> depend on comp2, so there's no way that anything about comp2 could cause
> another.u to rebuild.

Hmmm... I now realize that the way I wrote it only makes sense if
another.u is a phony target. However, touching it avoids recompiling
everything everytime.

> another.u depends only on source2, so only source2 changing (or not
> being there) could cause another.u to rebuild; but you have source2
> (based on your email).

Yes, it apparently works when I change the sources. In real life,
before touching $@, the rule finds sources in prerequisites and
builds comps with them.
 
> Maybe you meant this line:
> 
>  > comp2: another.u
> 
> to say this instead:
> 
>  > another.u: comp2
>
> ?  Then another.u depends on comp2, and a change (or missing) comp2
> would cause another.u to rebuild.  But as it stands you have no rule
> describing how to build comp2, so if it doesn't exist make will fail
> saying it doesn't know how to build it.

If I write

   another.u: comp2
   an.u: comp2

I'd then miss that comp2 should cause another.u to be built before an.u.
(It is difficult to simply say `an.u: another.u' because dependencies may
result from different units and the u basenames are somewhat arbitrary.)

I think I really need a target for comp%, but the following is overkill

   comp%:
        rm -f $(filter %.u,$^)
        $(MAKE)

Isn't it?

Thank you for your help, anyway.

Ciao
Ale




reply via email to

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