]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix export of virConnectAuthPtrDefault for MinGW builds
authorMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 16 Mar 2010 22:54:22 +0000 (23:54 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 23 Mar 2010 01:07:38 +0000 (02:07 +0100)
Use the __declspec(dllexport/dllimport) stuff to export the symbol,
otherwise accessing virConnectAuthPtrDefault triggers a segfault.

configure.ac
docs/apibuild.py
include/libvirt/libvirt.h.in
src/Makefile.am

index 1a3c78886bc3be0887872dc1d180896a5ac0435b..bcf1d5aff47b70950118a50a3b703ea5487e081d 100644 (file)
@@ -1732,6 +1732,7 @@ CYGWIN_EXTRA_LDFLAGS=
 CYGWIN_EXTRA_LIBADD=
 CYGWIN_EXTRA_PYTHON_LIBADD=
 MINGW_EXTRA_LDFLAGS=
+WIN32_EXTRA_CFLAGS=
 case "$host" in
   *-*-cygwin*)
     CYGWIN_EXTRA_LDFLAGS="-no-undefined"
@@ -1744,10 +1745,20 @@ case "$host" in
     MINGW_EXTRA_LDFLAGS="-no-undefined"
     ;;
 esac
+case "$host" in
+  *-*-mingw* | *-*-cygwin* | *-*-msvc* )
+    # If the host is Windows, and shared libraries are disabled, we
+    # need to add -DLIBVIRT_STATIC to the CFLAGS for proper linking
+    if test "x$enable_shared" = "xno"; then
+      WIN32_EXTRA_CFLAGS="-DLIBVIRT_STATIC"
+    fi
+    ;;
+esac
 AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
 AC_SUBST([CYGWIN_EXTRA_LIBADD])
 AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
 AC_SUBST([MINGW_EXTRA_LDFLAGS])
+AC_SUBST([WIN32_EXTRA_CFLAGS])
 
 dnl Look for windres to build a Windows icon resource.
 AC_CHECK_TOOL([WINDRES], [windres], [no])
index 0ab5db22ab41d8a9af3ec9bea227e50ec222d139..2dda4df1bab88b8e8e0f45b60eb162c4fd909644 100755 (executable)
@@ -28,6 +28,7 @@ ignored_words = {
   "ATTRIBUTE_UNUSED": (0, "macro keyword"),
   "ATTRIBUTE_SENTINEL": (0, "macro keyword"),
   "VIR_DEPRECATED": (0, "macro keyword"),
+  "VIR_EXPORT_VAR": (0, "macro keyword"),
   "WINAPI": (0, "Windows keyword"),
   "__declspec": (3, "Windows keyword"),
   "__stdcall": (0, "Windows keyword"),
index 12b8ea12b0e86b00e50f74e6d64781a3b69e793b..aaefa098bb1dc7d86805b0b2deaa06cba9581448 100644 (file)
@@ -29,6 +29,20 @@ extern "C" {
 # endif
 #endif /* VIR_DEPRECATED */
 
+#ifdef WIN32
+# ifdef LIBVIRT_STATIC
+#  define VIR_EXPORT_VAR extern
+# else
+#  ifdef IN_LIBVIRT
+#   define VIR_EXPORT_VAR __declspec(dllexport)
+#  else
+#   define VIR_EXPORT_VAR __declspec(dllimport) extern
+#  endif
+# endif
+#else
+# define VIR_EXPORT_VAR extern
+#endif
+
 /**
  * virConnect:
  *
@@ -499,7 +513,7 @@ struct _virConnectAuth {
 typedef struct _virConnectAuth virConnectAuth;
 typedef virConnectAuth *virConnectAuthPtr;
 
-extern virConnectAuthPtr virConnectAuthPtrDefault;
+VIR_EXPORT_VAR virConnectAuthPtr virConnectAuthPtrDefault;
 
 /**
  * VIR_UUID_BUFLEN:
index 08e204dd889bbe2d726a0001d3c821b4e0f4a1b1..0aa344351bb4866818f355ca91c9641d9e4f088c 100644 (file)
@@ -20,7 +20,9 @@ INCLUDES =                                                    \
                -DLOCAL_STATE_DIR=\""$(localstatedir)"\"        \
                -DGETTEXT_PACKAGE=\"$(PACKAGE)\"                \
                $(WARN_CFLAGS)                                  \
-               $(LOCK_CHECKING_CFLAGS)
+               $(LOCK_CHECKING_CFLAGS)                 \
+               -DIN_LIBVIRT                            \
+               $(WIN32_EXTRA_CFLAGS)
 
 EXTRA_DIST = $(conf_DATA)