help-make
[Top][All Lists]
Advanced

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

Re: simple explanation for order-only prerequisite?


From: pacalet
Subject: Re: simple explanation for order-only prerequisite?
Date: Mon, 4 Nov 2019 09:44:26 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.2.1

Le 03/11/2019 à 16:17, Robert P. J. Day a écrit :
> On Sun, 3 Nov 2019, Nicholas Clark wrote:
> 
>> I'd describe OOPs as "just like a regular dependency, except that
>> the timestamp isn't checked. Only whether it exists on the
>> filesystem."
> 
>   is it really that simple? just a test for "does it exist or not?"
> that suggests that make would not even bother consulting the rule for
> that OOP.
> 
>   i thought it was a bit more complicated in that make would still
> check the rule for the OOP and, if there were any prerequisites that
> had a newer timestamp, the OOP's recipe would be invoked, but beyond
> that, that would have no dependency effect on the original target. in
> short, an OOP would still be *processed* normally, it would just have
> no further effect.
> 
>   i'm trying to think of an example so what about this one. imagine a
> massive SW project, one of whose dependencies is "docs", to update the
> documentation. now if any of the (say) markdown files is updated, then
> the "docs" recipe is invoked to update the online docs. however, since
> documentation has no effect on the actual software, there is no point
> letting that target have any further effect in terms of recompiling
> anything.
> 
>   might not be the best example, but is it accurate?

Looks good to me (except your example, see below). An OOP is processed as any 
regular prerequisites: if it does not exist (or if it is out-of-date) it is 
(re)built before the targets for which it is an OOP. But whether it is 
(re)built or not has no impact on the firing of the rule it is an OOP of.

Simple demo:

$ cat Makefile
a: | b
b: c
a b c:
    touch $@
$ make
touch c
touch b
touch a
$ touch c; make
touch b
$ rm b; make
touch b
$ touch b; make
make: 'a' is up to date.

See? Whatever the reason why 'b' is (re)built, it does not cause 'a' to be 
rebuilt. And if 'b' is newer than 'a', 'a' is not rebuilt.

Your example is not the best we can imagine because in most cases the doc will 
not be a prerequisite at all of the executables. So there will be no need to 
use OOPs. In my humble opinion a better example is the one from the manual: if 
you want to put some of your targets in a subdirectory you must guarantee that 
this subdirectory exists before you build these targets. But you don't want 
these targets to be rebuilt just because the timestamp of the subdirectory 
changed. You want them to be rebuilt only if one of their regular prerequisites 
is newer. But this example is not ideal neither because if the subdirectory 
does not exist yet, the targets do not exist neither and so they will have to 
be rebuilt anyway. The example I personally prefer is the logging of some 
recipes in a 'log' directory. If it does not exist we must create the 'log' 
directory before we execute the recipes but we don't want to execute the 
recipes just because the 'log' directory does not exist or is newer than the 
targets:

apache-started: | /var/log
    systemctl start apache2.service
    touch $@

/var/log:
    mkdir $@
-- 
Renaud Pacalet
Télécom Paris
Campus SophiaTech
450 Route des Chappes, CS 50193
06904 Biot Sophia Antipolis cedex, FRANCE
Tel : +33 (0) 4 9300 8402
Web : http://www.telecom-paris.fr/

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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