Reputation: 1956
I want to parse variable in makefile, this variable has next syntax:
VARIABLE=folder1=file1,folder2=file2,...,folderN=fileN
and here what I want to do with it:
ifdef VARIABLE
#
# here I want to assign FOLDER to "folder1, folder2... folderN" in the loop
# and then compare it with current folder
#
ifeq ($(FOLDER),$(CURRENT_FOLDER))
#
# if true assign FILE1=file1
#
export MYFILE := FILE1
endif
else
export MYFILE = default_name
endif
How can I do that?
Upvotes: 0
Views: 677
Reputation: 74058
If you change the separator ,
to some other, :
for example
VARIABLE=folder1=file1:folder2=file2:...:folderN=fileN
you can split the list
L=$(subst :, ,$(VARIABLE))
extract the folder if any
E=$(filter $(CURRENT_FOLDER)=%, $L)
and assign the last part after =
to MYFILE
ifneq ($E,)
export MYFILE := $(patsubst $(CURRENT_FOLDER)=%,%,$E)
else
export MYFILE = default_name
endif
Upvotes: 1