Cheiron
Cheiron

Reputation: 3736

Expand variables after filtering them out

I have a lot of variables, some of these end with _OBJDIR. Now I want a single variable which contains the expansion of all the _OBJDIR. I know I can get halfway:

ALLOBJDIRS = $(filter %_OBJDIR,$(.VARIABLES))

But now I have:

ALLOBJDIRS = A_OBJDIR B_OBJDIR C_OBJDIR

And I want:

ALLOBJDIRS = a/obj b/obj c/obj

Where

A_OBJDIR = a/obj

Etcetera. How can I expand ALLOBJDIRS after the filter?

Upvotes: 0

Views: 44

Answers (1)

dash-o
dash-o

Reputation: 14432

Combining 'foreach' with 'value' function to expand variable values

@echo ALLOBJDIR = $(foreach v, $(filter %_OBJDIR,$(.VARIABLES)), $(value $v))

Also, the ${${VAR}} can be used,

@echo ALLOBJDIR = $(foreach v, $(filter %_OBJDIR,$(.VARIABLES)), ${${v}})

Upvotes: 2

Related Questions