7

I have lots of variables called allow_xxx where xxx is a feature.

I would like to create a variable inside my makefile with all values that are allowed.

This is what I try to do:

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

allowed := $(foreach V, $(list_features), $(ifeq ($(allow_$V),1),$V))

This does not work... Any idea how to do this properly?

Thanks !

Charles B
  • 160
  • 1
  • 12

2 Answers2

12

There is no such thing as the ifeq function, it is only a conditional directive. Use if and filter instead:

allowed := $(foreach V, $(list_features), $(if $(filter 1,$(allow_$V)),$V))
thiton
  • 35,651
  • 4
  • 70
  • 100
0

In case you want to reduce or create a range on the number of iterations you can do

MAX_RANGE := 4
vector_0_10 := 0 1 2 3 4 5 6 7 8 9 10 
vector_reduced := $(wordlist 1,$(MAX_RANGE),$(vector_0_10))
$(info $$vector_reduced is printed as [$(vector_reduced)])
//will print 0 1 2 3
FLAGS += $(foreach V, $(vector_reduced), -sdf min:$(ANOTHERVAR).test.text[$(V)].more_text:$(var2)/moretext )
$(info $$FLAGS is printed as [$(FLAGS )])`  
Joniale
  • 515
  • 4
  • 17