即使条件为真,Makefile ifeq 也不起作用

问题描述 投票:0回答:1

我有一个 Makefile,其中包含来自另一个 Makefile 的变量“verbose”,并且 ifeq 语句使用此变量永远无法工作,既不包含 makefile,也不包含顶级 makefile。

这是 makefile 代码: enter image description here

-include foo.mki

$(info Variable:$(verbose))

ifeq ($(verbose),yes)
$(info condition is true)
else
$(info condition is false)
endif

verbose 打印为 yes upper info,但从不打印条件为 true。

enter image description here

Variable:yes
condition is false

您知道为什么会发生这种情况吗?并推荐一种方法,我可以将配置参数带到另一个配置 Makefile 中,并在这里使用它们作为条件。

makefile
1个回答
0
投票

使用“$strip”函数解决了这个问题。这是一个新的代码块:

ifeq ($strip $(verbose)),yes)
.
.
.
© www.soinside.com 2019 - 2024. All rights reserved.