Makefile 条件语句不起作用
Makefile conditional statements not working
我有以下 makefile 代码,其中 ifeq
语句未评估为真,我不明白为什么不:
PROCESSOR=`uname -p`
ifeq ($(strip $(PROCESSOR)), x86_64)
PROCESSOR = -c -march=atom -fPIC -Wall -I../../inc
else
PROCESSOR = -c -march=i386 -fPIC -Wall -I../../inc
endif
我已在我的系统上确认 uname -p
结果为 "x86_64",但 ifeq
语句评估为 false 并且 PROCESSOR
被设置为 -c -march=i386 -fPIC -Wall -I../../inc
.我还尝试了 ifeq "$(strip $(PROCESSOR))" "x86_64"
和一些没有 strip
功能的变体。有人有什么建议吗?
反引号不是 makefile 中的命令执行。
在 ifeq
行上方添加 $(info $(PROCESSOR))
以了解我的意思。
你想要:
PROCESSOR=$(shell uname -p)
$ cat Makefile
PROCESSOR=`uname -p`
$(info backticks: $(PROCESSOR))
PROCESSOR=$(shell uname -p)
$(info $$shell: $(PROCESSOR))
$ make
backticks: `uname -p`
$shell: x86_64
我有以下 makefile 代码,其中 ifeq
语句未评估为真,我不明白为什么不:
PROCESSOR=`uname -p`
ifeq ($(strip $(PROCESSOR)), x86_64)
PROCESSOR = -c -march=atom -fPIC -Wall -I../../inc
else
PROCESSOR = -c -march=i386 -fPIC -Wall -I../../inc
endif
我已在我的系统上确认 uname -p
结果为 "x86_64",但 ifeq
语句评估为 false 并且 PROCESSOR
被设置为 -c -march=i386 -fPIC -Wall -I../../inc
.我还尝试了 ifeq "$(strip $(PROCESSOR))" "x86_64"
和一些没有 strip
功能的变体。有人有什么建议吗?
反引号不是 makefile 中的命令执行。
在 ifeq
行上方添加 $(info $(PROCESSOR))
以了解我的意思。
你想要:
PROCESSOR=$(shell uname -p)
$ cat Makefile
PROCESSOR=`uname -p`
$(info backticks: $(PROCESSOR))
PROCESSOR=$(shell uname -p)
$(info $$shell: $(PROCESSOR))
$ make
backticks: `uname -p`
$shell: x86_64