This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Dependency generation with -MM


Hello,

I want to implement an automated system that generates dependency information 
for my project's sources. I've used the standard technique:

OBJS=a.o b.o ../../directory/c.o

...

dep:
	/bin/rm -f depend
	for i in $(OBJS); do \
		$(CPP) -MM $(CPPFLAGS) `echo $$i | sed "s/\(.*\)\\.o$$/\1.cpp/"` >> depend;\
	done

ifeq (depend,$(wildcard depend))
include depend
endif

The problem with this approach is that the following line:
g++ -MM ../../directory/c.cpp
outputs the following make rule:
c.o: ../../directory/c.cpp

I would like it to output the rule as:
../../directory/c.o: ../../directory/c.cpp

Is there any way to do this with a g++ switch (I couldn't find one in the 
manual), or do I have to write my own utility to perform that conversion?

Thanks in advance.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]