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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With