[m-rev.] for review: fix mundroo readline linking problem

Simon Taylor stayl at cs.mu.OZ.AU
Tue Nov 19 19:16:51 AEDT 2002


On 19-Nov-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 19-Nov-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > 
> > Estimated hours taken: 1
> > Branches: main, release
> > 
> > scripts/ml.in:
> > 	Search /usr/local/lib for shared libraries. This fixes
> > 	problems linking debugging executables on mundroo.
> ...
> > +case $all_libs in
> > +	shared) system_shlib_dirs="/usr/local/lib" ;;
> > +	static)	system_shlib_dirs="" ;;
> > +esac
> 
> What happens if there is no /usr/local/lib directory?
> Do you get a warning or error in that case?
> 
> I think it might be safest to only include /usr/local/lib if
> "[ -d /usr/local/lib/. ]" succeeds.  (The "/." is to account for
> the case where /usr/local/lib is a symlink.)
> 
> Otherwise that looks fine.

Estimated hours taken: 1
Branches: main, release

Search /usr/local/lib for shared libraries. This fixes
problems linking debugging executables on mundroo.

configure.in:
aclocal.m4:
	Check for /usr/local/lib.

scripts/ml.in:
	Document why we don't default to static linking for
	all libraries on Solaris/x86.


Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.13.2.1
diff -u -u -r1.13.2.1 aclocal.m4
--- aclocal.m4	14 Nov 2002 08:31:35 -0000	1.13.2.1
+++ aclocal.m4	19 Nov 2002 08:09:05 -0000
@@ -72,15 +72,33 @@
 else
 	# It's some other compiler.  We don't know if it searches
 	# /usr/local/include by default, so add it.
-	if test -d /usr/local/include; then
+	if test -d /usr/local/include/.; then
 		AC_MSG_RESULT(yes)
 		ALL_LOCAL_C_INCL_DIRS="-I/usr/local/include "
 	else
-		AC_MSG_RESULT(nos)
+		AC_MSG_RESULT(no)
 	fi
 fi
 AC_SUBST(ALL_LOCAL_C_INCL_DIRS)
 ])
+#-----------------------------------------------------------------------------#
+#
+# Set ALL_LOCAL_C_LIB_DIRS to any extra directories we need to add to the
+# search path for libraries.
+#
+AC_DEFUN(MERCURY_CHECK_LOCAL_C_LIB_DIRS,
+[
+AC_MSG_CHECKING(whether to pass -L/usr/local/lib to the linker)
+if test -d /usr/local/lib/.; then
+	AC_MSG_RESULT(yes)
+	ALL_LOCAL_C_LIB_DIRS=/usr/local/lib
+else
+	AC_MSG_RESULT(no)
+	ALL_LOCAL_C_LIB_DIRS=
+fi
+AC_SUBST(ALL_LOCAL_C_LIB_DIRS)
+])
+
 #-----------------------------------------------------------------------------#
 #
 # Check for readline and related header files and libraries
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.338.2.1
diff -u -u -r1.338.2.1 configure.in
--- configure.in	17 Nov 2002 15:30:48 -0000	1.338.2.1
+++ configure.in	19 Nov 2002 06:24:51 -0000
@@ -406,9 +406,13 @@
 # doesn't search either of those by default.
 MERCURY_CHECK_LOCAL_C_INCL_DIRS
 CPPFLAGS="$ALL_LOCAL_C_INCL_DIRS $CPPFLAGS"
-if test -d /usr/local/lib/.; then
-	LIBS="-L/usr/local/lib $LIBS"
-fi
+MERCURY_CHECK_LOCAL_C_LIB_DIRS
+for dir in $ALL_LOCAL_C_LIB_DIRS kludge_for_broken_shells
+do
+	if test "$dir" != "kludge_for_broken_shells"; then
+		LIBS="-L$dir $LIBS"
+	fi
+done
 
 AC_PROG_CPP
 #-----------------------------------------------------------------------------#
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.101
diff -u -u -r1.101 ml.in
--- scripts/ml.in	30 Oct 2002 16:35:37 -0000	1.101
+++ scripts/ml.in	19 Nov 2002 08:06:25 -0000
@@ -24,7 +24,8 @@
 # include the file `parse_ml_options.sh-subr'
 @PARSE_ML_OPTIONS@
 
-
+# add /usr/local/lib to the default search path, if needed
+ALL_LOCAL_C_LIB_DIRS=${MERCURY_ALL_LOCAL_C_LIB_DIRS=@ALL_LOCAL_C_LIB_DIRS@}
 NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@}
 DEMANGLER=${MERCURY_DEMANGLER=mdemangle}
 CC=${MERCURY_C_COMPILER="@CC@"}
@@ -127,7 +128,12 @@
 	case $FULLARCH in i*86-*-linux*|i*86-*-freebsd*|i*86-*-cygwin*)
 		# shared libraries are not the default on Linux
 		# -- see README.Linux
-		# Likewise for FreeBSD
+		# Likewise for FreeBSD and Cygwin
+		#
+		# We don't do this for Solaris/x86 because -ldl is
+		# only available for dynamically linked executables
+		# XXX With these defaults linking with Mercury libraries
+		# other than the standard library will fail.
 		case $make_shared_lib in false)
 			all_libs=static
 			;;
@@ -351,9 +357,12 @@
 	@LIB_LIBPATH@$LIBDIR/$GRADE/$FULLARCH
 	@LIB_LIBPATH@$LIBDIR/$FULLARCH
 "
-system_libdir_opts="\
-	@LIB_LIBPATH@/usr/local/lib
-"
+system_libdir_opts=
+for dir in $ALL_LOCAL_C_LIB_DIRS kludge_for_broken_shells; do
+	if [ "$dir" != "kludge_for_broken_shells" ]; then
+		system_libdir_opts="@LIB_LIBPATH@$dir $system_libdir_opts"
+	fi
+done
 LIBDIR_OPTS="$user_libdir_opts $merc_libdir_opts $system_libdir_opts"
 
 case $mercury_libs in
@@ -379,12 +388,17 @@
 		;;
 esac
 
+case $all_libs in
+	shared) system_shlib_dirs=$ALL_LOCAL_C_LIB_DIRS ;;
+	static)	system_shlib_dirs="" ;;
+esac
 
 RPATH_OPT_LIST=
 # only set RPATH_OPT_LIST if the system supports shared libraries
 case $EXT_FOR_SHARED_LIB in so)
 	prev=""
-	for dir in $user_shlib_dirs $merc_shlib_dirs 'kludge for broken shells'
+	for dir in $user_shlib_dirs $merc_shlib_dirs \
+			$system_shlib_dirs 'kludge for broken shells'
 	do
 	    case "$dir" in
 		'kludge for broken shells')
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list