【发布时间】:2017-03-09 10:57:50
【问题描述】:
我在 makefile 中有两个变量,它们可以是 empty 或 empty string 或 valid string
如果变量是empty 或empty string,我需要错误退出
这是我正在使用的简单 makefile
ABC := ""
XYZ := hello
all:
ifeq ($(and $(ABC),$(XYZ)),)
$(error "Either of var is null")
endif
@echo "Done"
有了这个,我得到了Done 的输出,而我希望它失败。
如果我将ifeq 条件更改如下,
ifeq ($(and $(ABC),$(XYZ)),"") 然后在以下情况下,make 不会出错退出
ABC :=
XYZ := hello
all:
ifeq ($(and $(ABC),$(XYZ)),"")
$(error "Either of var is null")
endif
@echo "Done"
一种解决方案可能如下,(?)
ABC := hello
XYZ := hello
all:
ifeq ($(and $(ABC),$(XYZ)),)
$(error "Var is null")
endif
ifeq ($(and $(ABC),$(XYZ)),"")
$(error "Var is null2")
endif
@echo "Done"
但是我觉得有更好的方法,有什么建议吗?
编辑
只是为了说明我想要的是,
if ABC is empty string(ABC := "") OR empty(ABC := ) OR
XYZ is empty string(XYZ := "") OR empty(XYZ := )
$(error "empty string or null")
endif
【问题讨论】: