* ltconfig, ltmain.sh: Upgraded libtool files to 0.9d. It looks
authorJim Blandy <jimb@red-bean.com>
Fri, 11 Apr 1997 04:56:13 +0000 (04:56 +0000)
committerJim Blandy <jimb@red-bean.com>
Fri, 11 Apr 1997 04:56:13 +0000 (04:56 +0000)
like the 0.8 disty contains files that say "0.9" in the sources???

ltconfig
ltmain.sh

index c6d1a23..8bf0a14 100755 (executable)
--- a/ltconfig
+++ b/ltconfig
@@ -33,7 +33,7 @@ progname=`echo "$0" | sed 's%^.*/%%'`
 # Constants:
 PROGRAM=ltconfig
 PACKAGE=libtool
-VERSION=0.9
+VERSION=0.9d
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5'
 rm="rm -f"
 
@@ -54,12 +54,15 @@ nonopt=NONE
 verify_host=yes
 with_gcc=no
 
+old_AR="$AR"
 old_CC="$CC"
 old_CFLAGS="$CFLAGS"
 old_CPPFLAGS="$CPPFLAGS"
 old_LD="$LD"
 old_RANLIB="$RANLIB"
 
+test -z "$AR" && AR=ar
+
 # Parse the command line options.
 args=
 prev=
@@ -240,6 +243,12 @@ if test "$verify_host" = yes; then
   host=`$ac_config_sub $host_alias`
   echo "$ac_t""$host" 1>&6
 
+  # Transform *-*-linux* to *-*-linux-gnu*, to support old configure scripts.
+  case "$host" in
+  *-*-linux-gnu*) ;;
+  *-*-linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+  esac
+
 elif test "$host" = NONE; then
   echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2
   echo "$help" 1>&2
@@ -248,12 +257,18 @@ else
   host_alias=$host
 fi
 
+# Transform *-*-linux* to *-*-linux-gnu*, to support old configure scripts.
+case "$host" in
+*-*-linux-gnu*) ;;
+*-*-linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+esac
+
 host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
 host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
 host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
 
 # Determine commands to create old-style static archives.
-old_archive_cmds='ar cru $oldlib$oldobjs'
+old_archive_cmds='$AR cru $oldlib$oldobjs'
 old_postinstall_cmds='chmod 644 $oldlib'
 
 # If RANLIB is not set, then run the test.
@@ -407,7 +422,7 @@ else
     pic_flag=
     ;;
 
-  *-*-osf3*)
+  *-*-osf3* | *-*-osf4*)
     # FIXME - pic_flag is probably required for hppa*-osf* and i860-osf*
     wl='-Wl,'
     link_static_flag='-non_shared'
@@ -474,7 +489,7 @@ with_gnu_ld=no
 set dummy $LD
 linker="$2"
 echo $ac_n "checking if $LD is GNU ld... $ac_c" 1>&6
-if $LD --version 2>&1 | egrep 'with BFD' > /dev/null; then
+if $LD --version 2>&1 | egrep '(GNU ld|with BFD)' > /dev/null; then
   with_gnu_ld=yes
   linker="GNU ld"
 fi
@@ -484,7 +499,9 @@ echo $ac_t "$with_gnu_ld" 1>&6
 echo $ac_n "checking if $linker supports shared libraries... $ac_c" 1>&6
 
 archive_cmds=
-hardcode_libdir_flag=
+export_dynamic_flag=
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
 hardcode_direct=no
 hardcode_minus_L=no
 hardcode_shlibpath_var=unsupported
@@ -511,20 +528,21 @@ if test "$with_gnu_ld" = yes; then
 
   if test "$ld_shlibs" = yes; then
     archive_cmds='$cc -shared ${wl}-soname $wl$soname -o $lib$libobjs$deplibs'
-    hardcode_libdir_flag='${wl}-rpath $wl$libdir'
+    hardcode_libdir_flag_spec='${wl}-rpath $wl$libdir'
+    export_dynamic_flag='${wl}-export-dynamic'
   fi
 else
   # PORTME fill in a description of your system's linker (not GNU ld)
   case "$host" in
   *-*-aix3*)
-    archive_cmds='/usr/ucb/nm$libobjs | egrep \" D \" | sed \"s/^.* //\" > $lib.exp;$LD -o $objdir/$soname$libobjs -bE:$lib.exp -T512 -H512 -bM:SRE -lc$deplibs;ar cru $lib $objdir/$soname'
-    test "$with_gcc" != yes && hardcode_direct=yes
+    archive_cmds='/usr/ucb/nm$libobjs | egrep \" [BD] \" | sed \"s/^.* //\" > $lib.exp;$LD -o $objdir/$soname$libobjs -bE:$lib.exp -T512 -H512 -bM:SRE -lc$deplibs;$AR cru $lib $objdir/$soname'
+    # Note: this linker hardcodes the directories in LIBPATH if there
+    # are no directories specified by -L.
     hardcode_minus_L=yes
     ;;
 
   *-*-aix4*)
-    archive_cmds='/bin/nm -B$libobjs | egrep \" D \" | sed \"s/^.* //\" > $lib.exp;$cc -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry$deplibs;ar cru $lib $objdir/$soname'
-    test "$with_gcc" != yes && hardcode_direct=yes
+    archive_cmds='/bin/nm -B$libobjs | egrep \" [BD] \" | sed \"s/^.* //\" > $lib.exp;$cc -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry$deplibs;$AR cru $lib $objdir/$soname'
     hardcode_minus_L=yes
     ;;
 
@@ -537,34 +555,35 @@ else
 
   *-*-hpux9*)
     archive_cmds='$rm $objdir/$soname;$LD -b +s +b $install_libdir -o $objdir/$soname$libobjs$deplibs;mv $objdir/$soname $lib'
-    hardcode_libdir_flag='${wl}+b ${wl}$libdir'
+    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
     hardcode_direct=yes
     hardcode_minus_L=yes
     ;;
 
   *-*-hpux10*)
     archive_cmds='$LD -b +h $soname +s +b $install_libdir -o $lib$libobjs$deplibs'
-    hardcode_libdir_flag='${wl}+b ${wl}$libdir'
+    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
     hardcode_direct=yes
     hardcode_minus_L=yes
     ;;
 
   *-*-irix5* | *-*-irix6*)
     archive_cmds='$LD -shared -o $lib -soname $soname -set_version $verstring$libobjs -lc$deplibs'
-    hardcode_libdir_flag='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
     ;;
 
   *-*-netbsd*)
     # Tested with NetBSD 1.2 ld
     archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs'
-    hardcode_libdir_flag='-R$libdir'
+    hardcode_libdir_flag_spec='-R$libdir'
     hardcode_direct=yes
     hardcode_shlibpath_var=no
     ;;
 
-  *-*-osf3*)
+  *-*-osf3* | *-*-osf4*)
     archive_cmds='$LD -shared -o $lib -soname $soname -set_version $verstring$libobjs -lc$deplibs'
-    hardcode_libdir_flag='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
     ;;
 
   *-*-sco3.2v5*)
@@ -574,13 +593,13 @@ else
 
   *-*-solaris2*)
     archive_cmds='$LD -G -z text -h $soname -o $lib$libobjs$deplibs'
-    hardcode_libdir_flag='-R$libdir'
+    hardcode_libdir_flag_spec='-R$libdir'
     hardcode_shlibpath_var=no
     ;;
 
   *-*-sunos4*)
     archive_cmds='$LD -assert pure-text -Bstatic -o $lib$libobjs'
-    hardcode_libdir_flag='-L$libdir'
+    hardcode_libdir_flag_spec='-L$libdir'
     hardcode_direct=yes
     hardcode_minus_L=yes
     hardcode_shlibpath_var=no
@@ -597,7 +616,7 @@ echo $ac_t "$ld_shlibs" 1>&6
 # Check hardcoding attributes.
 echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6
 hardcode_action=
-if test -n "$hardcode_libdir_flag"; then
+if test -n "$hardcode_libdir_flag_spec"; then
   # We can hardcode non-existant directories.
   if test "$hardcode_direct" != no &&
      test "$hardcode_minus_L" != no &&
@@ -606,14 +625,14 @@ if test -n "$hardcode_libdir_flag"; then
     # Can't link without hardcoding.
     hardcode_action=relink
   else
-    hardcode_action=rpath
+    hardcode_action=immediate
   fi
 elif test "$hardcode_direct" = yes ||
      test "$hardcode_minus_L" = yes ||
      test "$hardcode_shlibpath_var" = yes; then
 
   # We can't hardcode non-existant directories, but we can existing ones.
-  hardcode_action=relink
+  hardcode_action=immediate
 else
   # We can't hardcode anything.
   hardcode_action=unsupported
@@ -631,7 +650,7 @@ echo $ac_t "$reload_flag"
 test -n "$reload_flag" && reload_flag=" $reload_flag"
 
 # PORTME Fill in your ld.so characteristics
-lib_names=
+library_names_spec=
 soname_spec=
 postinstall_cmds=
 finish_cmds=
@@ -642,11 +661,8 @@ dynamic_linker="$host_os ld.so"
 echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6
 case "$host" in
 *-*-aix3* | *-*-aix4*)
-  # Shared libraries and static libraries currently use the same namespace.
-  test "$enable_shared" = no || enable_static=no
-
   version_type=linux
-  lib_names='$libname.so.$versuffix $libname.a'
+  library_names_spec='$libname.so.$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX has no versioning support, so we append a major version to the name.
@@ -655,16 +671,12 @@ case "$host" in
 
 *-*-freebsd*)
   version_type=sunos
-  lib_names='$libname.so.$versuffix $libname.so'
+  library_names_spec='$libname.so.$versuffix $libname.so'
   finish_cmds='ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-*-*-gnu*)
-  version_type=sunos
-  lib_names='$libname.so.$versuffix'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+# *-*-gnu* needs to come after *-*-linux-gnu*.
 
 *-*-hpux9* | *-*-hpux10*)
   # Give a soname corresponding to the major version so that dld.sl refuses to
@@ -672,7 +684,7 @@ case "$host" in
   dynamic_linker="$host_os dld.sl"
   version_type=sunos
   shlibpath_var=SHLIB_PATH
-  lib_names='$libname.sl.$versuffix $libname.sl.$major $libname.sl'
+  library_names_spec='$libname.sl.$versuffix $libname.sl.$major $libname.sl'
   soname_spec='$libname.sl.$major'
   # HP-UX runs *really* slowly unless shared libraries are mode 555.
   postinstall_cmds='chmod 555 $lib'
@@ -681,55 +693,62 @@ case "$host" in
 *-*-irix5* | *-*-irix6*)
   version_type=osf
   soname_spec='$libname.so'
-  lib_names='$libname.so.$versuffix $libname.so'
+  library_names_spec='$libname.so.$versuffix $libname.so'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-# No shared lib support for linuxoldld or linuxaout.
-*-*-linuxoldld* | *-*-linuxaout*)
+# No shared lib support for Linux oldld, aout, or coff.
+*-*-linux-gnuoldld* | *-*-linux-gnuaout* | *-*-linux-gnucoff*)
   dynamic_linker=no
   can_build_shared=no
   ;;
 
-*-*-linux*)
+# This must be Linux ELF.
+*-*-linux-gnu*)
   version_type=linux
-  lib_names='$libname.so.$versuffix $libname.so.$major $libname.so'
+  library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
   soname_spec='$libname.so.$major'
   finish_cmds='ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
+*-*-gnu*)
+  version_type=sunos
+  library_names_spec='$libname.so.$versuffix'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
 *-*-netbsd*)
   version_type=sunos
-  lib_names='$libname.so.$versuffix'
+  library_names_spec='$libname.so.$versuffix'
   finish_cmds='ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-*-*-osf3*)
+*-*-osf3* | *-*-osf4*)
   version_type=osf
   soname_spec='$libname.so'
-  lib_names='$libname.so.$versuffix $libname.so'
+  library_names_spec='$libname.so.$versuffix $libname.so'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
 *-*-sco3.2v5*)
   version_type=osf
   soname_spec='$libname.so.$major'
-  lib_names='$libname.so.$versuffix $libname.so.$major $libname.so'
+  library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
 *-*-solaris2*)
   version_type=linux
-  lib_names='$libname.so.$versuffix $libname.so.$major $libname.so'
+  library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
   soname_spec='$libname.so.$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
 *-*-sunos4*)
   version_type=sunos
-  lib_names='$libname.so.$versuffix'
+  library_names_spec='$libname.so.$versuffix'
   finish_cmds='ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
@@ -771,21 +790,21 @@ echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6
 echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6
 test "$can_build_shared" = "no" && enable_shared=no
 
-if test "$enable_shared" = yes; then
-  # On AIX, we do not build both static and shared libraries.
-  case "$host_os" in
-  aix*)
-    test "$enable_static" = yes && enable_static=no
-    if test -n "$RANLIB"; then
-      archive_cmds="$archive_cmds;\$RANLIB \$lib"
-      postinstall_cmds='$RANLIB $lib'
-    fi
-    ;;
-  esac
-fi
+# On AIX, shared libraries and static libraries use the same namespace.
+case "$host_os" in
+aix*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds;\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+esac
 
 echo "$ac_t""$enable_shared" 1>&6
 
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
 
 ofile=libtool
 trap "$rm $ofile; exit 1" 1 2 15
@@ -819,6 +838,9 @@ build_old_libs=$enable_static
 host_alias="$host_alias"
 host="$host"
 
+# The archiver.
+AR='$AR'
+
 # The linker used to build libraries.
 LD='$LD'
 
@@ -835,6 +857,9 @@ pic_flag='$pic_flag'
 # Compiler flag to prevent dynamic linking.
 link_static_flag='$link_static_flag'
 
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag='$export_dynamic_flag'
+
 # Pattern to match compiler flags for creating libNAME_p libraries:
 profile_flag_pattern='$profile_flag_pattern'
 
@@ -843,7 +868,7 @@ version_type=$version_type
 
 # List of archive names.  First name is the real one, the rest are links.
 # The last name is the one that the linker finds with -lNAME.
-lib_names='$lib_names'
+library_names_spec='$library_names_spec'
 
 # The coded name of the library, if different from the real name.
 soname_spec='$soname_spec'
@@ -872,7 +897,10 @@ hardcode_action=$hardcode_action
 
 # Flag to hardcode \$libdir into a binary during linking.
 # This must work even if \$libdir does not exist.
-hardcode_libdir_flag='$hardcode_libdir_flag'
+hardcode_libdir_flag_spec='$hardcode_libdir_flag_spec'
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator='$hardcode_libdir_separator'
 
 # Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
 # resulting binary.
index 2dbefa4..d38fae1 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -28,7 +28,7 @@ progname=`echo "$0" | sed 's%^.*/%%'`
 # Constants.
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=0.9
+VERSION=0.9d
 
 default_mode=NONE
 help="Try \`$progname --help' for more information."
@@ -46,6 +46,13 @@ if test "$LTCONFIG_VERSION" != "$VERSION"; then
   exit 1
 fi
 
+#
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+  echo "$progname: not configured to build any kind of library" 1>&2
+  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit 1
+fi
+
 # Global variables.
 mode=$default_mode
 nonopt=
@@ -148,13 +155,16 @@ if test -z "$show_help"; then
     *rm)
       mode=uninstall
       ;;
+    *.la)
+      mode=dlname
+      ;;
     *)
       # Just use the default operation mode.
       if test "$mode" = NONE; then
        if test -n "$nonopt"; then
-         echo "$progname: warning: cannot infer operation mode from \`$nonopt $@'" 1>&2
+         echo "$progname: warning: cannot infer operation mode from \`$nonopt'" 1>&2
        else
-         echo "$progname: warning: cannot infer operation mode from no MODE-ARGS" 1>&2
+         echo "$progname: warning: cannot infer operation mode without MODE-ARGS" 1>&2
        fi
       fi
       ;;
@@ -169,6 +179,7 @@ if test -z "$show_help"; then
   case "$mode" in
   # libtool compile mode
   compile)
+    progname="$progname: compile"
     # Get the compilation command and the source file.
     base_compile="$nonopt"
     lastarg=
@@ -264,6 +275,7 @@ if test -z "$show_help"; then
 
   # libtool link mode
   link)
+    progname="$progname: link"
     # Go through the arguments, transforming them on the way.
     cc="$nonopt"
     args="$cc"
@@ -272,6 +284,8 @@ if test -z "$show_help"; then
     compile_shlibpath=
     finalize_shlibpath=
     deplibs=
+    export_dynamic=no
+    hardcode_libdirs=
     install_libdir=
     libobjs=
     link_against_libtool_libs=
@@ -283,18 +297,11 @@ if test -z "$show_help"; then
     prevarg=
     temp_rpath=
     vinfo=
-
-
-#    FIXME Maybe set the library names to libNAME_p.a if we are doing profiling.
-#    if echo " $@ " | egrep "[         ]$profile_flag_pattern[  ]" > /dev/null 2>&1; then
-#      suffix=p
-#    else
-#      suffix=
-#    fi
+    whole_archive=no
 
     # We need to know -static, to get the right output filenames.
     case " $@ " in
-    *" -static "*) build_libtool_libs=no ;;
+    *" -static "*) build_libtool_libs=no build_old_libs=yes ;;
     esac
 
     for arg
@@ -303,13 +310,8 @@ if test -z "$show_help"; then
       if test -n "$prev"; then
        case "$prev" in
        output)
-         if test "$build_libtool_libs" = yes; then
-           compile_command="$compile_command $objdir/$arg"
-           finalize_command="$finalize_command $objdir/$arg"T
-         else
-           compile_command="$compile_command $arg"
-           finalize_command="$finalize_command $arg"
-         fi
+         compile_command="$compile_command @OUTPUT@"
+         finalize_command="$finalize_command @OUTPUT@"
          args="$args $arg"
          ;;
        esac
@@ -324,6 +326,13 @@ if test -z "$show_help"; then
       prevarg="$arg"
 
       case "$arg" in
+      -export-dynamic)
+       export_dynamic=yes
+       compile_command="$compile_command $export_dynamic_flag"
+       finalize_command="$finalize_command $export_dynamic_flag"
+       continue
+       ;;
+
       -L*)
        dir=`echo "$arg" | sed 's%^-L\(.*\)$%\1%'`
        case "$dir" in
@@ -339,6 +348,8 @@ if test -z "$show_help"; then
 
       -l*) deplibs="$deplibs $arg" ;;
 
+      -no-whole-archive) whole_archive=no ;;
+
       -o) prev=output ;;
 
       -rpath)
@@ -363,13 +374,53 @@ if test -z "$show_help"; then
        continue
        ;;
 
+      -whole-archive) whole_archive=yes ;;
+
       -*) cc="$cc $arg" ;; # Some other compiler flag.
 
-      *.o | *.a)
+      *.o)
        # A standard object.
        objs="$objs $arg"
        ;;
 
+      *.a)
+       # Find the relevant object directory and library name.
+       file=`echo "$arg" | sed 's%^.*/%%'`
+       dir=`echo "$arg" | sed 's%/[^/]*$%/%'`
+       test "$dir" = "$arg" && dir=
+
+       # If -whole-archive was specified, we need to link all the members.
+       if test "$whole_archive" = yes; then
+         if test -f $arg; then :
+         else
+           echo "$progname: \`$arg' does not exist" 1>&2
+           echo "$help" 1>&2
+           exit 1
+         fi
+
+         # Get the names of the members of the archive.
+         members=`$AR t $arg 2>/dev/null`
+         for m in $members; do
+           case "$m" in
+           *.lo) libobjs="$libobjs $dir$m" ;;
+           *.o)
+             if test "$build_libtool_libs" = yes; then
+               objs="$objs $dir$m"
+             else
+               libobjs="$libobjs $dir$m"
+             fi
+             ;;
+           esac
+         done
+       elif test -f "$dir$objdir/$file"; then
+         # .libs/libfoo.a exists, so this is an archive of libobjects.
+         libobjs="$libobjs $arg"
+       else
+         # Standard archive.
+         objs="$objs $arg"
+       fi
+       ;;
+
       *.lo)
        # A library object.
        libobjs="$libobjs $arg"
@@ -400,12 +451,17 @@ if test -z "$show_help"; then
          exit 1
        fi
 
-       # Get the name of the link library.
+       # Get the name of the library we link against.
        linklib=
-       for linklib in $library_names; do
-         :
+       for l in $old_library $library_names; do
+         linklib="$l"
        done
 
+       if test -z "$linklib"; then
+         echo "$progname: cannot find name of link library for \`$arg'" 1>&2
+         exit 1
+       fi
+
        # Find the relevant object directory and library name.
        name=`echo "$arg" | sed 's%^.*/%%; s/\.la$//; s/^lib//'`
        dir=`echo "$arg" | sed 's%/[^/]*$%%'`
@@ -426,19 +482,28 @@ if test -z "$show_help"; then
            esac
          fi
 
-         if test -z "$linklib"; then
-           echo "$progname: cannot find name of link library for \`$arg'" 1>&2
-           exit 1
-         fi
+         if test -n "$hardcode_libdir_flag_spec"; then
+           if test -n "$hardcode_libdir_separator"; then
+             if test -z "$hardcode_libdirs"; then
+               # Put the magic libdir with the hardcode flag.
+               hardcode_libdirs="$libdir"
+               libdir="@HARDCODE_LIBDIRS@"
+             else
+               # Just accumulate the libdirs.
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               libdir=
+             fi
+           fi
 
-         if test -n "$hardcode_libdir_flag"; then
-           tmp=`eval echo \"$hardcode_libdir_flag\"`
-           compile_command="$compile_command $tmp"
-           finalize_command="$finalize_command $tmp"
+           if test -n "$libdir"; then
+             hardcode_libdir_flag=`eval echo \"$hardcode_libdir_flag_spec\"`
+             compile_command="$compile_command $hardcode_libdir_flag"
+             finalize_command="$finalize_command $hardcode_libdir_flag"
+           fi
          fi
 
          case "$hardcode_action" in
-         rpath)
+         immediate)
            if test "$hardcode_direct" = no; then
              compile_command="$compile_command $dir/$linklib"
            elif test "$hardcode_minus_L" = no; then
@@ -472,22 +537,30 @@ if test -z "$show_help"; then
              compile_command="$compile_command -l$name"
            fi
            ;;
+
+         *)
+           echo "$progname: \`$hardcode_action' is an unknown hardcode action" 1>&2
+           exit 1
+           ;;
          esac
 
          # Finalize command for both is simple: just hardcode it.
          if test "$hardcode_direct" = yes; then
            finalize_command="$finalize_command $libdir/$linklib"
-         elif test "$hardcode_minus_L" = no; then
+         elif test "$hardcode_minus_L" = yes; then
            finalize_command="$finalize_command -L$libdir -l$name"
-         elif test "$hardcode_shlibpath_var" = no; then
+         elif test "$hardcode_shlibpath_var" = yes; then
            finalize_shlibpath="$finalize_shlibpath$libdir:"
            finalize_command="$finalize_command -l$name"
+          else
+            # We can't seem to hardcode it, guess we'll fake it.
+           finalize_command="$finalize_command -L$libdir -l$name"
          fi
         else
           # Transform directly to old archives if we don't build new libraries.
-         test -z "$old_library" && old_library="$linklib"
-          compile_command="$compile_command $dir/$old_library"
-         finalize_command="$finalize_command $dir/$old_library"
+         test -z "$old_library" || linklib="$old_library"
+          compile_command="$compile_command $dir/$linklib"
+         finalize_command="$finalize_command $dir/$linklib"
         fi
        continue
        ;;
@@ -509,6 +582,12 @@ if test -z "$show_help"; then
       exit 1
     fi
 
+    # Substitute the hardcoded libdirs into the compile commands.
+    if test "$hardcode_libdir_colon_separated" = yes; then
+      compile_command=`echo "$compile_command" | sed "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"`
+      finalize_command=`echo "$finalize_command" | sed "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"`
+    fi
+
     oldlib=
     oldobjs=
     case "$output" in
@@ -525,6 +604,7 @@ if test -z "$show_help"; then
 
     *.a)
       # Old archive.
+      libname=`echo "$output" | sed 's/\.a$//'`
       build_old_libs=yes
 
       if test -n "$install_libdir"; then
@@ -539,14 +619,22 @@ if test -z "$show_help"; then
     *.la)
       libname=`echo "$output" | sed 's/\.la$//'`
 
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+      current=0
+      revision=0
+      age=0
+
       if test -n "$objs"; then
-       echo "$progname: cannot build libtool library \`$output' from non-libtool objects"
+       echo "$progname: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
        exit 1
       fi
 
       # How the heck are we supposed to write a wrapper for a shared library?
       if test -n "$link_against_libtool_libs"; then
-        echo "$progname: libtool libraries may not depend on uninstalled libraries" 1>&2
+        echo "$progname: libtool library \`$output' may not depend on uninstalled libraries:$link_against_libtool_libs" 1>&2
        exit 1
       fi
 
@@ -555,10 +643,6 @@ if test -z "$show_help"; then
        exit 1
       fi
 
-      current=0
-      revision=0
-      age=0
-
       # Parse the version information argument.
       IFS="${IFS=      }"; save_ifs="$IFS"; IFS=':'
       set dummy $vinfo
@@ -661,7 +745,7 @@ if test -z "$show_help"; then
 
       if test "$build_libtool_libs" = yes; then
        # Get the real and link names of the library.
-       library_names=`eval echo \"$lib_names\"`
+       library_names=`eval echo \"$library_names_spec\"`
        set dummy $library_names
        realname="$2"
        shift; shift
@@ -697,6 +781,12 @@ if test -z "$show_help"; then
          $show "$ln_s $realname $link"
          $run $ln_s $realname $link || exit $?
        done
+
+       # If -export-dynamic was specified, set the dlname.
+       if test "$export_dynamic" = yes; then
+         # On all known operating systems, these are identical.
+         dlname="$soname"
+       fi
       fi
       ;;
 
@@ -736,8 +826,10 @@ if test -z "$show_help"; then
       # Delete the old objects.
       $run $rm $obj $libobj
 
-      # Create the old-style object.
-      reload_objs="$objs"`echo "$libobjs " | sed 's/\.lo /.o /g; s/ $//g'`
+      # Create the old-style object (skipping any convenience libraries).
+      # FIXME: skipping them is simplistic.  We should determine which members
+      # are actually needed to resolve symbols.
+      reload_objs="$objs"`echo "$libobjs " | sed 's/[^         ]*\.a //g; s/\.lo /.o /g; s/ $//g'`
 
       output="$obj"
       cmds=`eval echo \"$reload_cmds\"`
@@ -788,6 +880,10 @@ if test -z "$show_help"; then
       fi
 
       if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then
+       # Replace the output file specification.
+       compile_command=`echo "$compile_command" | sed 's%@OUTPUT@%'"$output"'%g'`
+       finalize_command=`echo "$finalize_command" | sed 's%@OUTPUT@%'"$output"'%g'`
+
        # We have no uninstalled library dependencies, so finalize right now.
        $show "$compile_command"
        $run $compile_command
@@ -804,6 +900,10 @@ if test -z "$show_help"; then
        exit $status
       fi
 
+      # Replace the output file specification.
+      compile_command=`echo "$compile_command" | sed 's%@OUTPUT@%'"$objdir/$output"'%g'`
+      finalize_command=`echo "$finalize_command" | sed 's%@OUTPUT@%'"$objdir/$output"'T%g'`
+
       # Create the binary in the object directory, then wrap it.
       if test -d $objdir; then :
       else
@@ -934,19 +1034,21 @@ EOF
 
     # See if we need to build an old-fashioned archive.
     if test "$build_old_libs" = "yes"; then
-      # Transform .lo files to .o
-      oldobjs="$objs"`echo "$libobjs " | sed 's/\.lo /.o /g; s/ $//g'`
-      case "$output" in
-      *.la)
-       # Now set the variables for building old libraries.
-       oldlib="$objdir/$libname.a"
-       ;;
-      *)
-       oldlib="$output"
+      # Now set the variables for building old libraries.
+      oldlib="$objdir/$libname.a"
+
+      # Transform .lo files to .o (skipping convenience libraries).
+      # FIXME: skipping them is simplistic.  We should determine which members
+      # are actually needed to resolve symbols.
+      oldobjs="$objs"`echo "$libobjs " | sed 's/[^     ]*\.a //g; s/\.lo /.o /g; s/ $//g'`
+
+      if test -d "$objdir"; then
        $show "$rm $oldlib"
        $run $rm $oldlib
-       ;;
-      esac
+      else
+       $show "$mkdir $objdir"
+       $run $mkdir $objdir
+      fi
 
       # Do each command in the archive commands.
       cmds=`eval echo \"$old_archive_cmds\"`
@@ -957,6 +1059,38 @@ EOF
        eval "$run $cmd" || exit $?
       done
       IFS="$save_ifs"
+
+      case "$output" in
+      *.a)
+       # Just move into place if there were any non-libtool objects.
+       if test -n "$objs"; then
+         $show "$mv $oldlib $output"
+         $run $mv $oldlib $output
+
+       elif test -z "$pic_flag" || test "$build_libtool_libs" != yes; then
+         # Just symlink if libtool objects are the same.
+         $show "$rm $output"
+         $run $rm $output
+         $show "$ln_s $oldlib $output"
+         $run $ln_s $oldlib $output
+
+       else
+         # Create an archive of libtool objects.
+         oldlib="$output"
+         oldobjs="$libobjs"
+
+         # Do each command in the archive commands.
+         cmds=`eval echo \"$old_archive_cmds\"`
+         IFS="${IFS=   }"; save_ifs="$IFS"; IFS=';'
+         for cmd in $cmds; do
+           IFS="$save_ifs"
+           $show "$cmd"
+           eval "$run $cmd" || exit $?
+         done
+         IFS="$save_ifs"
+       fi
+       ;;
+      esac
     fi
 
     # Now create the libtool archive.
@@ -979,6 +1113,9 @@ library_names='$library_names'
 # The name of the static archive.
 old_library='$old_library'
 
+# The name that we can dlopen(3).
+dlname='$dlname'
+
 # Version information for $libname.
 current=$current
 age=$age
@@ -995,6 +1132,7 @@ EOF
 
   # libtool install mode
   install)
+    progname="$progname: install"
 
     # The first argument is the name of the installation program.
     install_prog="$nonopt"
@@ -1137,6 +1275,7 @@ EOF
          # Install the shared library and build the symlinks.
          $show "$install_prog $dir/$realname $destdir/$realname"
          eval "$run $install_prog $dir/$realname $destdir/$realname" || exit $?
+         test "X$dlname" = "X$realname" && dlname=
 
          # Support stripping libraries.
          if test -n "$stripme"; then
@@ -1161,11 +1300,18 @@ EOF
            # ... and create new ones.
            for linkname
            do
+             test "X$dlname" = "X$linkname" && dlname=
              $show "$ln_s $realname $destdir/$linkname"
              $run $ln_s $realname $destdir/$linkname
            done
          fi
 
+         if test -n "$dlname"; then
+           # Install the dynamically-loadable library.
+           $show "$install_prog $dir/$dlname $destdir/$dlname"
+           eval "$run $install_prog $dir/$dlname $destdir/$dlname" || exit $?
+         fi
+
          # Do each command in the postinstall commands.
          lib="$destdir/$realname"
          cmds=`eval echo \"$postinstall_cmds\"`
@@ -1259,15 +1405,6 @@ EOF
       esac
     done
 
-# FIXME Install any profiled libraries, too.
-#    newfiles=
-#    for file in $staticlibs; do
-#      newfiles="$newfiles $file"
-#      pfile=`echo "$file" | sed 's/\.a$/_p.a/'`
-#      test -f "$pfile" && newfiles="$newfiles $pfile"
-#    done
-#    staticlibs="$newfiles"
-
     for file in $staticlibs; do
       name=`echo "$file" | sed 's%^.*/%%'`
 
@@ -1312,8 +1449,51 @@ EOF
     exit 0
     ;;
 
+  # libtool dlname mode
+  dlname)
+    progname="$progname: dlname"
+    ltlibs="$nonopt"
+    for lib
+    do
+      ltlibs="$ltlibs $lib"
+    done
+
+    # Now check to make sure each one is a valid libtool library.
+    status=0
+    for lib in $ltlibs; do
+      dlname=
+      libdir=
+
+      # Check to see that this really is a libtool archive.
+      if egrep "^# Generated by $PROGRAM" $arg >/dev/null 2>&1; then :
+      else
+        echo "$progname: \`$arg' is not a valid libtool archive" 1>&2
+       status=1
+       continue
+      fi
+
+      # If there is no directory component, then add one.
+      case "$arg" in
+      */*) . $arg ;;
+      *) . ./$arg ;;
+      esac
+
+      if test -z "$libdir"; then
+        echo "$progname: \`$arg' contains no -rpath information" 1>&2
+        status=1
+      elif test -n "$dlname"; then
+       echo "$libdir/$dlname"
+      else
+        echo "$progname: \`$arg' was not linked with \`-export-dynamic'" 1>&2
+        status=1
+      fi
+    done
+    exit $status
+    ;;
+
   # libtool finish mode
   finish)
+    progname="$progname: finish"
     libdirs="$nonopt"
 
     if test -n "$finish_cmds" && test -n "$libdirs"; then
@@ -1345,6 +1525,7 @@ EOF
 
   # libtool uninstall mode
   uninstall)
+    progname="$progname: uninstall"
     rm="$nonopt"
     files=
 
@@ -1367,6 +1548,8 @@ EOF
       test "$dir" = "$file" && dir=.
       name=`echo "$file" | sed -e 's%^.*/%%'`
 
+      rmfiles="$file"
+
       case "$name" in
       *.la)
        # Possibly a libtool archive, so verify it.
@@ -1375,21 +1558,19 @@ EOF
 
          # Delete the libtool libraries and symlinks.
          for n in $library_names; do
-           $show "$rm $dir/$n"
-           $run $rm $dir/$n
+           rmfiles="$rmfiles $dir/$n"
+           test "X$n" = "X$dlname" && dlname=
          done
+         test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname"
+         test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library"
 
-         # Delete the old-fashioned archive.
-         if test -n "$old_library"; then
-           $show "$rm $dir/$old_library"
-           $run $rm $dir/$old_library
-         fi
+         # FIXME: should reinstall the best remaining shared library.
        fi
        ;;
       esac
 
-      $show "$rm $file"
-      $run $rm $file
+      $show "$rm $rmfiles"
+      $run $rm $rmfiles
     done
     exit 0
     ;;
@@ -1423,6 +1604,7 @@ Provide generalized library-building support services.
 MODE must be one of the following:
 
       compile         compile a source file into a libtool object
+      dlname          print filenames to use to \`dlopen' libtool libraries
       finish          complete the installation of libtool libraries
       install         install libraries or executables
       link            create a library or an executable
@@ -1448,6 +1630,19 @@ library object suffix, \`.lo'.
 EOF
   ;;
 
+dlname)
+  cat <<EOF
+Usage: $progname [OPTION]... --mode=dlname LTLIBRARY [LTLIBRARY]...
+
+Print filenames to use to \`dlopen' libtool libraries.
+
+Each LTLIBRARY is the name of a dynamically loadable libtool library (one that
+was linked using the \`-export-dynamic' option).
+
+The names to use are printed to standard output, one per line.
+EOF
+  ;;
+
 finish)
   cat <<EOF
 Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
@@ -1487,13 +1682,16 @@ a program from several object files.
 
 The following components of LINK-COMMAND are treated specially:
 
-  -LLIBDIR        search LIBDIR for required installed libraries
-  -lNAME          OUTPUT-FILE requires the installed library libNAME
-  -o OUTPUT-FILE  create OUTPUT-FILE from the specified objects
-  -rpath LIBDIR   the created library will eventually be installed in LIBDIR
-  -static         do not do any dynamic linking or shared library creation
+  -export-dynamic   allow the output file to be loaded with dlopen(3)
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -no-whole-archive turn off \`-whole-archive'
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -static           do not do any dynamic linking or shared library creation
   -version-info CURRENT[:REVISION[:AGE]]
-                 specify library version info [each variable defaults to 0]
+                   specify library version info [each variable defaults to 0]
+  -whole-archive    use all members from subsequent \`.a' files
 
 All other options (arguments beginning with \`-') are ignored.
 
@@ -1505,7 +1703,8 @@ If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only
 library objects (\`.lo' files) may be specified, and \`-rpath' is required.
 
 If OUTPUT-FILE ends in \`.a', then a standard library is created using \`ar'
-and \`ranlib'.
+and \`ranlib'.  If only libtool objects are specified, then the output file
+may be used in the creation of other libtool archives.
 
 If OUTPUT-FILE ends in \`.lo' or \`.o', then a reloadable object file is
 created, otherwise an executable program is created.