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: Stefano Lattarini
Subject: Re: order-only prerequisites don't behave as I'd have expected after reading the documentation
Date: Tue, 12 Jun 2012 09:58:38 +0200

Hi Paul, thanks for the quick answer.

On 06/12/2012 07:14 AM, Paul Smith wrote:
> 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.
>
Ah, all is clear now.  Then I think we are dealing with a documentation
bug here; in particular:

  - the name "order-only prerequisites" is IMHO poorly chosen, and don't
    really correspond to their actual semantics; a more appropriate might
    be "weak prerequisites" or "existence-only prerequisites";

  - the explanation given in the manual is imprecise and confusing; since
    the explanation you've given here is OTOH very clear and concise, I
    suggest you report it in the manual;

  - it might make sense to state explicitly that order-only prereqs
    which are phony behaves in all ways like standard prerequisites.

> 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.
> 

Thanks,
  Stefano



reply via email to

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