本文介绍了Makefile ifeq逻辑或的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用make的ifeq运算符执行逻辑或?

How do you perform a logical OR using make's ifeq operator?

例如,我有(简体):

ifeq ($(GCC_MINOR), 4)
    CFLAGS += -fno-strict-overflow
endif
ifeq ($(GCC_MINOR), 5)
    CFLAGS += -fno-strict-overflow
endif

但想合并这些行.

(是的,是的,自动工具,配置等;对于当前情况而言过于笨拙,想将所有内容保留在Makefile中)

(yes, yes, autotools, configure, etc etc; too heavy-handed for the current situation, would like to keep everything within the Makefile here)

[与此问题在逻辑上相反:如何使用"ifeq"语句中的多个条件]

[logical opposite of this question: How to Use of Multiple condition in 'ifeq' statement ]

推荐答案

在邮件列表存档中找到的

As found on the mailing list archive,

  • http://osdir.com/ml/gnu.make.windows/2004-03/msg00063.html
  • http://osdir.com/ml/gnu.make.general/2005-10/msg00064.html

一个人可以使用 filter 函数.

例如

 ifeq ($(GCC_MINOR),$(filter $(GCC_MINOR),4 5))

过滤器X,A B 将返回等于X的A,B.

filter X, A B will return those of A,B that are equal X.

这是

 ifneq (,$(filter $(GCC_MINOR),4 5))

其中使用了对空字符串的否定比较(如果GCC_MINOR与参数不匹配, filter 将返回空字符串)

where a negative comparison against an empty string is used instead (filter will return en empty string if GCC_MINOR doesn't match the arguments)

这些方法的缺点是参数必须是单个单词.

The downside to those methods is the arguments have to be single words.

这篇关于Makefile ifeq逻辑或的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 23:40