I have a string of source files
ENBL_PX11_LIBSRC = pltsub.f xpltlib.f xbuplot.c
I want to replace .f and .c with .o
to get
ENBL_PX11_LIBOBJ = pltsub.o xpltlib.o xbuplot.o
However I am having trouble doing this with subst.
I have a string of source files
ENBL_PX11_LIBSRC = pltsub.f xpltlib.f xbuplot.c
I want to replace .f and .c with .o
to get
ENBL_PX11_LIBOBJ = pltsub.o xpltlib.o xbuplot.o
However I am having trouble doing this with subst.
$ cat file
ENBL_PX11_LIBSRC = pltsub.f xpltlib.f xbuplot.c
$ sed 's/\.f/\.o/;s/\.c/\.o/' file
ENBL_PX11_LIBSRC = pltsub.o xpltlib.f xbuplot.o
The string is in a variable in a make file, I do not wish to read any file.
I dont see where is the problem. With the previous sed example you should be able to adapt it to your needs..
$ ENBL_PX11_LIBSRC="pltsub.f xpltlib.f xbuplot.c"
$ echo $ENBL_PX11_LIBSRC | sed 's/\.f/\.o/g;s/\.c/\.o/g'
pltsub.o xpltlib.o xbuplot.o
I see, like this it worked.
ENBL_PX11_LIBOBJ = `echo $(ENBL_PX11_LIBSRC) | sed 's/\.f/\.o/g; s/\.c/\.o/g'`
---------- Post updated at 12:45 PM ---------- Previous update was at 12:00 PM ----------
This is not working
ENBL_PX11_LIBOBJ = $(shell $(ECHO) $(ENBL_PX11_LIBSRC) | $(SED) 's/\.f/\.o/g; s/\.c/\.o/g')
---------- Post updated at 12:53 PM ---------- Previous update was at 12:45 PM ----------
[LEFT]I also tried this
ENBL_PX11_LIBOBJ = "$(shell $(ECHO) $(ENBL_PX11_LIBSRC) | $(SED) 's/\.f/\.o/g; s/\.c/\.o/g')"
[/LEFT]
This
sed 's/\.f/\.o/g;s/\.c/\.o/g'
can be shorten to
sed 's/\.[cf]/\.o/g'