diff --git a/caca/caca.h b/caca/caca.h index 9fc3fe4..e117bed 100644 --- a/caca/caca.h +++ b/caca/caca.h @@ -33,6 +33,8 @@ # define __extern extern __declspec(dllexport) #elif defined _WIN32 && !defined __LIBCACA__ && !defined CACA_STATIC # define __extern extern __declspec(dllimport) +#elif defined CACA_ENABLE_VISIBILITY +# define __extern extern __attribute__((visibility("default"))) #else # define __extern extern #endif diff --git a/caca/caca0.h b/caca/caca0.h index a48a921..3f852ab 100644 --- a/caca/caca0.h +++ b/caca/caca0.h @@ -26,6 +26,8 @@ # define __extern extern __declspec(dllexport) #elif defined _WIN32 && !defined __LIBCACA__ # define __extern extern __declspec(dllimport) +#elif defined CACA_ENABLE_VISIBILITY +# define __extern extern __attribute__((visibility("default"))) #else # define __extern extern #endif diff --git a/configure.ac b/configure.ac index 8f15b96..905b3a0 100644 --- a/configure.ac +++ b/configure.ac @@ -387,6 +387,16 @@ CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer" CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare" CXXFLAGS="${CXXFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare" +dnl Visibility annotations... +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fvisibility=hidden -Wall -Werror" +AC_MSG_CHECKING(whether compiler supports visibility annotations) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void __attribute__((visibility("default"))) foo(void); void foo(void) {}]])], + [CFLAGS="$saved_CFLAGS -fvisibility=hidden -DCACA_ENABLE_VISIBILITY"; + AC_MSG_RESULT(yes)], + [CFLAGS="$saved_CFLAGS" + AC_MSG_RESULT(no)]) + CACA_BINDINGS="" # Build the C++ bindings? diff --git a/cxx/caca++.h b/cxx/caca++.h index 2fc46ab..0494b22 100644 --- a/cxx/caca++.h +++ b/cxx/caca++.h @@ -26,6 +26,8 @@ #undef __class #if defined(_WIN32) && defined(__LIBCACA_PP__) # define __class class __declspec(dllexport) +#elif defined CACA_ENABLE_VISIBILITY +# define __class class __attribute__((visibility("default"))) #else # define __class class #endif