mastupristi
mastupristi

Reputation: 1478

Gnu Make: how to use the pattern rule

I have this sample (siimplified) makefile

all: a a.e b b.e

.SUFFIXES:

a a.e:
    touch $@

b: a
    ln -sf $(notdir $<) $@

b.e: a.e
    ln -sf $(notdir $<) $@

clean:
    rm -f a* b*

and it works.

I would like to use Pattern Rules as follow:

all: a a.e b b.e

.SUFFIXES:

a a.e:
    touch $@

b%: a%
    ln -sf $(notdir $<) $@

clean:
    rm -f a* b*

but it fails:

$ make
touch a
touch a.e
make: *** No rule to make target 'b', needed by 'all'.  Stop.

I cannot figure out why, and I don't know how to make it works

Upvotes: 0

Views: 134

Answers (1)

MadScientist
MadScientist

Reputation: 100781

Does this info from the manual give you your answer:

The target is a pattern for matching file names; the ‘%’ matches any nonempty substring, while other characters match only themselves.

(emphasis added)?

Upvotes: 2

Related Questions