$${HOME} or ${HOME} in Makefile?

后端 未结 1 1583
轮回少年
轮回少年 2021-02-20 00:56
$ 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 $         


        
1条回答
  •  情歌与酒
    2021-02-20 01:41

    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.)

    0 讨论(0)
提交回复
热议问题