- Parses .c files for other files they include, then
writes them in the form of a dependency rule in a
makefile.
- For example, if foo.c #includes foo.h, bar.h, and quux.c, it will
add a rule of the form:
foo.c: foo.h bar.h quux.c
to the makefile
- old way to use:
dep:
makedepend $(CPPFLAGS) *.c
will remake all dependencies when make dep is called,
and write them to the end of the current makefile
- gmake way to use (as suggested by Mike Whitson):
include *.d
%.d: %.c
$(SHELL) -ec '$(CC) -M \
$(CPPFLAGS) $< | \
sed '\''s/$*.o/& $@/g'\'' \
> $@'
(gmake considers all included makefiles as targets,
and, if any needed to be recreated, reruns itself with
the updated makefiles.)