Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match occurance of word in list in makefile

Tags:

makefile

I wonder how to match exact occurrence of a given word in the given list of words using only standard 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
like image 282
pmod Avatar asked Feb 26 '23 21:02

pmod


1 Answers

Use filter instead of findstring:

...
ifneq ($(filter $(WORD_TO_MATCH),$(INPUT_LIST)),)  
    $(warning List contains "$(WORD_TO_MATCH)")
...
like image 78
Andy Avatar answered Mar 01 '23 09:03

Andy