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