I'm trying to write a custom Makefile in which I collect all source files to compile against the main. First I collect their names:
# other sources to compile against (without extensions, separated by spaces) DEPENDENT_FILES = greet farewell
Then I'd like to append
.o to each word. In a shell, I can do this in many ways, e.g.
echo '$DEPENDENT_FILES' | sed 's/\>/\.o/g' # but I know, it's UNIX dependant # or ... echo '$DEPENDENT_FILES' | sed 's/[^ ]*/&\.o/g'
both result in
greet.o farewell.o on the terminal, but fail (resulting in empty strings) during the
I write them as
DEPENDENCIES := $(echo '$DEPENDENT_FILES' | sed 's/\>/\.o/g') # or ... DEPENDENCIES := $(echo '$DEPENDENT_FILES' | sed 's/[^ ]*/&\.o/g') # but they result in $(info DEPENDENCIES is $(DEPENDENCIES)) # "DEPENDENCIES is "
I don't know what I'm doing wrong here, I suspect it could be something related to echos or pipes in Makefiles but I can't figure it out.
Please, I'd prefer answers related to working sed and echo solutions, without proposing different approaches: it's not the first time that I'm facing problems with echo and pipes in Makefiles and I still don't know what is wrong in my approach.