From 10cb6155670a2a7b51356ada16206564cff748e2 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Mon, 6 Aug 2012 18:16:58 +0200 Subject: [PATCH] configure: check for visibility attribute. Add a check for GCC "visibility" attribute. Also define DLL_HIDDEN helper so that to declare functions as internal to a particular shared library. Signed-off-by: Gwenole Beauchesne --- configure.ac | 22 ++++++++++++++++++++++ va/sysdeps.h | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/configure.ac b/configure.ac index 7f7f9af..72eac8e 100644 --- a/configure.ac +++ b/configure.ac @@ -171,6 +171,28 @@ if test "$enable_docs" = "yes"; then fi AM_CONDITIONAL(ENABLE_DOCS, test "$enable_docs" = "yes") +# Check for __attribute__((visibility())) +AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], + ac_cv_have_gnuc_visibility_attribute, + [cat > conftest.c </dev/null 2>&1; then + if grep '\.hidden.*foo' conftest.s >/dev/null; then + if grep '\.protected.*bar' conftest.s >/dev/null; then + ac_cv_have_gnuc_visibility_attribute="yes" + fi + fi + fi + rm -f conftest.[cs] +]) +if test "$ac_cv_have_gnuc_visibility_attribute" = "yes"; then + AC_DEFINE([HAVE_GNUC_VISIBILITY_ATTRIBUTE], [1], + [Defined to 1 if GCC visibility attribute is supported]) +fi + # Check for X11 USE_X11="no" if test "$enable_x11" = "yes"; then diff --git a/va/sysdeps.h b/va/sysdeps.h index 2ab37e9..77db28a 100644 --- a/va/sysdeps.h +++ b/va/sysdeps.h @@ -42,4 +42,12 @@ # define False 0 #endif +#if defined __GNUC__ && defined HAVE_GNUC_VISIBILITY_ATTRIBUTE +# define DLL_HIDDEN __attribute__((visibility("hidden"))) +# define DLL_EXPORT __attribute__((visibility("default"))) +#else +# define DLL_HIDDEN +# define DLL_EXPORT +#endif + #endif /* SYSDEPS_H */ -- 2.7.4