The -M preprocessor option (and -MM and similar options) strips the directory part from the listed object file names. The documentaion for -M says:
"Unless specified explicitly (with `-MT' or `-MQ'), the object file name consists of the basename of the source file with any suffix replaced with object file suffix." I interpret the word "basename" in the manual text to include directories as the basename function in GNU make does, however the actual output is without directories: === Content of test/test.c === #include "test.h" #include <stdio.h> int main () { puts (GREETING); } === Content of test/test.h === #ifndef TEST_H #define TEST_H #define GREETING "Hello world" #endif =============================== $ gcc -MM test/test.c test.o: test/test.c test/test.h $ I had expected the output to be: "test/test.o: test/test.c test/test.h". -- Summary: The -M option gives object file names without directory Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: preprocessor AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bje at safepro dot dk CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20989