help-make
[Top][All Lists]
Advanced

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

Re: intermediate files rebuilt unexpectedly


From: Paul D. Smith
Subject: Re: intermediate files rebuilt unexpectedly
Date: Wed, 16 Apr 2003 16:53:13 -0400

%% NvB <address@hidden> writes:

  n> libmysf.a: sf1.o sf2.o sf3.o

Here you say, "to build libmysf.a I need to use the objects sf1.o,
sf2.o, and sf3.o".

  n> address@hidden prob1]# make
  n> gcc -Iincl   -c -o sf1.o src/sf1.c
  n> gcc -Iincl   -c -o sf2.o src/sf2.c
  n> gcc -Iincl   -c -o sf3.o src/sf3.c
  n> ar rf libmysf.a sf1.o sf2.o sf3.o

Here they all get built.

  n> rm sf1.o sf3.o sf2.o

And here, because you declared them intermediate, they all get removed
again.

  n> But when I touch sf3.c everything gets rebuilt.

That's because make sees that it needs to rebuild libmysf.a.  It sees
that in order to rebuild libmysf.a, it needs the objects sf1.o, sf2.o,
and sf3.o.  It sees that those don't exist, so it builds them.

Remember that make doesn't know that "libmysf.a" is some kind of special
target that doesn't really need all the objects to exist: to make it's
just another target and is treated the same way as, say, an executable:
to relink an executable you'd need make to rebuild all the .o's.

If you want to tell make that libmysf.a is a library and can be built
incrementally then you need to use the special library syntax in your
makefile; see the GNU make manual chapter on "Using 'make' to Update
Archive Files".

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