string - 生成文件: contains string

标签 string makefile conditional-statements

变量返回MINGW32_NT-5.1CYGWIN_NT-5.1。(是的,末尾有点)

需要比较给定的 var 是否包含位于任意位置的 NT-5.1

使用 cygwin 并希望与几乎任何 *nix 兼容。

最佳答案

findstring功能是您内心的渴望:

$(findstring find,in)

Searches in for an occurrence of find. If it occurs, the value is find; otherwise, the value is empty. You can use this function in a conditional to test for the presence of a specific substring in a given string. Thus, the two examples,

$(findstring a,a b c)
$(findstring a,b c)

produce the values "a" and "" (the empty string), respectively. See Testing Flags, for a practical application of findstring.

类似于:

ifneq (,$(findstring NT-5.1,$(VARIABLE)))
    # Found
else
    # Not found
endif

What is the comma here for ifneq (,$(...?

将其解析为 ifneq(A,B),其中 A 是空字符串,B$(findstring.. .)。这看起来很奇怪,因为您没有在 Makefile 中引用字符串。

关于string - 生成文件: contains string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2741708/

相关文章:

cygwin make - 对 INT_MAX 和 argp_usage 的 undefined reference

linux - 我怎样才能用这个制作文件

makefile - Makefile在后台运行进程

r - 通过给定变量查找条件的第一个匹配项

string - 定义一个没有 hex.DecodeString 的 []byte

javascript - 在 JavaScript 中过滤 "whitespace-only"字符串

c++ - 如何在以前读取的行中找到一些单词并在输出中删除它 - c++中的读/写字符串

c - 这个 "make a triangle loop"循环超过必要时间的任何原因

c++ - 在 Visual Studio 中使用 C++ 的条件断点

sql - MySQL 条件删除外键脚本