changeset 7770:15d36d1dc32d

Improve support for OpenBSD.
author Bruno Haible <bruno@clisp.org>
date Tue, 02 Jan 2007 20:53:28 +0000
parents 83801603af12
children c9ae009bb4e7
files ChangeLog build-aux/config.rpath m4/lib-link.m4
diffstat 3 files changed, 136 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-12-24  Bruno Haible  <bruno@clisp.org>
+
+	Improve support for OpenBSD.
+	* build-aux/config.rpath (libname_spec): Export.
+	(library_names_spec): New variable. Export.
+	* m4/lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Extract libname_spec and
+	library_names_spec from the config.rpath output. Locate shared library
+	through the name pattern in library_names_spec.
+
 2007-01-01  Eric Blake  <ebb9@byu.net>
 
 	* lib/version-etc.c (COPYRIGHT_YEAR): Bump for new year.
--- a/build-aux/config.rpath
+++ b/build-aux/config.rpath
@@ -488,33 +488,54 @@
 
 # Check dynamic linker characteristics
 # Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
+# Unlike libtool.m4, here we don't care about _all_ names of the library, but
+# only about the one the linker finds when passed -lNAME. This is the last
+# element of library_names_spec in libtool.m4, or possibly two of them if the
+# linker has special search rules.
+library_names_spec=      # the last element of library_names_spec in libtool.m4
 libname_spec='lib$name'
 case "$host_os" in
   aix3*)
+    library_names_spec='$libname.a'
     ;;
   aix4* | aix5*)
+    library_names_spec='$libname$shrext'
     ;;
   amigaos*)
+    library_names_spec='$libname.a'
     ;;
   beos*)
+    library_names_spec='$libname$shrext'
     ;;
   bsdi[45]*)
+    library_names_spec='$libname$shrext'
     ;;
   cygwin* | mingw* | pw32*)
     shrext=.dll
+    library_names_spec='$libname.dll.a $libname.lib'
     ;;
   darwin* | rhapsody*)
     shrext=.dylib
+    library_names_spec='$libname$shrext'
     ;;
   dgux*)
+    library_names_spec='$libname$shrext'
     ;;
   freebsd1*)
     ;;
   kfreebsd*-gnu)
+    library_names_spec='$libname$shrext'
     ;;
   freebsd* | dragonfly*)
+    case "$host_os" in
+      freebsd[123]*)
+        library_names_spec='$libname$shrext$versuffix' ;;
+      *)
+        library_names_spec='$libname$shrext' ;;
+    esac
     ;;
   gnu*)
+    library_names_spec='$libname$shrext'
     ;;
   hpux9* | hpux10* | hpux11*)
     case $host_cpu in
@@ -528,10 +549,13 @@
         shrext=.sl
         ;;
     esac
+    library_names_spec='$libname$shrext'
     ;;
   interix3*)
+    library_names_spec='$libname$shrext'
     ;;
   irix5* | irix6* | nonstopux*)
+    library_names_spec='$libname$shrext'
     case "$host_os" in
       irix5* | nonstopux*)
         libsuff= shlibsuff=
@@ -549,40 +573,56 @@
   linux*oldld* | linux*aout* | linux*coff*)
     ;;
   linux*)
+    library_names_spec='$libname$shrext'
     ;;
   knetbsd*-gnu)
+    library_names_spec='$libname$shrext'
     ;;
   netbsd*)
+    library_names_spec='$libname$shrext'
     ;;
   newsos6)
+    library_names_spec='$libname$shrext'
     ;;
   nto-qnx*)
+    library_names_spec='$libname$shrext'
     ;;
   openbsd*)
+    library_names_spec='$libname$shrext$versuffix'
     ;;
   os2*)
     libname_spec='$name'
     shrext=.dll
+    library_names_spec='$libname.a'
     ;;
   osf3* | osf4* | osf5*)
+    library_names_spec='$libname$shrext'
     ;;
   solaris*)
+    library_names_spec='$libname$shrext'
     ;;
   sunos4*)
+    library_names_spec='$libname$shrext$versuffix'
     ;;
   sysv4 | sysv4.3*)
+    library_names_spec='$libname$shrext'
     ;;
   sysv4*MP*)
+    library_names_spec='$libname$shrext'
     ;;
   sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+    library_names_spec='$libname$shrext'
     ;;
   uts4*)
+    library_names_spec='$libname$shrext'
     ;;
 esac
 
 sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
 escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
 shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
+escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
 escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
 
 LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
@@ -596,6 +636,12 @@
 # Shared library suffix (normally "so").
 shlibext="$shlibext"
 
+# Format of library name prefix.
+libname_spec="$escaped_libname_spec"
+
+# Library names that the linker finds when passed -lNAME.
+library_names_spec="$escaped_library_names_spec"
+
 # Flag to hardcode \$libdir into a binary during linking.
 # This must work even if \$libdir does not exist.
 hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
--- a/m4/lib-link.m4
+++ b/m4/lib-link.m4
@@ -1,4 +1,4 @@
-# lib-link.m4 serial 10 (gettext-0.16.2)
+# lib-link.m4 serial 11 (gettext-0.16.2)
 dnl Copyright (C) 2001-2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -120,6 +120,8 @@
   wl="$acl_cv_wl"
   libext="$acl_cv_libext"
   shlibext="$acl_cv_shlibext"
+  libname_spec="$acl_cv_libname_spec"
+  library_names_spec="$acl_cv_library_names_spec"
   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
   hardcode_direct="$acl_cv_hardcode_direct"
@@ -211,27 +213,53 @@
           found_la=
           found_so=
           found_a=
+          eval libname=\"$libname_spec\"        # typically: libname=lib$name
+          if test -n "$shlibext"; then
+            shrext=".$shlibext"                 # typically: shrext=.so
+          else
+            shrext=
+          fi
           if test $use_additional = yes; then
-            if test -n "$shlibext" \
-               && { test -f "$additional_libdir/lib$name.$shlibext" \
-                    || { test "$shlibext" = dll \
-                         && test -f "$additional_libdir/lib$name.dll.a"; }; }; then
-              found_dir="$additional_libdir"
-              if test -f "$additional_libdir/lib$name.$shlibext"; then
-                found_so="$additional_libdir/lib$name.$shlibext"
+            dir="$additional_libdir"
+            dnl The same code as in the loop below:
+            dnl First look for a shared library.
+            if test -n "$shlibext"; then
+              if test -f "$dir/$libname$shrext"; then
+                found_dir="$dir"
+                found_so="$dir/$libname$shrext"
               else
-                found_so="$additional_libdir/lib$name.dll.a"
+                if test "$library_names_spec" = '$libname$shrext$versuffix'; then
+                  ver=`(cd "$dir" && \
+                        for f in "$libname$shrext".*; do echo "$f"; done \
+                        | sed -e "s,^$libname$shrext\\\\.,," \
+                        | tr '.' ' ' | sort -n -r -k1 -k2 -k3 -k4 -k5 | tr ' ' '.' \
+                        | sed 1q ) 2>/dev/null`
+                  if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                    found_dir="$dir"
+                    found_so="$dir/$libname$shrext.$ver"
+                  fi
+                else
+                  eval library_names=\"$library_names_spec\"
+                  for f in $library_names; do
+                    if test -f "$dir/$f"; then
+                      found_dir="$dir"
+                      found_so="$dir/$f"
+                      break
+                    fi
+                  done
+                fi
               fi
-              if test -f "$additional_libdir/lib$name.la"; then
-                found_la="$additional_libdir/lib$name.la"
+            fi
+            dnl Then look for a static library.
+            if test "X$found_dir" = "X"; then
+              if test -f "$dir/$libname.$libext"; then
+                found_dir="$dir"
+                found_a="$dir/$libname.$libext"
               fi
-            else
-              if test -f "$additional_libdir/lib$name.$libext"; then
-                found_dir="$additional_libdir"
-                found_a="$additional_libdir/lib$name.$libext"
-                if test -f "$additional_libdir/lib$name.la"; then
-                  found_la="$additional_libdir/lib$name.la"
-                fi
+            fi
+            if test "X$found_dir" != "X"; then
+              if test -f "$dir/$libname.la"; then
+                found_la="$dir/$libname.la"
               fi
             fi
           fi
@@ -241,26 +269,44 @@
               case "$x" in
                 -L*)
                   dir=`echo "X$x" | sed -e 's/^X-L//'`
-                  if test -n "$shlibext" \
-                     && { test -f "$dir/lib$name.$shlibext" \
-                          || { test "$shlibext" = dll \
-                               && test -f "$dir/lib$name.dll.a"; }; }; then
-                    found_dir="$dir"
-                    if test -f "$dir/lib$name.$shlibext"; then
-                      found_so="$dir/lib$name.$shlibext"
+                  dnl First look for a shared library.
+                  if test -n "$shlibext"; then
+                    if test -f "$dir/$libname$shrext"; then
+                      found_dir="$dir"
+                      found_so="$dir/$libname$shrext"
                     else
-                      found_so="$dir/lib$name.dll.a"
+                      if test "$library_names_spec" = '$libname$shrext$versuffix'; then
+                        ver=`(cd "$dir" && \
+                              for f in "$libname$shrext".*; do echo "$f"; done \
+                              | sed -e "s,^$libname$shrext\\\\.,," \
+                              | tr '.' ' ' | sort -n -r -k1 -k2 -k3 -k4 -k5 | tr ' ' '.' \
+                              | sed 1q ) 2>/dev/null`
+                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                          found_dir="$dir"
+                          found_so="$dir/$libname$shrext.$ver"
+                        fi
+                      else
+                        eval library_names=\"$library_names_spec\"
+                        for f in $library_names; do
+                          if test -f "$dir/$f"; then
+                            found_dir="$dir"
+                            found_so="$dir/$f"
+                            break
+                          fi
+                        done
+                      fi
                     fi
-                    if test -f "$dir/lib$name.la"; then
-                      found_la="$dir/lib$name.la"
+                  fi
+                  dnl Then look for a static library.
+                  if test "X$found_dir" = "X"; then
+                    if test -f "$dir/$libname.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/$libname.$libext"
                     fi
-                  else
-                    if test -f "$dir/lib$name.$libext"; then
-                      found_dir="$dir"
-                      found_a="$dir/lib$name.$libext"
-                      if test -f "$dir/lib$name.la"; then
-                        found_la="$dir/lib$name.la"
-                      fi
+                  fi
+                  if test "X$found_dir" != "X"; then
+                    if test -f "$dir/$libname.la"; then
+                      found_la="$dir/$libname.la"
                     fi
                   fi
                   ;;