Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU Makefile and bash - escaping

Tags:

gnu-make

In the recipe for a target, I want to generate a bash script which processes command line arguments ... however the Makefile escaping escapes me

target: deps echo "./a.out \"$@\"" > wrapper.a.out

However, $@ has a special meaning in a GNU Makefile which messes things up.

Tried $@, $$@ ... nothing appears to work.

So, what is the right way to do this?

like image 332
Joe Avatar asked Jul 19 '11 23:07

Joe


1 Answers

echo './a.out "$$@"' >wrapper.a.out

You need to double the $ to get it past make. then use single quotes in the echo command so the shell spawned to run the echo doesn't expand $@ itself.

like image 96
geekosaur Avatar answered Oct 11 '22 18:10

geekosaur