help-make
[Top][All Lists]
Advanced

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

Re: Problem with .phony .secondary between 3.79.1 and 3.81


From: Andy Juniper
Subject: Re: Problem with .phony .secondary between 3.79.1 and 3.81
Date: Wed, 02 Dec 2009 09:36:44 +0000
User-agent: Thunderbird 2.0.0.21 (X11/20090320)



Philip Guenther wrote:
On Tue, Dec 1, 2009 at 8:39 AM, Andy Juniper <address@hidden> wrote:
  
I need some help with the behaviour .phony .secondary targets, and the way
that this has changed between 3.79.1 and 3.81.

I have a .phony target (i.e. a target which never exists as a real file)
which I only want to be 'built' if something that depends on it needs to be
rebuilt (i.e. a secondary).

This can be demonstrated with a simple makefile:

.PHONY: all
all: fileb

.PHONY: prepare
.SECONDARY: prepare
prepare:
  @echo $@

filea: prepare filea.dep
  @echo $@
  @touch $@

fileb: prepare filea fileb.dep
  @echo $@
  @touch $@

In 3.79.1, this works as expected and the "prepare" target is only rebuilt
if filea or fileb are rebuilt.  Running make a second time just reports that
there is nothing to be done.

But in 3.81, running make a second time will rebuild everything again.
    
...
  
So my questions are:
- was the behaviour which made this work in 3.79.1 accidental or deliberate?
    

The project includes a ChangeLog for *exactly* this reason: so you can
get more detail about what has changed and why.

$ cd make-3.81
$ grep -A1 .PHONY ChangeLog  | head -2
        * remake.c (check_dep): If a file is .PHONY, update it even if
        it's marked intermediate.  Fixes Savannah bug #12331.
$

Eyeballing this:
    http://savannah.gnu.org/bugs/?func=detailitem&item_id=12331

would seem to confirm the connection to .SECONDARY.

(Thus ends today's session of "teach a man to fish...")
  
Looking in the changelog would have been far too easy :-)

I stumbled across the bug after sending the email and concluded that it was probably related.

  
- how to recreate this behaviour in 3.81?
- is there a fix for 3.81 which will recreate the required behaviour?
    

What is the desired behavior when, say, filea.dep is touched and you
then run 'make'?  Do you need for 'prepare' to be built twice, once
before building filea and then again before building fileb?  Or just
the first of those?  If so, I think the simplest solution is to
replace the ".PHONY: prepare" line with "$(shell rm -f prepare)".
  
In the original makefile, the prepare target just deleted the directory in which the build takes place.

The desired effect is that if any one thing needs to be recompiled, then everything needs to be rebuilt from a clean start.

So prepare just needs to be built the once, but only if anything else depending on it needs to be rebuilt.

Earlier versions of make had the behaviour we expected from the docs; a secondary target is only rebuilt if the things depending on it are required.

The change now means that everything rebuilds (because the cleanup target ran) whenever make is invoked.

thanks,
Andy
(Also, I think it's slightly clearer to use .INTERMEDIATE instead of
.SECONDARY, but since the file will never be left around the behavior
will be the same.)


Philip Guenther

  

reply via email to

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