updated/corrected documentation
[swftools.git] / ltmain.sh
index a926477..32384b6 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -48,15 +48,18 @@ EOF
   exit 0
 fi
 
+# define SED for historic ltconfig's generated by Libtool 1.3
+test -z "$SED" && SED=sed
+
 # The name of this program.
-progname=`$echo "$0" | sed 's%^.*/%%'`
+progname=`$echo "$0" | ${SED} 's%^.*/%%'`
 modename="$progname"
 
 # Constants.
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=1.4.2a
-TIMESTAMP=" (1.922.2.79 2001/11/28 21:50:31)"
+VERSION=1.4.3
+TIMESTAMP=" (1.922.2.111 2002/10/23 02:54:36)"
 
 default_mode=
 help="Try \`$progname --help' for more information."
@@ -67,10 +70,19 @@ rm="rm -f"
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed="${SED}"' -e 1s/^X//'
 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
-SP2NL='tr \040 \012'
-NL2SP='tr \015\012 \040\040'
+# test EBCDIC or ASCII                                                         
+case `echo A|od -x` in                                                         
+ *[Cc]1*) # 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                                                                           
 
 # NLS nuisances.
 # Only set LANG and LC_ALL to C if already set.
@@ -144,7 +156,7 @@ do
     ;;
 
   --config)
-    sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
+    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
     exit 0
     ;;
 
@@ -207,6 +219,17 @@ if test -n "$prevopt"; then
   exit 1
 fi
 
+# Mandrake: (gc) It's bad to link C++ code with GCC, so we need to use the compiler name if provided
+if test "$mode" = link && test -n "$archive_cmds" && test -x "/usr/bin/perl"; then
+    case $nonopt in
+    *cc | *++ | gcc* | *-gcc* | egcs*)
+           archive_cmds=`echo $archive_cmds | perl -pe 's/^\S+\s+//'`
+           archive_cmds="$nonopt $archive_cmds"
+           archive_expsym_cmds=`echo $archive_expsym_cmds | perl -pe 's/^\S+\s+//'`
+           archive_expsym_cmds="$nonopt $archive_expsym_cmds"
+    esac
+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.
@@ -217,7 +240,7 @@ if test -z "$show_help"; then
   # Infer the operation mode.
   if test -z "$mode"; then
     case $nonopt in
-    *cc | *++ | gcc* | *-gcc*)
+    *cc | *++ | gcc* | *-gcc* | xlc*)
       mode=link
       for arg
       do
@@ -469,7 +492,7 @@ if test -z "$show_help"; then
       pic_mode=default
       ;;
     esac
-    if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
       # non-PIC code in shared libraries is not supported
       pic_mode=default
     fi
@@ -759,6 +782,7 @@ compiler."
     linker_flags=
     dllsearchpath=
     lib_search_path=`pwd`
+    inst_prefix_dir=
 
     avoid_version=no
     dlfiles=
@@ -889,6 +913,11 @@ compiler."
          prev=
          continue
          ;;
+        inst_prefix)
+         inst_prefix_dir="$arg"
+         prev=
+         continue
+         ;;
        release)
          release="-$arg"
          prev=
@@ -990,6 +1019,11 @@ compiler."
        continue
        ;;
 
+      -inst-prefix-dir)
+       prev=inst_prefix
+       continue
+       ;;
+
       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
       # so, if we see these flags be careful not to treat them like -L
       -L[A-Z][A-Z]*:*)
@@ -1514,7 +1548,7 @@ compiler."
        fi
 
        # Check to see that this really is a libtool archive.
-       if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
        else
          $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
          exit 1
@@ -1776,8 +1810,8 @@ compiler."
 
            # 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"
+           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
            if test -f "$output_objdir/$soname-def"; then :
@@ -1884,7 +1918,16 @@ compiler."
            if test "$hardcode_direct" = yes; then
              add="$libdir/$linklib"
            elif test "$hardcode_minus_L" = yes; then
-             add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             add_dir=
+             if test -n "$inst_prefix_dir"; then
+               case "$libdir" in
+               [\\/]*)
+                 add_dir="-L$inst_prefix_dir$libdir"
+                 ;;
+               esac
+             fi
+             add_dir="$add_dir -L$libdir"
              add="-l$name"
            elif test "$hardcode_shlibpath_var" = yes; then
              case :$finalize_shlibpath: in
@@ -1894,7 +1937,16 @@ compiler."
              add="-l$name"
            else
              # We cannot seem to hardcode it, guess we'll fake it.
-             add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             add_dir=
+             if test -n "$inst_prefix_dir"; then
+               case "$libdir" in
+               [\\/]*)
+                 add_dir="-L$inst_prefix_dir$libdir"
+                 ;;
+               esac
+             fi
+             add_dir="$add_dir -L$libdir"
              add="-l$name"
            fi
 
@@ -2022,7 +2074,7 @@ compiler."
                if grep "^installed=no" $deplib > /dev/null; then
                  path="-L$absdir/$objdir"
                else
-                 eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
                  if test -z "$libdir"; then
                    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
                    exit 1
@@ -2227,7 +2279,7 @@ compiler."
 
        # Check that each of the things are valid numbers.
        case $current in
-       0 | [1-9] | [1-9][0-9] | [1-9][0-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
@@ -2236,7 +2288,7 @@ compiler."
        esac
 
        case $revision in
-       0 | [1-9] | [1-9][0-9] | [1-9][0-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
@@ -2245,7 +2297,7 @@ compiler."
        esac
 
        case $age in
-       0 | [1-9] | [1-9][0-9] | [1-9][0-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
@@ -2287,14 +2339,14 @@ compiler."
          ;;
 
        irix | nonstopux)
+         major=`expr $current - $age + 1`
+
          case $version_type in
            nonstopux) verstring_prefix=nonstopux ;;
            *)         verstring_prefix=sgi ;;
          esac
          verstring="$verstring_prefix$major.$revision"
 
-         major=`expr $current - $age + 1`
-
          # Add in all the interfaces that we are compatible with.
          loop=$revision
          while test $loop != 0; do
@@ -2314,7 +2366,7 @@ compiler."
          ;;
 
        osf)
-         major=`expr $current - $age`
+         major=.`expr $current - $age`
          versuffix=".$current.$age.$revision"
          verstring="$current.$age.$revision"
 
@@ -2406,9 +2458,9 @@ compiler."
 
       # 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
@@ -2596,14 +2648,21 @@ EOF
                      # but so what?
                      potlib="$potent_lib"
                      while test -h "$potlib" 2>/dev/null; do
-                       potliblink=`ls -ld $potlib | sed 's/.* -> //'`
+                       potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
                        case $potliblink in
                        [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
                        *) 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 \
+                        | ${SED} 10q \
                         | egrep "$file_magic_regex" > /dev/null; then
                        newdeplibs="$newdeplibs $a_deplib"
                        a_deplib=""
@@ -2645,7 +2704,7 @@ EOF
                for potent_lib in $potential_libs; do
                  potlib="$potent_lib" # see symlink-check below in file_magic test
                  if eval echo \"$potent_lib\" 2>/dev/null \
-                     | sed 10q \
+                     | ${SED} 10q \
                      | egrep "$match_pattern_regex" > /dev/null; then
                    newdeplibs="$newdeplibs $a_deplib"
                    a_deplib=""
@@ -2931,7 +2990,18 @@ EOF
        if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
          eval cmds=\"$archive_expsym_cmds\"
        else
+         save_deplibs="$deplibs"
+         for conv in $convenience; do
+           tmp_deplibs=
+           for test_deplib in $deplibs; do
+             if test "$test_deplib" != "$conv"; then
+               tmp_deplibs="$tmp_deplibs $test_deplib"
+             fi
+           done
+           deplibs="$tmp_deplibs"
+         done
          eval cmds=\"$archive_cmds\"
+         deplibs="$save_deplibs"
        fi
        save_ifs="$IFS"; IFS='~'
        for cmd in $cmds; do
@@ -3130,7 +3200,7 @@ EOF
 
     prog)
       case $host in
-       *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;;
+       *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
@@ -3152,6 +3222,13 @@ EOF
        # 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 /'`
+       case $host in
+       *darwin*)
+         # Don't allow lazy linking, it breaks C++ global constructors
+         compile_command="$compile_command ${wl}-bind_at_load"
+         finalize_command="$finalize_command ${wl}-bind_at_load"
+         ;;
+       esac
        ;;
       esac
 
@@ -3318,9 +3395,9 @@ extern \"C\" {
            if test -z "$export_symbols"; then
              export_symbols="$output_objdir/$output.exp"
              $run $rm $export_symbols
-             $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+             $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/$output.exp"'
+             $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
              $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
              $run eval 'mv "$nlist"T "$nlist"'
            fi
@@ -3328,7 +3405,7 @@ extern \"C\" {
 
          for arg in $dlprefiles; do
            $show "extracting global C symbols from \`$arg'"
-           name=`echo "$arg" | sed -e 's%^.*/%%'`
+           name=`echo "$arg" | ${SED} -e 's%^.*/%%'`
            $run eval 'echo ": $name " >> "$nlist"'
            $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
          done
@@ -3343,7 +3420,13 @@ extern \"C\" {
            fi
 
            # Try sorting and uniquifying the output.
-           if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
+           if grep -v "^: " < "$nlist" |
+               if sort -k 3 </dev/null >/dev/null 2>&1; then
+                 sort -k 3
+               else
+                 sort +2
+               fi |
+               uniq > "$nlist"S; then
              :
            else
              grep -v "^: " < "$nlist" > "$nlist"S
@@ -3585,7 +3668,7 @@ static const void *lt_preloaded_setup() {
        # win32 will think the script is a binary if it has
        # a .exe suffix, so we strip it off here.
        case $output in
-         *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
+         *.exe) output=`echo $output|${SED} 's,.exe$,,'` ;;
        esac
        # test for cygwin because mv fails w/o .exe extensions
        case $host in
@@ -3609,7 +3692,7 @@ static const void *lt_preloaded_setup() {
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed="${SED}"' -e 1s/^X//'
 sed_quote_subst='$sed_quote_subst'
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
@@ -3647,7 +3730,7 @@ else
   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
 
   # Follow symbolic links until we get to the real thisdir.
-  file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
+  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
   while test -n \"\$file\"; do
     destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
 
@@ -3660,7 +3743,7 @@ else
     fi
 
     file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
-    file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
   done
 
   # Try to get the absolute directory name.
@@ -3674,7 +3757,7 @@ else
   progdir=\"\$thisdir/$objdir\"
 
   if test ! -f \"\$progdir/\$program\" || \\
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
 
     file=\"\$\$-\$program\"
@@ -3720,7 +3803,7 @@ else
     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
 
     # Some systems cannot cope with colon-terminated $shlibpath_var
-    # The second colon is a workaround for a bug in BeOS R4 sed
+    # The second colon is a workaround for a bug in BeOS R4 ${SED}
     $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
 
     export $shlibpath_var
@@ -3895,7 +3978,7 @@ fi\
        fi
       done
       # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args)"
+      relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)"
       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
 
       # Only create the output if not a dry run.
@@ -3912,21 +3995,58 @@ fi\
              case $deplib in
              *.la)
                name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
-               eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
                if test -z "$libdir"; then
                  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
                  exit 1
                fi
-               newdependency_libs="$newdependency_libs $libdir/$name"
+               # 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
+                 if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; 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.
+                 if test -n "`echo $deplib |grep -e "$S"`" && test "$S"; then
+                   mynewdependency_lib=""
+                 # We do not want portage's install root ($D) present.
+                 elif test -n "`echo $deplib |grep -e "$D"`" && 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
+                 if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; then
+                       newdependency_libs="$newdependency_libs $mynewdependency_lib"
+                 fi
+               fi
                ;;
-             *) newdependency_libs="$newdependency_libs $deplib" ;;
              esac
            done
            dependency_libs="$newdependency_libs"
            newdlfiles=
            for lib in $dlfiles; do
              name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-             eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
              if test -z "$libdir"; then
                $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
                exit 1
@@ -3937,7 +4057,7 @@ fi\
            newdlprefiles=
            for lib in $dlprefiles; do
              name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-             eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
              if test -z "$libdir"; then
                $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
                exit 1
@@ -3952,6 +4072,10 @@ fi\
          case $host,$output,$installed,$module,$dlname in
            *cygwin*,*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
@@ -4161,7 +4285,7 @@ relink_command=\"$relink_command\""
 
       *.la)
        # Check to see that this really is a libtool archive.
-       if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
        else
          $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
          $echo "$help" 1>&2
@@ -4196,12 +4320,30 @@ relink_command=\"$relink_command\""
        dir="$dir$objdir"
 
        if test -n "$relink_command"; then
+         # Determine the prefix the user has applied to our future dir.
+         inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"`
+
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+         # are installed to the same prefix.
+         if test "$inst_prefix_dir" = "$destdir"; then
+           $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+           exit 1
+         fi
+
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+           relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+         else
+           relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"`
+         fi
+
          $echo "$modename: warning: relinking \`$file'" 1>&2
          $show "$relink_command"
          if $run eval "$relink_command"; then :
          else
            $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
-           continue
+           exit 1
          fi
        fi
 
@@ -4312,13 +4454,13 @@ relink_command=\"$relink_command\""
        # Do a test to see if this is really a libtool program.
        case $host in
        *cygwin*|*mingw*)
-           wrapper=`echo $file | sed -e 's,.exe$,,'`
+           wrapper=`echo $file | ${SED} -e 's,.exe$,,'`
            ;;
        *)
            wrapper=$file
            ;;
        esac
-       if (sed -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
+       if (${SED} -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
          notinst_deplibs=
          relink_command=
 
@@ -4364,7 +4506,11 @@ relink_command=\"$relink_command\""
            if test "$finalize" = yes && test -z "$run"; then
              tmpdir="/tmp"
              test -n "$TMPDIR" && tmpdir="$TMPDIR"
-             tmpdir="$tmpdir/libtool-$$"
+              tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null`
+              if test $? = 0 ; then :
+              else
+                tmpdir="$tmpdir/libtool-$$"
+              fi
              if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
              else
                $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
@@ -4404,7 +4550,7 @@ relink_command=\"$relink_command\""
            destfile=$destfile.exe
            ;;
          *:*.exe)
-           destfile=`echo $destfile | sed -e 's,.exe$,,'`
+           destfile=`echo $destfile | ${SED} -e 's,.exe$,,'`
            ;;
          esac
          ;;
@@ -4552,7 +4698,7 @@ relink_command=\"$relink_command\""
       case $file in
       *.la)
        # Check to see that this really is a libtool archive.
-       if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
        else
          $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
          $echo "$help" 1>&2
@@ -4623,7 +4769,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
+       if (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
          # If there is no directory component, then add one.
          case $file in
          */* | *\\*) . $file ;;
@@ -4732,7 +4878,7 @@ relink_command=\"$relink_command\""
       case $name in
       *.la)
        # Possibly a libtool archive, so verify it.
-       if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+       if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
          . $dir/$name
 
          # Delete the libtool libraries and symlinks.
@@ -4787,7 +4933,7 @@ relink_command=\"$relink_command\""
       *)
        # Do a test to see if this is a libtool program.
        if test $mode = clean &&
-          (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+          (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
          relink_command=
          . $dir/$file