vinoth kumar
vinoth kumar

Reputation: 323

Match-Anything Pattern Rules

I am using GNU Make 3.81 version.

From the following example, I expect match anything pattern(%:) has to be print. Instead of that te%: has executed.

Can some one explain, why target '%:' did not run?

Is this not match all file name?

Makefile:

all: test
    echo $@
%: 
    echo 1: $@
te%:
    echo 2: $@

Output:

echo 2: test
2: test
echo all
all

Upvotes: 5

Views: 1121

Answers (1)

MadScientist
MadScientist

Reputation: 100836

There are special rules for how make treats match-anything pattern rules; see the documentation. You are creating a "non-terminal match-anything rule" here, and the rule for that is this:

A non-terminal 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.

In your case you have a non-match-anything implicit rule target (te%) which matches the file name (test) and so a non-terminal match-anything rule (%:) cannot match it.

Upvotes: 6

Related Questions