Gnu以环境变量为条件

时间:2016-10-18 10:44:56

标签: makefile gnu-make

我在Makefile中有以下内容:

ifndef MYVAR
$(error "MYVAR is not set")
else
$(warning "MYVAR is set to [$(MYVAR)]")
ifeq ($(MYVAR),"abc")
$(error "Value is known.")
else
$(error "Not known.")
endif
endif

我在调用make时设置了MYVAR:

MYVAR=abc make

我原本希望看到"价值已知。"但我得到以下内容:

Makefile:4: "MYVAR is set to [abc]"
Makefile:8: *** "Not known.".  Stop.

有人可以告诉我ifeq声明有什么问题吗?

1 个答案:

答案 0 :(得分:0)

@melpomene在评论中回答了问题。像往常一样,报价错误。

ifeq ($(MYVAR),abc) or MYVAR='"abc"' make