Index: config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.1.2.54
diff -u -u -5 -r1.1.2.54 ltmain.m4sh
--- config/ltmain.m4sh	5 Jun 2005 17:35:11 -0000	1.1.2.54
+++ config/ltmain.m4sh	9 Jun 2005 11:45:21 -0000
@@ -923,10 +923,29 @@
       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"
+    link -LIB -NOLOGO -LIST "$f_ex_a_lib_oldlib" | while read name
+    do
+      $show "(cd $f_ex_a_lib_dir && link -LIB -NOLOGO -EXTRACT:$name $f_ex_a_lib_oldlib)"
+      $run eval "(cd \$f_ex_a_lib_dir && link -LIB -NOLOGO -EXTRACT:\$name \$f_ex_a_lib_oldlib)" || exit $?
+    done
+    if (link -LIB -NOLOGO -LIST "$f_ex_a_lib_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+     func_fatal_error "object name conflicts in archive: $f_ex_a_lib_dir/$f_ex_a_lib_oldlib"
+    fi
+}
+
+
 # func_extract_an_archive dir oldlib
 func_extract_an_archive ()
 {
     $opt_debug
     f_ex_an_ar_dir="$1"; shift
@@ -1002,12 +1021,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"
@@ -2596,10 +2623,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
 	    ;;
@@ -3149,10 +3177,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"
@@ -4075,10 +4120,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
@@ -4656,12 +4712,17 @@
 		  ;;
 		esac
 	      fi
 	      if test -n "$a_deplib" ; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
+		if test -n "$file_magic_glob"; then
+		  libnameglob=`$ECHO "X$libname" | $Xsed -e $file_magic_glob`
+		else
+		  libnameglob=$libname
+		fi
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  potential_libs=`ls $i/$libname[[.-]]* 2>/dev/null`
+		  potential_libs=`ls $i/$libnameglob[[.-]]* 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
@@ -4680,11 +4741,18 @@
 			esac
 		      done
 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
 			 $SED -e 10q |
 			 $EGREP "$file_magic_regex" > /dev/null; then
-			newdeplibs="$newdeplibs $a_deplib"
+			case $with_gcc/$host in
+			no/*-*-mingw* | /*-*-mingw* | no/*-*-cygwin* | /*-*-cygwin*)
+			  newdeplibs="$newdeplibs ${name}.lib"
+			  ;;
+			*)
+			  newdeplibs="$newdeplibs $a_deplib"
+			  ;;
+			esac
 			a_deplib=""
 			break 2
 		      fi
 		  done
 		done
@@ -5680,11 +5748,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>
@@ -5732,15 +5802,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);
@@ -5844,10 +5918,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) ||
@@ -5858,10 +5935,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.58
diff -u -u -5 -r1.125.2.58 libtool.m4
--- m4/libtool.m4	6 Jun 2005 16:13:23 -0000	1.125.2.58
+++ m4/libtool.m4	9 Jun 2005 11:45:22 -0000
@@ -1816,10 +1816,12 @@
       ;;
     esac
     ;;
 
   *)
+    # Assume MSVC
+    libname_spec='$name'
     library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
     ;;
   esac
   dynamic_linker='Win32 ld.exe'
   # FIXME: first we should search . and the directory the executable is in
@@ -2648,18 +2650,30 @@
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 esac
 ])
+
+case $host_os in
+cygwin* | mingw* | pw32*)
+  file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | sed -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
+  ;;
+*)
+  file_magic_glob=
+  ;;
+esac
+
 file_magic_cmd=$lt_cv_file_magic_cmd
 deplibs_check_method=$lt_cv_deplibs_check_method
 test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 _LT_DECL([], [deplibs_check_method], [1],
     [Method to check whether dependent libraries are shared objects])
 _LT_DECL([], [file_magic_cmd], [1],
     [Command to use when deplibs_check_method == "file_magic"])
+_LT_DECL([], [file_magic_glob], [1],
+    [How to find potential files when deplibs_check_method == "file_magic"])
 ])# _LT_CHECK_MAGIC_METHOD
 
 
 # LT_PATH_NM
 # ----------
@@ -3941,17 +3955,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"`'
+      # FIXME: Should let the user specify the link program.
+      _LT_TAGVAR(old_archive_cmds, $1)='link -LIB -NOLOGO -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]])
