help-make
[Top][All Lists]
Advanced

[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: Wed, 10 May 2006 09:09:39 -0400

%% Lin George <address@hidden> writes:

  >> 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
  >> 
  >> cc -o prog foo.o bar.o
  >> cc: no such file or directory: bar.o

  lg> I think in this sample, you mean when bar.o is removed, the
  lg> command "cc -o prog foo.o bar.o" will not work to generate prog,
  lg> since bar.o will not be remade after deletion. Is it your points?

Yes.

  lg> If it is, my question is that, according to the rule in GNU make,
  lg> intermediate file will be remade if they are needed, so why in
  lg> this case (it seems that prog's dependency bar.o is needed) bar.o
  lg> is not remade? I think make treats bar.o in this case as a file
  lg> not needed?

No, not at all.  As I explained in a previous message, by declaring a
file to be intermediate you are CHANGING make's definition of "needed"
for that target.  That's what the "intermediate" flag DOES.

So, make uses one set of rules to determine when to rebuild normal
targets (that are not "intermediate"), and it uses a different set of
rules to determine when to rebuild targets that ARE "intermediate".


You suggested that make should treat all targets as "intermediate", but
it can't do that because the rules for rebuilding intermediate targets
aren't appropriate for all situations: I gave you an example of such a
situation.


Maybe it would help your understanding if you tried to write down, in
simple, detailed terms, exactly how make should determine whether a
target is "needed" or not.

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