In reading the manual, I assumed that .PHONY was a better way to force building phony targets.
But I have found a case where it is not and I am inclined to stop using .PHONY altogether because of this.

I want a general purpose 'clean' target for different source file types:
%.clean:
@rm *.$*

I have files: foo.c, foo.h

$make c.clean
should remove only foo.c
$make h.clean
should remove only foo.h

I want this to work even if the files 'c.clean' and 'h.clean' exist

You cannot add the pattern rule target to .PHONY with:
.PHONY: %.clean

If I add c.clean, h.clean to .PHONY however, the pattern rule will not match since there are no explicit rules for these targets
.PHONY: c.clean h.clean

[greg@p3 junk]$ make c.clean
make: Nothing to be done for `c.clean'

So in this case using FORCE: ; is a better solution:

FORCE: ;

%.clean: FORCE
rm *.$*

It might be good to add this to the manual.
- Greg Keraunen



_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to