Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pattern matching a Makefile target name

Tags:

makefile

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'?

like image 325
Roberto Aloi Avatar asked Mar 09 '26 13:03

Roberto Aloi


1 Answers

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

%.foo:
    @echo $*
like image 105
Beta Avatar answered Mar 12 '26 02:03

Beta