[Top][All Lists]

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

Re: question about Generating Prerequisites Automatically

From: Paul D. Smith
Subject: Re: question about Generating Prerequisites Automatically
Date: Sun, 7 May 2006 15:16:19 -0400

%% Lin George <address@hidden> writes:

  lg> Another comment is that, I think the way how make deals with
  lg> intermediate files is smarter than the way dealing with ordinary
  lg> files -- by saving time of remaking unnecessary files. So, why
  lg> make does not change the way dealing with ordinary file to the
  lg> (smarter) way dealing with the intermediate file?

Very simple: it often is not at all what you want.

Consider what happens:

    prog: foo.o bar.o

    .INTERMEDIATE: foo.o bar.o

Now, we run make:

    cc -o foo.o -c foo.c
    cc -o bar.o -c bar.c
    cc -o prog foo.o bar.o

Since there's no "prog" everything is out of date.  So far so good.
Now, we delete bar.o... uh oh!

    cc -o prog foo.o bar.o
    cc: no such file or directory: bar.o

Intermediate files ONLY work with targets that can be _incrementally
built_, or which are built from only one source.  Things like libraries,
where the "ar" program can add new objects to an archive without
recreating it from scratch, are good examples of this.  Or, copying
files from a staging area into a production area, where each file is
managed individually.

If the target needs all the prerequisites to exist at once, like a
linker, then intermediate files don't work.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]