Reputation: 51
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?
Upvotes: 5
Views: 1953
Reputation: 61467
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.
Upvotes: 5