Dependency files are a useful tool in optimizing the speed of incremental compiles of C/C++ code. They are a solution for answering the question:
When do I need to recompile this file?
This is what the contents of a dependency file looks like:
main.o: main.cpp ../FOO/FOOblah.h ../DST/DSTutils.h
One could in theory maintain these by hand - but it would be very error prone and time consuming. Instead most good (not Microsoft) C++ compilers can generate these automatically using the -MMD flag. The precise flag will vary depending on the compiler.
Dependency files can be problem for builds. If a change is made such that say a header file is deleted then old dependency files can break the build since they may refer to the deleted header file.
So typically when we clean the build, dependency files need to be deleted.
Couple of questions about dependency files:
What extension do they typically have?
*.d
Does the compiler use these files?
No. The make program uses these files to solve the problem of whether or not to invoke the compiler to translate a C/C++ source file into an object file.
How does GNU make typically use them?
Typically we have include statement in the make file:
# Include generate *.d files for header dependencies -include *.d