In my makefile, I need to make a variable assignment based on a command line variable value. for example, I do:
make var_1=xxx
where var_1
can have one of say 100 possible values. Based on the value of var_1
, I need to assign a value to var_2
in my makefile. I could do:
ifeq ($(var_1), a)
var_2 = A
endif
ifeq ($(var_1), b)
var_2 = B
endif
and so on for all 100 possible combinations of var_1
, var_2
. Here a
,A
,b
,B
represent some strings. How do I do this to avoid 100's of if
statements? I was thinking to define two variables:
var_1_values = a b c d
var_2_values = A B C D
I can use $(findstring $(var_1),$(var_1_values))
to see if $(var_1)
is among $(var_1_values)
, but how do I locate the position of $(var_1)
among all $(var_1_values)
? That position is then to be used to pick the corresponding word inside $(var_2_values)
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…