Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 为什么我的makefile变量在使用;定义;指令?_Bash_Shell_Makefile_Gnu Make - Fatal编程技术网

Bash 为什么我的makefile变量在使用;定义;指令?

Bash 为什么我的makefile变量在使用;定义;指令?,bash,shell,makefile,gnu-make,Bash,Shell,Makefile,Gnu Make,我用的是GNU Make 3.81。以下makefile工作正常: name=lucas all: test .PHONY: test test: echo $(name) # outputs variable correctly 但当我尝试使用“define”指令定义变量时,它停止工作: define name = lucas endef all: test .PHONY: test test: echo $(name) 为什么第二个版本不起作用?谢谢 编辑:已

我用的是GNU Make 3.81。以下makefile工作正常:

name=lucas

all: test

.PHONY: test
test: 
    echo $(name) # outputs variable correctly
但当我尝试使用“define”指令定义变量时,它停止工作:

define name =
lucas
endef

all: test

.PHONY: test
test: 
    echo $(name)
为什么第二个版本不起作用?谢谢


编辑:已找到。看起来这是一个版本的东西。
=
符号显然是从3.82版开始才在define语句中识别出来的。

我很确定您的
测试目标在
echo$(name)
之前没有
'\t'
。 当我复制并粘贴你的makefile代码时,我看到了这一点,我不认为这是错误的
markdown语言,因为我用makefiles检查了其他问题,它在那里工作。

找到了。看起来这是一个版本的东西。显然,3.82之前版本的define语句中无法识别=符号。

我使用的是GNU Make 3.81版本。我想知道这个版本是否是我的问题。我完全不知所措,我无法让它工作。你的意思是,“在
define
3.82版之前的语句中,=符号无法识别”,我想。