[Top][All Lists]

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

static pattern rules with no commands

From: J.T. Conklin
Subject: static pattern rules with no commands
Date: Wed, 27 Oct 2010 09:04:18 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, berkeley-unix)

I have a static pattern rule in a makefile that is really a
meta-target that is used to ensure others are built.  A cut
down example:

        .PHONY: foo-%
                @echo $@: $*

        .PHONY: bar-%
        bar-% : foo-%
                @echo $@: $*

        .PHONY: baz-%
        baz-%: bar-%
                @echo $@: $*

        .PHONY: quux-%
                @echo $@: $*

        .PHONY: all-%
        all-%: quux-% baz-% bar-% foo-%

When gmake 3.81 is invoked as "gmake all-whatever" returns "no rule to
make target `all-whatever'".  This surprised me, as a similar makefile
using general rules works.  

Static pattern rules without commands are not described in the manual.
So this may simply demonstrate a lack of understanding on my part.  If
the above isn't intended to work, perhaps some additional text could
be added warning users that commands are necessary.

For now, I've worked around this by adding a no-op "true" as a

Also The .PHONY targets in the above makefile don't seem to actually
work.  Is this an unrealistic expectation?  This isn't documented
either.  I can work around this with a FORCE target.

After my workarounds, my makefile looks something like:

        foo-%: FORCE
                @echo $@: $*

        bar-% : foo-% FORCE
                @echo $@: $*

        baz-%: bar-% FORCE
                @echo $@: $*

        quux-%: FORCE
                @echo $@: $*

        .PHONY: FORCE

        .PHONY: all-%
        all-%: quux-% baz-% bar-% foo-%

Is this right, or are there better ways to accomplish this?


J.T. Conklin

reply via email to

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