bug-make
[Top][All Lists]
Advanced

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

Re: order-only prerequisites don't behave as I'd have expected after rea


From: Paul Smith
Subject: Re: order-only prerequisites don't behave as I'd have expected after reading the documentation
Date: Tue, 12 Jun 2012 01:14:35 -0400

On Mon, 2012-06-11 at 18:40 +0200, Stefano Lattarini wrote:
> The GNU make 3.82 manual reads:
> 
>     Normally, this is exactly what you want: if a target's prerequisite
>     is updated, then the target should also be updated.
> 
>     Occasionally, however, you have a situation where you want to impose
>     a specific ordering on the rules to be invoked without forcing the
>     target to be updated if one of those rules is executed.
> 
> But if I write a makefile like this:
> 
>     ALL = a b c d
>     default:
>       echo Specify a target: $(ALL); exit 1
>     .PHONY: $(ALL)
>     $(ALL):
>         @echo $@
>     a: | b
>     b: | c
>     c: | d
> 
> then I get:
> 
>     $ make a # Not what I expected, but what actually happened.
>     d
>     c
>     b
>     a
> 
> which is not what I'd have expected reading the documentation above; what
> I would have expected was that "a" alone would be run:
> 
>     $ make a # What I expected, but did not happen.
>     a

No, that's not how order-only prerequisites work.  An order-only
prerequisite is treated identically to a normal prerequisite except for
exactly one thing: when make checks to see if a target needs to be
remade, the time-last-modified values for any order-only prerequisites
are not considered.

However, they are still considered prerequisites in that they are still
built, themselves, if necessary, before the target.  Since your targets
are all phony (and none of them update their target file either) they
will all always be remade every time.  You can't see how order-only
prerequisites work using this makefile.





reply via email to

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