This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: About g++ option -MM
On 1/28/06, Peng Yu wrote:
> The above method will replace old version ones with new version ones.
> What if I want to keep both versions like main-g.o and main-o.o?
>
This can be a litle tricky: implicit rules may be used, something like this:
%-g.o : %.cc
$(COMPILE.c) -o $@ -c $<
%-o.o : %.cc
....
The sufficient enough scheme can be much more trickier. I simlify it a lot.
( Nevertheless, you may want to read:
http://make.paulandlesley.org/autodep.html and
http://aegis.sourceforge.net/auug97.pdf )
So, depending on whether you are in debug mode, you generate uniform
suffix to your objects, usually it will be .g.o - debug, .o - optimized:
SUFF :=
for dependency generation you define the following implicit rule:
%.d : %.cc
g++ -MM -MT $<$SUFF $(CPPFLAGS) $(CXXFLAGS) $< > $@
and you include all *.d files that are created:
include $(MY_SRC_LIST: .cc=.d)
Dima.