OSDN Git Service

* lang-specs.h ("@objective-c"): Use cc1obj when -E is used so
[pf3gnuchains/gcc-fork.git] / ltmain.sh
index b81cb28..90925cb 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -55,8 +55,8 @@ modename="$progname"
 # Constants.
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=1.4a
-TIMESTAMP=" (1.641.2.198 2001/03/20 05:47:28)"
+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."
@@ -107,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
@@ -136,13 +137,22 @@ do
         ;;
       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"
@@ -238,6 +248,11 @@ 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.
@@ -1026,6 +1041,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.
@@ -1096,13 +1116,26 @@ 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"
 
@@ -1143,7 +1176,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
@@ -1165,7 +1198,7 @@ EOF
        esac
        continue
        ;;
-       
+
       -L*)
        dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
        # We need an absolute path.
@@ -1199,26 +1232,15 @@ 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
-           ;;
-         *-*-rhapsody* | *-*-darwin*)
-           # Darwin C library is in the System framework
-           deplibs="$deplibs -framework System"
-           ;;
-         esac
-       elif test "$arg" = "-lm"; then
+       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
            ;;
-         *-*-rhapsody* | *-*-darwin*)
-           # Darwin math library is in the System framework
-           deplibs="$deplibs -framework System"
+         *-*-mingw* | *-*-os2*)
+           # These systems don't actually have a C library (as such)
+           test "X$arg" = "X-lc" && continue
            ;;
          esac
        fi
@@ -1245,13 +1267,7 @@ EOF
          $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
          fast_install=no
          ;;
-       *-*-rhapsody* | *-*-darwin*)
-         # Darwin C library is in the System framework
-         deplibs="$deplibs -framework System"
-         ;;
-       *)
-         no_install=yes
-         ;;
+       *) no_install=yes ;;
        esac
        continue
        ;;
@@ -1301,7 +1317,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
@@ -1365,6 +1381,10 @@ EOF
        prev=xlinker
        continue
        ;;
+      -framework)
+       prev=framework
+       continue
+       ;;
 
       # Some other compiler flag.
       -* | +*)
@@ -1451,6 +1471,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.
@@ -1511,14 +1536,14 @@ EOF
          ;;
        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
@@ -1576,7 +1601,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"
@@ -1632,14 +1656,26 @@ 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"
@@ -1661,34 +1697,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
        -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
@@ -1705,6 +1736,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"
@@ -1714,7 +1746,7 @@ EOF
            fi
            continue
          fi
-         ;;
+         ;; # -l
        -L*)
          case $linkmode in
          lib)
@@ -1737,11 +1769,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//'`
@@ -1785,21 +1817,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
          ;;
@@ -1807,7 +1835,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
@@ -1840,15 +1868,23 @@ EOF
        *) . ./$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
@@ -1871,7 +1907,7 @@ EOF
            exit 1
          fi
          continue
-       fi
+       fi # $pass = conv
 
        # Get the name of the library we link against.
        linklib=
@@ -1891,15 +1927,13 @@ EOF
          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.  We also need to preload any
-           # dependent libraries so libltdl's deplib preloader doesn't
-           # bomb out in the load deplibs phase.
-           dlprefiles="$dlprefiles $lib $dependency_libs"
+           # 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
@@ -1930,8 +1964,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.
@@ -1950,17 +1984,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
@@ -1992,23 +2026,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.
@@ -2021,7 +2049,6 @@ EOF
              esac
              ;;
            esac
-
            case " $sys_lib_dlsearch_path " in
            *" $libdir "*) ;;
            *)
@@ -2031,7 +2058,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 ||
@@ -2040,40 +2078,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
@@ -2081,13 +2090,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
@@ -2095,9 +2116,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
@@ -2108,9 +2130,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
@@ -2119,7 +2142,7 @@ 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=
@@ -2218,6 +2241,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.
@@ -2234,6 +2266,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
@@ -2241,13 +2274,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" &&
@@ -2321,10 +2371,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
@@ -2332,6 +2381,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=
@@ -2350,8 +2400,7 @@ 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
@@ -2383,9 +2432,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"
@@ -2393,10 +2447,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
@@ -2432,6 +2482,7 @@ EOF
       case $outputname in
       lib*)
        name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+       eval shared_ext=\"$shrext\"
        eval libname=\"$libname_spec\"
        ;;
       *)
@@ -2443,6 +2494,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$//'`
@@ -2510,7 +2562,7 @@ EOF
 
        # Check that each of the things are valid numbers.
        case $current in
-       0 | [1-9] | [1-9][0-9]*) ;;
+       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
@@ -2519,7 +2571,7 @@ EOF
        esac
 
        case $revision in
-       0 | [1-9] | [1-9][0-9]*) ;;
+       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
@@ -2528,7 +2580,7 @@ EOF
        esac
 
        case $age in
-       0 | [1-9] | [1-9][0-9]*) ;;
+       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
@@ -2549,6 +2601,26 @@ EOF
        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"
@@ -2572,7 +2644,7 @@ EOF
          ;;
 
        osf)
-         major=`expr $current - $age`
+         major=.`expr $current - $age`
          versuffix=".$current.$age.$revision"
          verstring="$current.$age.$revision"
 
@@ -2593,16 +2665,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.
@@ -2620,7 +2682,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
@@ -2678,7 +2749,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'`
@@ -2725,11 +2796,18 @@ EOF
          *-*-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
@@ -2773,7 +2851,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" != "" -a "$name" != "0"; 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
@@ -2798,7 +2876,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" != "" -a "$name" != "0"; then
+             if test -n "$name" && test "$name" != "0"; then
                $rm conftest
                $LTCC -o conftest conftest.c $i
                # Did it work?
@@ -2838,7 +2916,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" != "" -a "$name" != "0"; 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`
@@ -2884,6 +2962,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$//' \
@@ -2906,6 +3018,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
@@ -2948,6 +3067,14 @@ EOF
            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
@@ -3016,6 +3143,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
@@ -3025,6 +3153,7 @@ EOF
        else
          soname="$realname"
        fi
+       test -z "$dlname" && dlname=$soname
 
        lib="$output_objdir/$realname"
        for link
@@ -3132,11 +3261,13 @@ 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$cmds" : ".*"` &&
+        if len=`expr "X$test_cmds" : ".*"` &&
            test $len -le $max_cmd_len; then
           :
         else
@@ -3212,6 +3343,7 @@ EOF
           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
@@ -3229,9 +3361,9 @@ EOF
 
          # Do each of the archive commands.
           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-            eval cmds=\"$archive_expsym_cmds\"
-          else
-            eval cmds=\"$archive_cmds\"
+           cmds=$archive_expsym_cmds
+         else
+           cmds=$archive_cmds
           fi
 
          # Append the command to remove the reloadable object files
@@ -3241,6 +3373,7 @@ EOF
         IFS="${IFS=    }"; save_ifs="$IFS"; IFS='~'
         for cmd in $cmds; do
           IFS="$save_ifs"
+         eval cmd=\"$cmd\"
           $show "$cmd"
           $run eval "$cmd" || exit $?
         done
@@ -3434,6 +3567,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
@@ -3449,6 +3585,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"
 
@@ -3877,6 +4034,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
 
@@ -3906,7 +4068,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
@@ -3955,7 +4117,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\" || \\
@@ -3974,8 +4136,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
@@ -4157,6 +4320,20 @@ fi\
           objlist=
           concat_cmds=
           save_oldobjs=$oldobjs
+         # GNU ar 2.10+ was changed to match POSIX; thus no paths are
+         # encoded into archives.  This makes 'ar r' malfunction in
+         # this piecewise linking case whenever conflicting object
+         # names appear in distinct ar calls; check, warn and compensate.
+          if (for obj in $save_oldobjs
+           do
+             $echo "X$obj" | $Xsed -e 's%^.*/%%'
+           done | sort | sort -uc >/dev/null 2>&1); then
+           :
+         else
+           $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
+           $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
+           AR_FLAGS=cq
+         fi
           for obj in $save_oldobjs
           do
             oldobjs="$objlist $obj"
@@ -4211,7 +4388,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)"
       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
 
       # Only create the output if not a dry run.
@@ -4263,6 +4444,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
@@ -4271,7 +4457,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'
@@ -4512,7 +4698,7 @@ relink_command=\"$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
 
@@ -4622,7 +4808,7 @@ 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.
@@ -4632,13 +4818,13 @@ relink_command=\"$relink_command\""
          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
@@ -4695,6 +4881,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"
@@ -4734,11 +4939,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
@@ -4776,7 +4980,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:"
@@ -4786,7 +4990,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"
@@ -4941,11 +5145,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
@@ -4962,6 +5163,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.
@@ -4970,6 +5173,7 @@ relink_command=\"$relink_command\""
     for arg
     do
       case $arg in
+      -f) rm="$rm $arg"; rmforce=yes ;;
       -*) rm="$rm $arg" ;;
       *) files="$files $arg" ;;
       esac
@@ -4996,12 +5200,24 @@ relink_command=\"$relink_command\""
 
       # Remember objdir for removal later, being careful to avoid duplicates
       if test $mode = clean; then
-        case " $rmdirs " in
+       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
@@ -5026,6 +5242,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
@@ -5038,6 +5257,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
@@ -5082,18 +5304,18 @@ relink_command=\"$relink_command\""
        ;;
       esac
       $show "$rm $rmfiles"
-      $run $rm $rmfiles
+      $run $rm $rmfiles || exit_status=1
     done
 
     # 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
+       $show "rmdir $dir"
+       $run rmdir $dir >/dev/null 2>&1
       fi
     done
 
-    exit 0
+    exit $exit_status
     ;;
 
   "")
@@ -5103,11 +5325,18 @@ 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
 "") $echo \
@@ -5165,6 +5394,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