Back in March 2006 I wrote about forcing GNU Make to rebuild
targets when commands change. Another common request is to
rebuild when the contents of a file change, and not just its
time stamp. This usually comes up because the timestamps on
generated code, or in code extracted from a source code control
system, are older than related objects and hence GNU Make does
not know to rebuild the object. This can occur even though the
contents of the file are different from the last time the object
was built. A common scenario is that an engineer working on a
build on their local machine rebuilds all objects and later gets
the latest version of source files from source code control.
Some source control systems set the timestamp on the source
files to the timestamp set when the file was checked in; in that
case the newer object files will have timestamps that are later
than then, potentially changed, source code. In this article I
show a simple hack to GNU Make to cause it to do the right thing
when the contents of a