Roberto Aloi
Roberto Aloi

Reputation: 30985

Pattern matching a Makefile target name

In a Makefile recipe, I can refer to the current target name by using '$@'.

Assuming you have:

%.foo:
  @echo "Blah!"

And you call that with:

make bar

'$@' would return 'bar.foo'. Is there a way to refer just to 'bar'?

Upvotes: 2

Views: 2582

Answers (1)

Beta
Beta

Reputation: 99094

Use $* to get the % part of the target:

%.foo:
    @echo $*

Upvotes: 14

Related Questions