The
makedepend program reads each
sourcefile in sequence and parses it like a C-preprocessor, processing all
#include, #define, #undef, #ifdef, #ifndef, #endif, #if, #elif and
#else directives so that it can correctly tell which
#include, directives would be used in a compilation. Any
#include, directives can reference files having other
#include directives, and parsing will occur in these files as well.
Every file that a sourcefile includes, directly or indirectly, is what makedepend calls a dependency. These dependencies are then written to a makefile in such a way that make(1) will know which object files must be recompiled when a dependency has changed.
By default,
makedepend places its output in the file named
makefile if it exists, otherwise
Makefile. An alternate makefile may be specified with the
-f option. It first searches the makefile for the line
# DO NOT DELETE THIS LINE -- make depend depends on it.
or one provided with the
-s option, as a delimiter for the dependency output. If it finds it, it will delete everything following this to the end of the makefile and put the output after this line. If it doesn't find it, the program will append the string to the end of the makefile and place the output following that. For each
sourcefile appearing on the command line,
makedepend puts lines in the makefile of the form
sourcefile.o: dfile ...
Where
sourcefile.o is the name from the command line with its suffix replaced with ``.o'', and dfile is a dependency discovered in a #include directive while parsing
sourcefile or one of the files it included.