Makefile在foreach循环中使用ifeq条件

Cha*_*s B 4 linux makefile

我有很多变量叫做allow_xxx,其中xxx是一个特性.

我想在makefile中创建一个包含所有允许值的变量.

这就是我尝试做的事情:

allow_feat1 := 1
allow_feat2 := 1
allow_feat3 := 1
list_features := feat1 feat2 feat3

allowed := $(foreach V, $(list_features), $(ifeq ($(allow_$V),1),$V))
Run Code Online (Sandbox Code Playgroud)

这不起作用......任何想法如何正确地做到这一点?

谢谢 !

thi*_*ton 8

没有ifeq函数这样的东西,它只是一个条件指令.使用iffilter替代:

allowed := $(foreach V, $(list_features), $(if $(filter 1,$(allow_$V)),$V))
Run Code Online (Sandbox Code Playgroud)