Reputation: 3012
I'm writing a Makefile, I have a list of all the files (without src/
or .cpp
), and I want to convert those to build/*.o
. Here's what I've tried already:
FILES=icxxabi list memory string
OBJECTS=$(echo ("${build/$$FILES[@].o}")[@])
So for the input a dir/b c
, it should output:
build/a.o build/dir/b.o build/c.o
Upvotes: 27
Views: 19110
Reputation: 85827
Take a look at the make file name functions:
OBJECTS = $(addprefix build/,$(addsuffix .o,$(FILES)))
Upvotes: 24
Reputation: 534
With GNU Make, you could try
OBJECTS=$(patsubst %, build/%.o, $(FILES))
Upvotes: 30