sed translate link arguments to make dependency

This is a discussion on sed translate link arguments to make dependency within the Editors forums in Theory and Concepts category; The following test script shows what I'm attempting to do. It will end up in a make file translating a make macro for library list into a macro for target dependency. pre_fix=lib suffix=.so echo Starting with: echo -L/usr/local/lib -ltom -ldick -lharry -L/usr/lib -ljane -ldoe echo -L/usr/local/lib -ltom -ldick -lharry -L/usr/lib -ljane -ldoe | sed -r \ -e 's|(-l)([^ ]+)|'$pre_fix'\2'$suffix'|g' \ -e ':a;s|(([ ]*-L)([^ ]+))+([ ]+)+('$pre_fix'[^ ]+)+|\1 \3/\5|g;ta' # Use lines below if not GNU sed and -r option #-e 's|\(-l\)\([^ ]\+\)|'$pre_fix'\2'$suffix'|g' \ #-e 's|\(\([ ]*-L\)\([^ ]\+\)\)\+\([ ]\+\)\+\('$pre_fix'[^ ]\+\)\+| \3/\5|g' Current output is: sh junk.txt Starting with: -L/usr/local/lib -ltom -ldick -lharry ...

Go Back   Application Development Forum > Theory and Concepts > Editors

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-14-2008, 12:48 AM
dhighley
Guest
 
Default sed translate link arguments to make dependency

The following test script shows what I'm attempting to do. It will end
up in a make file translating a make macro for library list into a
macro for target dependency.

pre_fix=lib
suffix=.so
echo Starting with:
echo -L/usr/local/lib -ltom -ldick -lharry -L/usr/lib -ljane -ldoe
echo -L/usr/local/lib -ltom -ldick -lharry -L/usr/lib -ljane -ldoe |
sed -r \
-e 's|(-l)([^ ]+)|'$pre_fix'\2'$suffix'|g' \
-e ':a;s|(([ ]*-L)([^ ]+))+([ ]+)+('$pre_fix'[^ ]+)+|\1 \3/\5|g;ta'

# Use lines below if not GNU sed and -r option
#-e 's|\(-l\)\([^ ]\+\)|'$pre_fix'\2'$suffix'|g' \
#-e 's|\(\([ ]*-L\)\([^ ]\+\)\)\+\([ ]\+\)\+\('$pre_fix'[^ ]\+\)\+|
\3/\5|g'

Current output is:
sh junk.txt
Starting with:
-L/usr/local/lib -ltom -ldick -lharry -L/usr/lib -ljane -ldoe
-L/usr/local/lib /usr/local/lib/libtom.so libdick.so libharry.so -L/
usr/lib /usr/lib/libjane.so libdoe.so

should look like this when done:
/usr/local/lib/libtom.so /usr/local/lib/libdick.so /usr/local/lib/
libharry.so /usr/lib/libjane.so /usr/lib/libdoe.so

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:38 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.