Makefile:包含string
variables返回MINGW32_NT-5.1或CYGWIN_NT-5.1. (是的,点到底)
需要比较给定的var包含NT-5.1定位在任何地方。
使用cygwin,并希望与几乎任何* nix兼容。
findtring函数是你的心所欲 :
$(findstringfind,in)search查找的发生。 如果发生,则值为find ; 否则,该值为空。 您可以在条件中使用此函数来testing给定string中是否存在特定的子string。 因此,这两个例子,
$(findstring a,abc) $(findstring a,bc)分别产生值
"a"和""(空string)。 有关findstring的实际应用,请参阅testing标志 。
就像是:
ifneq (,$(findstring NT-5.1,$(VARIABLE))) # Found else # Not found endif
VARIABLE=NT-5.1_Can_be_any_string ifeq ($(findstring NT-5.1,$(VARIABLE)),NT-5.1) # Found RESULT=found else # Not found RESULT=notfound endif all: @echo "RESULT=${RESULT} , output=$(findstring NT-5.1,$(VARIABLE))"
它匹配给定的string并返回