How do you define dynamic variables in a makefile target? For example:
all:
VAR := $@
@echo $(VAR)
Re: Setting Environment variable in Makefile To get the shell to see one "$", you must use "$$" in the Makefile. 2.) Environment variables can only be inherited from parent to child processes, not vice versa. In this case, the parent process is the 'make' that is processing the Makefile.
Expanded assignment = defines a recursively-expanded variable. := defines a simply-expanded variable.
I realize this is the correct way:
all: VAR = $@
all:
@echo $(VAR)
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