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: Philip Guenther
Subject: Re: Problem with .phony .secondary between 3.79.1 and 3.81
Date: Tue, 1 Dec 2009 13:27:29 -0800

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...")


> - 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)".

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