0.6.1.20060928-1 release
[manu/suphp.git] / config / ltmain.sh
index e0d11c7..ed4b44a 100644 (file)
@@ -33,6 +33,9 @@ basename="s,^.*/,,g"
 # function.
 progpath="$0"
 
+# define SED for historic ltconfig's generated by Libtool 1.3
+test -z "$SED" && SED=sed
+
 # The name of this program:
 progname=`echo "$progpath" | $SED $basename`
 modename="$progname"
@@ -43,14 +46,21 @@ EXIT_FAILURE=1
 
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION="1.5.22 Debian 1.5.22-1"
-TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
+VERSION=1.5.18
+TIMESTAMP=" (1.1220.2.246 2005/05/16 10:00:18)"
 
 # See if we are running on zsh, and set the options which allow our
 # commands through without removal of \ escapes.
 if test -n "${ZSH_VERSION+set}" ; then
   setopt NO_GLOB_SUBST
 fi
+# Same for EGREP, and just to be sure, do LTCC as well
+if test "X$EGREP" = X ; then
+    EGREP=egrep
+fi
+if test "X$LTCC" = X ; then
+    LTCC=${CC-gcc}
+fi
 
 # Check that we have a working $echo.
 if test "X$1" = X--no-reexec; then
@@ -88,15 +98,14 @@ rm="rm -f"
 Xsed="${SED}"' -e 1s/^X//'
 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
 # test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  SP2NL='tr \040 \012'
-  NL2SP='tr \015\012 \040\040'
+case `echo A|tr A '\301'` in
+ A) # EBCDIC based system
+  SP2NL="tr '\100' '\n'"
+  NL2SP="tr '\r\n' '\100\100'"
   ;;
- *) # EBCDIC based system
-  SP2NL='tr \100 \n'
-  NL2SP='tr \r\n \100\100'
+ *) # Assume ASCII based system
+  SP2NL="tr '\040' '\012'"
+  NL2SP="tr '\015\012' '\040\040'"
   ;;
 esac
 
@@ -132,52 +141,38 @@ run=
 show="$echo"
 show_help=
 execute_dlfiles=
-duplicate_deps=no
-preserve_args=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
+quote_scanset='[[~#^*{};<>?'"'"'       ]'
+
+if test -z "$max_cmd_len"; then
+  i=0
+  testring="ABCD"
+  new_result=
+  
+  # If test is not a shell built-in, we'll probably end up computing a
+  # maximum length that is only half of the actual maximum length, but
+  # we can't tell.
+  while (test "X"`$SHELL $0 --fallback-echo "X$testring" 2>/dev/null` \
+             = "XX$testring") >/dev/null 2>&1 &&
+          new_result=`expr "X$testring" : ".*" 2>&1` &&
+          max_cmd_len="$new_result" &&
+          test "$i" != 17 # 1/2 MB should be enough
+  do
+    i=`expr $i + 1`
+    testring="$testring$testring"
+  done
+  testring=
+  # Add a significant safety factor because C++ compilers can tack on massive
+  # amounts of additional arguments before passing them to the linker.
+  # It appears as though 1/2 is a usable value.
+  max_cmd_len=`expr $max_cmd_len \/ 2`
+fi
 
 #####################################
 # Shell function definitions:
 # This seems to be the best place for them
 
-# func_mktempdir [string]
-# Make a temporary directory that won't clash with other running
-# libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
-func_mktempdir ()
-{
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
-
-    if test "$run" = ":"; then
-      # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
-    else
-
-      # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
-
-      if test ! -d "$my_tmpdir"; then
-       # Failing that, at least try and use $RANDOM to avoid a race
-       my_tmpdir="${my_template}-${RANDOM-0}$$"
-
-       save_mktempdir_umask=`umask`
-       umask 0077
-       $mkdir "$my_tmpdir"
-       umask $save_mktempdir_umask
-      fi
-
-      # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || {
-        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
-       exit $EXIT_FAILURE
-      }
-    fi
-
-    $echo "X$my_tmpdir" | $Xsed
-}
-
-
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
@@ -196,11 +191,12 @@ func_win32_libid ()
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
       $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
       win32_nmres=`eval $NM -f posix -A $1 | \
-       $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
-      case $win32_nmres in
-      import*)  win32_libid_type="x86 archive import";;
-      *)        win32_libid_type="x86 archive static";;
-      esac
+       sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
+      if test "X$win32_nmres" = "Ximport" ; then
+        win32_libid_type="x86 archive import"
+      else
+        win32_libid_type="x86 archive static"
+      fi
     fi
     ;;
   *DLL*)
@@ -230,7 +226,7 @@ func_infer_tag ()
       CC_quoted=
       for arg in $CC; do
        case $arg in
-         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+         *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
          arg="\"$arg\""
          ;;
        esac
@@ -251,13 +247,23 @@ func_infer_tag ()
            for arg in $CC; do
            # Double-quote args containing other shell metacharacters.
            case $arg in
-             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
+             *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
              arg="\"$arg\""
              ;;
            esac
            CC_quoted="$CC_quoted $arg"
          done
+           # user sometimes does CC=<HOST>-gcc so we need to match that to 'gcc'
+           trimedcc=`echo ${CC} | $SED -e "s/${host}-//g"`
+           # and sometimes libtool has CC=<HOST>-gcc but user does CC=gcc
+           extendcc=${host}-${CC}
            case "$@ " in
+             "cc "* | " cc "* | "${host}-cc "* | " ${host}-cc "*|\
+             "gcc "* | " gcc "* | "${host}-gcc "* | " ${host}-gcc "*)
+             tagname=CC
+             break ;;
+             "$trimedcc "* | " $trimedcc "* | "`$echo $trimedcc` "* | " `$echo $trimedcc` "*|\
+             "$extendcc "* | " $extendcc "* | "`$echo $extendcc` "* | " `$echo $extendcc` "*|\
              " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
              # The compiler in the base compile command matches
              # the one in the tagged configuration.
@@ -333,9 +339,9 @@ func_extract_archives ()
       $run ${rm}r "$my_xdir"
       $show "$mkdir $my_xdir"
       $run $mkdir "$my_xdir"
-      exit_status=$?
-      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
-       exit $exit_status
+      status=$?
+      if test "$status" -ne 0 && test ! -d "$my_xdir"; then
+       exit $status
       fi
       case $host in
       *-darwin*)
@@ -375,7 +381,7 @@ func_extract_archives ()
            func_extract_an_archive "$my_xdir" "$my_xabs"
          fi # $darwin_arches
        fi # $run
-       ;;
+      ;;
       *)
         func_extract_an_archive "$my_xdir" "$my_xabs"
         ;;
@@ -390,8 +396,6 @@ func_extract_archives ()
 # Darwin sucks
 eval std_shrext=\"$shrext_cmds\"
 
-disable_libs=no
-
 # Parse our command line options once, thoroughly.
 while test "$#" -gt 0
 do
@@ -508,11 +512,7 @@ do
     preserve_args="$preserve_args $arg"
     ;;
 
-  --tag)
-    prevopt="--tag"
-    prev=tag
-    preserve_args="$preserve_args --tag"
-    ;;
+  --tag) prevopt="--tag" prev=tag ;;
   --tag=*)
     set tag "$optarg" ${1+"$@"}
     shift
@@ -544,18 +544,6 @@ if test -n "$prevopt"; then
   exit $EXIT_FAILURE
 fi
 
-case $disable_libs in
-no) 
-  ;;
-shared)
-  build_libtool_libs=no
-  build_old_libs=yes
-  ;;
-static)
-  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
-  ;;
-esac
-
 # 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.
@@ -632,7 +620,7 @@ if test -z "$show_help"; then
 
     for arg
     do
-      case $arg_mode in
+      case "$arg_mode" in
       arg  )
        # do not "continue".  Instead, add this to base_compile
        lastarg="$arg"
@@ -683,7 +671,7 @@ if test -z "$show_help"; then
            # Many Bourne shells cannot handle close brackets correctly
            # in scan sets, so we specify it separately.
            case $arg in
-             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
+             *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
              arg="\"$arg\""
              ;;
            esac
@@ -718,7 +706,7 @@ if test -z "$show_help"; then
       # in scan sets (worked around with variable expansion),
       # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
       # at all, so we specify them separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
        lastarg="\"$lastarg\""
        ;;
       esac
@@ -793,12 +781,13 @@ if test -z "$show_help"; then
 
     qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
     case $qlibobj in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
        qlibobj="\"$qlibobj\"" ;;
     esac
-    test "X$libobj" != "X$qlibobj" \
-       && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"'  &()|`$[]' \
-       && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
+    if test "X$libobj" != "X$qlibobj"; then
+       $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
+       exit $EXIT_FAILURE
+    fi
     objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
     xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
     if test "X$xdir" = "X$obj"; then
@@ -851,7 +840,7 @@ if test -z "$show_help"; then
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
     if test "$need_locks" = yes; then
-      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
+      until $run ln "$srcfile" "$lockfile" 2>/dev/null; do
        $show "Waiting for $lockfile to be removed"
        sleep 2
       done
@@ -879,7 +868,7 @@ compiler."
     fi
     qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
     case $qsrcfile in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
       qsrcfile="\"$qsrcfile\"" ;;
     esac
 
@@ -912,9 +901,9 @@ EOF
       if test ! -d "${xdir}$objdir"; then
        $show "$mkdir ${xdir}$objdir"
        $run $mkdir ${xdir}$objdir
-       exit_status=$?
-       if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
-         exit $exit_status
+       status=$?
+       if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
+         exit $status
        fi
       fi
 
@@ -1117,7 +1106,6 @@ EOF
     no_install=no
     objs=
     non_pic_objects=
-    notinst_path= # paths that contain not-installed libtool libraries
     precious_files_regex=
     prefer_static_libs=no
     preload=no
@@ -1146,15 +1134,14 @@ EOF
          if test -n "$link_static_flag"; then
            dlopen_self=$dlopen_self_static
          fi
-         prefer_static_libs=yes
        else
          if test -z "$pic_flag" && test -n "$link_static_flag"; then
            dlopen_self=$dlopen_self_static
          fi
-         prefer_static_libs=built
        fi
        build_libtool_libs=no
        build_old_libs=yes
+       prefer_static_libs=yes
        break
        ;;
       esac
@@ -1168,7 +1155,7 @@ EOF
       arg="$1"
       shift
       case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
        qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
        ;;
       *) qarg=$arg ;;
@@ -1329,11 +1316,6 @@ 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.
@@ -1417,8 +1399,8 @@ EOF
          prev=
          continue
          ;;
-       darwin_framework|darwin_framework_skip)
-         test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
+        darwin_framework)
+         compiler_flags="$compiler_flags $arg"
          compile_command="$compile_command $arg"
          finalize_command="$finalize_command $arg"
          prev=
@@ -1482,17 +1464,13 @@ EOF
        continue
        ;;
 
-      -framework|-arch|-isysroot)
-       case " $CC " in
-         *" ${arg} ${1} "* | *" ${arg} ${1} "*) 
-               prev=darwin_framework_skip ;;
-         *) compiler_flags="$compiler_flags $arg"
-            prev=darwin_framework ;;
-       esac
+      -framework)
+        prev=darwin_framework
+        compiler_flags="$compiler_flags $arg"
        compile_command="$compile_command $arg"
        finalize_command="$finalize_command $arg"
-       continue
-       ;;
+        continue
+        ;;
 
       -inst-prefix-dir)
        prev=inst_prefix
@@ -1520,8 +1498,7 @@ EOF
          absdir=`cd "$dir" && pwd`
          if test -z "$absdir"; then
            $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
-           absdir="$dir"
-           notinst_path="$notinst_path $dir"
+           exit $EXIT_FAILURE
          fi
          dir="$absdir"
          ;;
@@ -1535,15 +1512,10 @@ EOF
        esac
        case $host in
        *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-         testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
          case :$dllsearchpath: in
          *":$dir:"*) ;;
          *) dllsearchpath="$dllsearchpath:$dir";;
          esac
-         case :$dllsearchpath: in
-         *":$testbindir:"*) ;;
-         *) dllsearchpath="$dllsearchpath:$testbindir";;
-         esac
          ;;
        esac
        continue
@@ -1552,11 +1524,11 @@ EOF
       -l*)
        if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
          case $host in
-         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
+         *-*-cygwin* | *-*-pw32* | *-*-beos*)
            # These systems don't actually have a C or math library (as such)
            continue
            ;;
-         *-*-os2*)
+         *-*-mingw* | *-*-os2*)
            # These systems don't actually have a C library (as such)
            test "X$arg" = "X-lc" && continue
            ;;
@@ -1568,15 +1540,6 @@ EOF
            # Rhapsody C and math libraries are in the System framework
            deplibs="$deplibs -framework System"
            continue
-           ;;
-         *-*-sco3.2v5* | *-*-sco5v6*)
-           # Causes problems with __ctype
-           test "X$arg" = "X-lc" && continue
-           ;;
-         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-           # Compiler inserts libc in the correct place for threads to work
-           test "X$arg" = "X-lc" && continue
-           ;;
          esac
        elif test "X$arg" = "X-lc_r"; then
         case $host in
@@ -1618,24 +1581,21 @@ EOF
       # +DA*, +DD* enable 64-bit mode on the HP compiler
       # -q* pass through compiler args for the IBM compiler
       # -m* pass through architecture-specific compiler args for GCC
-      # -m*, -t[45]*, -txscale* pass through architecture-specific
-      # compiler args for GCC
-      # -pg pass through profiling flag for GCC
-      # @file GCC response files
-      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
-      -t[45]*|-txscale*|@*)
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*)
 
        # 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
-       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+       *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
          arg="\"$arg\""
          ;;
        esac
         compile_command="$compile_command $arg"
         finalize_command="$finalize_command $arg"
-        compiler_flags="$compiler_flags $arg"
+        if test "$with_gcc" = "yes" ; then
+          compiler_flags="$compiler_flags $arg"
+        fi
         continue
         ;;
 
@@ -1743,7 +1703,7 @@ EOF
        for flag in $args; do
          IFS="$save_ifs"
          case $flag in
-           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
+           *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
            flag="\"$flag\""
            ;;
          esac
@@ -1761,7 +1721,7 @@ EOF
        for flag in $args; do
          IFS="$save_ifs"
          case $flag in
-           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
+           *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
            flag="\"$flag\""
            ;;
          esac
@@ -1788,13 +1748,18 @@ EOF
        continue
        ;;
 
+      -Kthread | -mthreads | -mt | -pthread | -pthreads | -threads | -qthreaded | -kthread )
+        compiler_flags="$compiler_flags $arg"
+        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
-       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+       *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
          arg="\"$arg\""
          ;;
        esac
@@ -1873,11 +1838,6 @@ 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.
@@ -1933,7 +1893,7 @@ EOF
        # to be aesthetically quoted because they are evaled later.
        arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
        case $arg in
-       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+       *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
          arg="\"$arg\""
          ;;
        esac
@@ -1983,9 +1943,9 @@ EOF
     if test ! -d "$output_objdir"; then
       $show "$mkdir $output_objdir"
       $run $mkdir $output_objdir
-      exit_status=$?
-      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
-       exit $exit_status
+      status=$?
+      if test "$status" -ne 0 && test ! -d "$output_objdir"; then
+       exit $status
       fi
     fi
 
@@ -2048,6 +2008,7 @@ EOF
     newlib_search_path=
     need_relink=no # whether we're linking any 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"
@@ -2082,10 +2043,7 @@ EOF
        case $pass in
        dlopen) libs="$dlfiles" ;;
        dlpreopen) libs="$dlprefiles" ;;
-       link)
-         libs="$deplibs %DEPLIBS%"
-         test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
-         ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
        esac
       fi
       if test "$pass" = dlopen; then
@@ -2286,7 +2244,7 @@ EOF
        esac # case $deplib
        if test "$found" = yes || test -f "$lib"; then :
        else
-         $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
+         $echo "$modename: cannot find the library \`$lib'" 1>&2
          exit $EXIT_FAILURE
        fi
 
@@ -2500,7 +2458,7 @@ EOF
              case "$temp_rpath " in
              *" $dir "*) ;;
              *" $absdir "*) ;;
-             *) temp_rpath="$temp_rpath $absdir" ;;
+             *) temp_rpath="$temp_rpath $dir" ;;
              esac
            fi
 
@@ -2537,12 +2495,8 @@ EOF
        fi
 
        link_static=no # Whether the deplib will be linked statically
-       use_static_libs=$prefer_static_libs
-       if test "$use_static_libs" = built && test "$installed" = yes ; then
-         use_static_libs=no
-       fi
        if test -n "$library_names" &&
-          { test "$use_static_libs" = no || test -z "$old_library"; }; then
+          { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
          if test "$installed" = no; then
            notinst_deplibs="$notinst_deplibs $lib"
            need_relink=yes
@@ -2655,15 +2609,11 @@ EOF
              if test "$hardcode_direct" = no; then
                add="$dir/$linklib"
                case $host in
-                 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-                 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
-                 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-                   *-*-unixware7*) add_dir="-L$dir" ;;
+                 *-*-sco3.2v5* ) add_dir="-L$dir" ;;
                  *-*-darwin* )
                    # if the lib is a module then we can not link against
                    # it, someone is ignoring the new warnings I added
-                   if /usr/bin/file -L $add 2> /dev/null |
-                      $EGREP ": [^:]* bundle" >/dev/null ; then
+                   if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
                      $echo "** Warning, lib $linklib is a module, not a shared library"
                      if test -z "$old_library" ; then
                        $echo
@@ -2694,7 +2644,7 @@ EOF
                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
+                 case "$libdir" in
                    [\\/]*)
                      add_dir="$add_dir -L$inst_prefix_dir$libdir"
                      ;;
@@ -2767,7 +2717,7 @@ EOF
              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
+               case "$libdir" in
                  [\\/]*)
                    add_dir="$add_dir -L$inst_prefix_dir$libdir"
                    ;;
@@ -2828,6 +2778,8 @@ EOF
              fi
            fi
          else
+           convenience="$convenience $dir/$old_library"
+           old_convenience="$old_convenience $dir/$old_library"
            deplibs="$dir/$old_library $deplibs"
            link_static=yes
          fi
@@ -3204,11 +3156,6 @@ EOF
            age="$number_minor"
            revision="$number_minor"
            ;;
-         *)
-           $echo "$modename: unknown library version type \`$version_type'" 1>&2
-           $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
-           exit $EXIT_FAILURE
-           ;;
          esac
          ;;
        no)
@@ -3419,9 +3366,9 @@ EOF
 
       # Eliminate all temporary directories.
       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"`
+       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'`
       done
 
       if test -n "$xrpath"; then
@@ -3474,12 +3421,7 @@ EOF
            ;;
          *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
            # Do not include libc due to us having libc/libc_r.
-           ;;
-         *-*-sco3.2v5* | *-*-sco5v6*)
-           # Causes problems with __ctype
-           ;;
-         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-           # Compiler inserts libc in the correct place for threads to work
+           test "X$arg" = "X-lc" && continue
            ;;
          *)
            # Add libc to deplibs on all other systems if necessary.
@@ -3523,11 +3465,11 @@ EOF
          int main() { return 0; }
 EOF
          $rm conftest
-         $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
+         $LTCC -o conftest conftest.c $deplibs
          if test "$?" -eq 0 ; then
            ldd_output=`ldd conftest`
            for i in $deplibs; do
-             name=`expr $i : '-l\(.*\)'`
+             name="`expr $i : '-l\(.*\)'`"
              # If $name is empty we are operating on a -L argument.
               if test "$name" != "" && test "$name" -ne "0"; then
                if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
@@ -3564,11 +3506,11 @@ EOF
            # Error occurred in the first compile.  Let's try to salvage
            # the situation: Compile a separate program for each library.
            for i in $deplibs; do
-             name=`expr $i : '-l\(.*\)'`
+             name="`expr $i : '-l\(.*\)'`"
              # If $name is empty we are operating on a -L argument.
               if test "$name" != "" && test "$name" != "0"; then
                $rm conftest
-               $LTCC $LTCFLAGS -o conftest conftest.c $i
+               $LTCC -o conftest conftest.c $i
                # Did it work?
                if test "$?" -eq 0 ; then
                  ldd_output=`ldd conftest`
@@ -3616,7 +3558,7 @@ EOF
          set dummy $deplibs_check_method
          file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
          for a_deplib in $deplibs; do
-           name=`expr $a_deplib : '-l\(.*\)'`
+           name="`expr $a_deplib : '-l\(.*\)'`"
            # If $name is empty we are operating on a -L argument.
             if test "$name" != "" && test  "$name" != "0"; then
              if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
@@ -3650,6 +3592,13 @@ EOF
                        *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
                        esac
                      done
+                     # It is ok to link against an archive when
+                     # building a shared library.
+                     if $AR -t $potlib > /dev/null 2>&1; then
+                       newdeplibs="$newdeplibs $a_deplib"
+                       a_deplib=""
+                       break 2
+                     fi
                      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
                         | ${SED} 10q \
                         | $EGREP "$file_magic_regex" > /dev/null; then
@@ -3685,7 +3634,7 @@ EOF
          set dummy $deplibs_check_method
          match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
          for a_deplib in $deplibs; do
-           name=`expr $a_deplib : '-l\(.*\)'`
+           name="`expr $a_deplib : '-l\(.*\)'`"
            # If $name is empty we are operating on a -L argument.
            if test -n "$name" && test "$name" != "0"; then
              if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
@@ -3815,35 +3764,6 @@ EOF
        deplibs=$newdeplibs
       fi
 
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-       case " $new_libs " in
-       *" -L$path/$objdir "*) ;;
-       *)
-         case " $deplibs " in
-         *" -L$path/$objdir "*)
-           new_libs="$new_libs -L$path/$objdir" ;;
-         esac
-         ;;
-       esac
-      done
-      for deplib in $deplibs; do
-       case $deplib in
-       -L*)
-         case " $new_libs " in
-         *" $deplib "*) ;;
-         *) new_libs="$new_libs $deplib" ;;
-         esac
-         ;;
-       *) new_libs="$new_libs $deplib" ;;
-       esac
-      done
-      deplibs="$new_libs"
-
-
       # All the library-specific variables (install_libdir is set above).
       library_names=
       old_library=
@@ -3927,7 +3847,6 @@ EOF
        fi
 
        lib="$output_objdir/$realname"
-       linknames=
        for link
        do
          linknames="$linknames $link"
@@ -3956,9 +3875,6 @@ EOF
                # The command line is too long to execute in one step.
                $show "using reloadable object file for export list..."
                skipped_export=:
-               # Break out early, otherwise skipped_export may be
-               # set to false by a later but shorter cmd.
-               break
              fi
            done
            IFS="$save_ifs"
@@ -4028,8 +3944,7 @@ EOF
          fi
        fi
 
-       if test "X$skipped_export" != "X:" &&
-          len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+       if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` &&
           test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
          :
        else
@@ -4064,7 +3979,7 @@ EOF
          do
            eval test_cmds=\"$reload_cmds $objlist $last_robj\"
            if test "X$objlist" = X ||
-              { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+              { len=`expr "X$test_cmds" : ".*"` &&
                 test "$len" -le "$max_cmd_len"; }; then
              objlist="$objlist $obj"
            else
@@ -4154,30 +4069,13 @@ EOF
          IFS="$save_ifs"
          eval cmd=\"$cmd\"
          $show "$cmd"
-         $run eval "$cmd" || {
-           lt_exit=$?
-
-           # Restore the uninstalled library and exit
-           if test "$mode" = relink; then
-             $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
-           fi
-
-           exit $lt_exit
-         }
+         $run eval "$cmd" || exit $?
        done
        IFS="$save_ifs"
 
        # Restore the uninstalled library and exit
        if test "$mode" = relink; then
          $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
-
-         if test -n "$convenience"; then
-           if test -z "$whole_archive_flag_spec"; then
-             $show "${rm}r $gentop"
-             $run ${rm}r "$gentop"
-           fi
-         fi
-
          exit $EXIT_SUCCESS
        fi
 
@@ -4359,35 +4257,6 @@ EOF
         ;;
       esac
 
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-       case " $new_libs " in
-       *" -L$path/$objdir "*) ;;
-       *)
-         case " $compile_deplibs " in
-         *" -L$path/$objdir "*)
-           new_libs="$new_libs -L$path/$objdir" ;;
-         esac
-         ;;
-       esac
-      done
-      for deplib in $compile_deplibs; do
-       case $deplib in
-       -L*)
-         case " $new_libs " in
-         *" $deplib "*) ;;
-         *) new_libs="$new_libs $deplib" ;;
-         esac
-         ;;
-       *) new_libs="$new_libs $deplib" ;;
-       esac
-      done
-      compile_deplibs="$new_libs"
-
-
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 
@@ -4432,15 +4301,10 @@ EOF
        fi
        case $host in
        *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-         testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
          case :$dllsearchpath: in
          *":$libdir:"*) ;;
          *) dllsearchpath="$dllsearchpath:$libdir";;
          esac
-         case :$dllsearchpath: in
-         *":$testbindir:"*) ;;
-         *) dllsearchpath="$dllsearchpath:$testbindir";;
-         esac
          ;;
        esac
       done
@@ -4556,23 +4420,11 @@ extern \"C\" {
            if test -z "$export_symbols"; then
              export_symbols="$output_objdir/$outputname.exp"
              $run $rm $export_symbols
-             $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
-              case $host in
-              *cygwin* | *mingw* )
-               $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-               $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
-                ;;
-              esac
+             $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
            else
-             $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+             $run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
              $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
              $run eval 'mv "$nlist"T "$nlist"'
-              case $host in
-              *cygwin* | *mingw* )
-               $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-               $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
-                ;;
-              esac
            fi
          fi
 
@@ -4689,29 +4541,16 @@ static const void *lt_preloaded_setup() {
          esac
 
          # Now compile the dynamic symbol file.
-         $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
-         $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+         $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+         $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
 
          # Clean up the generated files.
          $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
          $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
 
          # Transform the symbol file into the correct name.
-          case $host in
-          *cygwin* | *mingw* )
-            if test -f "$output_objdir/${outputname}.def" ; then
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
-            else
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-             fi
-            ;;
-          * )
-            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-            ;;
-          esac
+         compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+         finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
          ;;
        *)
          $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
@@ -4736,7 +4575,7 @@ static const void *lt_preloaded_setup() {
        # We have no uninstalled library dependencies, so finalize right now.
        $show "$link_command"
        $run eval "$link_command"
-       exit_status=$?
+       status=$?
 
        # Delete the generated files.
        if test -n "$dlsyms"; then
@@ -4744,7 +4583,7 @@ static const void *lt_preloaded_setup() {
          $run $rm "$output_objdir/${outputname}S.${objext}"
        fi
 
-       exit $exit_status
+       exit $status
       fi
 
       if test -n "$shlibpath_var"; then
@@ -4884,12 +4723,10 @@ static const void *lt_preloaded_setup() {
        esac
        case $host in
          *cygwin* | *mingw* )
-            output_name=`basename $output`
-            output_path=`dirname $output`
-            cwrappersource="$output_path/$objdir/lt-$output_name.c"
-            cwrapper="$output_path/$output_name.exe"
-            $rm $cwrappersource $cwrapper
-            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+           cwrappersource=`$echo ${objdir}/lt-${outputname}.c`
+           cwrapper=`$echo ${output}.exe`
+           $rm $cwrappersource $cwrapper
+           trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
            cat > $cwrappersource <<EOF
 
@@ -4914,9 +4751,6 @@ EOF
 #include <malloc.h>
 #include <stdarg.h>
 #include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/stat.h>
 
 #if defined(PATH_MAX)
 # define LT_PATHMAX PATH_MAX
@@ -4927,19 +4761,15 @@ EOF
 #endif
 
 #ifndef DIR_SEPARATOR
-# define DIR_SEPARATOR '/'
-# define PATH_SEPARATOR ':'
+#define DIR_SEPARATOR '/'
 #endif
 
 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
   defined (__OS2__)
-# define HAVE_DOS_BASED_FILE_SYSTEM
-# ifndef DIR_SEPARATOR_2
-#  define DIR_SEPARATOR_2 '\\'
-# endif
-# ifndef PATH_SEPARATOR_2
-#  define PATH_SEPARATOR_2 ';'
-# endif
+#define HAVE_DOS_BASED_FILE_SYSTEM
+#ifndef DIR_SEPARATOR_2
+#define DIR_SEPARATOR_2 '\\'
+#endif
 #endif
 
 #ifndef DIR_SEPARATOR_2
@@ -4949,32 +4779,17 @@ EOF
         (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
 #endif /* DIR_SEPARATOR_2 */
 
-#ifndef PATH_SEPARATOR_2
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
-#else /* PATH_SEPARATOR_2 */
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
-#endif /* PATH_SEPARATOR_2 */
-
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
   if (stale) { free ((void *) stale); stale = 0; } \
 } while (0)
 
-/* -DDEBUG is fairly common in CFLAGS.  */
-#undef DEBUG
-#if defined DEBUGWRAPPER
-# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
-#else
-# define DEBUG(format, ...)
-#endif
-
 const char *program_name = NULL;
 
 void * xmalloc (size_t num);
 char * xstrdup (const char *string);
-const char * base_name (const char *name);
-char * find_executable(const char *wrapper);
-int    check_executable(const char *path);
+char * basename (const char *name);
+char * fnqualify(const char *path);
 char * strendzap(char *str, const char *pat);
 void lt_fatal (const char *message, ...);
 
@@ -4984,51 +4799,29 @@ main (int argc, char *argv[])
   char **newargz;
   int i;
 
-  program_name = (char *) xstrdup (base_name (argv[0]));
-  DEBUG("(main) argv[0]      : %s\n",argv[0]);
-  DEBUG("(main) program_name : %s\n",program_name);
+  program_name = (char *) xstrdup ((char *) basename (argv[0]));
   newargz = XMALLOC(char *, argc+2);
 EOF
 
-            cat >> $cwrappersource <<EOF
-  newargz[0] = (char *) xstrdup("$SHELL");
+           cat >> $cwrappersource <<EOF
+  newargz[0] = "$SHELL";
 EOF
 
-            cat >> $cwrappersource <<"EOF"
-  newargz[1] = find_executable(argv[0]);
-  if (newargz[1] == NULL)
-    lt_fatal("Couldn't find %s", argv[0]);
-  DEBUG("(main) found exe at : %s\n",newargz[1]);
+           cat >> $cwrappersource <<"EOF"
+  newargz[1] = fnqualify(argv[0]);
   /* we know the script has the same name, without the .exe */
   /* so make sure newargz[1] doesn't end in .exe */
   strendzap(newargz[1],".exe");
   for (i = 1; i < argc; i++)
     newargz[i+1] = xstrdup(argv[i]);
   newargz[argc+1] = NULL;
-
-  for (i=0; i<argc+1; i++)
-  {
-    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
-    ;
-  }
-
 EOF
 
-            case $host_os in
-              mingw*)
-                cat >> $cwrappersource <<EOF
-  execv("$SHELL",(char const **)newargz);
-EOF
-              ;;
-              *)
-                cat >> $cwrappersource <<EOF
+           cat >> $cwrappersource <<EOF
   execv("$SHELL",newargz);
 EOF
-              ;;
-            esac
 
-            cat >> $cwrappersource <<"EOF"
-  return 127;
+           cat >> $cwrappersource <<"EOF"
 }
 
 void *
@@ -5048,148 +4841,48 @@ xstrdup (const char *string)
 ;
 }
 
-const char *
-base_name (const char *name)
+char *
+basename (const char *name)
 {
   const char *base;
 
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
   /* Skip over the disk name in MSDOS pathnames. */
-  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
+  if (isalpha (name[0]) && name[1] == ':')
     name += 2;
 #endif
 
   for (base = name; *name; name++)
     if (IS_DIR_SEPARATOR (*name))
       base = name + 1;
-  return base;
+  return (char *) base;
 }
 
-int
-check_executable(const char * path)
-{
-  struct stat st;
-
-  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
-  if ((!path) || (!*path))
-    return 0;
-
-  if ((stat (path, &st) >= 0) &&
-      (
-        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
-#if defined (S_IXOTH)
-       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
-#endif
-#if defined (S_IXGRP)
-       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
-#endif
-       ((st.st_mode & S_IXUSR) == S_IXUSR))
-      )
-    return 1;
-  else
-    return 0;
-}
-
-/* Searches for the full path of the wrapper.  Returns
-   newly allocated full path name if found, NULL otherwise */
 char *
-find_executable (const char* wrapper)
+fnqualify(const char *path)
 {
-  int has_slash = 0;
-  const char* p;
-  const char* p_next;
-  /* static buffer for getcwd */
+  size_t size;
+  char *p;
   char tmp[LT_PATHMAX + 1];
-  int tmp_len;
-  char* concat_name;
-
-  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
 
-  if ((wrapper == NULL) || (*wrapper == '\0'))
-    return NULL;
+  assert(path != NULL);
 
-  /* Absolute path? */
+  /* Is it qualified already? */
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
-  {
-    concat_name = xstrdup (wrapper);
-    if (check_executable(concat_name))
-      return concat_name;
-    XFREE(concat_name);
-  }
-  else
-  {
-#endif
-    if (IS_DIR_SEPARATOR (wrapper[0]))
-    {
-      concat_name = xstrdup (wrapper);
-      if (check_executable(concat_name))
-        return concat_name;
-      XFREE(concat_name);
-    }
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  }
+  if (isalpha (path[0]) && path[1] == ':')
+    return xstrdup (path);
 #endif
+  if (IS_DIR_SEPARATOR (path[0]))
+    return xstrdup (path);
 
-  for (p = wrapper; *p; p++)
-    if (*p == '/')
-    {
-      has_slash = 1;
-      break;
-    }
-  if (!has_slash)
-  {
-    /* no slashes; search PATH */
-    const char* path = getenv ("PATH");
-    if (path != NULL)
-    {
-      for (p = path; *p; p = p_next)
-      {
-        const char* q;
-        size_t p_len;
-        for (q = p; *q; q++)
-          if (IS_PATH_SEPARATOR(*q))
-            break;
-        p_len = q - p;
-        p_next = (*q == '\0' ? q : q + 1);
-        if (p_len == 0)
-        {
-          /* empty path: current directory */
-          if (getcwd (tmp, LT_PATHMAX) == NULL)
-            lt_fatal ("getcwd failed");
-          tmp_len = strlen(tmp);
-          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
-          memcpy (concat_name, tmp, tmp_len);
-          concat_name[tmp_len] = '/';
-          strcpy (concat_name + tmp_len + 1, wrapper);
-        }
-        else
-        {
-          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
-          memcpy (concat_name, p, p_len);
-          concat_name[p_len] = '/';
-          strcpy (concat_name + p_len + 1, wrapper);
-        }
-        if (check_executable(concat_name))
-          return concat_name;
-        XFREE(concat_name);
-      }
-    }
-    /* not found in PATH; assume curdir */
-  }
-  /* Relative path | not found in path: prepend cwd */
+  /* prepend the current directory */
+  /* doesn't handle '~' */
   if (getcwd (tmp, LT_PATHMAX) == NULL)
     lt_fatal ("getcwd failed");
-  tmp_len = strlen(tmp);
-  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
-  memcpy (concat_name, tmp, tmp_len);
-  concat_name[tmp_len] = '/';
-  strcpy (concat_name + tmp_len + 1, wrapper);
-
-  if (check_executable(concat_name))
-    return concat_name;
-  XFREE(concat_name);
-  return NULL;
+  size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
+  p = XMALLOC(char, size);
+  sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
+  return p;
 }
 
 char *
@@ -5233,16 +4926,16 @@ lt_fatal (const char *message, ...)
   va_end (ap);
 }
 EOF
-          # we should really use a build-platform specific compiler
-          # here, but OTOH, the wrappers (shell script and this C one)
-          # are only useful if you want to execute the "real" binary.
-          # Since the "real" binary is built for $host, then this
-          # wrapper might as well be built for $host, too.
-          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
-          ;;
-        esac
-        $rm $output
-        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
+         # we should really use a build-platform specific compiler
+         # here, but OTOH, the wrappers (shell script and this C one)
+         # are only useful if you want to execute the "real" binary.
+         # Since the "real" binary is built for $host, then this
+         # wrapper might as well be built for $host, too.
+         $run $LTCC -s -o $cwrapper $cwrappersource
+         ;;
+       esac
+       $rm $output
+       trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
 
        $echo > $output "\
 #! $SHELL
@@ -5392,13 +5085,13 @@ else
        # Backslashes separate directories on plain windows
        *-*-mingw | *-*-os2*)
          $echo >> $output "\
-      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+      exec \$progdir\\\\\$program \${1+\"\$@\"}
 "
          ;;
 
        *)
          $echo >> $output "\
-      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+      exec \$progdir/\$program \${1+\"\$@\"}
 "
          ;;
        esac
@@ -5408,7 +5101,7 @@ else
     fi
   else
     # The program doesn't exist.
-    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
     \$echo \"This script is just a wrapper for \$program.\" 1>&2
     $echo \"See the $PACKAGE documentation for more information.\" 1>&2
     exit $EXIT_FAILURE
@@ -5472,9 +5165,9 @@ fi\
            $run ${rm}r "$gentop"
            $show "$mkdir $gentop"
            $run $mkdir "$gentop"
-           exit_status=$?
-           if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
-             exit $exit_status
+           status=$?
+           if test "$status" -ne 0 && test ! -d "$gentop"; then
+             exit $status
            fi
          fi
 
@@ -5531,7 +5224,7 @@ fi\
            oldobjs="$objlist $obj"
            objlist="$objlist $obj"
            eval test_cmds=\"$old_archive_cmds\"
-           if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+           if len=`expr "X$test_cmds" : ".*"` &&
               test "$len" -le "$max_cmd_len"; then
              :
            else
@@ -5614,9 +5307,53 @@ fi\
                  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
                  exit $EXIT_FAILURE
                fi
-               newdependency_libs="$newdependency_libs $libdir/$name"
+               if test "X$EGREP" = X ; then
+                       EGREP=egrep
+               fi
+               # We do not want portage's install root ($D) present.  Check only for
+               # this if the .la is being installed.
+               if test "$installed" = yes && test "$D"; then
+                 eval mynewdependency_lib=`echo "$libdir/$name" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
+               else
+                 mynewdependency_lib="$libdir/$name"
+               fi
+               # Do not add duplicates
+               if test "$mynewdependency_lib"; then
+                 my_little_ninja_foo_1=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
+                 if test -z "$my_little_ninja_foo_1"; then
+                   newdependency_libs="$newdependency_libs $mynewdependency_lib"
+                 fi
+               fi
+               ;;
+                 *)
+               if test "$installed" = yes; then
+                 # Rather use S=WORKDIR if our version of portage supports it.
+                 # This is because some ebuild (gcc) do not use $S as buildroot.
+                 if test "$PWORKDIR"; then
+                   S="$PWORKDIR"
+                 fi
+                 # We do not want portage's build root ($S) present.
+                 my_little_ninja_foo_2=`echo $deplib |$EGREP -e "$S"`
+                 if test -n "$my_little_ninja_foo_2" && test "$S"; then
+                   mynewdependency_lib=""
+                 # We do not want portage's install root ($D) present.
+                 my_little_ninja_foo_3=`echo $deplib |$EGREP -e "$D"`
+                 elif test -n "$my_little_ninja_foo_3" && test "$D"; then
+                   eval mynewdependency_lib=`echo "$deplib" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
+                 else
+                   mynewdependency_lib="$deplib"
+                 fi
+               else
+                 mynewdependency_lib="$deplib"
+               fi
+               # Do not add duplicates
+               if test "$mynewdependency_lib"; then
+                 my_little_ninja_foo_4=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
+                 if test -z "$my_little_ninja_foo_4"; then
+                       newdependency_libs="$newdependency_libs $mynewdependency_lib"
+                 fi
+               fi
                ;;
-             *) newdependency_libs="$newdependency_libs $deplib" ;;
              esac
            done
            dependency_libs="$newdependency_libs"
@@ -5668,6 +5405,10 @@ fi\
          case $host,$output,$installed,$module,$dlname in
            *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
          esac
+         # Do not add duplicates
+         if test "$installed" = yes && test "$D"; then
+           install_libdir=`echo "$install_libdir" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
+         fi
          $echo > $output "\
 # $outputname - a libtool library file
 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
@@ -5728,11 +5469,11 @@ relink_command=\"$relink_command\""
     # install_prog (especially on Windows NT).
     if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
        # Allow the use of GNU shtool's install command.
-       $echo "X$nonopt" | grep shtool > /dev/null; then
+       $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
       # Aesthetically quote it.
       arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
       case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
        arg="\"$arg\""
        ;;
       esac
@@ -5741,14 +5482,14 @@ relink_command=\"$relink_command\""
       shift
     else
       install_prog=
-      arg=$nonopt
+      arg="$nonopt"
     fi
 
     # 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
-    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \      ]*|*]*|"")
+    *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
       arg="\"$arg\""
       ;;
     esac
@@ -5766,31 +5507,28 @@ relink_command=\"$relink_command\""
     do
       if test -n "$dest"; then
        files="$files $dest"
-       dest=$arg
+       dest="$arg"
        continue
       fi
 
       case $arg in
       -d) isdir=yes ;;
-      -f) 
-       case " $install_prog " in
-       *[\\\ /]cp\ *) ;;
-       *) prev=$arg ;;
-       esac
-       ;;
-      -g | -m | -o) prev=$arg ;;
+      -f) prev="-f" ;;
+      -g) prev="-g" ;;
+      -m) prev="-m" ;;
+      -o) prev="-o" ;;
       -s)
        stripme=" -s"
        continue
        ;;
-      -*)
-       ;;
+      -*) ;;
+
       *)
        # If the previous option needed an argument, then skip it.
        if test -n "$prev"; then
          prev=
        else
-         dest=$arg
+         dest="$arg"
          continue
        fi
        ;;
@@ -5799,7 +5537,7 @@ relink_command=\"$relink_command\""
       # Aesthetically quote the argument.
       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
       case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
        arg="\"$arg\""
        ;;
       esac
@@ -5968,14 +5706,11 @@ relink_command=\"$relink_command\""
 
          if test "$#" -gt 0; then
            # Delete the old symlinks, and create new ones.
-           # Try `ln -sf' first, because the `ln' binary might depend on
-           # the symlink we replace!  Solaris /bin/ln does not understand -f,
-           # so we also need to try rm && ln -s.
            for linkname
            do
              if test "$linkname" != "$realname"; then
-                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
-                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+               $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+               $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
              fi
            done
          fi
@@ -5988,16 +5723,7 @@ relink_command=\"$relink_command\""
            IFS="$save_ifs"
            eval cmd=\"$cmd\"
            $show "$cmd"
-           $run eval "$cmd" || {
-             lt_exit=$?
-
-             # Restore the uninstalled library and exit
-             if test "$mode" = relink; then
-               $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
-             fi
-
-             exit $lt_exit
-           }
+           $run eval "$cmd" || exit $?
          done
          IFS="$save_ifs"
        fi
@@ -6091,15 +5817,17 @@ relink_command=\"$relink_command\""
          notinst_deplibs=
          relink_command=
 
-         # Note that it is not necessary on cygwin/mingw to append a dot to
-         # foo even if both foo and FILE.exe exist: automatic-append-.exe
-         # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-         # `FILE.' does not work on cygwin managed mounts.
-         #
+         # To insure that "foo" is sourced, and not "foo.exe",
+         # finese the cygwin/MSYS system by explicitly sourcing "foo."
+         # which disallows the automatic-append-.exe behavior.
+         case $build in
+         *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+         *) wrapperdot=${wrapper} ;;
+         esac
          # If there is no directory component, then add one.
-         case $wrapper in
-         */* | *\\*) . ${wrapper} ;;
-         *) . ./${wrapper} ;;
+         case $file in
+         */* | *\\*) . ${wrapperdot} ;;
+         *) . ./${wrapperdot} ;;
          esac
 
          # Check the variables that should have been set.
@@ -6127,21 +5855,34 @@ relink_command=\"$relink_command\""
          done
 
          relink_command=
-         # Note that it is not necessary on cygwin/mingw to append a dot to
-         # foo even if both foo and FILE.exe exist: automatic-append-.exe
-         # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-         # `FILE.' does not work on cygwin managed mounts.
-         #
+         # To insure that "foo" is sourced, and not "foo.exe",
+         # finese the cygwin/MSYS system by explicitly sourcing "foo."
+         # which disallows the automatic-append-.exe behavior.
+         case $build in
+         *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+         *) wrapperdot=${wrapper} ;;
+         esac
          # If there is no directory component, then add one.
-         case $wrapper in
-         */* | *\\*) . ${wrapper} ;;
-         *) . ./${wrapper} ;;
+         case $file in
+         */* | *\\*) . ${wrapperdot} ;;
+         *) . ./${wrapperdot} ;;
          esac
 
          outputname=
          if test "$fast_install" = no && test -n "$relink_command"; then
            if test "$finalize" = yes && test -z "$run"; then
-             tmpdir=`func_mktempdir`
+             tmpdir="/tmp"
+             test -n "$TMPDIR" && tmpdir="$TMPDIR"
+             tmpdir="$tmpdir/libtool-$$"
+             save_umask=`umask`
+             umask 0077
+             if $mkdir "$tmpdir"; then
+               umask $save_umask
+             else
+               umask $save_umask
+               $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
+               continue
+             fi
              file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
              outputname="$tmpdir/$file"
              # Replace the output file specification.
@@ -6165,7 +5906,7 @@ relink_command=\"$relink_command\""
        fi
 
        # remove .exe since cygwin /usr/bin/install will append another
-       # one anyway 
+       # one anyways
        case $install_prog,$host in
        */usr/bin/install*,*cygwin*)
          case $file:$destfile in
@@ -6265,7 +6006,7 @@ relink_command=\"$relink_command\""
     # Exit here if they wanted silent mode.
     test "$show" = : && exit $EXIT_SUCCESS
 
-    $echo "X----------------------------------------------------------------------" | $Xsed
+    $echo "----------------------------------------------------------------------"
     $echo "Libraries have been installed in:"
     for libdir in $libdirs; do
       $echo "   $libdir"
@@ -6298,7 +6039,7 @@ relink_command=\"$relink_command\""
     $echo
     $echo "See any operating system documentation about shared libraries for"
     $echo "more information, such as the ld(1) and ld.so(8) manual pages."
-    $echo "X----------------------------------------------------------------------" | $Xsed
+    $echo "----------------------------------------------------------------------"
     exit $EXIT_SUCCESS
     ;;
 
@@ -6515,17 +6256,9 @@ relink_command=\"$relink_command\""
            rmfiles="$rmfiles $objdir/$n"
          done
          test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+         test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
 
-         case "$mode" in
-         clean)
-           case "  $library_names " in
-           # "  " in the beginning catches empty $dlname
-           *" $dlname "*) ;;
-           *) rmfiles="$rmfiles $objdir/$dlname" ;;
-           esac
-            test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
-           ;;
-         uninstall)
+         if test "$mode" = uninstall; then
            if test -n "$library_names"; then
              # Do each command in the postuninstall commands.
              cmds=$postuninstall_cmds
@@ -6558,8 +6291,7 @@ relink_command=\"$relink_command\""
              IFS="$save_ifs"
            fi
            # FIXME: should reinstall the best remaining shared library.
-           ;;
-         esac
+         fi
        fi
        ;;
 
@@ -6858,11 +6590,12 @@ exit $?
 # configuration.  But we'll never go from static-only to shared-only.
 
 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-disable_libs=shared
+build_libtool_libs=no
+build_old_libs=yes
 # ### END LIBTOOL TAG CONFIG: disable-shared
 
 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
-disable_libs=static
+build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
 # ### END LIBTOOL TAG CONFIG: disable-static
 
 # Local Variables: