Make Dependency Files for C/C++ Headers

When header files change we need to recompile the C/C++ source files which #include them.

This process of incremental compiles can be optimized make dependency files.

These end in the extension *.d. The contents of one might look like:

main.o: main.cpp ../FOO/FOOblah.h ../DST/DSTutils.h

Notice it is in fact a makefile rule.

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.

To support using these files

# Include generate *.d files for header dependencies -include *.d

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.

Â