Reputation: 2913
I am building several "main" files and currently have the following implicit rule:
$(PROJECT_ROOT)build/%.bin: $(PROJECT_ROOT)obj/%.o $(DEPS)
@mkdir -p $(dir $@)
@g++ -o $@ $^
Now I need to have special linking instructions for some of the "main" files. I defined the exceptions as follows:
SPECIAL_TARGET_1 = $(PROJECT_ROOT)build/...
SPECIAL_TARGET_2 = $(PROJECT_ROOT)build/...
SPECIAL_TARGETS = $(SPECIAL_TARGET_1) $(SPECIAL_TARGET_2)
and tried to filter them out as follows:
$(filter-out $(SPECIAL_TARGETS), $(PROJECT_ROOT)build/%.bin): $(PROJECT_ROOT)obj/%.o $(DEPS)
@mkdir -p $(dir $@)
@g++ -o $@ $^
but the filter-out
is not filtering anything.
What is the correct way of exluding a few files from an implicit rule?
Upvotes: 1
Views: 474
Reputation: 9962
The filter-out
function is used to remove things from a list. But you do not have a list: you only have the single text string $(PROJECT_ROOT)build/%.bin
.
If you were to add the new rule:
$(SPECIAL_TARGETS):
@echo TODO I need to write some special linking instructions for $@
then this specific rule will override the generic pattern-matching rule.
Upvotes: 1