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 <[email protected]>          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



_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to