Is GNU make wildcard able to match more complex patterns, like a regexp for example?

find, gnu-make, linux, regex, wildcard

Solution

Downloading the source code and grepping for `wildcard`, we find the definition of the function on line 1332 of function.c—`wildcard` calls `string_glob`, which just does globbing, not regular expressions. And grepping the source code for `regex` turns up nothing :/

Since make has no built-in regex function, we'll have to use an external command. grepping for `regex` on the find(1) man page shows that the following will work:

data-files = $(shell find . -regextype posix-extended -regex '.*\.\w{1,2}')

Problem

Let's say I have the following wildcard matches in a makefile: ``` data-files = $(wildcard $(ptdf)/*.png) \ $(wildcard $(ptdf)/*.gif) \ $(wildcard $(ptdf)/*.bmp) \ $(wildcard $(ptdf)/*.jpg) \ $(wildcard $(ptdf)/*.ico) \ $(wildcard $(ptdf)/*.dist) \ $(wildcard $(ptdf)/*.html) ``` Can the wildcard syntax give me the power to match, for example, file names containing from 1 to 2 letters, as the regexp `\w{1,2}` would do? With no filename extension? If not, how can I do that with other syntax with linux command (such as `find`, etc)?

Original source