Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does GNU make keep track of file changes?

So when you run make without changing any of the dependencies it says target upto date. I was curious how it keeps track of changes to the files, does it have some kind of revision control system under the hood. If so, where are these files stored?

like image 762
abc def foo bar Avatar asked Apr 08 '14 15:04

abc def foo bar


People also ask

How does makefile know if 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.

How does GNU make work?

GNU Make is a program that automates the running of shell commands and helps with repetitive tasks. It is typically used to transform files into some other form, e.g. compiling source code files into programs or libraries. It does this by tracking prerequisites and executing a hierarchy of commands to produce targets.

How does make know when to update?

It checks is to see if the date/time stamp on the source file is later than that on the corresponding intermediate file (or perhaps the output file - it's been a while since I dealt with make files). If it is then the file needs to be complied. This will then trigger the linking of the final executable.

What does make for makefile do?

The make utility requires a file, Makefile (or makefile ), which defines set of tasks to be executed. You may have used make to compile a program from source code. Most open source projects use make to compile a final executable binary, which can then be installed using make install .


1 Answers

No, it just compares the last-modified dates of the files.

If the target is newer than all of its dependencies, it's up to date. Otherwise the relevant dependencies are re-built.

like image 59
unwind Avatar answered Sep 22 '22 14:09

unwind