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: Thu, 4 May 2006 08:31:20 -0400

%% Lin George <address@hidden> writes:

  >> For "normal" targets, if the file does not exist it WILL be remade,
  >> and that WILL cause the ultimate target to be remade.
  >> 
  >> For intermediate files, they won't be remade unless needed, EVEN IF
  >> THEY DON'T EXIST.

  lg> I think the above statements mean that if immediate
  lg> files are needed, they will be remade. Correct? I
  lg> think it is the same as ordinary file.

Sure.  If a file is needed and make knows how to make it, make will make
it.

However, with intermediate files the definition of "needed" is slightly
altered.

  lg> I think another meaning of above statements is ordinary file will
  lg> be remade if they do not exist even if they are not needed. I can
  lg> not imagine why they will be remade even if they are not needed?

Your statement is not true: in both cases files are remade if and only
if they are "needed".  But "needed" is an ambiguous term.

  lg> Could you show me an example please? :-)

  $ cat Makefile

  prog: inter ; touch $@
  inter: source ; touch $@

  $ touch source
  $ touch prog

All of the targets prog, inter, and source are ordinary targets.  prog
is newer than source, but inter does not exist.

If I run "make" here, inter will be remade because it does not exist,
then prog will be touched because inter is now newer than prog.


If I add a line:

    .INTERMEDIATE: inter

to change inter into an intermediate file, then I run "make", make will
see that prog is newer than source, and because inter is intermediate
make knows that it does not have to exist.  So, make will do nothing
here, just say "prog is up to date".


For ordinary files, a file is automatically determined to be out of date
(and thus MUST be rebuilt) if it doesn't exist, regardless of the
relationship of its prerequisites.

For intermediate files, a file that does not exist is not out of date
just because it doesn't exist.  It's only out of date if make determines
that one of its prereqisites is newer than one of its upstream targets.

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