I want to use the match pattern of a Makefile rule in a text function in the perquisites list.
Let's say I want to build a file, and that files perquisites are any other files with the same name in a list.
list_of_files=a/x b/x a/y b/y c/z
%:
echo 0 $@
touch $@
build/%: $(filter %/$*,$(list_of_files))
echo 1 target $@
echo 1 prereq $?
touch $@
.PHONY:
all: build/x
echo
In the above case, I want for a/x and b/x rules to also be triggered as they are filtered out of the list, however they are not.
The docs are pretty clear that what you're trying won't work as-is:
One way to deal with this (as mentioned in the above documentation) is to use the secondary expansion capability: