Phony targets not being made

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Phony targets not being made

christian
Hi

I have the following makefile
--
PHON1 := rr1 rr2
PHON2 := rr1-sim

.PHONY: all $(PHON1)
# remove below line to get rr1-sim done
.PHONY: $(PHON2)

all: $(PHON1) $(PHON2)
        @echo all done

%-sim: %
        @echo doing $@

$(PHON1):
        @echo doing $@
--
The command 'make' gives the output
doing rr1
doing rr2
all done
Thus rr1-sim is not done.
The command 'make rr1-sim' gives the output
make: Nothing to be done for 'rr1-sim'.
Removing the phony declaration of rr1-sim makes things work as I expect.
'make' gives the output
doing rr1
doing rr2
doing rr1-sim
all done

Is this a bug or is there anything wrong in the Makefile?

Regards
Christian Paulsen


Reply | Threaded
Open this post in threaded view
|

Re: Phony targets not being made

Gnu - Make - Bugs mailing list
Good morning.

Your makefile is incorrect.
Make does not search implicit rules for phony targets.

regards, Dmitry

On Thu, Feb 13, 2020 at 2:31 PM <[hidden email]> wrote:

>
> Hi
>
> I have the following makefile
> --
> PHON1 := rr1 rr2
> PHON2 := rr1-sim
>
> .PHONY: all $(PHON1)
> # remove below line to get rr1-sim done
> .PHONY: $(PHON2)
>
> all: $(PHON1) $(PHON2)
>         @echo all done
>
> %-sim: %
>         @echo doing $@
>
> $(PHON1):
>         @echo doing $@
> --
> The command 'make' gives the output
> doing rr1
> doing rr2
> all done
> Thus rr1-sim is not done.
> The command 'make rr1-sim' gives the output
> make: Nothing to be done for 'rr1-sim'.
> Removing the phony declaration of rr1-sim makes things work as I expect.
> 'make' gives the output
> doing rr1
> doing rr2
> doing rr1-sim
> all done
>
> Is this a bug or is there anything wrong in the Makefile?
>
> Regards
> Christian Paulsen
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Phony targets not being made

Peter Dons Tychsen
Hi All,

> Your makefile is incorrect.
> Make does not search implicit rules for phony targets.

There are no implicit rules used in the example AFAIK.
They are all phony and/or pattern rules, but not implicit unless i am
missing something.

Still, it does not explain why marking the addtional rule as PHONY
changes the result.

I think the example is valid.

Thanks,

/pedro


Reply | Threaded
Open this post in threaded view
|

Re: Phony targets not being made

Gnu - Make - Bugs mailing list
In reply to this post by Gnu - Make - Bugs mailing list
On Sun, Feb 16, 2020 at 5:35 PM Peter Dons Tychsen <[hidden email]> wrote:
> There are no implicit rules used in the example AFAIK.

'%-sim: %' is the intended implicit rule that make does not look for
because rr1-sim is phony.


> They are all phony, but not implicit unless i am missing something.
Targets could be phony. Rules could be implicit.


> Still, it does not explain why marking the addtional rule as PHONY
> changes the result.

There is no such thing as 'marking the addtional rule as PHONY'.
As soon as 'PHONY: $(PHON2)' line is removed rr1-sim is no longer a
phony target and make finds
implicit rule %-sim: % to build this target.

regards, Dmitry

>
> I think the example is valid.
>
> Thanks,
>
> /pedro
>
> > >
> > >

Reply | Threaded
Open this post in threaded view
|

Re: Phony targets not being made

Peter Dons Tychsen
Hi Dmitry

> '%-sim: %' is the intended implicit rule that make does not look for
> because rr1-sim is phony.

Ah, yes i missed that the pattern rule was also an implicit rule.

> There is no such thing as 'marking the addtional rule as PHONY'.
> As soon as 'PHONY: $(PHON2)' line is removed rr1-sim is no longer a

Yes, i meant the target, not the rule.

> phony target and make finds
> implicit rule %-sim: % to build this target.

OK, thanks for clearing this up.

I also found this in the docs:

"The implicit rule search (see Implicit Rules) is skipped for .PHONY
targets. This is why declaring a target as .PHONY is good for
performance, even if you are not worried about the actual file
existing".

Thanks for the help.

/pedro