help-make
[Top][All Lists]
Advanced

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

Re: prerequisites of targets are not made?|?


From: Alessandro Vesely
Subject: Re: prerequisites of targets are not made?|?
Date: Wed, 01 Dec 2004 01:53:15 +0100

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]