OSDN Git Service

* config/m68k/m68k.c (notice_update_cc): Use SET_DEST and
[pf3gnuchains/gcc-fork.git] / ltmain.sh
index 2bccd11..474423a 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -1,7 +1,8 @@
 # ltmain.sh - Provide generalized library-building support services.
 # NOTE: Changing this file will not affect anything until you rerun ltconfig.
 #
-# Copyright (C) 1996-2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
 #
 # This program is free software; you can redistribute it and/or modify
@@ -16,7 +17,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -54,8 +55,8 @@ modename="$progname"
 # Constants.
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=1.4a
-TIMESTAMP=" (1.641.2.122 2000/09/30 05:27:52)"
+VERSION=1.4a-GCC3.0
+TIMESTAMP=" (1.641.2.256 2001/05/28 20:09:07 with GCC-local changes)"
 
 default_mode=
 help="Try \`$progname --help' for more information."
@@ -106,6 +107,7 @@ show_help=
 execute_dlfiles=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
+taglist=
 
 # Parse our command line options once, thoroughly.
 while test $# -gt 0
@@ -113,35 +115,44 @@ do
   arg="$1"
   shift
 
-  case "$arg" in
+  case $arg in
   -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
   *) optarg= ;;
   esac
 
   # If the previous option needs an argument, assign it.
   if test -n "$prev"; then
-    case "$prev" in
+    case $prev in
     execute_dlfiles)
-      eval "$prev=\"\$$prev \$arg\""
+      execute_dlfiles="$execute_dlfiles $arg"
       ;;
     tag)
       tagname="$arg"
 
       # Check whether tagname contains only valid characters
-      case "$tagname" in
+      case $tagname in
       *[!-_A-Za-z0-9,/]*)
        echo "$progname: invalid tag name: $tagname" 1>&2
        exit 1
         ;;
       esac
 
-      if grep "^### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then
-        taglist="$taglist $tagname"
-       # Evaluate the configuration.
-       eval "`sed -n -e '/^### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`"
-      else
-       echo "$progname: ignoring unknown tag $tagname" 1>&2
-      fi
+      case $tagname in
+      CC)
+       # Don't test for the "default" C tag, as we know, it's there, but
+       # not specially marked.
+       taglist="$taglist $tagname"
+       ;;
+      *)
+        if grep "^### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then
+          taglist="$taglist $tagname"
+         # Evaluate the configuration.
+         eval "`sed -n -e '/^### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`"
+        else
+         echo "$progname: ignoring unknown tag $tagname" 1>&2
+        fi
+        ;;
+      esac
       ;;
     *)
       eval "$prev=\$arg"
@@ -154,7 +165,7 @@ do
   fi
 
   # Have we seen a non-optional argument yet?
-  case "$arg" in
+  case $arg in
   --help)
     show_help=yes
     ;;
@@ -237,16 +248,21 @@ if test -n "$prevopt"; then
   exit 1
 fi
 
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
 if test -z "$show_help"; then
 
   # Infer the operation mode.
   if test -z "$mode"; then
-    case "$nonopt" in
+    case $nonopt in
     *cc | *++ | gcc* | *-gcc*)
       mode=link
       for arg
       do
-       case "$arg" in
+       case $arg in
        -c)
           mode=compile
           break
@@ -291,7 +307,7 @@ if test -z "$show_help"; then
   help="Try \`$modename --help --mode=$mode' for more information."
 
   # These modes are in order of execution frequency so that they run quickly.
-  case "$mode" in
+  case $mode in
   # libtool compile mode
   compile)
     modename="$modename: compile"
@@ -305,14 +321,14 @@ if test -z "$show_help"; then
     user_target=no
     for arg
     do
-      case "$prev" in
+      case $prev in
       "") ;;
       xcompiler)
        # Aesthetically quote the previous argument.
        prev=
        lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
 
-       case "$arg" in
+       case $arg in
        # Double-quote args containing other shell metacharacters.
        # Many Bourne shells cannot handle close brackets correctly
        # in scan sets, so we specify it separately.
@@ -332,7 +348,7 @@ if test -z "$show_help"; then
       esac
 
       # Accept any command-line options.
-      case "$arg" in
+      case $arg in
       -o)
        if test "$user_target" != "no"; then
          $echo "$modename: you cannot specify \`-o' more than once" 1>&2
@@ -371,7 +387,7 @@ if test -z "$show_help"; then
          # Double-quote args containing other shell metacharacters.
          # Many Bourne shells cannot handle close brackets correctly
          # in scan sets, so we specify it separately.
-         case "$arg" in
+         case $arg in
            *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
            arg="\"$arg\""
            ;;
@@ -391,7 +407,7 @@ if test -z "$show_help"; then
        ;;
       esac
 
-      case "$user_target" in
+      case $user_target in
       next)
        # The next one is the -o target name
        user_target=yes
@@ -419,7 +435,7 @@ if test -z "$show_help"; then
       # Double-quote args containing other shell metacharacters.
       # Many Bourne shells cannot handle close brackets correctly
       # in scan sets, so we specify it separately.
-      case "$lastarg" in
+      case $lastarg in
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
        lastarg="\"$lastarg\""
        ;;
@@ -433,7 +449,7 @@ if test -z "$show_help"; then
       fi
     done
 
-    case "$user_target" in
+    case $user_target in
     set)
       ;;
     no)
@@ -449,7 +465,7 @@ if test -z "$show_help"; then
     # Recognize several different file suffixes.
     # If the user specifies -o file.o, it is replaced with file.lo
     xform='[cCFSfmso]'
-    case "$libobj" in
+    case $libobj in
     *.ada) xform=ada ;;
     *.adb) xform=adb ;;
     *.ads) xform=ads ;;
@@ -466,7 +482,7 @@ if test -z "$show_help"; then
 
     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
 
-    case "$libobj" in
+    case $libobj in
     *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
     *)
       $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
@@ -544,7 +560,7 @@ if test -z "$show_help"; then
     trap "$run $rm $removelist; exit 1" 1 2 15
 
     # On Cygwin there's no "real" PIC flag so we must build both object types
-    case "$host_os" in
+    case $host_os in
     cygwin* | mingw* | pw32* | os2*)
       pic_mode=default
       ;;
@@ -777,7 +793,7 @@ EOF
   # libtool link mode
   link | relink)
     modename="$modename: link"
-    case "$host" in
+    case $host in
     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
       # It is impossible to link a dll without this setting, and
       # we shouldn't force the makefile maintainer to figure out
@@ -813,6 +829,7 @@ EOF
     linker_flags=
     dllsearchpath=
     lib_search_path=`pwd`
+    inst_prefix_dir=
 
     avoid_version=no
     dlfiles=
@@ -843,7 +860,7 @@ EOF
     # We need to know -static, to get the right output filenames.
     for arg
     do
-      case "$arg" in
+      case $arg in
       -all-static | -static)
        if test "X$arg" = "X-all-static"; then
          if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
@@ -873,7 +890,7 @@ EOF
       arg="$1"
       base_compile="$base_compile $arg"
       shift
-      case "$arg" in
+      case $arg in
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
        qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
        ;;
@@ -883,14 +900,14 @@ EOF
 
       # If the previous option needs an argument, assign it.
       if test -n "$prev"; then
-       case "$prev" in
+       case $prev in
        output)
          compile_command="$compile_command @OUTPUT@"
          finalize_command="$finalize_command @OUTPUT@"
          ;;
        esac
 
-       case "$prev" in
+       case $prev in
        dlfiles|dlprefiles)
          if test "$preload" = no; then
            # Add the symbol object into the linking commands.
@@ -898,7 +915,7 @@ EOF
            finalize_command="$finalize_command @SYMFILE@"
            preload=yes
          fi
-         case "$arg" in
+         case $arg in
          *.la | *.lo) ;;  # We handle these cases below.
          force)
            if test "$dlself" = no; then
@@ -945,14 +962,131 @@ EOF
          prev=
          continue
          ;;
+       inst_prefix)
+         inst_prefix_dir="$arg"
+         prev=
+         continue
+         ;;
        release)
          release="-$arg"
          prev=
          continue
          ;;
+       objectlist)
+         if test -f "$arg"; then
+            save_arg=$arg
+           moreargs=
+           for fil in `cat $save_arg`
+           do
+#            moreargs="$moreargs $fil"
+              arg=$fil
+              # A libtool-controlled object.
+
+             # Check to see that this really is a libtool object.
+             if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+                pic_object=
+                non_pic_object=
+
+                # Read the .lo file
+                # If there is no directory component, then add one.
+                case $arg in
+                */* | *\\*) . $arg ;;
+                *) . ./$arg ;;
+                esac
+
+                if test -z "$pic_object" || \
+                   test -z "$non_pic_object" ||
+                   test "$pic_object" = none && \
+                   test "$non_pic_object" = none; then
+                  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+                  exit 1
+                fi
+
+               # Extract subdirectory from the argument.
+               xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+               if test "X$xdir" = "X$arg"; then
+                 xdir=
+               else
+                 xdir="$xdir/"
+               fi
+
+                if test "$pic_object" != none; then
+                  # Prepend the subdirectory the object is found in.
+                 pic_object="$xdir$pic_object"
+
+                 if test "$prev" = dlfiles; then
+                   if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+                     dlfiles="$dlfiles $pic_object"
+                     prev=
+                     continue
+                   else
+                     # If libtool objects are unsupported, then we need to preload.
+                     prev=dlprefiles
+                   fi
+                 fi
+
+                 # CHECK ME:  I think I busted this.  -Ossama
+                  if test "$prev" = dlprefiles; then
+                   # Preload the old-style object.
+                   dlprefiles="$dlprefiles $pic_object"
+                   prev=
+                  fi
+
+                  # A PIC object.
+                 libobjs="$libobjs $pic_object"
+                 arg="$pic_object"
+                fi
+
+                # Non-PIC object.
+                if test "$non_pic_object" != none; then
+                  # Prepend the subdirectory the object is found in.
+                 non_pic_object="$xdir$non_pic_object"
+
+                  # A standard non-PIC object
+                  non_pic_objects="$non_pic_objects $non_pic_object"
+                  if test -z "$pic_object" || test "$pic_object" = none ; then
+                    arg="$non_pic_object"
+                  fi
+               else
+                 # If the PIC object exists, use it instead.
+                 # $xdir was prepended to $pic_object above.
+                 non_pic_object="$pic_object"
+                 non_pic_objects="$non_pic_objects $non_pic_object"
+                fi
+              else
+                # Only an error if not doing a dry-run.
+                if test -z "$run"; then
+                  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+                  exit 1
+                else
+                  # Dry-run case.
+
+                 # Extract subdirectory from the argument.
+                 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+                 if test "X$xdir" = "X$arg"; then
+                   xdir=
+                 else
+                   xdir="$xdir/"
+                 fi
+
+                  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+                  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+                 libobjs="$libobjs $pic_object"
+                  non_pic_objects="$non_pic_objects $non_pic_object"
+                fi
+             fi
+           done
+         else
+           $echo "$modename: link input file \`$save_arg' does not exist"
+           exit 1
+         fi
+          arg=$save_arg
+         prev=
+         continue
+         ;;
        rpath | xrpath)
          # We need an absolute path.
-         case "$arg" in
+         case $arg in
          [\\/]* | [A-Za-z]:[\\/]*) ;;
          *)
            $echo "$modename: only absolute run-paths are allowed" 1>&2
@@ -988,17 +1122,30 @@ EOF
          finalize_command="$finalize_command $wl$qarg"
          continue
          ;;
+       framework)
+         case $host in
+          *-*-darwin*)
+            case "$deplibs " in
+              *" $qarg.framework "*) ;;
+              *) deplibs="$deplibs $qarg.framework" # this is fixed later
+                 ;;
+            esac
+            ;;
+         esac
+         prev=
+         continue
+         ;;
        *)
          eval "$prev=\"\$arg\""
          prev=
          continue
          ;;
        esac
-      fi
+      fi # test -n $prev
 
       prevarg="$arg"
 
-      case "$arg" in
+      case $arg in
       -all-static)
        if test -n "$link_static_flag"; then
          compile_command="$compile_command $link_static_flag"
@@ -1035,7 +1182,7 @@ EOF
 
       -export-symbols | -export-symbols-regex)
        if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
-         $echo "$modename: not more than one -exported-symbols argument allowed"
+         $echo "$modename: more than one -exported-symbols argument is not allowed"
          exit 1
        fi
        if test "X$arg" = "X-export-symbols"; then
@@ -1046,6 +1193,11 @@ EOF
        continue
        ;;
 
+      -inst-prefix-dir)
+       prev=inst_prefix
+       continue
+       ;;
+
       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
       # so, if we see these flags be careful not to treat them like -L
       -L[A-Z][A-Z]*:*)
@@ -1057,11 +1209,11 @@ EOF
        esac
        continue
        ;;
-       
+
       -L*)
        dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
        # We need an absolute path.
-       case "$dir" in
+       case $dir in
        [\\/]* | [A-Za-z]:[\\/]*) ;;
        *)
          absdir=`cd "$dir" && pwd`
@@ -1079,9 +1231,9 @@ EOF
          lib_search_path="$lib_search_path $dir"
          ;;
        esac
-       case "$host" in
+       case $host in
        *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-         case ":$dllsearchpath:" in
+         case :$dllsearchpath: in
          *":$dir:"*) ;;
          *) dllsearchpath="$dllsearchpath:$dir";;
          esac
@@ -1091,19 +1243,16 @@ EOF
        ;;
 
       -l*)
-       if test "$arg" = "-lc"; then
-         case "$host" in
-         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
-           # These systems don't actually have c library (as such)
-           continue
-           ;;
-         esac
-       elif test "$arg" = "-lm"; then
-         case "$host" in
+       if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+         case $host in
          *-*-cygwin* | *-*-pw32* | *-*-beos*)
-           # These systems don't actually have math library (as such)
+           # These systems don't actually have a C or math library (as such)
            continue
            ;;
+         *-*-mingw* | *-*-os2*)
+           # These systems don't actually have a C library (as such)
+           test "X$arg" = "X-lc" && continue
+           ;;
          esac
        fi
        deplibs="$deplibs $arg"
@@ -1121,7 +1270,7 @@ EOF
        ;;
 
       -no-install)
-       case "$host" in
+       case $host in
        *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
          # The PATH hackery in wrapper scripts is required on Windows
          # in order for the loader to find any dlls it needs.
@@ -1129,13 +1278,7 @@ EOF
          $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
          fast_install=no
          ;;
-       *-*-rhapsody*)
-         # rhapsody is a little odd...
-         deplibs="$deplibs -framework System"
-         ;;
-       *)
-         no_install=yes
-         ;;
+       *) no_install=yes ;;
        esac
        continue
        ;;
@@ -1145,6 +1288,11 @@ EOF
        continue
        ;;
 
+      -objectlist)
+       prev=objectlist
+       continue
+       ;;
+
       -o) prev=output ;;
 
       -release)
@@ -1165,7 +1313,7 @@ EOF
       -R*)
        dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
        # We need an absolute path.
-       case "$dir" in
+       case $dir in
        [\\/]* | [A-Za-z]:[\\/]*) ;;
        *)
          $echo "$modename: only absolute run-paths are allowed" 1>&2
@@ -1180,7 +1328,7 @@ EOF
        ;;
 
       -static)
-        # The effects of -static are defined in a previous loop.
+       # The effects of -static are defined in a previous loop.
        # We used to do the same as -all-static on platforms that
        # didn't have a PIC flag, but the assumption that the effects
        # would be equivalent was wrong.  It would break on at least
@@ -1204,7 +1352,7 @@ EOF
        IFS="${IFS=     }"; save_ifs="$IFS"; IFS=','
        for flag in $args; do
          IFS="$save_ifs"
-         case "$flag" in
+         case $flag in
            *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
            flag="\"$flag\""
            ;;
@@ -1222,7 +1370,7 @@ EOF
        IFS="${IFS=     }"; save_ifs="$IFS"; IFS=','
        for flag in $args; do
          IFS="$save_ifs"
-         case "$flag" in
+         case $flag in
            *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
            flag="\"$flag\""
            ;;
@@ -1244,13 +1392,17 @@ EOF
        prev=xlinker
        continue
        ;;
+      -framework)
+       prev=framework
+       continue
+       ;;
 
       # Some other compiler flag.
       -* | +*)
        # Unknown arguments in both finalize_command and compile_command need
        # to be aesthetically quoted because they are evaled later.
        arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-       case "$arg" in
+       case $arg in
        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
          arg="\"$arg\""
          ;;
@@ -1272,7 +1424,7 @@ EOF
 
           # Read the .lo file
           # If there is no directory component, then add one.
-          case "$arg" in
+          case $arg in
           */* | *\\*) . $arg ;;
           *) . ./$arg ;;
           esac
@@ -1330,6 +1482,11 @@ EOF
             if test -z "$pic_object" || test "$pic_object" = none ; then
               arg="$non_pic_object"
             fi
+         else
+           # If the PIC object exists, use it instead.
+           # $xdir was prepended to $pic_object above.
+           non_pic_object="$pic_object"
+           non_pic_objects="$non_pic_objects $non_pic_object"
           fi
         else
           # Only an error if not doing a dry-run.
@@ -1384,20 +1541,20 @@ EOF
        # Unknown arguments in both finalize_command and compile_command need
        # to be aesthetically quoted because they are evaled later.
        arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-       case "$arg" in
+       case $arg in
        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
          arg="\"$arg\""
          ;;
        esac
        ;;
-      esac
+      esac # arg
 
       # Now actually substitute the argument into the commands.
       if test -n "$arg"; then
        compile_command="$compile_command $arg"
        finalize_command="$finalize_command $arg"
       fi
-    done
+    done # argument parsing loop
 
     if test -n "$prev"; then
       $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
@@ -1455,7 +1612,6 @@ EOF
       finalize_command="$finalize_command $arg"
     fi
 
-    oldlibs=
     # calculate the name of the file, without its directory
     outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
     libobjs_save="$libobjs"
@@ -1486,7 +1642,7 @@ EOF
     fi
 
     # Determine the type of output
-    case "$output" in
+    case $output in
     "")
       $echo "$modename: you must specify an output file" 1>&2
       $echo "$help" 1>&2
@@ -1511,19 +1667,31 @@ EOF
 
     if test $linkmode = lib; then
       libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      for pre_post_dep in $predeps $postdeps; do
+        case "$pre_post_deps " in
+       *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+       esac
+       pre_post_deps="$pre_post_deps $pre_post_dep"
+      done
+      pre_post_deps=
     fi
 
     deplibs=
     newdependency_libs=
     newlib_search_path=
     need_relink=no # whether we're linking any uninstalled libtool libraries
-    uninst_deplibs= # uninstalled libtool libraries
-    uninst_path= # paths that contain uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
     case $linkmode in
     lib)
        passes="conv link"
        for file in $dlfiles $dlprefiles; do
-         case "$file" in
+         case $file in
          *.la) ;;
          *)
            $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
@@ -1540,34 +1708,29 @@ EOF
        newdlprefiles=
        passes="conv scan dlopen dlpreopen link"
        ;;
-    *) passes="conv"
+    *)  passes="conv"
        ;;
     esac
     for pass in $passes; do
-      if test "$linkmode,$pass" = "lib,link" ||
-        test "$linkmode,$pass" = "prog,scan"; then
-       libs="$deplibs"
-       deplibs=
-      fi
       if test $linkmode = prog; then
+       # Determine which files to process
        case $pass in
-       dlopen) libs="$dlfiles" ;;
+       dlopen)
+         libs="$dlfiles"
+         save_deplibs="$deplibs" # Collect dlpreopened libraries
+         deplibs=
+         ;;
        dlpreopen) libs="$dlprefiles" ;;
        link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
        esac
       fi
-      if test $pass = dlopen; then
-       # Collect dlpreopened libraries
-       save_deplibs="$deplibs"
-       deplibs=
-      fi
       for deplib in $libs; do
        lib=
        found=no
-       case "$deplib" in
+       case $deplib in
        -l*)
-         if test $linkmode != lib && test $linkmode != prog; then
-           $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
+         if test $linkmode = oldlib && test $linkmode = obj; then
+           $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2
            continue
          fi
          if test $pass = conv; then
@@ -1584,6 +1747,7 @@ EOF
            fi
          done
          if test "$found" != yes; then
+           # deplib doesn't seem to be a libtool library
            if test "$linkmode,$pass" = "prog,link"; then
              compile_deplibs="$deplib $compile_deplibs"
              finalize_deplibs="$deplib $finalize_deplibs"
@@ -1593,7 +1757,7 @@ EOF
            fi
            continue
          fi
-         ;;
+         ;; # -l
        -L*)
          case $linkmode in
          lib)
@@ -1616,11 +1780,11 @@ EOF
            fi
            ;;
          *)
-           $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
+           $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2
            ;;
-         esac
+         esac # linkmode
          continue
-         ;;
+         ;; # -L
        -R*)
          if test $pass = link; then
            dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
@@ -1664,21 +1828,17 @@ EOF
            fi
            continue
            ;;
-         esac
-         ;;
+         esac # linkmode
+         ;; # *.$libext
        *.lo | *.$objext)
-         if test $pass = conv; then
-           deplibs="$deplib $deplibs"
-         elif test $linkmode = prog; then
-           if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
-             # If there is no dlopen support or we're linking statically,
-             # we need to preload.
-             newdlprefiles="$newdlprefiles $deplib"
-             compile_deplibs="$deplib $compile_deplibs"
-             finalize_deplibs="$deplib $finalize_deplibs"
-           else
-             newdlfiles="$newdlfiles $deplib"
-           fi
+         if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+           # If there is no dlopen support or we're linking statically,
+           # we need to preload.
+           newdlprefiles="$newdlprefiles $deplib"
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+         else
+           newdlfiles="$newdlfiles $deplib"
          fi
          continue
          ;;
@@ -1686,7 +1846,7 @@ EOF
          alldeplibs=yes
          continue
          ;;
-       esac
+       esac # case $deplib
        if test $found = yes || test -f "$lib"; then :
        else
          $echo "$modename: cannot find the library \`$lib'" 1>&2
@@ -1714,20 +1874,28 @@ EOF
        installed=yes
 
        # Read the .la file
-       case "$lib" in
+       case $lib in
        */* | *\\*) . $lib ;;
        *) . ./$lib ;;
        esac
 
+       case $host in
+           *-*-darwin*)
+         # Convert "-framework foo" to "foo.framework" in dependency_libs
+               test -n "$dependency_libs" && dependency_libs=`$echo "X$dependency_libs" | $Xsed -e 's/-framework \([^ $]*\)/\1.framework/g'`
+               ;;
+       esac
+
        if test "$linkmode,$pass" = "lib,link" ||
           test "$linkmode,$pass" = "prog,scan" ||
-          { test $linkmode != prog && test $linkmode != lib; }; then
+          { test $linkmode = oldlib && test $linkmode = obj; }; then
+          # Add dl[pre]opened files of deplib
          test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
          test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
        fi
 
        if test $pass = conv; then
-         # only check for convenience libraries
+         # Only check for convenience libraries
          deplibs="$lib $deplibs"
          if test -z "$libdir"; then
            if test -z "$old_library"; then
@@ -1750,7 +1918,7 @@ EOF
            exit 1
          fi
          continue
-       fi
+       fi # $pass = conv
 
        # Get the name of the library we link against.
        linklib=
@@ -1769,17 +1937,17 @@ EOF
            exit 1
          fi
          if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
-           # If there is no dlname, no dlopen support or we're linking statically,
-           # we need to preload.
+           # If there is no dlname, no dlopen support or we're linking
+           # statically, we need to preload.
            dlprefiles="$dlprefiles $lib"
          else
            newdlfiles="$newdlfiles $lib"
          fi
          continue
-       fi
+       fi # $pass = dlopen
 
        # We need an absolute path.
-       case "$ladir" in
+       case $ladir in
        [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
        *)
          abs_ladir=`cd "$ladir" && pwd`
@@ -1807,8 +1975,8 @@ EOF
          dir="$ladir/$objdir"
          absdir="$abs_ladir/$objdir"
          # Remove this search path later
-         uninst_path="$uninst_path $abs_ladir"
-       fi
+         notinst_path="$notinst_path $abs_ladir"
+       fi # $installed = yes
        name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
 
        # This library was specified with -dlpreopen.
@@ -1827,17 +1995,17 @@ EOF
          else
            newdlprefiles="$newdlprefiles $dir/$linklib"
          fi
-       fi
+       fi # $pass = dlpreopen
 
        if test -z "$libdir"; then
-         # link the convenience library
+         # Link the convenience library
          if test $linkmode = lib; then
            deplibs="$dir/$old_library $deplibs"
          elif test "$linkmode,$pass" = "prog,link"; then
            compile_deplibs="$dir/$old_library $compile_deplibs"
            finalize_deplibs="$dir/$old_library $finalize_deplibs"
          else
-           deplibs="$lib $deplibs" # used for prog,scan pass
+           deplibs="$lib $deplibs"
          fi
          continue
        fi
@@ -1854,7 +2022,7 @@ EOF
 
          tmp_libs=
          for deplib in $dependency_libs; do
-           case "$deplib" in
+           case $deplib in
            -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
            esac
            # Need to link against all dependency_libs?
@@ -1869,23 +2037,17 @@ EOF
            *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
            esac
            tmp_libs="$tmp_libs $deplib"
-         done
+         done # for deplib
          continue
-       fi
+       fi # $linkmode = prog...
 
-       if test "$linkmode,$pass" = "prog,link"; then
-         if test -n "$library_names" &&
-            { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
-           # We need to hardcode the library path
-           if test -n "$shlibpath_var"; then
-             # Make sure the rpath contains only unique directories.
-             case "$temp_rpath " in
-             *" $dir "*) ;;
-             *" $absdir "*) ;;
-             *) temp_rpath="$temp_rpath $dir" ;;
-             esac
-           fi
+       link_static=no # Whether the deplib will be linked statically
+       if test -n "$library_names" &&
+          { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+         # Link against this shared library
 
+         if test "$linkmode,$pass" = "prog,link" ||
+          { test $linkmode = lib && test $hardcode_into_libs = yes; }; then
            # Hardcode the library path.
            # Skip directories that are in the system default run-time
            # search path.
@@ -1898,7 +2060,6 @@ EOF
              esac
              ;;
            esac
-
            case " $sys_lib_dlsearch_path " in
            *" $libdir "*) ;;
            *)
@@ -1908,7 +2069,18 @@ EOF
              esac
              ;;
            esac
-         fi
+           if test $linkmode = prog; then
+             # We need to hardcode the library path
+             if test -n "$shlibpath_var"; then
+               # Make sure the rpath contains only unique directories.
+               case "$temp_rpath " in
+               *" $dir "*) ;;
+               *" $absdir "*) ;;
+               *) temp_rpath="$temp_rpath $dir" ;;
+               esac
+             fi
+           fi
+         fi # $linkmode,$pass = prog,link...
 
          if test "$alldeplibs" = yes &&
             { test "$deplibs_check_method" = pass_all ||
@@ -1917,40 +2089,11 @@ EOF
            # We only need to search for static libraries
            continue
          fi
-       fi
 
-       link_static=no # Whether the deplib will be linked statically
-       if test -n "$library_names" &&
-          { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
          if test "$installed" = no; then
-           uninst_deplibs="$uninst_deplibs $lib"
+           notinst_deplibs="$notinst_deplibs $lib"
            need_relink=yes
          fi
-         # This is a shared library
-         if test $linkmode = lib &&
-            test $hardcode_into_libs = yes; then
-           # Hardcode the library path.
-           # Skip directories that are in the system default run-time
-           # search path.
-           case " $sys_lib_dlsearch_path " in
-           *" $absdir "*) ;;
-           *)
-             case "$compile_rpath " in
-             *" $absdir "*) ;;
-             *) compile_rpath="$compile_rpath $absdir"
-             esac
-             ;;
-           esac
-           case " $sys_lib_dlsearch_path " in
-           *" $libdir "*) ;;
-           *)
-             case "$finalize_rpath " in
-             *" $libdir "*) ;;
-             *) finalize_rpath="$finalize_rpath $libdir"
-             esac
-             ;;
-           esac
-         fi
 
          if test -n "$old_archive_from_expsyms_cmds"; then
            # figure out the soname
@@ -1958,13 +2101,25 @@ EOF
            realname="$2"
            shift; shift
            libname=`eval \\$echo \"$libname_spec\"`
-           if test -n "$soname_spec"; then
+           # use dlname if we got it. it's perfectly good, no?
+           if test -n "$dlname"; then
+             soname="$dlname"
+           elif test -n "$soname_spec"; then
+             # bleh windows
+             case $host in
+             *cygwin*)
+               major=`expr $current - $age`
+               versuffix="-$major"
+               ;;
+             esac
              eval soname=\"$soname_spec\"
            else
              soname="$realname"
            fi
 
            # Make a new name for the extract_expsyms_cmds to use
+           soroot="$soname"
+           soname=`echo $soroot | sed -e 's/^.*\///'`
            newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a"
 
            # If the library has no export list, then create one now
@@ -1972,9 +2127,10 @@ EOF
            else
              $show "extracting exported symbol list from \`$soname'"
              IFS="${IFS=       }"; save_ifs="$IFS"; IFS='~'
-             eval cmds=\"$extract_expsyms_cmds\"
+             cmds=$extract_expsyms_cmds
              for cmd in $cmds; do
                IFS="$save_ifs"
+               eval cmd=\"$cmd\"
                $show "$cmd"
                $run eval "$cmd" || exit $?
              done
@@ -1985,9 +2141,10 @@ EOF
            if test -f "$output_objdir/$newlib"; then :; else
              $show "generating import library for \`$soname'"
              IFS="${IFS=       }"; save_ifs="$IFS"; IFS='~'
-             eval cmds=\"$old_archive_from_expsyms_cmds\"
+             cmds=$old_archive_from_expsyms_cmds
              for cmd in $cmds; do
                IFS="$save_ifs"
+               eval cmd=\"$cmd\"
                $show "$cmd"
                $run eval "$cmd" || exit $?
              done
@@ -1996,19 +2153,19 @@ EOF
            # make sure the library variables are pointing to the new library
            dir=$output_objdir
            linklib=$newlib
-         fi
+         fi # test -n $old_archive_from_expsyms_cmds
 
          if test $linkmode = prog || test "$mode" != relink; then
            add_shlibpath=
            add_dir=
            add=
            lib_linked=yes
-           case "$hardcode_action" in
+           case $hardcode_action in
            immediate | unsupported)
              if test "$hardcode_direct" = no; then
                add="$dir/$linklib"
              elif test "$hardcode_minus_L" = no; then
-               case "$host" in
+               case $host in
                *-*-sunos*) add_shlibpath="$dir" ;;
                esac
                add_dir="-L$dir"
@@ -2025,6 +2182,14 @@ EOF
                add="$dir/$linklib"
              elif test "$hardcode_minus_L" = yes; then
                add_dir="-L$dir"
+               # Try looking first in the location we're being installed to.
+               if test -n "$inst_prefix_dir"; then
+                 case "$libdir" in
+                   [\\/]*)
+                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                     ;;
+                 esac
+               fi
                add="-l$name"
              elif test "$hardcode_shlibpath_var" = yes; then
                add_shlibpath="$dir"
@@ -2042,7 +2207,7 @@ EOF
            fi
 
            if test -n "$add_shlibpath"; then
-             case ":$compile_shlibpath:" in
+             case :$compile_shlibpath: in
              *":$add_shlibpath:"*) ;;
              *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
              esac
@@ -2056,7 +2221,7 @@ EOF
              if test "$hardcode_direct" != yes && \
                 test "$hardcode_minus_L" != yes && \
                 test "$hardcode_shlibpath_var" = yes; then
-               case ":$finalize_shlibpath:" in
+               case :$finalize_shlibpath: in
                *":$libdir:"*) ;;
                *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
                esac
@@ -2075,7 +2240,7 @@ EOF
              add_dir="-L$libdir"
              add="-l$name"
            elif test "$hardcode_shlibpath_var" = yes; then
-             case ":$finalize_shlibpath:" in
+             case :$finalize_shlibpath: in
              *":$libdir:"*) ;;
              *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
              esac
@@ -2083,6 +2248,14 @@ EOF
            else
              # We cannot seem to hardcode it, guess we'll fake it.
              add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             if test -n "$inst_prefix_dir"; then
+               case "$libdir" in
+                 [\\/]*)
+                   add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                   ;;
+               esac
+             fi
              add="-l$name"
            fi
 
@@ -2095,6 +2268,15 @@ EOF
            fi
          fi
        elif test $linkmode = prog; then
+         if test "$alldeplibs" = yes &&
+            { test "$deplibs_check_method" = pass_all ||
+              { test "$build_libtool_libs" = yes &&
+                test -n "$library_names"; }; }; then
+           # We only need to search for static libraries
+           continue
+         fi
+
+         # Try to link the static library
          # Here we assume that one of hardcode_direct or hardcode_minus_L
          # is not unsupported.  This is valid on all known static and
          # shared platforms.
@@ -2111,6 +2293,7 @@ EOF
          if test "$deplibs_check_method" != pass_all; then
            # We're trying link a shared library against a static one
            # but the system doesn't support it.
+
            # Just print a warning and add the library to dependency_libs so
            # that the program can be linked against the static library.
            echo
@@ -2118,13 +2301,30 @@ EOF
            echo "*** I have the capability to make that library automatically link in when"
            echo "*** you link to this library.  But I can only do this if you have a"
            echo "*** shared version of the library, which you do not appear to have."
+           if test "$module" = yes; then
+             echo "*** Therefore, libtool will create a static module, that should work "
+             echo "*** as long as the dlopening application is linked with the -dlopen flag."
+             if test -z "$global_symbol_pipe"; then
+               echo
+               echo "*** However, this would only work if libtool was able to extract symbol"
+               echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+               echo "*** not find such a program.  So, this module is probably useless."
+               echo "*** \`nm' from GNU binutils and a full rebuild may help."
+             fi
+             if test "$build_old_libs" = no; then
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
          else
            convenience="$convenience $dir/$old_library"
            old_convenience="$old_convenience $dir/$old_library"
            deplibs="$dir/$old_library $deplibs"
            link_static=yes
          fi
-       fi
+       fi # link shared/static library?
 
        if test $linkmode = lib; then
          if test -n "$dependency_libs" &&
@@ -2133,7 +2333,7 @@ EOF
            # Extract -R from dependency_libs
            temp_deplibs=
            for libdir in $dependency_libs; do
-             case "$libdir" in
+             case $libdir in
              -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
                   case " $xrpath " in
                   *" $temp_xrpath "*) ;;
@@ -2161,13 +2361,13 @@ EOF
          if test $link_all_deplibs != no; then
            # Add the search paths of all dependency libraries
            for deplib in $dependency_libs; do
-             case "$deplib" in
+             case $deplib in
              -L*) path="$deplib" ;;
              *.la)
                dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
                test "X$dir" = "X$deplib" && dir="."
                # We need an absolute path.
-               case "$dir" in
+               case $dir in
                [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
                *)
                  absdir=`cd "$dir" && pwd`
@@ -2198,10 +2398,9 @@ EOF
              *) deplibs="$path $deplibs" ;;
              esac
            done
-         fi
-       fi
-      done
-      dependency_libs="$newdependency_libs"
+         fi # link_all_deplibs != no
+       fi # linkmode = lib
+      done # for deplib in $libs
       if test $pass = dlpreopen; then
        # Link the dlpreopened libraries before other libraries
        for deplib in $save_deplibs; do
@@ -2209,6 +2408,7 @@ EOF
        done
       fi
       if test $pass != dlopen; then
+       test $pass != scan && dependency_libs="$newdependency_libs"
        if test $pass != conv; then
          # Make sure lib_search_path contains only unique directories.
          lib_search_path=
@@ -2227,12 +2427,11 @@ EOF
          vars="compile_deplibs finalize_deplibs"
        fi
        for var in $vars dependency_libs; do
-         # Make sure that $var contains only unique libraries
-         # and add them in reverse order
+         # Add libraries to $var in reverse order
          eval tmp_libs=\"\$$var\"
          new_libs=
          for deplib in $tmp_libs; do
-           case "$deplib" in
+           case $deplib in
            -L*) new_libs="$deplib $new_libs" ;;
            *)
              case " $specialdeplibs " in
@@ -2249,7 +2448,7 @@ EOF
          done
          tmp_libs=
          for deplib in $new_libs; do
-           case "$deplib" in
+           case $deplib in
            -L*)
              case " $tmp_libs " in
              *" $deplib "*) ;;
@@ -2260,9 +2459,14 @@ EOF
            esac
          done
          eval $var=\"$tmp_libs\"
-       done
+       done # for var
       fi
-    done
+      if test "$pass" = "conv" &&
+       { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then
+       libs="$deplibs" # reset libs
+       deplibs=
+      fi
+    done # for pass
     if test $linkmode = prog; then
       dlfiles="$newdlfiles"
       dlprefiles="$newdlprefiles"
@@ -2270,10 +2474,6 @@ EOF
 
     case $linkmode in
     oldlib)
-      if test -n "$deplibs"; then
-       $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
-      fi
-
       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
        $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
       fi
@@ -2306,9 +2506,10 @@ EOF
 
     lib)
       # Make sure we only generate libraries of the form `libNAME.la'.
-      case "$outputname" in
+      case $outputname in
       lib*)
        name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+       eval shared_ext=\"$shrext\"
        eval libname=\"$libname_spec\"
        ;;
       *)
@@ -2320,6 +2521,7 @@ EOF
        if test "$need_lib_prefix" != no; then
          # Add the "lib" prefix for modules if required
          name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+         eval shared_ext=\"$shrext\"
          eval libname=\"$libname_spec\"
        else
          libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
@@ -2386,8 +2588,8 @@ EOF
        age="$4"
 
        # Check that each of the things are valid numbers.
-       case "$current" in
-       0 | [1-9] | [1-9][0-9]*) ;;
+       case $current in
+       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
        *)
          $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
          $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2395,8 +2597,8 @@ EOF
          ;;
        esac
 
-       case "$revision" in
-       0 | [1-9] | [1-9][0-9]*) ;;
+       case $revision in
+       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
        *)
          $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
          $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2404,8 +2606,8 @@ EOF
          ;;
        esac
 
-       case "$age" in
-       0 | [1-9] | [1-9][0-9]*) ;;
+       case $age in
+       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
        *)
          $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
          $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2423,9 +2625,29 @@ EOF
        major=
        versuffix=
        verstring=
-       case "$version_type" in
+       case $version_type in
        none) ;;
 
+       darwin)
+         # Like Linux, but with the current version available in
+         # verstring for coding it into the library header
+         major=.`expr $current - $age`
+         versuffix="$major.$age.$revision"
+         # Darwin ld doesn't like 0 for these options...
+         minor_current=`expr $current + 1`
+         verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+         ;;
+
+       freebsd-aout)
+         major=".$current"
+         versuffix=".$current.$revision";
+         ;;
+
+       freebsd-elf)
+         major=".$current"
+         versuffix=".$current";
+         ;;
+
        irix)
          major=`expr $current - $age + 1`
          verstring="sgi$major.$revision"
@@ -2449,7 +2671,7 @@ EOF
          ;;
 
        osf)
-         major=`expr $current - $age`
+         major=.`expr $current - $age`
          versuffix=".$current.$age.$revision"
          verstring="$current.$age.$revision"
 
@@ -2470,16 +2692,6 @@ EOF
          versuffix=".$current.$revision"
          ;;
 
-       freebsd-aout)
-         major=".$current"
-         versuffix=".$current.$revision";
-         ;;
-
-       freebsd-elf)
-         major=".$current"
-         versuffix=".$current";
-         ;;
-
        windows)
          # Use '-' rather than '.', since we only want one
          # extension on DOS 8.3 filesystems.
@@ -2497,7 +2709,16 @@ EOF
        # Clear the version info if we defaulted, and they specified a release.
        if test -z "$vinfo" && test -n "$release"; then
          major=
-         verstring="0.0"
+         case $version_type in
+         darwin)
+           # we can't check for "0.0" in archive_cmds due to quoting
+           # problems, so we reset it completely
+           verstring=
+           ;;
+         *)
+           verstring="0.0"
+           ;;
+         esac
          if test "$need_version" = no; then
            versuffix=
          else
@@ -2531,7 +2752,7 @@ EOF
         removelist=
         tempremovelist=`echo "$output_objdir/*"`
        for p in $tempremovelist; do
-          case "$p" in
+          case $p in
             *.$objext)
                ;;
             $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
@@ -2555,7 +2776,7 @@ EOF
       fi
 
       # Eliminate all temporary directories.
-      for path in $uninst_path; do
+      for path in $notinst_path; do
        lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'`
        deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'`
        dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'`
@@ -2598,15 +2819,22 @@ EOF
 
       if test "$build_libtool_libs" = yes; then
        if test -n "$rpath"; then
-         case "$host" in
+         case $host in
          *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
            # these systems don't actually have a c library (as such)!
            ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C library is in the System framework
+           deplibs="$deplibs -framework System"
+           ;;
+         *-*-netbsd*)
+           # Don't link with libc until the a.out ld.so is fixed.
+           ;;
          *)
-           # Add libc to deplibs on all other systems if necessary.
-           if test $build_libtool_need_lc = "yes"; then
-             deplibs="$deplibs -lc"
-           fi
+           # Add libc to deplibs on all other systems if necessary.
+           if test $build_libtool_need_lc = "yes"; then
+             deplibs="$deplibs -lc"
+           fi
            ;;
          esac
        fi
@@ -2625,7 +2853,7 @@ EOF
        major=""
        newdeplibs=
        droppeddeps=no
-       case "$deplibs_check_method" in
+       case $deplibs_check_method in
        pass_all)
          # Don't check for shared/static.  Everything works.
          # This might be a little naive.  We might want to check
@@ -2650,7 +2878,7 @@ EOF
            for i in $deplibs; do
              name="`expr $i : '-l\(.*\)'`"
              # If $name is empty we are operating on a -L argument.
-             if test "$name" != "" ; then
+             if test -n "$name" && test "$name" != "0"; then
                libname=`eval \\$echo \"$libname_spec\"`
                deplib_matches=`eval \\$echo \"$library_names_spec\"`
                set dummy $deplib_matches
@@ -2675,7 +2903,7 @@ EOF
            for i in $deplibs; do
              name="`expr $i : '-l\(.*\)'`"
             # If $name is empty we are operating on a -L argument.
-             if test "$name" != "" ; then
+             if test -n "$name" && test "$name" != "0"; then
                $rm conftest
                $LTCC -o conftest conftest.c $i
                # Did it work?
@@ -2715,7 +2943,7 @@ EOF
          for a_deplib in $deplibs; do
            name="`expr $a_deplib : '-l\(.*\)'`"
            # If $name is empty we are operating on a -L argument.
-           if test "$name" != "" ; then
+           if test -n "$name" && test "$name" != "0"; then
              libname=`eval \\$echo \"$libname_spec\"`
              for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
                    potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
@@ -2733,7 +2961,7 @@ EOF
                      potlib="$potent_lib"
                      while test -h "$potlib" 2>/dev/null; do
                        potliblink=`ls -ld $potlib | sed 's/.* -> //'`
-                       case "$potliblink" in
+                       case $potliblink in
                        [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
                        *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
                        esac
@@ -2761,6 +2989,40 @@ EOF
            fi
          done # Gone through all deplibs.
          ;;
+       match_pattern*)
+         set dummy $deplibs_check_method
+         match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+         for a_deplib in $deplibs; do
+           name="`expr $a_deplib : '-l\(.*\)'`"
+           # If $name is empty we are operating on a -L argument.
+           if test -n "$name" && test "$name" != "0"; then
+             libname=`eval \\$echo \"$libname_spec\"`
+             for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+               potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+               for potent_lib in $potential_libs; do
+                 if eval echo \"$potent_lib\" 2>/dev/null \
+                     | sed 10q \
+                     | egrep "$match_pattern_regex" > /dev/null; then
+                   newdeplibs="$newdeplibs $a_deplib"
+                   a_deplib=""
+                   break 2
+                 fi
+               done
+             done
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               echo
+               echo "*** Warning: This library needs some functionality provided by $a_deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have."
+             fi
+           else
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+           fi
+         done # Gone through all deplibs.
+         ;;
        none | unknown | *)
          newdeplibs=""
          if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
@@ -2783,6 +3045,13 @@ EOF
        libname=$libname_save
        name=$name_save
 
+       case $host in
+       *-*-rhapsody* | *-*-darwin1.[012])
+         # On Rhapsody replace the C library is the System framework
+         newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
+         ;;
+       esac
+
        if test "$droppeddeps" = yes; then
          if test "$module" = yes; then
            echo
@@ -2808,8 +3077,31 @@ EOF
            echo "*** The inter-library dependencies that have been dropped here will be"
            echo "*** automatically added whenever a program is linked with this library"
            echo "*** or is declared to -dlopen it."
+
+           if test $allow_undefined = no; then
+             echo
+             echo "*** Since this library must not contain undefined symbols,"
+             echo "*** because either the platform does not support them or"
+             echo "*** it was explicitly requested with -no-undefined,"
+             echo "*** libtool will only create a static version of it."
+             if test "$build_old_libs" = no; then
+               oldlibs="$output_objdir/$libname.$libext"
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
          fi
        fi
+       # Time to change all our "foo.framework" stuff back to "-framework foo"
+       case $host in
+           *-*-darwin*)
+               newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+               dependency_libs=`$echo "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+               ;;
+       esac
+       # Done checking deplibs!
        # Done checking deplibs!
        deplibs=$newdeplibs
       fi
@@ -2834,7 +3126,7 @@ EOF
                  hardcode_libdirs="$libdir"
                else
                  # Just accumulate the unique libdirs.
-                 case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+                 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
                  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
                    ;;
                  *)
@@ -2878,6 +3170,7 @@ EOF
 
        # Get the real and link names of the library.
        eval library_names=\"$library_names_spec\"
+       eval shared_ext=\"$shrext\"
        set dummy $library_names
        realname="$2"
        shift; shift
@@ -2887,6 +3180,7 @@ EOF
        else
          soname="$realname"
        fi
+       test -z "$dlname" && dlname=$soname
 
        lib="$output_objdir/$realname"
        for link
@@ -2943,6 +3237,7 @@ EOF
 
        if test -n "$convenience"; then
          if test -n "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
            eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
          else
            gentop="$output_objdir/${outputname}x"
@@ -2958,7 +3253,7 @@ EOF
 
            for xlib in $convenience; do
              # Extract the objects.
-             case "$xlib" in
+             case $xlib in
              [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
              *) xabs=`pwd`"/$xlib" ;;
              esac
@@ -2993,13 +3288,143 @@ EOF
 
        # Do each of the archive commands.
        if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-         eval cmds=\"$archive_expsym_cmds\"
+         eval test_cmds=\"$archive_expsym_cmds\"
+         cmds=$archive_expsym_cmds
        else
-         eval cmds=\"$archive_cmds\"
+         eval test_cmds=\"$archive_cmds\"
+         cmds=$archive_cmds
+       fi
+        if len=`expr "X$test_cmds" : ".*"` &&
+           test $len -le $max_cmd_len; then
+          :
+        else
+         # The command line is too long to link in one step, link piecewise.
+
+         # Save the value of $output and $libobjs because we want to
+         # use them later.  If we have whole_archive_flag_spec, we
+         # want to use save_libobjs as it was before
+         # whole_archive_flag_spec was expanded, because we can't
+         # assume the linker understands whole_archive_flag_spec.
+         # This may have to be revisited, in case too many
+         # convenience libraries get linked in and end up exceeding
+         # the spec.
+         if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+         fi
+          save_output=$output
+         output_la=`$echo "X$output" | $Xsed -e "s,^.*/,,"`
+
+         # Clear the reloadable object creation command queue and
+         # initialize k to one.
+          test_cmds=
+          concat_cmds=
+          objlist=
+          delfiles=
+          last_robj=
+          k=1
+
+         if test "$with_gnu_ld" = yes; then
+           output=${output_objdir}/${output_la}.lnkscript
+           $echo "creating GNU ld script: $output"
+           $echo 'INPUT (' > $output
+           for obj in $save_libobjs
+           do
+             $echo \""$obj"\" >> $output
+           done
+           $echo ')' >> $output
+           delfiles="$delfiles $output"
+         elif test "X$file_list_spec" != X; then
+           output=${output_objdir}/${output_la}.lnk
+           $echo "creating linker input file list: $output"
+           : > $output
+           for obj in $save_libobjs
+           do
+             $echo "$obj" >> $output
+           done
+           delfiles="$delfiles $output"
+           output=\"$file_list_spec$output\"
+         else
+           $echo "creating reloadable object files..."
+           output=$output_objdir/$save_output-${k}.$objext
+           # Loop over the list of objects to be linked.
+           for obj in $save_libobjs
+           do
+             eval test_cmds=\"$reload_cmds $objlist $last_robj\"
+             if test "X$objlist" = X ||
+                { len=`expr "X$test_cmds" : ".*"` &&
+                  test $len -le $max_cmd_len; }; then
+               objlist="$objlist $obj"
+             else
+               # The command $test_cmds is almost too long, add a
+               # command to the queue.
+               if test $k -eq 1 ; then
+                 # The first file doesn't have a previous command to add.
+                 eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+               else
+                 # All subsequent reloadable object files will link in
+                 # the last one created.
+                 eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
+               fi
+               last_robj=$output_objdir/$save_output-${k}.$objext
+               k=`expr $k + 1`
+               output=$output_objdir/$save_output-${k}.$objext
+               objlist=$obj
+               len=1
+             fi
+           done
+           # Handle the remaining objects by creating one last
+           # reloadable object file.  All subsequent reloadable object
+           # files will link in the last one created.
+           test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+           eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+
+           # Set up a command to remove the reloadale object files
+           # after they are used.
+           i=0
+           while test $i -lt $k
+           do
+             i=`expr $i + 1`
+             delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
+           done
+
+           $echo "creating a temporary reloadable object file: $output"
+
+           # Loop through the commands generated above and execute them.
+           IFS="${IFS=         }"; save_ifs="$IFS"; IFS='~'
+           for cmd in $concat_cmds; do
+             IFS="$save_ifs"
+             eval cmd=\"$cmd\"
+             $show "$cmd"
+             $run eval "$cmd" || exit $?
+           done
+           IFS="$save_ifs"
+         fi
+
+         libobjs=$output
+         # Restore the value of output.
+         output=$save_output
+
+         if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+         fi
+         # Expand the library linking commands again to reset the
+         # value of $libobjs for piecewise linking.
+
+         # Do each of the archive commands.
+          if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+           cmds=$archive_expsym_cmds
+         else
+           cmds=$archive_cmds
+         fi
+
+         # Append the command to remove the reloadable object files
+         # to the just-reset $cmds.
+         eval cmds=\"\$cmds~$rm $delfiles\"
        fi
        IFS="${IFS=     }"; save_ifs="$IFS"; IFS='~'
        for cmd in $cmds; do
          IFS="$save_ifs"
+         eval cmd=\"$cmd\"
          $show "$cmd"
          $run eval "$cmd" || exit $?
        done
@@ -3052,7 +3477,7 @@ EOF
        $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
       fi
 
-      case "$output" in
+      case $output in
       *.lo)
        if test -n "$objs$old_deplibs"; then
          $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
@@ -3097,7 +3522,7 @@ EOF
 
          for xlib in $convenience; do
            # Extract the objects.
-           case "$xlib" in
+           case $xlib in
            [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
            *) xabs=`pwd`"/$xlib" ;;
            esac
@@ -3193,6 +3618,9 @@ EOF
       ;;
 
     prog)
+      case $host in
+       *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;;
+      esac
       if test -n "$vinfo"; then
        $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
       fi
@@ -3208,6 +3636,27 @@ EOF
        fi
       fi
 
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+       # On Rhapsody replace the C library is the System framework
+       compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+       finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+       ;;
+      esac
+
+      case $host in
+      *-*-darwin*)
+      # Don't allow lazy linking, it breaks C++ global constructors
+       if test "$tagname" = CXX ; then
+          compile_command="$compile_command ${wl}-bind_at_load"
+          finalize_command="$finalize_command ${wl}-bind_at_load"
+       fi
+      # Time to change all our "foo.framework" stuff back to "-framework foo"
+       compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+       finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+       ;;
+      esac
+
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 
@@ -3232,7 +3681,7 @@ EOF
              hardcode_libdirs="$libdir"
            else
              # Just accumulate the unique libdirs.
-             case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
              *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
                ;;
              *)
@@ -3250,9 +3699,9 @@ EOF
          *) perm_rpath="$perm_rpath $libdir" ;;
          esac
        fi
-       case "$host" in
+       case $host in
        *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-         case ":$dllsearchpath:" in
+         case :$dllsearchpath: in
          *":$libdir:"*) ;;
          *) dllsearchpath="$dllsearchpath:$libdir";;
          esac
@@ -3276,7 +3725,7 @@ EOF
              hardcode_libdirs="$libdir"
            else
              # Just accumulate the unique libdirs.
-             case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
              *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
                ;;
              *)
@@ -3313,7 +3762,7 @@ EOF
       fi
 
       if test -n "$dlsyms"; then
-       case "$dlsyms" in
+       case $dlsyms in
        "") ;;
        *.c)
          # Discover the nlist of each of the dlfiles.
@@ -3444,7 +3893,7 @@ static const void *lt_preloaded_setup() {
          fi
 
          pic_flag_for_symtable=
-         case "$host" in
+         case $host in
          # compiling the symbol table file with pic_flag works around
          # a FreeBSD bug that causes programs to crash when -lm is
          # linked before any other PIC object.  But we must not use
@@ -3512,7 +3961,7 @@ static const void *lt_preloaded_setup() {
        # We should set the shlibpath_var
        rpath=
        for dir in $temp_rpath; do
-         case "$dir" in
+         case $dir in
          [\\/]* | [A-Za-z]:[\\/]*)
            # Absolute path.
            rpath="$rpath$dir:"
@@ -3620,7 +4069,7 @@ static const void *lt_preloaded_setup() {
 
       # Quote $echo for shipping.
       if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
-       case "$0" in
+       case $0 in
        [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
        *) qecho="$SHELL `pwd`/$0 --fallback-echo";;
        esac
@@ -3636,6 +4085,11 @@ static const void *lt_preloaded_setup() {
        case $output in
          *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
        esac
+       # test for cygwin because mv fails w/o .exe extensions
+       case $host in
+         *cygwin*) exeext=.exe ;;
+         *) exeext= ;;
+       esac
        $rm $output
        trap "$rm $output; exit 1" 1 2 15
 
@@ -3665,7 +4119,7 @@ relink_command=\"$relink_command\"
 # This environment variable determines our operation mode.
 if test \"\$libtool_install_magic\" = \"$magic\"; then
   # install mode needs the following variable:
-  uninst_deplibs='$uninst_deplibs'
+  notinst_deplibs='$notinst_deplibs'
 else
   # When we are sourced in execute mode, \$file and \$echo are already set.
   if test \"\$libtool_execute_magic\" != \"$magic\"; then
@@ -3714,7 +4168,7 @@ else
 
        if test "$fast_install" = yes; then
          echo >> $output "\
-  program=lt-'$outputname'
+  program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
 
   if test ! -f \"\$progdir/\$program\" || \\
@@ -3733,8 +4187,9 @@ else
 
     # relink executable if necessary
     if test -n \"\$relink_command\"; then
-      if (eval \$relink_command); then :
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
       else
+        $echo \"\$relink_command_output\" >&2
        $rm \"\$progdir/\$file\"
        exit 1
       fi
@@ -3859,7 +4314,7 @@ fi\
        # Add in members from convenience archives.
        for xlib in $addlibs; do
          # Extract the objects.
-         case "$xlib" in
+         case $xlib in
          [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
          *) xabs=`pwd`"/$xlib" ;;
          esac
@@ -3903,7 +4358,97 @@ fi\
 #        fi
 #      done
 
-       eval cmds=\"$old_archive_cmds\"
+       # POSIX demands no paths to be encoded in archives.  We have
+       # to avoid creating archives with duplicate basenames if we
+       # might have to extract them afterwards, e.g., when creating a
+       # static archive out of a convenience library, or when linking
+       # the entirety of a libtool archive into another (currently
+       # not supported by libtool).
+        if (for obj in $oldobjs
+           do
+             $echo "X$obj" | $Xsed -e 's%^.*/%%'
+           done | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         $echo "copying selected object files to avoid basename conflicts..."
+
+         if test -z "$gentop"; then
+           gentop="$output_objdir/${outputname}x"
+
+           $show "${rm}r $gentop"
+           $run ${rm}r "$gentop"
+           $show "$mkdir $gentop"
+           $run $mkdir "$gentop"
+           status=$?
+           if test $status -ne 0 && test ! -d "$gentop"; then
+             exit $status
+           fi
+           generated="$generated $gentop"
+         fi
+
+         save_oldobjs=$oldobjs
+         oldobjs=
+         counter=1
+         for obj in $save_oldobjs
+         do
+           objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+           case " $oldobjs " in
+           " ") oldobjs=$obj ;;
+           *[\ /]"$objbase "*)
+             while :; do
+               # Make sure we don't pick an alternate name that also
+               # overlaps.
+               newobj=lt$counter-$objbase
+               counter=`expr $counter + 1`
+               case " $oldobjs " in
+               *[\ /]"$newobj "*) ;;
+               *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+               esac
+             done
+             $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+             $run ln "$obj" "$gentop/$newobj" ||
+             $run cp "$obj" "$gentop/$newobj"
+             oldobjs="$oldobjs $gentop/$newobj"
+             ;;
+           *) oldobjs="$oldobjs $obj" ;;
+           esac
+         done
+       fi
+
+        eval cmds=\"$old_archive_cmds\"
+
+        if len=`expr "X$cmds" : ".*"` &&
+             test $len -le $max_cmd_len; then
+          :
+        else
+          # the command line is too long to link in one step, link in parts
+          $echo "using piecewise archive linking..."
+         save_RANLIB=$RANLIB
+         RANLIB=:
+          objlist=
+          concat_cmds=
+          save_oldobjs=$oldobjs
+
+          for obj in $save_oldobjs
+          do
+            oldobjs="$objlist $obj"
+            objlist="$objlist $obj"
+            eval test_cmds=\"$old_archive_cmds\"
+            if len=`expr "X$test_cmds" : ".*"` &&
+               test $len -le $max_cmd_len; then
+              :
+            else
+              # the above command should be used before it gets too long
+              oldobjs=$objlist
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+              eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+              objlist=
+            fi
+          done
+         RANLIB=$save_RANLIB
+          oldobjs=$objlist
+          eval cmds=\"\$concat_cmds~$old_archive_cmds\"
+        fi
       fi
       IFS="${IFS=      }"; save_ifs="$IFS"; IFS='~'
       for cmd in $cmds; do
@@ -3920,7 +4465,7 @@ fi\
     fi
 
     # Now create the libtool archive.
-    case "$output" in
+    case $output in
     *.la)
       old_library=
       test "$build_old_libs" = yes && old_library="$libname.$libext"
@@ -3938,7 +4483,11 @@ fi\
        fi
       done
       # Quote the link command for shipping.
-      relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args"
+      tagopts=
+      for tag in $taglist; do
+        tagopts="$tagopts --tag $tag"
+      done
+      relink_command="(cd `pwd`; $SHELL $0$tagopts --mode=relink $libtool_args @inst_prefix_dir@)"
       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
 
       # Only create the output if not a dry run.
@@ -3952,7 +4501,7 @@ fi\
            # Replace all uninstalled libtool libraries with the installed ones
            newdependency_libs=
            for deplib in $dependency_libs; do
-             case "$deplib" in
+             case $deplib in
              *.la)
                name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
                eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
@@ -3990,6 +4539,11 @@ fi\
            dlprefiles="$newdlprefiles"
          fi
          $rm $output
+         # place dlname in correct position for cygwin
+         tdlname=$dlname
+         case $host,$output,$installed,$module,$dlname in
+           *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+         esac
          $echo > $output "\
 # $outputname - a libtool library file
 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
@@ -3998,7 +4552,7 @@ fi\
 # It is necessary for linking the library.
 
 # The name that we can dlopen(3).
-dlname='$dlname'
+dlname='$tdlname'
 
 # Names of this library.
 library_names='$library_names'
@@ -4050,7 +4604,7 @@ relink_command=\"$relink_command\""
        $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
       # Aesthetically quote it.
       arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
-      case "$arg" in
+      case $arg in
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*)
        arg="\"$arg\""
        ;;
@@ -4066,7 +4620,7 @@ relink_command=\"$relink_command\""
     # The real first argument should be the name of the installation program.
     # Aesthetically quote it.
     arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-    case "$arg" in
+    case $arg in
     *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \      ]*|*]*)
       arg="\"$arg\""
       ;;
@@ -4089,7 +4643,7 @@ relink_command=\"$relink_command\""
        continue
       fi
 
-      case "$arg" in
+      case $arg in
       -d) isdir=yes ;;
       -f) prev="-f" ;;
       -g) prev="-g" ;;
@@ -4114,7 +4668,7 @@ relink_command=\"$relink_command\""
 
       # Aesthetically quote the argument.
       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-      case "$arg" in
+      case $arg in
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*)
        arg="\"$arg\""
        ;;
@@ -4165,11 +4719,11 @@ relink_command=\"$relink_command\""
        exit 1
       fi
     fi
-    case "$destdir" in
+    case $destdir in
     [\\/]* | [A-Za-z]:[\\/]*) ;;
     *)
       for file in $files; do
-       case "$file" in
+       case $file in
        *.lo) ;;
        *)
          $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
@@ -4191,7 +4745,7 @@ relink_command=\"$relink_command\""
     for file in $files; do
 
       # Do each installation.
-      case "$file" in
+      case $file in
       *.$libext)
        # Do the static libraries later.
        staticlibs="$staticlibs $file"
@@ -4210,7 +4764,7 @@ relink_command=\"$relink_command\""
        old_library=
        relink_command=
        # If there is no directory component, then add one.
-       case "$file" in
+       case $file in
        */* | *\\*) . $file ;;
        *) . ./$file ;;
        esac
@@ -4234,12 +4788,33 @@ relink_command=\"$relink_command\""
        dir="$dir$objdir"
 
        if test -n "$relink_command"; then
+         # Determine the prefix the user has applied to our future dir.
+         inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"`
+
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+         # are installed to the same prefix.
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+         if test "$inst_prefix_dir" = "$destdir"; then
+           $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+           exit 1
+         fi
+
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+           relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+         else
+           relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"`
+         fi
+
          $echo "$modename: warning: relinking \`$file'" 1>&2
          $show "$relink_command"
          if $run eval "$relink_command"; then :
          else
            $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
-           continue
+           exit 1
          fi
        fi
 
@@ -4306,7 +4881,7 @@ relink_command=\"$relink_command\""
        fi
 
        # Deduce the name of the destination old-style object file.
-       case "$destfile" in
+       case $destfile in
        *.lo)
          staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
          ;;
@@ -4349,28 +4924,28 @@ relink_command=\"$relink_command\""
 
        # Do a test to see if this is really a libtool program.
        if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-         uninst_deplibs=
+         notinst_deplibs=
          relink_command=
 
          # If there is no directory component, then add one.
-         case "$file" in
+         case $file in
          */* | *\\*) . $file ;;
          *) . ./$file ;;
          esac
 
          # Check the variables that should have been set.
-         if test -z "$uninst_deplibs"; then
+         if test -z "$notinst_deplibs"; then
            $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
            exit 1
          fi
 
          finalize=yes
-         for lib in $uninst_deplibs; do
+         for lib in $notinst_deplibs; do
            # Check to see that each library is installed.
            libdir=
            if test -f "$lib"; then
              # If there is no directory component, then add one.
-             case "$lib" in
+             case $lib in
              */* | *\\*) . $lib ;;
              *) . ./$lib ;;
              esac
@@ -4384,7 +4959,7 @@ relink_command=\"$relink_command\""
 
          relink_command=
          # If there is no directory component, then add one.
-         case "$file" in
+         case $file in
          */* | *\\*) . $file ;;
          *) . ./$file ;;
          esac
@@ -4422,6 +4997,25 @@ relink_command=\"$relink_command\""
          fi
        fi
 
+
+       # remove .exe since cygwin /usr/bin/install will append another
+       # one anyways
+       case $install_prog,$host in
+       */usr/bin/install*,*cygwin*)
+         case $file:$destfile in
+         *.exe:*.exe)
+           # this is ok
+           ;;
+         *.exe:*)
+           destfile=$destfile.exe
+           ;;
+         *:*.exe)
+           destfile=`echo $destfile | sed -e 's,.exe$,,'`
+           ;;
+         esac
+         ;;
+       esac
+
        $show "$install_prog$stripme $file $destfile"
        $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
        test -n "$outputname" && ${rm}r "$tmpdir"
@@ -4461,11 +5055,10 @@ relink_command=\"$relink_command\""
     if test -n "$current_libdirs"; then
       # Maybe just do a dry run.
       test -n "$run" && current_libdirs=" -n$current_libdirs"
-      exec $SHELL $0 --finish$current_libdirs
-      exit 1
+      exec_cmd='$SHELL $0 --finish$current_libdirs'
+    else
+      exit 0
     fi
-
-    exit 0
     ;;
 
   # libtool finish mode
@@ -4503,7 +5096,7 @@ relink_command=\"$relink_command\""
     fi
 
     # Exit here if they wanted silent mode.
-    test "$show" = : && exit 0
+    test "$show" = ":" && exit 0
 
     echo "----------------------------------------------------------------------"
     echo "Libraries have been installed in:"
@@ -4513,7 +5106,7 @@ relink_command=\"$relink_command\""
     echo
     echo "If you ever happen to want to link against installed libraries"
     echo "in a given directory, LIBDIR, you must either use libtool, and"
-    echo "specify the full pathname of the library, or use \`-LLIBDIR'"
+    echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
     echo "flag during linking and do at least one of the following:"
     if test -n "$shlibpath_var"; then
       echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
@@ -4563,7 +5156,7 @@ relink_command=\"$relink_command\""
       fi
 
       dir=
-      case "$file" in
+      case $file in
       *.la)
        # Check to see that this really is a libtool archive.
        if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
@@ -4578,7 +5171,7 @@ relink_command=\"$relink_command\""
        library_names=
 
        # If there is no directory component, then add one.
-       case "$file" in
+       case $file in
        */* | *\\*) . $file ;;
        *) . ./$file ;;
        esac
@@ -4633,13 +5226,13 @@ relink_command=\"$relink_command\""
     args=
     for file
     do
-      case "$file" in
+      case $file in
       -*) ;;
       *)
        # Do a test to see if this is really a libtool program.
        if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
          # If there is no directory component, then add one.
-         case "$file" in
+         case $file in
          */* | *\\*) . $file ;;
          *) . ./$file ;;
          esac
@@ -4668,11 +5261,8 @@ relink_command=\"$relink_command\""
        LANG="$save_LANG"; export LANG
       fi
 
-      # Now actually exec the command.
-      eval "exec \$cmd$args"
-
-      $echo "$modename: cannot exec \$cmd$args"
-      exit 1
+      # Now prepare to actually exec the command.
+      exec_cmd='"$cmd"$args'
     else
       # Display what would be done.
       if test -n "$shlibpath_var"; then
@@ -4689,6 +5279,8 @@ relink_command=\"$relink_command\""
     modename="$modename: $mode"
     rm="$nonopt"
     files=
+    rmforce=
+    exit_status=0
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
@@ -4696,7 +5288,8 @@ relink_command=\"$relink_command\""
 
     for arg
     do
-      case "$arg" in
+      case $arg in
+      -f) rm="$rm $arg"; rmforce=yes ;;
       -*) rm="$rm $arg" ;;
       *) files="$files $arg" ;;
       esac
@@ -4708,6 +5301,8 @@ relink_command=\"$relink_command\""
       exit 1
     fi
 
+    rmdirs=
+
     for file in $files; do
       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
       if test "X$dir" = "X$file"; then
@@ -4719,9 +5314,29 @@ relink_command=\"$relink_command\""
       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
       test $mode = uninstall && objdir="$dir"
 
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test $mode = clean; then
+       case " $rmdirs " in
+         *" $objdir "*) ;;
+         *) rmdirs="$rmdirs $objdir" ;;
+       esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if (test -L "$file") >/dev/null 2>&1 \
+        || (test -h "$file") >/dev/null 2>&1 \
+       || test -f "$file"; then
+        :
+      elif test -d "$file"; then
+        exit_status=1
+       continue
+      elif test "$rmforce" = yes; then
+        continue
+      fi
+
       rmfiles="$file"
 
-      case "$name" in
+      case $name in
       *.la)
        # Possibly a libtool archive, so verify it.
        if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
@@ -4743,6 +5358,9 @@ relink_command=\"$relink_command\""
                IFS="$save_ifs"
                $show "$cmd"
                $run eval "$cmd"
+               if test $? != 0 && test "$rmforce" != yes; then
+                 exit_status=1
+               fi
              done
              IFS="$save_ifs"
            fi
@@ -4755,6 +5373,9 @@ relink_command=\"$relink_command\""
                IFS="$save_ifs"
                $show "$cmd"
                $run eval "$cmd"
+               if test $? != 0 && test "$rmforce" != yes; then
+                 exit_status=1
+               fi
              done
              IFS="$save_ifs"
            fi
@@ -4765,10 +5386,10 @@ relink_command=\"$relink_command\""
 
       *.lo)
        # Possibly a libtool object, so verify it.
-       if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+       if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
 
           # Read the .lo file
-          . ./$file
+          . $dir/$name
 
          # Add PIC object to the list of files to remove.
           if test -n "$pic_object" \
@@ -4799,9 +5420,18 @@ relink_command=\"$relink_command\""
        ;;
       esac
       $show "$rm $rmfiles"
-      $run $rm $rmfiles
+      $run $rm $rmfiles || exit_status=1
     done
-    exit 0
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+       $show "rmdir $dir"
+       $run rmdir $dir >/dev/null 2>&1
+      fi
+    done
+
+    exit $exit_status
     ;;
 
   "")
@@ -4811,13 +5441,20 @@ relink_command=\"$relink_command\""
     ;;
   esac
 
-  $echo "$modename: invalid operation mode \`$mode'" 1>&2
-  $echo "$generic_help" 1>&2
-  exit 1
+  if test -z "$exec_cmd"; then
+    $echo "$modename: invalid operation mode \`$mode'" 1>&2
+    $echo "$generic_help" 1>&2
+    exit 1
+  fi
 fi # test -z "$show_help"
 
+if test -n "$exec_cmd"; then
+  eval exec $exec_cmd
+  exit 1
+fi
+
 # We need to display help for each of the modes.
-case "$mode" in
+case $mode in
 "") $echo \
 "Usage: $modename [OPTION]... [MODE-ARG]...
 
@@ -4873,6 +5510,8 @@ Compile a source file into a libtool library object.
 This mode accepts the following additional options:
 
   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
   -static           always build a \`.o' file suitable for static linking
 
 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
@@ -4956,6 +5595,7 @@ The following components of LINK-COMMAND are treated specially:
   -no-install       link a not-installable executable
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
   -release RELEASE  specify package release information
   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries