Cinolt Yuklair
Cinolt Yuklair

Reputation: 407

Makefile match anything rule as intermediate

Consider this simple Makefile:

%.one: %.two
    echo one
%.two: %.three
    echo two
%.three: %.four
    echo three

all: hi.one

As expected, make all will produce:

echo three
three
echo two
two
echo one
one

But if I make an intermediate rule without any prefix/suffix:

%.one: %
    echo one
%: %.three
    echo one
%.three: %.four
    echo one

all: hi.one

Make will fail saying there is no rule to make hi.one. Is this simply impossible with Make?

Upvotes: 2

Views: 204

Answers (1)

user657267
user657267

Reputation: 21000

No this isn't possible, non-terminal match-anything rules are ignored for dependencies of pattern rules.

This isn't actually mentioned in the manual, but the following comment in the make source (implicit.c:321) makes it clear

      /* Rules that can match any filename and are not terminal
         are ignored if we're recursing, so that they cannot be
         intermediate files.  */

Upvotes: 4

Related Questions