[bug] -MT option and generating dependencies in one compiler pass.
Neil Booth
neil@daikokuya.co.uk
Fri May 2 22:59:00 GMT 2003
Manu wrote:-
> > -MMD implies an -MQ target. Since you can specify multiple targets
> > for the dependency, your -MT is in addition to the implicit target,
> > and does not replace it.
>
> Ok, I see.
>
> Though, I have the same result with -MQ:
> $(OBJDIR)/%.o : %.c
> $(COMPILE) -MQ$@ -MMD -MF$(DEPDIR)/$*.Po -c $< -o $@
>
> Result:
> ../obj/file1.o ../obj/file1.o: file1.c file1.h
>
> OTOH, if I remove -MT or -MQ, it works as expected:
> $(OBJDIR)/%.o : %.cpp
> $(COMPILE) -MMD -MF$(DEPDIR)/$*.Po -c $< -o $@
>
> Result:
> ../obj/file2.o: file2.cpp file1.h
Yes, that's what I meant above.
> So, if I understand well, I must not use -MT / -MQ ?
There's nothing to stop you, just that -MD and -MMD add an invisible
extra target.
> This confuses me, because the manual says "With `-MT' you can specify a
> target yourself, overriding the default one."
Unfortunately, for historical reasons, the behaviour of the -M options
is complex and convoluted, but changing it would break backwards
compatibility.
The manual entry is referring to the non-MMD and -MD options (i.e. -M
and -MM). -MMD and -MD have the default appended by the driver, again
for historical reasons, so CPP has no way of knowing what was your
switch and what was added by the driver.
The docs on the -M options need rewriting. Unforunately, the rewrite
would be full of "but if you do A, then B, except if C then D"...
One day, when I've finished CPP language support, I'll rewrite the
-M documentation. Or someone else could beat me to it.
Neil.
More information about the Gcc-bugs
mailing list