I’ve been trying to create an executable file from a Makefile to run a java program and I need the executable to have the text: java program $@. This is so any arguments will be passed into the program when it runs.
From the Makefile, I’ve been trying to echo into the new file:
@echo "java Program $@" >> exec
However, $@ results in “all” being written to exec, and $$@ becomes blank when written to exec. Is there another way to escape this sequence in a Makefile? I essentially need it to ignore $@.
I appreciate your time.
$$is the correct way to escape the$for Make, but the result is then being expanded by Bash. Try this:Single quotes in Bash mean that variables don’t get expanded.