help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make dependency using gcc??


From: Paul Smith
Subject: Re: Make dependency using gcc??
Date: Mon, 08 Jan 2007 08:58:48 -0500

On Mon, 2007-01-08 at 19:11 +0530, Geraldin Arthy wrote:

> Actually I'm very confused now.When I use the gcc -MD option it
> compiles and redirects the outout to .d files.But when a modify any
> hearder file specified in the .d file it doesn't recompile at
> all.Could you please help me out to fix this.

As I said, you should be asking on address@hidden  I've cc'd them to
this reply.

> I have included the following lines in my makefile.
>  
> $(OBJS):$(OUTPUT_DIR)/%.o:%.cxx
>         $(CXX) $(CFLAGS) -MD $<
>         $(CXX) $(CFLAGS) $(@F:.o=.cxx) -o $@

You don't need two different commands.  One of the nice things about GCC
is that it will generate the dependency information as a side-effect of
compilation, which saves a lot of time in your builds.

> It generates the dependency information correctly but it does not
> recompile when any change is done to a header file.

You have not given enough information to answer your question.  Where
are your source files?  Where are your object files?  Where are your
output prerequisite files files?  Where is make invoked from in relation
to these?  What does your include line look like for the prerequisite
files?

Almost without question the problem is one of pathnames.

> I also tried giving the following option but still it doesnn't work.
> $(OBJS):$(OUTPUT_DIR)/%.o:%.cxx
>         $(CXX) $(CFLAGS) -MD -o $@ $<

>From this it looks like your .cxx files are in the same directory make
is invoked from, and your object files get put into $(OUTPUT_DIR).
Where do you expect your .d files to be placed?  Are they being placed
there?

If you look at the content of the .d file does it use the full name of
the .o ($(OUTPUT_DIR)/xxxx.o) not just the filename with no path?  To
make, the files "xxxx.o" and "$(OUTPUT_DIR)/xxxx.o" are two totally
different files (unless OUTPUT_DIR=.), and prerequisites declared for
one won't impact the other at all.

Etc.  This is where you have to look to solve your problem.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]