[m-dev.] For review: "Absolutify" relative paths for shared libraries

Warwick Harvey wharvey at cs.monash.edu.au
Thu Jul 1 12:06:56 AEST 1999


Oops, I accidentally sent this to just Fergus (when mail is Cc:ed to me, if 
the copy to me arrives before the copy to the list, I don't get the 
automatic "Reply-To:" field set).

Fergus wrote:
> You should also add
> 
> 	--no-leave-shared-lib-dirs-relative)
> 		leave_shlib_dirs_relative=false
> 		;;

Done.

> >  	-R|--shared-lib-dir)
> >  		dir="$2"
> > +		case $leave_shlib_dirs_relative in false)
> > +			dir="`expr $dir : '\(/.*\)' '|' $PWD/$dir`"
> > +			;;
> > +		esac
> 
> `$PWD' is a bash-ism.  It's not portable.

Ouch.

> It would be more efficient to use `case' rather than `expr' here
> (saves a process invocation):
> 
> 			case "$dir" in
> 				/*) ;;
> 				*)  dir="`pwd`/$dir" ;;
> 			esac

I'm thick!  I had tried to figure out how I could do it without invoking 
another process, and came up blank.  :-)  This is much better.  Thanks.

Revised diff below.

Warwick

Estimated hours taken: 1.5

scripts/ml.in:
	If a shared library directory given to `ml' is relative, turn it
	into an absolute path by prepending the current directory.  Also
	add options `--[no-]leave-shared-lib-dirs-relative' to `ml' to
	turn off/on this behaviour.


Index: ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.63
diff -u -r1.63 ml.in
- --- ml.in	1999/06/21 07:45:52	1.63
+++ ml.in	1999/07/01 01:50:36
@@ -63,6 +63,12 @@
 	-R <directory>, --shared-lib-dir <directory>
 		Include <directory> in the list of directories that the
 		dynamic linker will use to search for shared libraries.
+	--leave-shared-lib-dirs-relative
+		Don't convert relative shared library directory names
+		into absolute paths.
+	--no-leave-shared-lib-dirs-relative
+		Convert relative shared library directory names into
+		absolute paths.  This is the default.
 
 Debugging options:
 	-t, --trace
@@ -151,6 +157,7 @@
 demangle=true
 MAYBE_STATIC_OPT=""
 make_shared_lib=false
+leave_shlib_dirs_relative=false
 user_shlib_dirs=""
 
 # include the file `init_grade_options.sh-subr'
@@ -246,13 +253,33 @@
 	-L*)
 		user_libdir_opts="$user_libdir_opts $1"
 		;;
+	--leave-shared-lib-dirs-relative)
+		leave_shlib_dirs_relative=true
+		;;
+	--no-leave-shared-lib-dirs-relative)
+		leave_shlib_dirs_relative=false
+		;;
 	-R|--shared-lib-dir)
 		dir="$2"
+		case $leave_shlib_dirs_relative in false)
+			case "$dir" in
+				/*) ;;
+				*)  dir="`pwd`/$dir" ;;
+			esac
+			;;
+		esac
 		user_shlib_dirs="$user_shlib_dirs $dir"
 		shift
 		;;
 	-R*)
 		dir="` expr $1 : '-R\(.*\)' `"
+		case $leave_shlib_dirs_relative in false)
+			case "$dir" in
+				/*) ;;
+				*)  dir="`pwd`/$dir" ;;
+			esac
+			;;
+		esac
 		user_shlib_dirs="$user_shlib_dirs $dir"
 		;;
 



--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list