help-make
[Top][All Lists]
Advanced

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

Re: The explanation of order-only prerequisites is not clear


From: Paul Smith
Subject: Re: The explanation of order-only prerequisites is not clear
Date: Mon, 13 Sep 2010 09:18:03 -0400

On Sun, 2010-09-12 at 11:16 +0430, ali hagigat wrote:
> I have copied one line of the make manual:
> -----------------------------------------------------------------------------
> "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. "
> ------------------------------------------------------------------------------
> Now Lets take a look at the following example:
> target1:  | di1
>         @echo "inside target1"
>         @touch target1
> di1:
>         @echo "inside di1"
> 
> If target1 does not exist, even the order-only prerequisite, di1, will
> force target1 to be updated!

No it won't.  Yes, the target will be updated, but not because of the
order-only prerequisite.  It's because the target doesn't exist.

This can be trivially proven, by removing the order-only prerequisite
and observing that target1 is still rebuilt.  Therefore it's clear that
the existence of the order-only prereq is not the triggering factor.

Note that the manual says "without _forcing_ the target to be
update" (emphasis added).  It doesn't say the target will not be
updated.  It says that it won't be updated due to the order-only prereq
being newer.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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