Makefile : 包含字符串 [英] Makefile : contains string
问题描述
一个变量返回 MINGW32_NT-5.1
或 CYGWIN_NT-5.1.
(是的,点在末尾)
需要比较给定的 var 包含位于任何位置的 NT-5.1
.
使用 cygwin 并希望与几乎任何 *nix 兼容.
findstring 功能是你的心愿:
<块引用>$(findstring find,in)
在 in 中搜索 find.如果发生,则值为find;否则,该值为空.您可以在条件中使用此函数来测试给定字符串中是否存在特定子字符串.因此,这两个例子,
$(查找字符串 a,a b c)$(查找字符串 a,b c)
分别产生值 "a"
和 ""
(空字符串).Testing Flags,查找字符串
.
类似:
ifneq (,$(findstring NT-5.1,$(VARIABLE)))# 成立别的# 未找到万一
<块引用>
这里 ifneq (,$(...
?
将其解析为 ifneq(A,B)
其中 A 是空字符串,B 是 $(findstring...)代码>.这看起来很奇怪,因为您没有在 Makefile 中引用字符串.
A variable returns MINGW32_NT-5.1
or CYGWIN_NT-5.1.
(yea, dot at the end)
Need to compare that given var contains NT-5.1
positioned anywhere.
Using cygwin and would like to be compatible with pretty much any *nix.
The findstring function is what your heart desires:
$(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
.
Something like:
ifneq (,$(findstring NT-5.1,$(VARIABLE)))
# Found
else
# Not found
endif
What is the comma here for
ifneq (,$(...
?
Parse it as ifneq(A,B)
where A is the empty string and B is $(findstring...)
. It looks odd because you don't quote strings in Makefiles.
这篇关于Makefile : 包含字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!