4.3 Types of Prerequisites
There are actually two different types of prerequisites understood by
GNU make
: normal prerequisites such as described in the
previous section, and order-only prerequisites. A normal
prerequisite actually makes two statements: first, it imposes an order
of execution of build commands: any commands necessary to build any of
a target's prerequisites will be fully executed before any commands
necessary to build the target. 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.
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. In that
case, you want to define order-only prerequisites. Order-only
prerequisites can be specified by placing a pipe symbol (|
)
in the prerequisites list: any prerequisites to the left of the pipe
symbol are normal; any prerequisites to the right are order-only:
| targets : normal-prerequisites | order-only-prerequisites
|
The normal prerequisites section may of course be empty. Also, you
may still declare multiple lines of prerequisites for the same target:
they are appended appropriately. Note that if you declare the same
file to be both a normal and an order-only prerequisite, the normal
prerequisite takes precedence (since they are a strict superset of the
behavior of an order-only prerequisite).