添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
乖乖的荒野  ·  GreptimeDB vs. ...·  1小时前    · 
留胡子的香菜  ·  iOS 16 Shader ...·  1小时前    · 
俊秀的熊猫  ·  mysql ...·  3 周前    · 
威武的蜡烛  ·  盐神阁入口2024 ...·  1 月前    · 
没读研的鸡蛋面  ·  packages: ...·  2 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

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.

Something like:

ifneq (,$(findstring NT-5.1,$(VARIABLE)))
    # Found
    # 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.

Is findstring case sensitive? If so, is there a simple way to do case insensitive matching? The manual wasn't clear... – Isaac Turner Feb 16, 2014 at 17:45 @IsaacTurner: Yes, make functions are invariably case-sensitive. Sadly, there are no case-insensitive variants, but as a workaround you could use the $(shell ...) function to use a shell command for case conversion - clunky, but it works; e.g.: $(findstring $(shell echo 'BC' | tr '[:upper:]' '[:lower:]'), 'abcd'). If you don't mind specifying SHELL := bash to have make use bash as the shell, you can take advantage of shopt -s nocasematch and perform entire comparisons case-insensitively inside a single $(shell ...) call. – mklement0 Dec 1, 2014 at 18:27 Shouldn't the if and else be reversed in you example? As I understand it, if findstring returns an empty string, the value was not found. – szx Oct 4 at 19:57 @szx Notice that this has ifneq rather than ifeq. If findstring does not return an empty string, then it found something. That's how I read it. – John Kugelman Oct 4 at 23:25

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.