Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering using multiple wildcards

I've git a project where, at some point in its Makefile, I'm filtering out stuff from a certain directory:

relevant = $(filter-out irrelevant/%,$^)

Now I want to use this in a VPATH-enabled environment. So the paths of my dependencies in $^ might not start with irrelevant any more, but instead something like ../src/irrelevant or similar.

Is there a way to filter-out anything that contains irrelevant, in any position? I.e. something like the following?

relevant = $(filter-out %irrelevant/%,$^)

This doesn't work, since apparently patterns for filter-out can contain only a single % wildcard. I know I could possibly achieve this via a shell invocation, grep or whatever, but I was hoping for some combinations of functions inside the Makefile.

like image 764
MvG Avatar asked Jun 07 '26 23:06

MvG


1 Answers

Try

relevant = $(foreach a,$^,$(if $(findstring irrelevant,$a),,$a))
like image 82
MadScientist Avatar answered Jun 10 '26 19:06

MadScientist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!