diff -uprN libxml2-2.7.6/configure.in libxml2-2.7.6.az/configure.in --- libxml2-2.7.6/configure.in 2009-10-06 18:28:58 +0200 +++ libxml2-2.7.6.az/configure.in 2009-11-05 09:23:25 +0200 @@ -64,6 +64,22 @@ dnl Make sure we have an ANSI compiler AM_C_PROTOTYPES test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant) +dnl Are we building on Windows? +case ${host} in + dnl We support gcc compatible builds via autotools + *-*-mingw* | *-*-cygwin* | *-*-pw32* | *-*-cegcc*) + libxml_win32=yes + ;; + * ) + libxml_win32=no + ;; +esac + +dnl Default to shared building on Win32 +if test x"$libxml_win32" = xyes; then + AM_DISABLE_STATIC +fi + AC_LIBTOOL_WIN32_DLL AM_PROG_LIBTOOL @@ -668,20 +684,21 @@ case ${host} in hppa*-hp-mpeix) NEED_TRIO=1 ;; - *-*-mingw* | *-*-cygwin* | *-*-msvc* ) - # If the host is Windows, and shared libraries are disabled, we - # need to add -DLIBXML_STATIC to CFLAGS in order for linking to - # work properly (without it, xmlexports.h would force the use of - # DLL imports, which obviously aren't present in a static - # library). - if test "x$enable_shared" = "xno"; then - XML_CFLAGS="$XML_CFLAGS -DLIBXML_STATIC" - CFLAGS="$CFLAGS -DLIBXML_STATIC" - fi - ;; esac +WITH_STATIC=0 +if test "x$libxml_win32" = "xyes"; then + if test x$enable_static = xyes -a x$enable_shared = xyes; then + AC_MSG_ERROR([Can not build both shared and static at the same time on Windows.]) + fi + if test x$enable_static = xyes; then + WITH_STATIC=1 + fi +fi +AC_SUBST(WITH_STATIC) + + dnl dnl check for python dnl diff -uprN libxml2-2.7.6/elfgcchack.h libxml2-2.7.6.az/elfgcchack.h --- libxml2-2.7.6/elfgcchack.h 2009-09-24 17:31:59 +0200 +++ libxml2-2.7.6.az/elfgcchack.h 2009-11-05 09:23:25 +0200 @@ -45,7 +45,10 @@ #include "libxml/xlink.h" #include "libxml/xmlautomata.h" #include "libxml/xmlerror.h" +#if 0 +/* Included by xmlversion.h */ #include "libxml/xmlexports.h" +#endif #include "libxml/xmlIO.h" #include "libxml/xmlmemory.h" #include "libxml/xmlreader.h" diff -uprN libxml2-2.7.6/include/libxml/xmlexports.h libxml2-2.7.6.az/include/libxml/xmlexports.h --- libxml2-2.7.6/include/libxml/xmlexports.h 2009-09-24 17:31:59 +0200 +++ libxml2-2.7.6.az/include/libxml/xmlexports.h 2009-11-05 09:26:07 +0200 @@ -10,6 +10,10 @@ #ifndef __XML_EXPORTS_H__ #define __XML_EXPORTS_H__ +#ifndef __XML_VERSION_H__ +#error "Do not include directly." +#endif + /** * XMLPUBFUN, XMLPUBVAR, XMLCALL * @@ -56,17 +60,22 @@ #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL - #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) - #define XMLPUBFUN __declspec(dllexport) - #define XMLPUBVAR __declspec(dllexport) - #else - #define XMLPUBFUN - #if !defined(LIBXML_STATIC) - #define XMLPUBVAR __declspec(dllimport) extern - #else - #define XMLPUBVAR extern - #endif - #endif + #define XMLPUBFUN + #if defined(LIBXML_STATIC) + #define XMLPUBVAR extern + #else /* !LIBXML_STATIC */ + #if defined(IN_LIBXML) + #if defined(DLL_EXPORT) + #undef XMLPUBFUN + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else /* !DLL_EXPORT */ + #define XMLPUBVAR extern + #endif /* !DLL_EXPORT */ + #else /* !IN_LIBXML */ + #define XMLPUBVAR extern __declspec(dllimport) + #endif /* !IN_LIBXML */ + #endif /* !LIBXML_STATIC */ #if defined(LIBXML_FASTCALL) #define XMLCALL __fastcall #else @@ -84,17 +93,23 @@ #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL - #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) - #define XMLPUBFUN __declspec(dllexport) - #define XMLPUBVAR __declspec(dllexport) extern - #else - #define XMLPUBFUN - #if !defined(LIBXML_STATIC) - #define XMLPUBVAR __declspec(dllimport) extern - #else - #define XMLPUBVAR extern - #endif - #endif + #define XMLPUBFUN + #if defined(LIBXML_STATIC) + #define XMLPUBVAR extern + #else /* !LIBXML_STATIC */ + #if defined(IN_LIBXML) + #if defined(DLL_EXPORT) + #undef XMLPUBFUN + #define XMLPUBFUN __declspec(dllexport) + /* XXX: extern really needed? */ + #define XMLPUBVAR extern __declspec(dllexport) + #else /* !DLL_EXPORT */ + #define XMLPUBVAR extern + #endif /* !DLL_EXPORT */ + #else /* !IN_LIBXML */ + #define XMLPUBVAR extern __declspec(dllimport) + #endif /* !IN_LIBXML */ + #endif /* !LIBXML_STATIC */ #define XMLCALL __cdecl #define XMLCDECL __cdecl #if !defined _REENTRANT @@ -108,22 +123,22 @@ #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL - /* - * if defined(IN_LIBXML) this raises problems on mingw with msys - * _imp__xmlFree listed as missing. Try to workaround the problem - * by also making that declaration when compiling client code. - */ - #if !defined(LIBXML_STATIC) - #define XMLPUBFUN __declspec(dllexport) - #define XMLPUBVAR __declspec(dllexport) - #else - #define XMLPUBFUN - #if !defined(LIBXML_STATIC) - #define XMLPUBVAR __declspec(dllimport) extern - #else - #define XMLPUBVAR extern - #endif - #endif + #define XMLPUBFUN + #if defined(LIBXML_STATIC) + #define XMLPUBVAR extern + #else /* !LIBXML_STATIC */ + #if defined(IN_LIBXML) + #if defined(DLL_EXPORT) + #undef XMLPUBFUN + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else /* !DLL_EXPORT */ + #define XMLPUBVAR extern + #endif /* !DLL_EXPORT */ + #else /* !IN_LIBXML */ + #define XMLPUBVAR extern __declspec(dllimport) + #endif /* !IN_LIBXML */ + #endif /* !LIBXML_STATIC */ #define XMLCALL __cdecl #define XMLCDECL __cdecl #if !defined _REENTRANT @@ -137,17 +152,22 @@ #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL - #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) - #define XMLPUBFUN __declspec(dllexport) - #define XMLPUBVAR __declspec(dllexport) - #else - #define XMLPUBFUN - #if !defined(LIBXML_STATIC) - #define XMLPUBVAR __declspec(dllimport) extern - #else - #define XMLPUBVAR - #endif - #endif + #define XMLPUBFUN + #if defined(LIBXML_STATIC) + #define XMLPUBVAR extern + #else /* !LIBXML_STATIC */ + #if defined(IN_LIBXML) + #if defined(DLL_EXPORT) + #undef XMLPUBFUN + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else /* !DLL_EXPORT */ + #define XMLPUBVAR extern + #endif /* !DLL_EXPORT */ + #else /* !IN_LIBXML */ + #define XMLPUBVAR extern __declspec(dllimport) + #endif /* !IN_LIBXML */ + #endif /* !LIBXML_STATIC */ #define XMLCALL __cdecl #define XMLCDECL __cdecl #endif diff -uprN libxml2-2.7.6/include/libxml/xmlversion.h.in libxml2-2.7.6.az/include/libxml/xmlversion.h.in --- libxml2-2.7.6/include/libxml/xmlversion.h.in 2009-09-24 17:31:59 +0200 +++ libxml2-2.7.6.az/include/libxml/xmlversion.h.in 2009-11-05 09:23:25 +0200 @@ -10,20 +10,10 @@ #ifndef __XML_VERSION_H__ #define __XML_VERSION_H__ -#include - #ifdef __cplusplus extern "C" { #endif -/* - * use those to be sure nothing nasty will happen if - * your library and includes mismatch - */ -#ifndef LIBXML2_COMPILING_MSCCDEF -XMLPUBFUN void XMLCALL xmlCheckVersion(int version); -#endif /* LIBXML2_COMPILING_MSCCDEF */ - /** * LIBXML_DOTTED_VERSION: * @@ -382,6 +372,26 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i #define LIBXML_ZLIB_ENABLED #endif +/** + * LIBXML_STATIC: + * + * Whether compiled the libraries was compiled static on Windows + */ +#if @WITH_STATIC@ +#define LIBXML_STATIC +#endif + +/* XXX: This should be included *after* above LIBXML_STATIC */ +#include + +/* + * use those to be sure nothing nasty will happen if + * your library and includes mismatch + */ +#ifndef LIBXML2_COMPILING_MSCCDEF +XMLPUBFUN void XMLCALL xmlCheckVersion(int version); +#endif /* LIBXML2_COMPILING_MSCCDEF */ + #ifdef __GNUC__ #ifdef HAVE_ANSIDECL_H #include diff -uprN libxml2-2.7.6/testdso.c libxml2-2.7.6.az/testdso.c --- libxml2-2.7.6/testdso.c 2009-09-24 17:32:00 +0200 +++ libxml2-2.7.6.az/testdso.c 2009-11-05 09:23:25 +0200 @@ -1,6 +1,7 @@ #include #define IN_LIBXML +#include "libxml/xmlversion.h" #include "libxml/xmlexports.h" XMLPUBFUN int hello_world(void); diff -uprN libxml2-2.7.6/win32/Makefile.mingw libxml2-2.7.6.az/win32/Makefile.mingw --- libxml2-2.7.6/win32/Makefile.mingw 2009-09-24 17:32:00 +0200 +++ libxml2-2.7.6.az/win32/Makefile.mingw 2009-11-05 09:24:31 +0200 @@ -22,7 +22,7 @@ include $(AUTOCONF) XML_NAME = xml2 XML_BASENAME = lib$(XML_NAME) XML_SO = $(XML_BASENAME).dll -XML_IMP = $(XML_BASENAME).lib +XML_IMP = $(XML_BASENAME).dll.a XML_A = $(XML_BASENAME).a # Place where we let the compiler put its output. @@ -63,8 +63,10 @@ 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) +SO_LDFLAGS = +SO_LDFLAGS += -Wl,--major-image-version,$(LIBXML_MAJOR_VERSION) +SO_LDFLAGS += -Wl,--minor-image-version,$(LIBXML_MINOR_VERSION) +SO_LDFLAGS += -Wl,--enable-auto-image-base LDFLAGS += -Wl,-L,$(BINDIR) -Wl,-L,$(LIBPREFIX) LIBS = ifeq ($(WITH_FTP),1) @@ -228,7 +230,11 @@ ifeq ($(WITH_THREADS),posix) UTILS += $(BINDIR)/testThreads.exe endif -all : dep libxml libxmla utils +ifeq ($(STATIC),1) +all : dep libxmla utils +else +all : dep libxml utils +endif libxml : $(BINDIR)/$(XML_SO) @@ -254,9 +260,12 @@ install-libs : all cmd.exe /C "if not exist $(BINPREFIX) mkdir $(BINPREFIX)" cmd.exe /C "if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)" cmd.exe /C "copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml" - cmd.exe /C "copy $(BINDIR)\$(XML_SO) $(SOPREFIX)" - cmd.exe /C "copy $(BINDIR)\$(XML_A) $(LIBPREFIX)" - cmd.exe /C "copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)" + ifeq ($(STATIC),1) + cmd.exe /C "copy $(BINDIR)\$(XML_A) $(LIBPREFIX)" + else + cmd.exe /C "copy $(BINDIR)\$(XML_SO) $(SOPREFIX)" + cmd.exe /C "copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)" + endif cmd.exe /C "copy $(BINDIR)\xml*.exe $(BINPREFIX)" install : install-libs @@ -298,7 +307,7 @@ $(XML_INTDIR)/%.o : $(XML_SRCDIR)/%.c # An implicit rule for static libxml compilation. $(XML_INTDIR_A)/%.o : $(XML_SRCDIR)/%.c - $(CC) $(CFLAGS) -DLIBXML_STATIC -o $@ -c $< + $(CC) $(CFLAGS) -o $@ -c $< # Compiles libxml source. Uses the implicit rule for commands. @@ -308,7 +317,7 @@ $(XML_OBJS) : $(XML_INTDIR) $(XML_OBJS_A) : $(XML_INTDIR_A) # Creates the libxml shared object. -XMLSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XML_IMP) +XMLSO_LDFLAGS = $(LDFLAGS) $(SO_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) @@ -322,18 +331,16 @@ $(UTILS_INTDIR) : cmd.exe /C 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)/$(