11

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

agent.smith
  • 9,134
  • 9
  • 37
  • 49

2 Answers2

12

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.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
  • 2
    Does that mean, make creates a database when it runs for the first time? If that is the case then I wont be able to improve compilation time when thr repo is checked out. – agent.smith Sep 21 '11 at 22:48
  • @agent.smith: The makefile itself is a database of sorts, a database of production rules. – mu is too short Sep 21 '11 at 23:26
  • Is there any way to improve compilation time one first checkout using already compiled binaries on the server? – agent.smith Sep 21 '11 at 23:37
  • You just have to make sure the timestamps line up so `make` doesn't think it needs to build anything. – mu is too short Sep 21 '11 at 23:59
  • Relying on last-modification times seems like a shortcoming. [Some file systems](http://stackoverflow.com/questions/18403588/how-to-return-millisecond-information-for-file-access-on-mac-os-x-in-java) only record these times to the nearest second. So how can `make` know how to do the right thing if file modifications and calls to `make` happen quickly and repeatedly? – landau Feb 11 '17 at 18:52
-1

If you are using make I do not think that you should put these binaries into the repository - simply just enable make to check that they are up to date. You can always rebuildd them. This is especially true if you are not the only person working on the project. You will need to update some of these files in the future and hence recompile them. If you are under the illusion that they are not going to change you might get bitten when things do not work.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127
  • @Ed: The idea is most of the files in the project do not change. When any one gets a new copy of repo then I dont want him/her to compile the whole thing. I am wondering if I can keep a track of git tags and binaries. If git tag and binary matches then just copy the binary else compile. I am just experimenting with an idea to improve speed of compilations. – agent.smith Sep 21 '11 at 22:46