变量返回MINGW32_NT-5.1
或CYGWIN_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 offindstring
.
类似于:
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/