Index: config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.1.2.51
diff -u -u -5 -r1.1.2.51 ltmain.m4sh
--- config/ltmain.m4sh	27 Apr 2005 11:31:16 -0000	1.1.2.51
+++ config/ltmain.m4sh	24 May 2005 21:38:47 -0000
@@ -923,10 +923,57 @@
       compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
       finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
     fi
 }
 
+# func_extract_a_lib dir oldlib
+func_extract_a_lib ()
+{
+    $opt_debug
+    f_ex_a_lib_dir="$1"; shift
+    f_ex_a_lib_oldlib="$1"
+    lib -NOLOGO -LIST "$f_ex_a_lib_oldlib" | while read name
+    do
+      $show "(cd $f_ex_a_lib_dir && lib -EXTRACT:$name $f_ex_a_lib_oldlib)"
+      $run eval "(cd \$f_ex_a_lib_dir && lib -EXTRACT:\$name \$f_ex_a_lib_oldlib)" || exit $?
+    done
+    if (lib -NOLOGO -LIST "$f_ex_a_lib_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      f_ex_a_lib_lib=`$ECHO "X$f_ex_a_lib_oldlib" | $Xsed -e 's%^.*/%%'`
+      func_warning "$modename: warning: object name conflicts; renaming object files" 1>&2
+      func_warning "$modename: warning: to ensure that they will not overwrite" 1>&2
+      $show "cp $f_ex_a_lib_oldlib $f_ex_a_lib_dir/$f_ex_a_lib_lib"
+      $run eval "cp \$f_ex_a_lib_oldlib \$f_ex_a_lib_dir/\$f_ex_a_lib_lib"
+      lib -LIST "$f_ex_a_lib_oldlib" | sort | uniq -c | while read count name
+      do
+	# We don't want to do anything to objects with unique names
+        if test "$count" -eq 1; then
+          lib -EXTRACT:$name $f_ex_a_lib_oldlib
+	  continue
+        fi
+	i=1
+	while test "$i" -le "$count"
+	  do
+	  # Put our $i before any first dot (extension)
+	  # Never overwrite any file
+	  name_to="$name"
+	  while test "X$name_to" = "X$name" || test -f "$f_ex_a_lib_dir/$name_to"
+	    do
+	    name_to=`$ECHO "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+	  done
+	  $show "(cd $f_ex_a_lib_dir && $AR x $f_ex_a_lib_lib '$name' && $MV '$name' '$name_to' && $AR d $f_ex_a_lib_lib '$name')"
+	  $run eval "(cd \$f_ex_a_lib_dir && $AR x \$f_ex_a_lib_lib '$name' && $MV '$name' '$name_to' && $AR d \$f_ex_a_lib_lib '$name')" || exit $?
+	  i=`expr $i + 1`
+	done
+      done
+      $show "$RM $f_ex_a_lib_dir/$f_ex_a_lib_lib"
+      $run eval "$RM \$f_ex_a_lib_dir/\$f_ex_a_lib_lib"
+    fi
+}
+
+
 # func_extract_an_archive dir oldlib
 func_extract_an_archive ()
 {
     $opt_debug
     f_ex_an_ar_dir="$1"; shift
@@ -1027,12 +1074,20 @@
 	    func_extract_an_archive "$my_xdir" "$my_xabs"
 	  fi # $darwin_arches
 	fi # $run
       ;;
       *)
-        func_extract_an_archive "$my_xdir" "$my_xabs"
+	case $with_gcc/$host in
+	no/*-*-mingw* | /*-*-mingw* | no/*-*-cygwin* | /*-*-cygwin*)
+	  # assume MSVC
+	  func_extract_a_lib "$my_xdir" "$my_xabs"
+	;;
+	*)
+	  func_extract_an_archive "$my_xdir" "$my_xabs"
 	;;
+	esac
+      ;;
       esac
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
     done
 
     func_extract_archives_result="$my_oldobjs"
@@ -2620,10 +2675,11 @@
 	    continue
 	    ;;
 	  *-*-mingw* | *-*-os2*)
 	    # These systems don't actually have a C library (as such)
 	    test "X$arg" = "X-lc" && continue
+	    test "X$with_gcc" != "Xyes" -a "X$arg" = "X-lm" && continue
 	    ;;
 	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
 	    # Do not include libc due to us having libc/libc_r.
 	    test "X$arg" = "X-lc" && continue
 	    ;;
@@ -3173,10 +3229,27 @@
 		fi
 		break 2
 	      fi
 	    done
 	  done
+	  if test "$found" != "yes"; then
+	    case $linkmode/$with_gcc/$host in
+	    prog/no/*-*-mingw* | prog//*-*-mingw* | prog/no/*-*-cygwin* | prog//*-*-cygwin*)
+	      # assume MSVC, which will look in $LIB for libraries
+	      save_ifs="$IFS"; IFS=';'
+	      for msvc_libdir in $LIB; do
+		IFS="$save_ifs"
+		# assume windows drives are accessible as /D, where D is a drive letter.
+		if test -f "/$($ECHO "X$msvc_libdir" | Xsed -e s.\\\\./.g -e s.\\:..)/${name}.lib"; then
+		  found=no
+		  break
+		fi
+	      done
+	      IFS="$save_ifs"
+	      ;;
+	    esac
+	  fi
 	  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"
@@ -4101,10 +4174,21 @@
 	      case " $tmp_libs " in
 	      *" $deplib "*) ;;
 	      *) tmp_libs="$tmp_libs $deplib" ;;
 	      esac
 	      ;;
+	    -l*)
+	      if test "$linkmode" = prog -a "X$with_gcc" != Xyes; then
+		case $host in
+		*-*-mingw* | *-*-cygwin*)
+		  # assume MSVC
+		  deplib=`$ECHO "X${deplib}.lib" | $Xsed -e 's/^-l//'`
+		  ;;
+		esac
+	      fi
+	      tmp_libs="$tmp_libs $deplib"
+	      ;;
 	    *) tmp_libs="$tmp_libs $deplib" ;;
 	    esac
 	  done
 	  eval $var=\"$tmp_libs\"
 	done # for var
@@ -4714,10 +4798,43 @@
 		      fi
 		  done
 		done
 	      fi
 	      if test -n "$a_deplib" ; then
+		libname=$name
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$name.lib 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		      # Follow soft links.
+		      if ls -lLd "$potent_lib" 2>/dev/null |
+			 $GREP " -> " >/dev/null; then
+			continue
+		      fi
+		      # The statement above tries to avoid entering an
+		      # endless loop below, in case of cyclic links.
+		      # We might still enter an endless loop, since a link
+		      # loop can be closed while we follow links,
+		      # but so what?
+		      potlib="$potent_lib"
+		      while test -h "$potlib" 2>/dev/null; do
+			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			case $potliblink in
+			[[\\/]]* | [[A-Za-z]]:[[\\/]]*) potlib="$potliblink";;
+			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[[^/]]*$,,'`"$potliblink";;
+			esac
+		      done
+		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+			 $SED -e 10q |
+			 $EGREP "$file_magic_regex" > /dev/null; then
+			newdeplibs="$newdeplibs ${name}.lib"
+			a_deplib=""
+			break 2
+		      fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
 		droppeddeps=yes
 		$ECHO
 		$ECHO "*** Warning: linker path does not have real file for library $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"
@@ -5706,11 +5823,13 @@
 */
 EOF
 	    cat >> $cwrappersource<<"EOF"
 #include <stdio.h>
 #include <stdlib.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <malloc.h>
 #include <stdarg.h>
 #include <assert.h>
 #include <ctype.h>
 #include <string.h>
@@ -5758,15 +5877,19 @@
   if (stale) { free ((void *) stale); stale = 0; } \
 } while (0)
 
 /* -DDEBUG is fairly common in CFLAGS.  */
 #undef DEBUG
+#ifdef _MSC_VER
+# define DEBUG()
+#else
 #if defined DEBUGWRAPPER
 # define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
 #else
 # define DEBUG(format, ...)
 #endif
+#endif
 
 const char *program_name = NULL;
 
 void * xmalloc (size_t num);
 char * xstrdup (const char *string);
@@ -5870,10 +5993,13 @@
 
   DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
   if ((!path) || (!*path))
     return 0;
 
+#ifdef _MSC_VER
+  return 1;
+#else
   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) ||
@@ -5884,10 +6010,11 @@
        ((st.st_mode & S_IXUSR) == S_IXUSR))
       )
     return 1;
   else
     return 0;
+#endif
 }
 
 /* Searches for the full path of the wrapper.  Returns
    newly allocated full path name if found, NULL otherwise */
 char *
Index: m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/libtool.m4,v
retrieving revision 1.125.2.57
diff -u -u -5 -r1.125.2.57 libtool.m4
--- m4/libtool.m4	15 May 2005 16:31:51 -0000	1.125.2.57
+++ m4/libtool.m4	24 May 2005 21:38:48 -0000
@@ -3941,17 +3941,20 @@
       # Tell ltmain to make .lib files, not .a files.
       libext=lib
       # Tell ltmain to make .dll files, not .so files.
       shrext_cmds=".dll"
       # FIXME: Setting linknames here is a bad hack.
-      _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=~mv .libs/${libname}`$ECHO "X${release}" | $Xsed -e s/[.]/-/g`${versuffix}.lib .libs/${libname}.lib'
+      _LT_TAGVAR(module_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
       # The linker will automatically build a .lib file if we build a DLL.
       _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
       # FIXME: Should let the user specify the lib program.
-      _LT_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      #_LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      # Don't use ranlib
+      _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
       ;;
 
     darwin* | rhapsody*)
       case $host_os in
       rhapsody* | darwin1.[[012]])
