user52366
user52366

Reputation: 1137

Process list of files in makefile with $(notdir ...)

I would like to apply the 'notdir'-function to a list of files I obtain from a wildcard match. While '$(notdir $(wildcard dir/*.tst))' works, I do not manage to first store the list in a variable ('FILES' in the Makefile below) that then is processed by $(notdir ...). Using the variable directly ('$(notdir $(FILES))') results in the wildcard being returned, using value ('$(notdir $(value $(FILES)))') yields an empty result.

.PHONY: show

FILES := dir/*.tst
FILES2 := dir/a.tst dir/b.tst
#NAMES := $(notdir $(FILES))
NAMES1 := $(notdir $(value $(FILES)))
NAMES2 := $(notdir $(FILES2))
NAMES3 := $(notdir $(wildcard dir/*.tst))

show:
    @echo "FILES: " $(FILES)
    @echo "NAMES1: " $(NAMES1)
    @echo "NAMES2: " $(NAMES2)
    @echo "NAMES3: " $(NAMES3)

I also tried $(notdir $(eval $$(FILES))), but this results in a "missing separator" error.

What am I missing here? I'd have expected that value would do the job...

Upvotes: 1

Views: 1184

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136286

Try the following:

FILES := $(wildcard dir/*.tst)
NAMES := $(notdir ${FILES})

Upvotes: 2

Related Questions