I was using this question: Assign a makefile variable value to a bash command result? to try and solve my problem, but it doesn't seem to work.
I have a one-liner to get the current port of a connected Arduino, that I need in my Makefile as a parameter:
[bf@localhost GameCode]$ arduino-cli board list | grep arduino:megaavr:nona4809 | awk '{ print $1; }'
/dev/ttyACM0
As you see this works fine. But now I want to use that in my Makefile:
BOARD=arduino:megaavr:nona4809
PORT=$(shell arduino-cli board list | grep $$BOARD | awk '{ print $$1; }')
OUTPUT=mycode.hex
program: $(OUTPUT)
eeprom-program -f $(OUTPUT) -p $(PORT)
But, $(PORT) seems to be completely empty. I know I can fix this with a shell script, but as this is only a single line, I don't want to clutter my directory with small scripts.
How can I get that command in my Makefile?
$$1is the makefile variable$1, which doesn't exist, just as$$BOARDis the makefile variable$BOARD.shellin front, and$$1should then be an escaped$. After addingshellit still doesn't seem to work though.grep $$BBOARDshould begrep $(BBOARD). Makefile variables need$()around them. You're escaping the$, so it's trying to grep a shell variable namedBBOARD.