help-make
[Top][All Lists]
Advanced

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

Re: PHONY targets and implicit rules


From: Philip Guenther
Subject: Re: PHONY targets and implicit rules
Date: Tue, 20 Dec 2011 20:58:52 -0800

On Tue, Dec 20, 2011 at 6:05 AM, Ilya Loginov <address@hidden> wrote:
> I've created simple Makefile:
>
> .PHONY: Makefile
> %:
>       address@hidden "executing target $*"
>
> I suppose that implicit rule will be called for target Makefile. But I have 
> following:
>
> $ make Makefile
> make: Nothing to be done for `Makefile'.
>
> After that I've created explicit rule for Makefile:
>
> Makefile:
>       address@hidden "executing target Makefile"
>
> Now I have following:
>
> $ make Makefile
> executing target Makefile
> make: Nothing to be done for `Makefile'.
>
> So, I have 2 questions:
> 1) Does implicit rules called for phony targets?

No.  As it says in the info pages:
----
   Since it knows that phony targets do not name actual files that
could be remade from other files, `make' skips the implicit rule search
for phony targets (*note Implicit Rules::).
----

> 2) Why in second case I get message "Nothing to be done for `Makefile'"?

Your Makefile, if taken literally, would result in an infinite loop,
as make would have to build the Makefile, then reinvoke itself, then
rebuild the Makefile, then reinvoke itself, etc.  So, since your
Makefile is broken, *anything* make does is correct.  No?


Philip Guenther



reply via email to

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