[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The problem of the chained implicit rule?
From: |
Paul Smith |
Subject: |
Re: The problem of the chained implicit rule? |
Date: |
Tue, 24 Nov 2009 01:54:47 -0500 |
On Tue, 2009-11-24 at 00:26 -0600, Peng Yu wrote:
> I have the following makefile. I thought that 'a.y' and 'b.y' should
> be printed. But it is not. What is the problem?
>
> $ ls
> a.x b.x Makefile
> $ cat Makefile
> .PHONY: all
>
> Y_FILES=$(patsubst %x,%y,$(wildcard *.x))
>
> .PHONY: $(Y_FILES)
>
> all: $(Y_FILES)
>
> %.y: %.x
> echo $@
> $ make
> make: Nothing to be done for `all'.
You have missed one of the fundamental features of .PHONY targets. From
the GNU make manual section on "Phony Targets":
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::). This is why
declaring a target phony is good for performance, even if you
are not worried about the actual file existing.
If you remove the ".PHONY: $(Y_FILES)" line above it will work as you
expect.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist