开发者

How to match occurance of word in list in makefile

开发者 https://www.devze.com 2023-01-03 01:33 出处:网络
I wonder how to match exact occurrence of a given word in the given list of words using only standar开发者_StackOverflow中文版d makefile operations. In the below example for WORD_TO_MATCH = a the resu

I wonder how to match exact occurrence of a given word in the given list of words using only standar开发者_StackOverflow中文版d makefile operations. In the below example for WORD_TO_MATCH = a the result is positive and apparently wrong.

INPUT_LIST= aa bb

WORD_TO_MATCH = aa
#WORD_TO_MATCH = a

ifneq ($(findstring $(WORD_TO_MATCH),$(INPUT_LIST)),)
    $(warning List contains "$(WORD_TO_MATCH)")
else
    $(warning List doesnt contain "$(WORD_TO_MATCH)")
endif


Use filter instead of findstring:

...
ifneq ($(filter $(WORD_TO_MATCH),$(INPUT_LIST)),)  
    $(warning List contains "$(WORD_TO_MATCH)")
...
0

精彩评论

暂无评论...
验证码 换一张
取 消