bug-make
[Top][All Lists]
Advanced

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

Re: Potential Bug: `.PHONY` targets and order-only prerequisites


From: Martin Dorey
Subject: Re: Potential Bug: `.PHONY` targets and order-only prerequisites
Date: Tue, 17 May 2022 22:32:36 +0000

all your targets are .PHONY, and thus are always rebuilt anyway

If you "make down", the rule for "down-clean" doesn't run.  They're only rebuilt if something causes them to be considered.

order-only prerequisites are totally irrelevant and have no impact on
> your makefile.

If you comment-out the order-only prerequisite that says that the up target depends on down-clean, then the recipe for down-clean doesn't get run when you "make up".


From: Bug-make <bug-make-bounces+martin.dorey=hds.com@gnu.org> on behalf of Paul Smith <psmith@gnu.org>
Sent: Tuesday, May 17, 2022 14:20
To: Jacob Kopczynski <jacob.kopczynski@luthersystems.com>; bug-make@gnu.org <bug-make@gnu.org>
Subject: Re: Potential Bug: `.PHONY` targets and order-only prerequisites
 
***** EXTERNAL EMAIL *****

On Tue, 2022-05-17 at 14:00 -0700, Jacob Kopczynski wrote:
> I'm unsure whether this is a bug or just undocumented, but I found a
> confusing interaction in a simple Makefile:

You are misreading the documentation.  I will quote:

> A normal prerequisite makes two statements: first, it imposes an
> order in which recipes will be invoked: the recipes for all
> prerequisites of a target will be completed before the recipe for the
> target is run. Second, it imposes a dependency relationship: if any
> prerequisite is newer than the target, then the target is considered
> out-of-date and must be rebuilt.

Hopefully that is clear.  To give an example, if you have:

  a: b c

this says two things: first, that b and c will both be rebuilt (if
necessary) before a's recipe is started, and second, that if either b
or c are newer than a (if a is out of date with respect to b or c),
then a will be considered out of date and rebuilt.

The docs go on to say:

> 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. In that case,
> you want to define order-only prerequisites.

What this means is that if you have:

  a: b | c

then the ordering statement (that both b and c will be rebuilt (if
necessary) before a's recipe is started) is still in place for both
prerequisites b and c.

However, the second statement, that a is considered out of date if it's
older than the prerequisite, only is in effect for b, and not for c.

"c" is an "order-only" prerequisite in that it is ordered before "a",
but if it's updated then that doesn't mean "a" will be updated.

Since all your targets are .PHONY, and thus are always rebuilt anyway,
order-only prerequisites are totally irrelevant and have no impact on
your makefile.


reply via email to

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