Given the line:
program_OBJS := ${program_SRCS:.cpp=.o}
I would like to append .o
to each filename instead of replacing .cpp
with .o
.
How do I do that?
Given the line:
program_OBJS := ${program_SRCS:.cpp=.o}
I would like to append .o
to each filename instead of replacing .cpp
with .o
.
How do I do that?
To just append something to a list of space separated items you can use:
program_OBJS := $(foreach program,$(program_SRCS),$(program).o)
To use the substitution method (like you show in your question):
program_OBJS := $(program_SRCS:.cpp=.cpp.o)
but for that the list must contain the .cpp suffices, or the substitutions will not occur.
Shorter alternative, using a pattern substitution: program_OBJS := ${program_SRCS:%=%.o}