10.5.5 Match-Anything Pattern Rules
When a pattern rule's target is just `%', it matches any file name
whatever. We call these rules match-anything rules. They are very
useful, but it can take a lot of time for
make to think about them,
because it must consider every such rule for each file name listed either
as a target or as a prerequisite.
Suppose the makefile mentions `foo.c'. For this target,
would have to consider making it by linking an object file `foo.c.o',
or by C compilation-and-linking in one step from `foo.c.c', or by
Pascal compilation-and-linking from `foo.c.p', and many other
We know these possibilities are ridiculous since `foo.c' is a C source
file, not an executable. If
make did consider these possibilities,
it would ultimately reject them, because files such as `foo.c.o' and
`foo.c.p' would not exist. But these possibilities are so
make would run very slowly if it had to consider
To gain speed, we have put various constraints on the way
considers match-anything rules. There are two different constraints that
can be applied, and each time you define a match-anything rule you must
choose one or the other for that rule.
One choice is to mark the match-anything rule as terminal by defining
it with a double colon. When a rule is terminal, it does not apply unless
its prerequisites actually exist. Prerequisites that could be made with
other implicit rules are not good enough. In other words, no further
chaining is allowed beyond a terminal rule.
For example, the built-in implicit rules for extracting sources from RCS
and SCCS files are terminal; as a result, if the file `foo.c,v' does
make will not even consider trying to make it as an
intermediate file from `foo.c,v.o' or from `RCS/SCCS/s.foo.c,v'.
RCS and SCCS files are generally ultimate source files, which should not be
remade from any other files; therefore,
make can save time by not
looking for ways to remake them.
If you do not mark the match-anything rule as terminal, then it is
nonterminal. A nonterminal match-anything rule cannot apply to a file name
that indicates a specific type of data. A file name indicates a specific
type of data if some non-match-anything implicit rule target matches it.
For example, the file name `foo.c' matches the target for the pattern
rule `%.c : %.y' (the rule to run Yacc). Regardless of whether this
rule is actually applicable (which happens only if there is a file
`foo.y'), the fact that its target matches is enough to prevent
consideration of any nonterminal match-anything rules for the file
make will not even consider trying to make
`foo.c' as an executable file from `foo.c.o', `foo.c.c',
The motivation for this constraint is that nonterminal match-anything
rules are used for making files containing specific types of data (such as
executable files) and a file name with a recognized suffix indicates some
other specific type of data (such as a C source file).
Special built-in dummy pattern rules are provided solely to recognize
certain file names so that nonterminal match-anything rules will not be
considered. These dummy rules have no prerequisites and no commands, and
they are ignored for all other purposes. For example, the built-in
exists to make sure that Pascal source files such as `foo.p' match a
specific target pattern and thereby prevent time from being wasted looking
for `foo.p.o' or `foo.p.c'.
Dummy pattern rules such as the one for `%.p' are made for every
suffix listed as valid for use in suffix rules (see section Old-Fashioned Suffix Rules).