bug-make
[Top][All Lists]
Advanced

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

Order-only prerequisites


From: Frank Heckenbach
Subject: Order-only prerequisites
Date: Wed, 07 Jun 2023 04:20:19 +0200

GNU Make 4.4.1

Consider this makefile:

.PHONY: a b
a:; @echo a
b:; @echo b
b: | a

What I want to achieve is that a and b can be made independently,
but when both of them are made, a is always made first. I assumed
that's what order-only prerequisites are for, but they don't seem to
work like this:

% make a b
a
b

As expected.

% make b a
a
b
make: Nothing to be done for 'a'.

Correct order, but the last message seems strange.

Is this supposed to appear?

% make b
a
b

That's my real problem here. So apparently ": |" does not affect
order only, as the name seems to imply, but also forces a to be
made. So in this case they seem to behave just like normal
prerequisites (including the questionable message above).

Are they supposed to behave like this?

If so, is there another way to achieve what I want?

--

The manual says:

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

Actually, there's a third statement: When the target is made, any
prerequsite is made (if necessary), too.

You may say that's part of the dependency relationship (2.), but
then the behaviour of order-only prerequsites is even more strange,
since they do 1. and 3., but not 2. as I understand it.

If that's really intended, you might want to explain this much more
clearly in the manual, and perhaps rename them, since that's not
about order only.



reply via email to

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