Makefile:如何在多个通配符上应用相同的过滤器 [英] Makefile: How to apply an equivalent to filter on multiple wildcards
问题描述
事实上,过滤器只需要一个通配符。
我想要做的是:
我有一个列表文件,一些匹配正则表达式有些不是。但是为此我需要2个通配符,因此我不能使用过滤器函数。
我想将我的原始列表拆分成2个列表,其中一个包含所有包含blabla的元素字符串(相当于过滤器),另一个包含不匹配的(过滤等效)。
$ b $ p
感谢您的帮助。
您可以在不运行任何外部命令的情况下执行此操作。定义两个宏包含= $(foreach v,$ 2,$(如果$(findstring $ 1,$ v),$($ v $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $) v)
不包含= $(foreach v,$ 2,$(如果$(findstring $ 1,$ v),, $ v))
$ p
LIST_OLD:= $(call contains,old,$(LIST))
LIST_NOT_OLD:= $(调用不包含的旧的$(LIST))
I am writing a Makefile and I get stuck on a filter function limitation. Indeed, filter takes only one wildcard.
What I would like to do is: I have a list a files, some matching the regexp blabla, some not. But for this I need 2 wildcards, thus i cannot use filter function.
I would like to split my original list in 2 lists, one containing all the element containing the blabla string (filter equivalent) and the other one containing the not matching one (filter-out equivalent).
thanks for your help.
You can do this without running any external commands. Define the two macros
containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))
Now you can do
LIST := a_old_tt x_old_da a_new_da q_ty_we
LIST_OLD := $(call containing,old,$(LIST))
LIST_NOT_OLD := $(call not-containing,old,$(LIST))
这篇关于Makefile:如何在多个通配符上应用相同的过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!