gcc-makedepend -- gcc-based makedepend clone


gcc-makedepend {-p prefix} [gcc or g++ options] {source}


gcc-makedepend works like makedepend but is based upon the -MM option of gcc. This has the advantage that all standard include directories are considered including those which are not known to makedepend.

gcc-makedepend updates either makefile or Makefile, whatever is found first, by adding or updating the actual list of header file dependencies of all given sources.

Like makedepend, gcc-makedepend generates and honors the


comment line within the to-be-updated makefile, i.e. if this line is found, all makefile lines behind it are considered to be a to-be-updated list of dependencies, and, if this line is not yet present, it will be generated together with the newly generated dependencies. In consequence, neither this line nor any makefile contents beyond this line should be touched except by gcc-makedepend.

The option -p allows to specify a prefix that will be prepended to all dependency lines output by gcc. This is useful if the target directory for output files is not the current directory. If multiple prefix options are given, each output line by gcc will be repeated for each prefix with the individual prefix applied.


This is not the first attempt to develop a gcc-based replacement of makedepend. Another solution named makedependgcc was previously developed by David Coppit which, however, diverts from the original makedepend invocation line, provides no error recovery with the danger of corrupting the to-be-updated makefile, and which does not come with a manual page. makedependgcc gave, however, the insight that the -M option of gcc can be used to avoid makedepend.


Andreas F. Borchert