integrated mingw into jscript configure
diff --git a/win32/Makefile.mingw b/win32/Makefile.mingw
index c6b297a..a812156 100644
--- a/win32/Makefile.mingw
+++ b/win32/Makefile.mingw
@@ -1,175 +1,336 @@
-# This Makefile will allow you to build the static library, a DLL, the

-# DLL-import library, and the test executables using the "mingw" gcc

-# compiler environment.  This Makefile is based on Alfred Reibenschuh's

-# version for 2.1.1, and was modified by Wayne Davison.

-# Modified 2001/10/10 Tobias Peters for libxml2-2.4.5

-# Modified 2002/07/12 Elizabeth Barham for libxml2.4.23

-

-# Set "PREFIX" to the root of the mingw installed files.

-

-# PREFIX = /mingw

-PREFIX = F:\WIN98\PROGR~-I\DEV-C~QN

-

-CC       = gcc

-CFLAGS   = -Iinclude -fnative-struct -D_WINSOCKAPI_ \

-           -Dsnprintf=_snprintf -Dvsnprintf=_vsnprintf \

-           -DLIBXML_THREAD_ENABLED

-LDFLAGS  = -L. -L$(PREFIX)\lib

-LIBS     = -lwsock32 -lz -liconv_dll

-

-AR=ar rc

-DLLTOOL=dlltool

-DLLWRAP=dllwrap

-

-

-LIBSRCS=SAX.c entities.c encoding.c error.c parserInternals.c  \

-		parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c  \

-		valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c  \

-		xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \

-                catalog.c c14n.c threads.c xmlschemastypes.c xmlschemas.c \

-                xmlregexp.c xmlunicode.c globals.c

-

-#                strio.c

-

-LIBOBJS=$(LIBSRCS:.c=.o)

-

-OBJS=$(LIBOBJS)

-

-LIBBASE=xml

-LIB=lib$(LIBBASE).a

-DLL=$(LIB:.a=.dll)

-

-OBJ1=testHTML.o

-OBJ2=testSAX.o

-OBJ3=testURI.o

-OBJ4=testSchemas.o

-OBJ5=testAutomata.o

-OBJ6=testC14N.o

-OBJ7=testDocbook.o

-OBJ8=testRegexp.o

-OBJ9=testThreadsWin32.o

-OBJ10=testXPath.o

-OBJ11=xmllint.o

-EXE1=$(OBJ1:.o=.exe)

-EXE2=$(OBJ2:.o=.exe)

-EXE3=$(OBJ3:.o=.exe)

-EXE4=$(OBJ4:.o=.exe)

-EXE5=$(OBJ5:.o=.exe)

-EXE6=$(OBJ6:.o=.exe)

-EXE7=$(OBJ7:.o=.exe)

-EXE8=$(OBJ8:.o=.exe)

-EXE9=$(OBJ9:.o=.exe)

-EXE10=$(OBJ10:.o=.exe)

-EXE11=$(OBJ11:.o=.exe)

-

-IMPBASE=$(LIBBASE)_dll

-IMP=lib$(IMPBASE).a

-

-DLLFLAGS = --shared -o $(DLL) -Wl,--out-implib,$(IMP)

-

-DEF=$(DLL:.dll=.def)

-

-all: $(LIB) $(DLL) $(DEF) $(IMP) $(EXE1) $(EXE2) $(EXE3) $(EXE4) $(EXE5) \

-        $(EXE6) $(EXE7) $(EXE8) $(EXE9) $(EXE10) $(EXE11)

-

-dll: $(DLL)

-

-lib: $(LIB)

-

-$(DLL) $(IMP): $(LIBOBJS)

-	$(CC) $(DLLFLAGS) $(LIBOBJS) $(LDFLAGS) $(LIBS)

-# -mwindows

-

-$(LIB): $(LIBOBJS)

-	$(AR) $@ $^

-

-$(DEF): $(LIBOBJS)

-	$(DLLTOOL) --kill-at --export-all -D $(DLL) --output-def $@ $^

-

-$(EXE1): $(OBJ1) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE2): $(OBJ2) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE3): $(OBJ3) $(LIB)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(LIBBASE) $(LIBS)

-	strip $@

-

-$(EXE4): $(OBJ4) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE5): $(OBJ5) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE6): $(OBJ6) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE7): $(OBJ7) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE8): $(OBJ8) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE9): $(OBJ9) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE10): $(OBJ10) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(EXE11): $(OBJ11) $(DLL)

-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -l$(IMPBASE) $(LIBS)

-	strip $@

-

-$(OBJ1): $(OBJ1:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ2): $(OBJ2:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ3): $(OBJ3:.o=.c)

-	$(CC) $(CFLAGS) -c $< -o $@

-

-$(OBJ4): $(OBJ4:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ5): $(OBJ5:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ6): $(OBJ6:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ7): $(OBJ7:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ8): $(OBJ8:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ9): $(OBJ9:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ10): $(OBJ10:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-$(OBJ11): $(OBJ11:.o=.c)

-	$(CC) $(CFLAGS) -DLIBXML_DLL_IMPORT=__declspec'(dllimport)' -c $< -o $@

-

-

-

-.c.o:

-	$(CC) $(CFLAGS) -DIN_LIBXML -c $< -o $@	

-

-clean:

-	rm *.o *.a *.dll *.def

-

-test: all

-	./$(EXE1)	-c $(OBJS) | xxd | head -3

+# Makefile for libxml2, specific for Windows, GCC (mingw) and GNU make.
+#
+# Take a look at the beginning and modify the variables to suit your 
+# environment. Having done that, you can do a
+#
+# nmake [all]     to build the libxml and the accompanying utilities.
+# nmake clean     to remove all compiler output files and return to a
+#                 clean state.
+# nmake rebuild   to rebuild everything from scratch. This basically does
+#                 a 'nmake clean' and then a 'nmake all'.
+# nmake install   to install the library and its header files.
+#
+# November 2002, Igor Zlatkovic <igor@stud.fh-frankfurt.de>
+
+AUTOCONF = .\config.mingw
+
+# If you cannot run the configuration script, which would take the burden of
+# editing this file from your back, then remove the following line...
+include $(AUTOCONF)
+# ...and enable the following lines and adapt them to your environment.
+#XML_SRCDIR = ..
+#UTILS_SRCDIR = ..
+#BINDIR = binaries
+#LIBXML_MAJOR_VERSION = 0 # set this to the right value.
+#LIBXML_MINOR_VERSION = 0 # set this to the right value.
+#LIBXML_MICRO_VERSION = 0 # set this to the right value.
+#WITH_TRIO = 0
+#WITH_THREADS = 0
+#WITH_FTP = 1
+#WITH_HTTP = 1
+#WITH_HTML = 1
+#WITH_C14N = 1
+#WITH_CATALOG = 1
+#WITH_DOCB = 1
+#WITH_XPATH = 1
+#WITH_XPTR = 1
+#WITH_XINCLUDE = 1
+#WITH_ICONV = 1
+#WITH_ZLIB = 0
+#WITH_DEBUG = 1
+#WITH_MEM_DEBUG = 0
+#WITH_SCHEMAS = 1
+#DEBUG = 0
+#STATIC = 0
+#PREFIX = . # set this to the right value.
+#BINPREFIX = $(PREFIX)\bin
+#INCPREFIX = $(PREFIX)\include
+#LIBPREFIX = $(PREFIX)\lib
+#SOPREFIX = $(PREFIX)\lib
+#INCLUDE += ;$(INCPREFIX)
+#LIB += ;$(LIBPREFIX) 
+
+
+# There should never be a need to modify anything below this line.
+# ----------------------------------------------------------------
+
+
+# Names of various input and output components.
+XML_NAME = xml2
+XML_BASENAME = lib$(XML_NAME)
+XML_SO = $(XML_BASENAME).dll
+XML_IMP = $(XML_BASENAME).lib
+XML_A = $(XML_BASENAME).a
+
+# Place where we let the compiler put its intermediate trash.
+XML_INTDIR = $(XML_BASENAME).int
+XML_INTDIR_A = $(XML_BASENAME)_a.int
+UTILS_INTDIR = utils.int
+
+# The preprocessor and its options.
+CPP = gcc.exe -E
+CPPFLAGS += -I$(XML_SRCDIR)/include
+ifeq ($(WITH_THREADS),1)
+CPPFLAGS += -D_REENTRANT
+endif
+
+# The compiler and its options.
+CC = gcc.exe
+CFLAGS += -DWIN32 -D_WINDOWS -D_MBCS
+CFLAGS += -I$(XML_SRCDIR) -I$(XML_SRCDIR)/include -I$(INCPREFIX)
+ifneq ($(WITH_THREADS),no)
+CFLAGS += -D_REENTRANT
+endif
+ifeq ($(WITH_THREADS),yes) 
+CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
+endif
+ifeq ($(WITH_THREADS),ctls)
+CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
+endif
+ifeq ($(WITH_THREADS),native)
+CFLAGS += -DHAVE_WIN32_THREADS
+endif
+ifeq ($(WITH_THREADS),posix)
+CFLAGS += -DHAVE_PTHREAD_H
+endif
+ifeq ($(WITH_ZLIB),1)
+CFLAGS += -DHAVE_ZLIB_H
+endif
+
+# The linker and its options.
+LD = gcc.exe
+LDFLAGS += -Wl,--major-image-version,$(LIBXML_MAJOR_VERSION)
+LDFLAGS += -Wl,--minor-image-version,$(LIBXML_MINOR_VERSION)
+LDFLAGS += -Wl,-L,$(BINDIR) -Wl,-L,$(LIBPREFIX)
+LIBS = 
+ifeq ($(WITH_FTP),1)
+CFLAGS += -D_WINSOCKAPI_
+LIBS += -lwsock32
+endif 
+ifeq ($(WITH_HTTP),1)
+CFLAGS += -D_WINSOCKAPI_
+LIBS += -lwsock32
+endif 
+ifeq ($(WITH_ICONV),1)
+LIBS += -liconv
+endif 
+ifeq ($(WITH_ZLIB),1)
+LIBS += -lzlib
+endif
+ifeq ($(WITH_THREADS),posix)
+LIBS += -lpthreadGC
+endif
+
+# The archiver and its options.
+AR = ar.exe
+ARFLAGS = -r
+
+# Optimisation and debug symbols.
+ifeq ($(DEBUG),1)
+CFLAGS += -D_DEBUG -g
+LDFLAGS += 
+else
+CFLAGS += -DNDEBUG -O2 
+LDFLAGS += 
+endif
+
+
+# Libxml object files.
+XML_OBJS = $(XML_INTDIR)/c14n.o\
+	$(XML_INTDIR)/catalog.o\
+	$(XML_INTDIR)/debugXML.o\
+	$(XML_INTDIR)/DOCBparser.o\
+	$(XML_INTDIR)/encoding.o\
+	$(XML_INTDIR)/entities.o\
+	$(XML_INTDIR)/error.o\
+	$(XML_INTDIR)/globals.o\
+	$(XML_INTDIR)/hash.o\
+	$(XML_INTDIR)/HTMLparser.o\
+	$(XML_INTDIR)/HTMLtree.o\
+	$(XML_INTDIR)/list.o\
+	$(XML_INTDIR)/nanoftp.o\
+	$(XML_INTDIR)/nanohttp.o\
+	$(XML_INTDIR)/parser.o\
+	$(XML_INTDIR)/parserInternals.o\
+	$(XML_INTDIR)/SAX.o\
+	$(XML_INTDIR)/threads.o\
+	$(XML_INTDIR)/tree.o\
+	$(XML_INTDIR)/uri.o\
+	$(XML_INTDIR)/valid.o\
+	$(XML_INTDIR)/xinclude.o\
+	$(XML_INTDIR)/xlink.o\
+	$(XML_INTDIR)/xmlIO.o\
+	$(XML_INTDIR)/xmlmemory.o\
+	$(XML_INTDIR)/xmlregexp.o\
+	$(XML_INTDIR)/xmlschemas.o\
+	$(XML_INTDIR)/xmlschemastypes.o\
+	$(XML_INTDIR)/xmlunicode.o\
+	$(XML_INTDIR)/xpath.o\
+	$(XML_INTDIR)/xpointer.o
+
+XML_SRCS = $(subst .o,.c,$(subst $(XML_INTDIR)/,$(XML_SRCDIR)/,$(XML_OBJS)))
+
+# Static libxml object files.
+XML_OBJS_A = $(XML_INTDIR_A)/c14n.o\
+	$(XML_INTDIR_A)/catalog.o\
+	$(XML_INTDIR_A)/debugXML.o\
+	$(XML_INTDIR_A)/DOCBparser.o\
+	$(XML_INTDIR_A)/encoding.o\
+	$(XML_INTDIR_A)/entities.o\
+	$(XML_INTDIR_A)/error.o\
+	$(XML_INTDIR_A)/globals.o\
+	$(XML_INTDIR_A)/hash.o\
+	$(XML_INTDIR_A)/HTMLparser.o\
+	$(XML_INTDIR_A)/HTMLtree.o\
+	$(XML_INTDIR_A)/list.o\
+	$(XML_INTDIR_A)/nanoftp.o\
+	$(XML_INTDIR_A)/nanohttp.o\
+	$(XML_INTDIR_A)/parser.o\
+	$(XML_INTDIR_A)/parserInternals.o\
+	$(XML_INTDIR_A)/SAX.o\
+	$(XML_INTDIR_A)/threads.o\
+	$(XML_INTDIR_A)/tree.o\
+	$(XML_INTDIR_A)/uri.o\
+	$(XML_INTDIR_A)/valid.o\
+	$(XML_INTDIR_A)/xinclude.o\
+	$(XML_INTDIR_A)/xlink.o\
+	$(XML_INTDIR_A)/xmlIO.o\
+	$(XML_INTDIR_A)/xmlmemory.o\
+	$(XML_INTDIR_A)/xmlregexp.o\
+	$(XML_INTDIR_A)/xmlschemas.o\
+	$(XML_INTDIR_A)/xmlschemastypes.o\
+	$(XML_INTDIR_A)/xmlunicode.o\
+	$(XML_INTDIR_A)/xpath.o\
+	$(XML_INTDIR_A)/xpointer.o
+
+XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A)))
+
+# Xmllint and friends executables.
+UTILS = $(BINDIR)/xmllint.exe\
+	$(BINDIR)/xmlcatalog.exe\
+	$(BINDIR)/testAutomata.exe\
+	$(BINDIR)/testC14N.exe\
+	$(BINDIR)/testDocbook.exe\
+	$(BINDIR)/testHTML.exe\
+	$(BINDIR)/testRegexp.exe\
+	$(BINDIR)/testSAX.exe\
+	$(BINDIR)/testSchemas.exe\
+	$(BINDIR)/testURI.exe\
+	$(BINDIR)/testXPath.exe
+ifeq ($(WITH_THREADS),yes)
+UTILS += $(BINDIR)/testThreadsWin32.exe
+endif
+ifeq ($(WITH_THREADS),ctls) 
+UTILS += $(BINDIR)/testThreadsWin32.exe
+endif
+ifeq ($(WITH_THREADS),native)
+UTILS += $(BINDIR)/testThreadsWin32.exe
+endif
+ifeq ($(WITH_THREADS),posix)
+UTILS += $(BINDIR)/testThreads.exe
+endif
+
+all : dep libxml libxmla utils
+
+libxml : $(BINDIR)/$(XML_SO) 
+
+libxmla : $(BINDIR)/$(XML_A)
+
+utils : $(UTILS)
+
+clean :
+	if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)
+	if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)
+	if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
+	if exist $(BINDIR) rmdir /S /Q $(BINDIR)
+	if exist depends.mingw del depends.mingw
+
+distclean : clean
+	if exist config.* del config.*
+	if exist Makefile del Makefile
+
+rebuild : clean all
+
+install : all
+	if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml
+	if not exist $(BINPREFIX) mkdir $(BINPREFIX)
+	if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
+	copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml
+	copy $(BINDIR)\$(XML_SO) $(SOPREFIX)
+	copy $(BINDIR)\$(XML_A) $(LIBPREFIX)
+	copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)
+	copy $(BINDIR)\*.exe $(BINPREFIX)
+
+# This is a target for me, to make a binary distribution. Not for the public use,
+# keep your hands off :-)
+BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION)
+BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32
+bindist : all
+	$(MAKE) PREFIX=$(BDPREFIX) BINPREFIX=$(BDPREFIX)/util install
+	cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
+
+
+# Creates the dependency file
+dep :
+	$(CC) $(CFLAGS) -M $(XML_SRCS) > depends.mingw
+
+
+# Makes the output directory.
+$(BINDIR) :
+	if not exist $(BINDIR) mkdir $(BINDIR)
+
+
+# Makes the libxml intermediate directory.
+$(XML_INTDIR) :
+	if not exist $(XML_INTDIR) mkdir $(XML_INTDIR)
+
+# Makes the static libxml intermediate directory.
+$(XML_INTDIR_A) :
+	if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A)
+
+# An implicit rule for libxml compilation.
+$(XML_INTDIR)/%.o : $(XML_SRCDIR)/%.c
+	$(CC) $(CFLAGS) -o $@ -c $<
+
+# An implicit rule for static libxml compilation.
+$(XML_INTDIR_A)/%.o : $(XML_SRCDIR)/%.c
+	$(CC) $(CFLAGS) -DLIBXML_STATIC -o $@ -c $<
+
+
+# Compiles libxml source. Uses the implicit rule for commands.
+$(XML_OBJS) : $(XML_INTDIR)
+
+# Compiles static libxml source. Uses the implicit rule for commands.
+$(XML_OBJS_A) : $(XML_INTDIR_A) 
+
+# Creates the libxml shared object.
+XMLSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XML_IMP)
+$(BINDIR)/$(XML_SO) : $(BINDIR) $(XML_OBJS)
+	$(LD) $(XMLSO_LDFLAGS) -o $(BINDIR)/$(XML_SO) $(XML_OBJS) $(LIBS)
+
+# Creates the libxml archive.
+$(BINDIR)/$(XML_A) : $(BINDIR) $(XML_OBJS_A)
+	$(AR) $(ARFLAGS) $(BINDIR)\$(XML_A) $(XML_OBJS_A)
+
+
+# Makes the utils intermediate directory.
+$(UTILS_INTDIR) :
+	if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
+
+# An implicit rule for xmllint and friends.
+ifeq ($(STATIC),1)
+$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
+	$(CC) -DLIBXML_STATIC $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $< 
+	$(LD) $(LDFLAGS) -o $@ -l$(XML_BASENAME) $(LIBS) $(subst .c,.o,$(UTILS_INTDIR)/$(<F))
+else
+$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
+	$(CC) $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $< 
+	$(LD) $(LDFLAGS) -o $@ -l$(XML_BASENAME) $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) 
+endif
+
+# Builds xmllint and friends. Uses the implicit rule for commands.
+$(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxml libxmla
+
+# Source dependencies
+#-include depends.mingw
+
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index 2a236a6..682b45a 100644
--- a/win32/Makefile.msvc
+++ b/win32/Makefile.msvc
@@ -12,7 +12,7 @@
 #
 # March 2002, Igor Zlatkovic <igor@stud.fh-frankfurt.de>
 
-AUTOCONF = .\configure.txt
+AUTOCONF = .\config.msvc
 
 # If you cannot run the configuration script, which would take the burden of
 # editing this file from your back, then remove the following line...
@@ -222,6 +222,10 @@
 	if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
 	if exist $(BINDIR) rmdir /S /Q $(BINDIR)
 
+distclean : clean
+	if exist config.* del config.*
+	if exist Makefile del Makefile
+
 rebuild : clean all
 
 install : all
diff --git a/win32/configure.js b/win32/configure.js
index 662c26c..b9d7ecc 100644
--- a/win32/configure.js
+++ b/win32/configure.js
@@ -17,7 +17,7 @@
 /* Configure file which contains the version and the output file where
    we can store our build configuration. */
 var configFile = srcDirXml + "\\configure.in";
-var versionFile = ".\\configure.txt";
+var versionFile = ".\\config.msvc";
 /* Input and output files regarding the libxml features. The second
    output file is there for the compatibility reasons, otherwise it
    is identical to the first. */
@@ -47,6 +47,7 @@
 var withSchemas = true;
 var withRegExps = true;
 /* Win32 build options. */
+var compiler = "msvc";
 var buildDebug = 0;
 var buildStatic = 0;
 var buildPrefix = ".";
@@ -92,7 +93,7 @@
 	txt += "  cscript " + WScript.ScriptName + " help\n\n";
 	txt += "Options can be specified in the form <option>=<value>, where the value is\n";
 	txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
-	txt += "XML processor options, default value given in parentheses:\n\n";
+	txt += "\nXML processor options, default value given in parentheses:\n\n";
 	txt += "  trio:       Enable TRIO string manipulator (" + (withTrio? "yes" : "no")  + ")\n";
 	txt += "  threads:    Enable thread safety [no|ctls|native|posix] (" + (withThreads)  + ") \n";
 	txt += "  ftp:        Enable FTP client (" + (withFtp? "yes" : "no")  + ")\n";
@@ -111,6 +112,7 @@
 	txt += "  regexps:    Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
 	txt += "  schemas:    Enable XML Schema support (" + (withSchemas? "yes" : "no")  + ")\n";
 	txt += "\nWin32 build options, default value given in parentheses:\n\n";
+	txt += "  compiler:   Compiler to be used [msvc|mingw] (" + compiler + ")\n";
 	txt += "  debug:      Build unoptimised debug executables (" + (buildDebug? "yes" : "no")  + ")\n";
 	txt += "  static:     Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no")  + ")\n";
 	txt += "  prefix:     Base directory for the installation (" + buildPrefix + ")\n";
@@ -137,6 +139,10 @@
 	var fso, cf, vf, ln, s;
 	fso = new ActiveXObject("Scripting.FileSystemObject");
 	cf = fso.OpenTextFile(configFile, 1);
+	if (compiler == "msvc")
+		versionFile = ".\\config.msvc";
+	else if (compiler == "mingw")
+		versionFile = ".\\config.mingw";
 	vf = fso.CreateTextFile(versionFile, true);
 	vf.WriteLine("# " + versionFile);
 	vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
@@ -183,8 +189,13 @@
 	vf.WriteLine("INCPREFIX=" + buildIncPrefix);
 	vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
 	vf.WriteLine("SOPREFIX=" + buildSoPrefix);
-	vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
-	vf.WriteLine("LIB=$(LIB);" + buildLib);
+	if (compiler == "msvc") {
+		vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
+		vf.WriteLine("LIB=$(LIB);" + buildLib);
+	} else if (compiler == "mingw") {
+		vf.WriteLine("INCLUDE+=;" + buildInclude);
+		vf.WriteLine("LIB+=;" + buildLib);
+	}
 	vf.Close();
 }
 
@@ -346,6 +357,8 @@
 			withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "regexps")
 			withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
+		else if (opt == "compiler")
+			compiler = arg.substring(opt.length + 1, arg.length);
 		else if (opt == "debug")
 			buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "static")
@@ -405,7 +418,10 @@
 
 // Create the makefile.
 var fso = new ActiveXObject("Scripting.FileSystemObject");
-fso.CopyFile(".\\Makefile.msvc", ".\\Makefile", true);
+var makefile = ".\\Makefile.msvc";
+if (compiler == "mingw")
+	makefile = ".\\Makefile.mingw";
+fso.CopyFile(makefile, ".\\Makefile", true);
 WScript.Echo("Created Makefile.");
 
 // Display the final configuration. 
@@ -431,6 +447,7 @@
 txtOut += "\n";
 txtOut += "Win32 build configuration\n";
 txtOut += "-------------------------\n";
+txtOut += "          Compiler: " + compiler + "\n";
 txtOut += "     Debug symbols: " + boolToStr(buildDebug) + "\n";
 txtOut += "    Static xmllint: " + boolToStr(buildStatic) + "\n";
 txtOut += "    Install prefix: " + buildPrefix + "\n";