The makedepend program reads each sourcefile in sequence and parses it like a C-preprocessor so that it can correctly tell which #include directives would be used in a compilation.
These dependencies are then written to a makefile in such a way that make will know which object files must be recompiled when a dependency has changed.