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.
–
–
–
–
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.