Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile Using ifeq condition inside foreach loop

Tags:

linux

makefile

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 !

like image 985
Charles B Avatar asked Dec 14 '11 10:12

Charles B


1 Answers

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))
like image 93
thiton Avatar answered Nov 08 '22 09:11

thiton