I am using gcc 4.8.2, and I am trying to build both the object file and the dependency file concurrently.
This works:
$ g++ -std=c++11 -MP -MD -c foo.cxx -o foo.o
$ [ -s foo.d ] && [ -s foo.o ] && echo yay
yay
However, instead of generating foo.d, I want to generate foo.D, so I tried:
$ rm foo.d foo.o
$ g++ -std=c++11 -MP -M -MF foo.D -c foo.cxx -o foo.o
$ [ -s foo.D ] && [ -s foo.o ] && echo yay
$
That successfully generates foo.D, but makes an empty foo.o. Why? The documentation for -MD starts with:
-MD is equivalent to -M -MF file, except that -E is not implied.
-MF foo.Dto the original call?-MFexplicitly mention it that's why I suggested it. I'm not sure why-M -MFdoesn't work though. That strikes me as odd.