[Top][All Lists]

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

Re: static pattern rules with no commands

From: Paul Smith
Subject: Re: static pattern rules with no commands
Date: Wed, 27 Oct 2010 13:01:23 -0400

On Wed, 2010-10-27 at 09:04 -0700, J.T. Conklin wrote:
> 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:

These are not static pattern rules.  They are pattern rules.

Static pattern rules are actually explicit rules, while pattern rules
are a form of implicit rules (I didn't name them!! :-)).  Check the

A static pattern rule would look like:

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

>         .PHONY: all-%

I'd have to double-check but I'm pretty sure you cannot use patterns
in .PHONY targets.  In other words, this declares the actual static
string "all-%" as a phony target, it does not declare every target that
starts with "all-" as phony.

>         all-%: quux-% baz-% bar-% foo-%

If you look in the GNU make manual for pattern rules, not static pattern
rules, you can find the section "Canceling Implicit Rules" which will
explain the behavior you're seeing.

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

This is correct although I recommend using the shell builtin ":", or
else the empty string; GNU make actually has special handling which will
treat these more efficiently (it won't try to run a command at all).  If
you elect the "empty-string" approach I HIGHLY recommend using an empty
variable, so it's obvious what's going on:

        NO-OP :=

        all-%: ...


        all-%: ...
                : do nothing

reply via email to

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