Using make subst


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using make subst
# 1  
Old 01-23-2013
Using make subst

I have a string of source files

Code:
ENBL_PX11_LIBSRC = pltsub.f xpltlib.f xbuplot.c

I want to replace .f and .c with .o

to get

Code:
ENBL_PX11_LIBOBJ = pltsub.o xpltlib.o xbuplot.o

However I am having trouble doing this with subst.
# 2  
Old 01-23-2013
Code:
$ 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

# 3  
Old 01-23-2013
The string is in a variable in a make file, I do not wish to read any file.
# 4  
Old 01-23-2013
I dont see where is the problem. With the previous sed example you should be able to adapt it to your needs..

Code:
$ 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

# 5  
Old 01-23-2013
I see, like this it worked.

Code:
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

Code:
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 ----------

I also tried this

Code:
ENBL_PX11_LIBOBJ = "$(shell $(ECHO) $(ENBL_PX11_LIBSRC) | $(SED) 's/\.f/\.o/g; s/\.c/\.o/g')"

# 6  
Old 01-24-2013
This
Code:
sed 's/\.f/\.o/g;s/\.c/\.o/g'

can be shorten to
Code:
sed 's/\.[cf]/\.o/g'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut determinate values amb subst for ;

Hello I have a output file that contains the next info: host_name LET-234-WDFD-2 address 10.11.0.62 host_name XWERWE-234-WEDF-EMEEH-GIDF-3 address 10.11.32.48 host_name DFG-745-WE-EMEEEH-GIDF-4 address 10.11.32.176 host_name ... (6 Replies)
Discussion started by: capilla
6 Replies

2. Shell Programming and Scripting

A simple variable subst is not working

Hi what i want: listing files in a special range ls -lrt 20120601{05..06}* ... -rw-rw-r-- 1 imp imp 279 1. Jun 07:51 201206010550 -rw-rw-r-- 1 imp imp 279 1. Jun 07:01 201206010600 -rw-rw-r-- 1 imp imp 279 1. Jun 07:11 201206010610 -rw-rw-r-- 1 imp imp 279 1. Jun 07:21... (1 Reply)
Discussion started by: IMPe
1 Replies

3. Programming

Issue with make, no rule to make target etc.

I have been trying to split up my src directory to clear out files that are not re-compiled very often. Now I have the following setup in my trunk, trunk/bld trunk/src/ trunk/src/src_server trunk/makefile.linux In the make file, I have compile rules SOURCELOC = src # compile src c++... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

4. UNIX for Dummies Questions & Answers

Difference between configure/make/make install.

Hi, While installation of apache on linux, we perform the below tasks. 1) Untar 2) configure 3) make 4) make install. I wanted to understand the difference and working of configure/make/make install. Can any one help me understanding this? Thanks in advance. (1 Reply)
Discussion started by: praveen_b744
1 Replies

5. UNIX for Dummies Questions & Answers

How to make a make from other folder

Hi, Sorry for my English. I want Execute a make from other folder but no it's a normal make. The comand is: make telosb install,3 And for example if i have to execute this comand in /tmp and i am in /$HOME how he would be now the comand? thx (7 Replies)
Discussion started by: Grobix
7 Replies

6. Solaris

Gani Network Driver Won't Install - make: Fatal error: Don't know how to make targ...

I attached a README file that I will refer to. I successfully completed everything in the README file until step 4. # pwd /gani/gani-2.4.4 # ls COPYING Makefile.macros gem.c Makefile Makefile.sparc_gcc gem.h Makefile.amd64_gcc ... (1 Reply)
Discussion started by: Bradj47
1 Replies

7. Linux

Error in issuing a make and make install

Hi, Recently I install a package and try to do a make and make install. However, in the make it gives me below error:- make:Nothing to be done for 'install-exec-am' make:Nothing to be done for 'install-data-am' Can anyone please explain to me what does this mean? I have been trying... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

8. Shell Programming and Scripting

assign subst|grep|sed command result to a variable

Hi, I'm quite new to scripting and I want to modify following line of an existing script: MYVAR=`subst |grep 'L:\\\:' | sed -e 's/.*\\\//'`; What I have to do is to use the content of a variable instead of the constant expression 'L:\\\:' as the grep string to be matched. Assuming I already... (5 Replies)
Discussion started by: snowbiker99
5 Replies

9. Shell Programming and Scripting

Command param subst to reg expression

I want to find out Row which starts with, the user specified details to a script. In general I know what command to be given. awk '$0~/^Vi/' BReject But I need to pass on $1 param of command line at the place of 'Vi'. I tried with -v subst=$1 awk -v subst=$1 '$0~/^subst/' BReject But it... (5 Replies)
Discussion started by: videsh77
5 Replies

10. UNIX for Dummies Questions & Answers

make and make install commands

Hi there, I am installing a package at the moment on to my Solaris version 8 and I have run into a problem with the 'make' command. I have installed the package using the 'pkgadd' command and I am now at the stage where I have to use the 'make' command followed by the 'make install'... (4 Replies)
Discussion started by: gerwhelan
4 Replies
Login or Register to Ask a Question