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: Lin George
Subject: Re: question about Generating Prerequisites Automatically
Date: Sun, 7 May 2006 01:07:33 -0700 (PDT)

Thank you Paul!


Your answer is cool! It has answered my question. BTW,
your example is very nice for a newbie to learn the
concepts of intermediate file, so I suggest it could
be added to GNU make manual.

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


regards,
George

--- "Paul D. Smith" <address@hidden> wrote:

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


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]