[glib/wip/win32-visibility: 3/4] win32: check for mingw, adjust visibility setup



commit 3c198fbc5002b983478e2a627cc90f101f7c153b
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Jan 13 15:35:40 2013 -0500

    win32: check for mingw, adjust visibility setup
    
    If we're on mingw32 then use __declspec(dllepxort) along with the normal
    GCC visibility attribute for public symbols.
    
    This means that we don't have to use the .def file while generating the
    .dll.

 configure.ac |   42 ++++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fcbbfbb..9e48f90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3566,26 +3566,36 @@ fi
 
 AC_SUBST(GLIB_LINK_FLAGS)
 
-
 dnl
 dnl Check for -fvisibility=hidden to determine if we can do GNU-style
 dnl visibility attributes for symbol export control
 dnl
-SAVED_CFLAGS="${CFLAGS}"
-CFLAGS="-fvisibility=hidden"
-AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
-AC_TRY_COMPILE([], [int main (void) { return 0; }],
-               AC_MSG_RESULT(yes)
-               enable_fvisibility_hidden=yes,
-               AC_MSG_RESULT(no)
-               enable_fvisibility_hidden=no)
-CFLAGS="${SAVED_CFLAGS}"
-
-AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
-  AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern],
-            [defines how to decorate public symbols while building])
-  CFLAGS="${CFLAGS} -fvisibility=hidden"
-])
+case "$host" in
+  *-*-mingw*)
+    dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+    AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+              [defines how to decorate public symbols while building])
+    CFLAGS="${CFLAGS} -fvisibility=hidden"
+    ;;
+  *)
+    dnl on other compilers, check if we can do -fvisibility=hidden
+    SAVED_CFLAGS="${CFLAGS}"
+    CFLAGS="-fvisibility=hidden"
+    AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
+    AC_TRY_COMPILE([], [int main (void) { return 0; }],
+                   AC_MSG_RESULT(yes)
+                   enable_fvisibility_hidden=yes,
+                   AC_MSG_RESULT(no)
+                   enable_fvisibility_hidden=no)
+    CFLAGS="${SAVED_CFLAGS}"
+
+    AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
+      AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern],
+                [defines how to decorate public symbols while building])
+      CFLAGS="${CFLAGS} -fvisibility=hidden"
+    ])
+    ;;
+esac
 
 dnl Compiler flags; macro originates from systemd
 dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]