$ cat Makefile
all:
echo VAR is ${HOME}
echo VAR is $${HOME}
Gives
$ make
echo VAR is /home/abc
VAR is /home/abc
echo VAR is ${HOME}
VAR is /home/abc
Why does echo VAR is ${HOME}
syntax work in Makefile? I thought, to use shell variables you have to use $${HOME}}
Yes and no. It is best to use $$
to be explicit. However, there is a special rule for environment variables:
Variables in make can come from the environment in which make is run. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value. But an explicit assignment in the makefile, or with a command argument, overrides the environment. (If the `-e' flag is specified, then values from the environment override assignments in the makefile. See section Summary of Options. But this is not recommended practice.)