代码(红色部分)来自于《GNU Make Manual》4.14 Generating Prerequisites Automatically
http://www.gnu.org/software/make/manual/html_node/Automatic-Prerequisites.html#Automatic-Prerequisites
%.d: %.c
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; /
sed 's,/($*/)/.o[ :]*,/1.o $@ : ,g' < $@.$$$$ > $@; /
rm -f $@.$$$$
$ cat hello.c
#include <stdio.h>
int main(int argc, char* argv[])
{
printf("Hello, world!/n");
}
$ gcc -M hello.c
hello.o: hello.c /usr/include/stdio.h /usr/include/features.h /
/usr/include/sys/cdefs.h /usr/include/bits/wordsize.h /
/usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h /
/usr/lib/gcc/i686-redhat-linux/4.5.1/include/stddef.h /
/usr/include/bits/types.h /usr/include/bits/typesizes.h /
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h /
/usr/lib/gcc/i686-redhat-linux/4.5.1/include/stdarg.h /
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h
$ gcc -M hello.c | sed 's//(hello/)/.o[ :]*//1.o hello.d : /g'
hello.o hello.d : hello.c /usr/include/stdio.h /usr/include/features.h /
/usr/include/sys/cdefs.h /usr/include/bits/wordsize.h /
/usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h /
/usr/lib/gcc/i686-redhat-linux/4.5.1/include/stddef.h /
/usr/include/bits/types.h /usr/include/bits/typesizes.h /
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h /
/usr/lib/gcc/i686-redhat-linux/4.5.1/include/stdarg.h /
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h