Reputation: 940
I have this simple pattern rule
%.o : %.cpp
recipe
I'd like to use this rule but with the added constraint that the pattern matches one of the words in a variable called FILENAMES.
Is there a way I can do this?
Upvotes: 1
Views: 548
Reputation: 65928
This is known as Static Pattern Rules.
With that syntax you provide list of possible targets, but use pattern for generate own rule for every target in this list:
FILENAMES = foo bar
# Generate list of precise targets names
FILENAMES_OBJ = $(addsuffix .o, $(FILENAMES))
$(FILENAMES_OBJ): %.o: %.cpp
<recipe>
Upvotes: 3