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?
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.
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.
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.
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 .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With