help-make
[Top][All Lists]
Advanced

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

Re: INTERMEDIATE and include files


From: Paul Smith
Subject: Re: INTERMEDIATE and include files
Date: Wed, 13 Oct 2010 14:09:40 -0400

On Wed, 2010-10-13 at 17:39 +0000, Saurabh T wrote:
> The following is a simple Makefile that demonstrates the problem I'm facing:
> 
> a.out: tmp hw.o
>         cc hw.o
> 
> include tmp
> .INTERMEDIATE: tmp
> 
> tmp:
>         echo -e "hw.o: hw.c\n\tcc -o hw.o -c hw.c" >$@
> 
> 
> hw.c exists and compiles (it's a hello world).
> 
> What I want to happen is tmp is built, hw.o is built, a.out is built, tmp is 
> removed.
> What happens is make goes into an infinite loop doing just the tmp target.

You cannot do this: included files cannot be intermediate.

When make decides to rebuild an included file it runs all the normal
rules and cleans up just as it normally would, which removes
intermediate files, then it re-execs itself.

On re-exec, the included file does not exist (because the previous
invocation cleaned up intermediate files) and so make builds it again,
cleans it up again, re-execs itself... etc.

It would be good if make could detect this and either fail or ignore the
intermediate setting on included files, rather than going into an
infinite loop.


However, in order to work the way you'd like (which is, I assume, that
intermediate files are somehow only removed in the final re-exec of make
but in the intermediate ones) make would somehow have to communicate to
the re-exec'd version of make that these files were created as
intermediates.  Currently there's no way for make to do that, so such a
thing would have to be invented first.




reply via email to

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