help-make
[Top][All Lists]
Advanced

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

Re: auto-dependency usefulness?


From: Paul D. Smith
Subject: Re: auto-dependency usefulness?
Date: Thu, 2 Oct 2003 01:13:30 -0400

%% Bryce Schober <address@hidden> writes:

  bs> When I first looked at the auto-dependency stuff at 
  bs> http://make.paulandlesley.org/autodep.html, I was pretty excited, but 
  bs> now I'm not so sure.  What I'd really like is this:

  bs> lib/
  bs>    foo.h
  bs>    foo.c
  bs> src/
  bs>    main.c

  bs> In this scenario, foo.h declares a "library" function defined in
  bs> foo.c.  This function is called in main.c, which includes foo.h.
  bs> As far as I know, this is the generally accepted way to modularize
  bs> things.  However, gcc's dependency generation doesn't trace
  bs> main.c's dependency on foo.c, only on foo.h.

That's because there isn't a dependency between main.c and foo.c.

  bs> How can this dependency be known?  Or even assumed, given that
  bs> there is a corresponding .c file for .h file?

It can't be known, because it doesn't exist.

If you change something in foo.c, do you have to recompile main.c?  No.
So, there is no dependency relationship there.


Now, maybe you take foo.c and turn it into foo.o, then you turn that
into libfoo.a.  And maybe you compile main.c into main.o, then you link
main.o with libfoo.a and create a program "main".

In that case, the program "main" has a dependency on both main.o and the
library libfoo.a, and main.o depends on main.c and foo.h.  Also,
libfoo.a depends on foo.o which depends on foo.c and foo.h.

But, main.c does not depend on foo.c.


As for that auto-dependency generation yes, it's very true that it only
deals with header files, or "source file prerequisites".  You still have
to define all the "internal" prerequisites, like "main" depending on
main.o and libfoo.a, yourself in the makefile.  No automated dependency
generator could ever figure out that part for you.

-- 
-------------------------------------------------------------------------------
 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]