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	17 Jun 2005 13:11:37 -0000
@@ -626,10 +626,40 @@
   esac
   $ECHO "$win32_libid_type"
 }
 
 
+# func_msvc_dashL_to_LINK deplibs_variable deplibs...
+func_msvc_dashL_to_LINK ()
+{
+  $opt_debug
+  # weed out -L options
+  deplibs_variable="$1"
+  shift
+  tmp_libs=
+  for deplib in $@; do
+    case $deplib in
+    -L*)
+      deplib="$($ECHO "X${deplib}" | $Xsed -e 's/^-L//')"
+      case $host_os in
+      mingw*)
+	LINK="$LINK -LIBPATH:$(cmd \\/C echo "$deplib " | sed -e "s/\"\(.*\) \" /\1/")"
+	;;
+      *)
+	LINK="$LINK -LIBPATH:`cygpath -w "$deplib"`"
+	;;
+      esac
+      ;;
+    *)  
+      tmp_libs="$tmp_libs $deplib"
+      ;;
+    esac
+  done
+  eval $deplibs_variable=\"$tmp_libs\"
+}
+
+
 
 # func_infer_tag arg
 # Infer tagged configuration to use if any are available and
 # if one wasn't chosen via the "--tag" command line option.
 # Only attempt this if the compiler in the base compile
@@ -929,13 +959,21 @@
 func_extract_an_archive ()
 {
     $opt_debug
     f_ex_an_ar_dir="$1"; shift
     f_ex_an_ar_oldlib="$1"
-    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
-    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
-    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+    if test "X$ar_extract_one_by_one" != "Xyes"; then
+      $show "(cd $f_ex_an_ar_dir && $AR ${AR_XFLAGS}$f_ex_an_ar_oldlib)"
+      $run eval "(cd \$f_ex_an_ar_dir && $AR ${AR_XFLAGS}\$f_ex_an_ar_oldlib)" || exit $?
+    else
+      $AR ${AR_LFLAGS}"$f_ex_an_ar_oldlib" | while read name
+      do
+        $show "(cd $f_ex_an_ar_dir && $AR ${AR_XFLAGS}$name $f_ex_an_ar_oldlib)"
+        $run eval "(cd \$f_ex_an_ar_dir && $AR ${AR_XFLAGS}\$name \$f_ex_an_ar_oldlib)" || exit $?
+      done
+    fi
+    if ($AR ${AR_LFLAGS}"$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
      :
     else
      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
     fi
 }
@@ -2596,10 +2634,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
 	    ;;
@@ -4075,10 +4114,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 +4706,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 +4735,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
@@ -5184,10 +5246,17 @@
 
 	  func_extract_archives $gentop $dlprefiles
 	  libobjs="$libobjs $func_extract_archives_result"
 	fi
 
+	case $host_os/$with_gcc/$pass in
+	  mingw*/no/link | mingw*//link | cygwin*/no/link | cygwin*//link)
+	    # assume MSVC
+	    func_msvc_dashL_to_LINK deplibs $deplibs
+	  ;;
+	esac
+
 	save_ifs="$IFS"; IFS='~'
 	for cmd in $cmds; do
 	  IFS="$save_ifs"
 	  eval cmd=\"$cmd\"
 	  func_quote_for_expand "$cmd"
@@ -5394,10 +5463,17 @@
 	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
 	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
 	;;
       esac
 
+      case $host_os/$with_gcc/$pass in
+        mingw*/no/link | mingw*//link | cygwin*/no/link | cygwin*//link)
+	  # assume MSVC
+	  func_msvc_dashL_to_LINK compile_deplibs $compile_deplibs
+	;;
+      esac
+
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 
       if test -n "$rpath$xrpath"; then
 	# If the user specified any rpath flags, then add them.
@@ -5680,11 +5756,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 +5810,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 +5926,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 +5943,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 *
@@ -6008,11 +6094,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 $LTCFLAGS -s -o $cwrapper $cwrappersource
+	  if test "$with_gcc" = "yes"; then
+	    $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
+	  else
+	    $run $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+	  fi
 	  ;;
 	esac
 	$RM $output
 	trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
 
Index: m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/libtool.m4,v
retrieving revision 1.125.2.60
diff -u -u -5 -r1.125.2.60 libtool.m4
--- m4/libtool.m4	11 Jun 2005 11:02:52 -0000	1.125.2.60
+++ m4/libtool.m4	17 Jun 2005 13:11:37 -0000
@@ -995,18 +995,62 @@
 
 need_locks="$enable_libtool_lock"
 ])# _LT_ENABLE_LOCK
 
 
+# LT_PROG_AR
+# ----------
+m4_defun([LT_PROG_AR],
+[AC_CHECK_TOOLS(AR, [ar lib "link -lib"], false)
+test -z "$AR" && AR=ar
+_LT_DECL([], [AR], [1], [The archiver])
+
+AC_CACHE_CHECK([the archiver ($AR) interface],[lt_cv_ar_interface],
+  [lt_cv_ar_interface="ar"
+  printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+  (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval "$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext" &>conftest.err)
+  ac_status=$?
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  if test $ac_status = 0 -a -f conftest.lib; then
+    lt_cv_ar_interface="lib"
+  fi
+  rm -f conftest*])
+
+case $lt_cv_ar_interface in
+ar)
+  test -z "$AR_FLAGS" && AR_FLAGS=cru
+  test -z "$AR_LFLAGS" && AR_LFLAGS=t
+  test -z "$AR_XFLAGS" && AR_XFLAGS=x
+  AR_FLAGS="$AR_FLAGS "
+  AR_LFLAGS="$AR_LFLAGS "
+  AR_XFLAGS="$AR_XFLAGS "
+  _LT_TAGVAR(ar_extract_one_by_one, $1)=no
+  ;;
+lib)
+  test -z "$AR_FLAGS" && AR_FLAGS="-NOLOGO -OUT:"
+  test -z "$AR_LFLAGS" && AR_LFLAGS="-NOLOGO -LIST "
+  test -z "$AR_XFLAGS" && AR_XFLAGS="-NOLOGO -EXTRACT:"
+  _LT_TAGVAR(ar_extract_one_by_one, $1)=yes
+  ;;
+esac
+
+_LT_DECL([], [ar_extract_one_by_one], [1],
+  [Extract archive members one by one])
+
+_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
+_LT_DECL([], [AR_LFLAGS], [1], [Flags to list archive content])
+_LT_DECL([], [AR_XFLAGS], [1], [Flags to extract an archive])
+])# LT_PROG_AR
+
+
 # _LT_CMD_OLD_ARCHIVE
 # -------------------
 m4_defun([_LT_CMD_OLD_ARCHIVE],
-[AC_CHECK_TOOL(AR, ar, false)
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-_LT_DECL([], [AR], [1], [The archiver])
-_LT_DECL([], [AR_FLAGS], [1])
+[LT_PROG_AR
 
 AC_CHECK_TOOL(STRIP, strip, :)
 test -z "$STRIP" && STRIP=:
 _LT_DECL([], [STRIP], [1], [A symbol stripping program])
 
@@ -1014,11 +1058,11 @@
 test -z "$RANLIB" && RANLIB=:
 _LT_DECL([], [RANLIB], [1],
     [Commands used to install an old-style archive])
 
 # Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_archive_cmds='$AR $AR_FLAGS$oldlib$oldobjs$old_deplibs'
 old_postinstall_cmds='chmod 644 $oldlib'
 old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
@@ -1096,11 +1140,11 @@
   [$2=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $3"
    printf "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The compiler can only warn and ignore the option if not recognized
+     # The linker can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&AS_MESSAGE_LOG_FD
      else
@@ -1818,11 +1862,19 @@
       ;;
     esac
     ;;
 
   *)
+    # Assume MSVC
+    libname_spec='$name'
     library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
     ;;
   esac
   dynamic_linker='Win32 ld.exe'
   # FIXME: first we should search . and the directory the executable is in
   shlibpath_var=PATH
@@ -2650,18 +2702,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
 # ----------
@@ -3943,17 +4007,21 @@
       # 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 $deplibs -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 $deplibs -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"`'
+      case $host_os in
+	# Not needed on MinGW
+	cygwin*) _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' ;;
+      esac
       _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]])
