another patch from Kenneth Haley for Mingw, c.f. #128787 Daniel

* configure.in Makefile.am: another patch from Kenneth Haley
  for Mingw, c.f. #128787
Daniel
diff --git a/ChangeLog b/ChangeLog
index 88cb17e..2dc61e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Dec  9 15:18:32 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+	* configure.in Makefile.am: another patch from Kenneth Haley
+	  for Mingw, c.f. #128787
+
 Tue Dec  9 15:07:09 CET 2003 Daniel Veillard <daniel@veillard.com>
 
 	* include/libxml/xmlexports.h: applied patch from Kenneth Haley
diff --git a/Makefile.am b/Makefile.am
index cedd520..d40f253 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@
 bin_SCRIPTS=xml2-config
 
 lib_LTLIBRARIES = libxml2.la
-libxml2_la_LIBADD = @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm
+libxml2_la_LIBADD = @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
 
 libxml2_la_LDFLAGS = -version-info @LIBXML_VERSION_INFO@
 
@@ -40,7 +40,7 @@
 endif
 
 DEPS = $(top_builddir)/libxml2.la
-LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
+LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
 
 
 man_MANS = xml2-config.1 libxml.3
@@ -78,7 +78,7 @@
 testC14N_DEPENDENCIES = $(DEPS)
 testC14N_LDADD= $(LDADDS)
 
-testThreads_SOURCES=testThreads.c
+testThreads_SOURCES=testThreads@THREADS_W32@.c
 testThreads_LDFLAGS = 
 testThreads_DEPENDENCIES = $(DEPS)
 testThreads_LDADD= $(LDADDS)
diff --git a/configure.in b/configure.in
index fd6ac34..079c646 100644
--- a/configure.in
+++ b/configure.in
@@ -39,6 +39,7 @@
 AM_C_PROTOTYPES
 test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant)
 
+AC_LIBTOOL_WIN32_DLL
 AM_PROG_LIBTOOL
 
 # AM_MAINTAINER_MODE
@@ -248,7 +249,7 @@
 dnl ******************************End IPv6 checks******************************
 
 dnl Checks for isnan in libm if not in libc
-AC_CHECK_FUNC(isnan, , AC_CHECK_LIB(m, isnan,
+AC_CHECK_FUNC(isnan, AC_DEFINE([HAVE_ISNAN],[], [Define if isnan is there]) , AC_CHECK_LIB(m, isnan,
   [AC_DEFINE([HAVE_ISNAN],[], [Define if isnan is there])]))
 
 AC_CHECK_FUNC(isinf, AC_DEFINE([HAVE_ISINF], [], [Define if isinf is there]) , AC_CHECK_LIB(m, isinf,
@@ -458,6 +459,7 @@
 WITH_THREADS=0
 THREAD_CFLAGS=""
 TEST_THREADS=""
+THREADS_W32=""
 
 AC_ARG_WITH(threads,
 [  --with-threads          add multithread support(on)])
@@ -476,7 +478,12 @@
 	   AC_DEFINE([HAVE_LIBPTHREAD], [], [Define if pthread library is there (-lpthread)])
 	   AC_DEFINE([HAVE_PTHREAD_H], [], [Define if <pthread.h> is there])
 	   WITH_THREADS="1"]))
-
+    case $host_os in
+       *mingw32*) WITH_THREADS="1"
+           THREADS_W32="Win32"
+	   THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
+       ;;
+    esac
     if test "$WITH_THREADS" = "1" ; then
 	THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
 	TEST_THREADS="Threadtests"
@@ -496,6 +503,7 @@
 AC_SUBST(WITH_THREADS)
 AC_SUBST(THREAD_CFLAGS)
 AC_SUBST(TEST_THREADS)
+AC_SUBST(THREADS_W32)
 
 AC_ARG_WITH(history,
 [  --with-history          add history support to xmllint shell(off)])
@@ -905,7 +913,12 @@
 		LIBS="${_libs}"
 		LDFLAGS="${_ldflags}"])]))
 fi
-M_LIBS="-lm"
+case "$host" in
+	*mingw*) M_LIBS=""
+	;;
+	*) M_LIBS="-lm"
+	;;
+esac
 XML_LIBS="-lxml2 $Z_LIBS $THREAD_LIBS $ICONV_LIBS $M_LIBS $LIBS"
 XML_LIBTOOLLIBS="libxml2.la"
 AC_SUBST(WITH_ICONV)
@@ -1000,7 +1013,8 @@
 WIN32_EXTRA_LDFLAGS=
 case "$host" in
  *-*-mingw*)
- WIN32_EXTRA_LIBADD="-lwsock32"
+ CPPFLAGS="$CPPFLAGS -DWIN32"
+ WIN32_EXTRA_LIBADD="-lws2_32"
  WIN32_EXTRA_LDFLAGS="-no-undefined"
  AC_DEFINE([_WINSOCKAPI_],1,[Using the Win32 Socket implementation])
  AC_DEFINE([snprintf],[_snprintf],[Win32 Std C name mangling work-around])
@@ -1010,7 +1024,7 @@
 AC_SUBST(WIN32_EXTRA_LIBADD)
 AC_SUBST(WIN32_EXTRA_LDFLAGS)
 
-
+AC_SUBST(CPPFLAGS)
 AC_SUBST(CFLAGS)
 AC_SUBST(XML_CFLAGS)