在linux makefile中使用OR条件

时间:2015-09-18 12:28:08

标签: linux makefile

ifeq (ABC,$(strip $(TYPE)))
include src1.mk
else ifeq (EFG,$(strip $(TYPE)))
include src1.mk
else
include src2.mk

如何结合上述两个条件。

我试过这个

ifeq ($(TYPE),$(filter $(TYPE),ABC EFG))
include src1.mk
else
include src2.mk

但是行为不正常,即使TYPE不是ABC或EFG,如果是这样的话也会进入。

1 个答案:

答案 0 :(得分:0)

ifneq ($(filter $(TYPE),ABC EFG),)

我有以下内容:

ifneq ($(filter $(TYPE),ABC EFG),)
 $(info TYPE is in ABC EFG)
endif

ifeq ($(TYPE),$(filter $(TYPE),ABC EFG))
 $(info Ruchis test passed)
endif

all:
        @# do nothing

然后我跑

~/tmp> make TYPE=ABC
TYPE is in ABC EFG
Ruchis test passed

~/tmp> make TYPE=EFG
TYPE is in ABC EFG
Ruchis test passed

~/tmp> make TYPE=HIJ

~/tmp> make TYPE=
Ruchis test passed

如果$(TYPE)为空,则您的测试会出现误报。