[Xfce4-commits] <xfce4-dev-tools:master> add XDT_FEATURE_VISIBILITY

Brian J. Tarricone noreply at xfce.org
Sat Sep 19 01:16:01 CEST 2009


Updating branch refs/heads/master
         to 104a024b94ae87ee87aedefd21b140505220a2c4 (commit)
       from 806ee07598a912c3e92498e98c29b35d29ea65ac (commit)

commit 104a024b94ae87ee87aedefd21b140505220a2c4
Author: Brian J. Tarricone <brian at tarricone.org>
Date:   Fri Sep 18 16:16:13 2009 -0700

    add XDT_FEATURE_VISIBILITY

 NEWS                     |    2 +
 m4macros/xdt-features.m4 |   51 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index 757420e..a4018b3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 4.7.1
 =====
 - Also support the newer AC_CONFIG_HEADERS macro.
+- Add XDT_FEATURE_VISIBILITY to check for and enable symbol visibility
+  support (only useful for building libraries).
 
 4.7.0
 =====
diff --git a/m4macros/xdt-features.m4 b/m4macros/xdt-features.m4
index 9a35926..c2d2cd5 100644
--- a/m4macros/xdt-features.m4
+++ b/m4macros/xdt-features.m4
@@ -109,6 +109,57 @@ AC_HELP_STRING([--disable-debug], [Include no debugging support [default]]),
 ])
 
 
+dnl XDT_FEATURE_VISIBILITY()
+dnl
+dnl Checks to see if the compiler supports the 'visibility' attribute
+dnl If so, adds -DHAVE_GNUC_VISIBILTY to CPPFLAGS.  Also sets the
+dnl automake conditional HAVE_GNUC_VISIBILITY.
+dnl
+AC_DEFUN([XDT_FEATURE_VISIBILITY],
+[
+  AC_ARG_ENABLE([visibility],
+                AC_HELP_STRING([--disable-visibility],
+                               [Don't use ELF visibility attributes]),
+                               [], [enable_visibility=yes])
+  have_gnuc_visibility=no
+  if test "x$enable_visibility" != "xno"; then
+    XDT_SUPPORTED_FLAGS([xdt_vis_test_cflags], [-Wall -Werror -Wno-unused-parameter])
+    saved_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $xdt_vis_test_cflags"
+    AC_MSG_CHECKING([whether $CC supports the GNUC visibility attribute])
+    AC_COMPILE_IFELSE(AC_LANG_SOURCE(
+    [
+      void test_default (void);
+      void test_hidden (void);
+
+      void __attribute__ ((visibility("default"))) test_default (void) {}
+      void __attribute__ ((visibility("hidden"))) test_hidden (void) {}
+
+      int main (int argc, char **argv) {
+        test_default ();
+        test_hidden ();
+        return 0;
+      }
+    ]),
+    [
+      have_gnuc_visibility=yes
+      AC_MSG_RESULT([yes])
+    ],
+    [
+      AC_MSG_RESULT([no])
+    ])
+    CFLAGS="$saved_CFLAGS"
+  fi
+
+  if test "x$have_gnuc_visibility" = "xyes"; then
+    CPPFLAGS="$CPPFLAGS -DHAVE_GNUC_VISIBILITY"
+    XDT_SUPPORTED_FLAGS([xdt_vis_hidden_cflags], [-fvisibility=hidden])
+    CFLAGS="$CFLAGS $xdt_vis_hidden_cflags"
+  fi
+
+  AM_CONDITIONAL([HAVE_GNUC_VISIBILITY], [test "x$have_gnuc_visibility" = "xyes"])
+])
+
 
 dnl BM_DEBUG_SUPPORT()
 dnl



More information about the Xfce4-commits mailing list