Reputation: 3099
Given the following GNU Makefile code.
ENDING = '\.cpp'
OBJ = $(SOURCES:$(ENDING)=.o) # (does not work)
This does replace nothing, however,
OBJ = $(SOURCES:.cpp=.o)
does (for cpp files). Is there a way to tell patsubst specific endings? Or at least to replace all kind of endings, like below?
OBJ = $(SOURCES:.*=.o) # (does not work)
Upvotes: 1
Views: 529
Reputation: 99144
This works:
ENDING = .cpp
OBJ = $(SOURCES:$(ENDING)=.o)
And this will replace all endings:
OBJ = $(addsuffix .o,$(basename $(SOURCES)))
Upvotes: 4