This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Dependency generation with -MM
- From: Mihnea Balta <dark_lkml at mymail dot ro>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 30 Jul 2003 12:17:36 +0300
- Subject: Re: Dependency generation with -MM
- References: <200307301209.27990.dark_lkml@mymail.ro>
As a side note, these two manual entries seem conflicting:
The entry for the -M flag says:
"The preprocessor outputs one make rule containing the object file name for
that source file, a colon, and the names of all the included files [...]"
The entry for the -MT flag says:
"By default CPP takes the name of the main input file, _including any path_,
deletes any file suffix such as .c, and appends the platform's usual object
suffix. The result is the target."
On Wednesday 30 July 2003 12:09, Mihnea Balta wrote:
> 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.
>
> ---------------------------------------------------------------
> Acasa.ro vine cu albumele, tu vino doar cu pozele ;)
> http://poze.acasa.ro/