help-make
[Top][All Lists]
Advanced

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

RE: this is embarrasing... prerequisiste gets updated, but make still sa


From: Paul Smith
Subject: RE: this is embarrasing... prerequisiste gets updated, but make still says it is older than target
Date: Mon, 02 Apr 2012 08:24:09 -0400

On Mon, 2012-04-02 at 05:01 -0700, Mark Galeck (CW) wrote:
> Now, consider the target foobar, and prerequisite foobar1.  foobar1 is
> updated, somehow and it moves the timestamp of foobar1 to newer than
> foobar. Therefore by the manual, foobar should update.  

No.  Because as far as make is concerned (as far as the rules in your
makefile have described it), that did not happen.

Think of it like this: internally make constructs a state machine.  The
initial state of the machine consists of the timestamps on the target
files at the time make is invoked.  Make knows, because of the rules
that have been defined in the makefile, how to transition the machine
from one state to another (change the timestamp on the files) by
invoking recipes.

Make has no way of knowing that recipes might transition the machine to
some state other than what they say they will, so it assumes they won't.

Because make is working with an _abstraction_ (the state machine), it's
possible for rules to make changes in the reality (the filesystem) which
make doesn't know about.  If that's true then the result is not what you
expect.


Now, I don't mean to suggest that make works exactly like this in real
life.  In real life, make doesn't look up the timestamps on every target
before it starts, of course.  But, make DOES _cache_ the timestamps of
files as it looks them up and it doesn't update those cached values
unless it has reason to think it needs to (because it believes something
changed).

In your makefile, there's no reason for make to think that the timestamp
on foobar1 has changed, so make doesn't check to see if it did.

-- 
-------------------------------------------------------------------------------
 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]