Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does make track timestamps

Tags:

makefile

How does make keep timestamps for files? I am trying to put in place my git repo. I am adding precompiled binaries for files which are mostly not gonna change. Now, when I checkout repo from git then I dont want to compile these c files. I want to use these prebuilt binaries. So, to set up this scheme, I want to know how makefile tracks timestamps. Can anyone help me?

Thanks

like image 780
agent.smith Avatar asked Sep 21 '11 22:09

agent.smith


People also ask

How does make detect changes?

In typical usage make detects that a file input to the build has changed (by observing its timestamp relative to the output) and uses this to decide that a rebuild of this part of the system is needed.

How does make know when a file has changed?

Make works by inspecting information about files, not their contents. Make works out dependencies between targets and their dependencies, and then looks to see whether the files exist. If they do, it asks the operating system for the time and date the file was last modified.


1 Answers

make looks at the last-modified times. From the GNU make manual:

The make program uses the makefile data base and the last-modification times of the files to decide which of the files need to be updated.

And from IEEE Std 1003.1-2008 make manual:

The make utility examines time relationships and shall update those derived files (called targets) that have modified times earlier than the modified times of the files (called prerequisites) from which they are derived.

You can use touch:

touch - change file access and modification times

to adjust the timestamps if necessary.

like image 114
mu is too short Avatar answered Oct 03 '22 01:10

mu is too short