diff --git a/config/config.h.in b/config/config.h.in index 8260fc6b..5ff3c7fd 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -126,8 +126,8 @@ slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK -/* Define if g++ supports C++ visibility features */ -#undef HAVE_GXXCLASSVISIBILITY +/* Define if C++ visibility support is enabled */ +#undef WANT_VISIBILITY_SUPPORT /* Define if we have / are building a shared library (DLL) */ #undef HAVE_DLL @@ -204,24 +204,36 @@ # define EXV_UNICODE_PATH #endif -/* Shared library support, see http://gcc.gnu.org/wiki/Visibility */ +/* Symbol visibility support */ #ifdef WIN32 # define EXV_IMPORT __declspec(dllimport) # define EXV_EXPORT __declspec(dllexport) # define EXV_DLLLOCAL # define EXV_DLLPUBLIC #else -# ifdef EXV_HAVE_GXXCLASSVISIBILITY -# define EXV_IMPORT __attribute__ ((visibility("default"))) -# define EXV_EXPORT __attribute__ ((visibility("default"))) -# define EXV_DLLLOCAL __attribute__ ((visibility("hidden"))) -# define EXV_DLLPUBLIC __attribute__ ((visibility("default"))) -# else +# ifdef EXV_WANT_VISIBILITY_SUPPORT +# if defined(__GNUC__) && (__GNUC__ >= 4) +# define EXV_IMPORT __attribute__ ((visibility("default"))) +# define EXV_EXPORT __attribute__ ((visibility("default"))) +# define EXV_DLLLOCAL __attribute__ ((visibility("hidden"))) +# define EXV_DLLPUBLIC __attribute__ ((visibility("default"))) +# elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +# define EXV_IMPORT __global +# define EXV_EXPORT __global +# define EXV_DLLLOCAL __hidden +# define EXV_DLLPUBLIC __global +# else +# define EXV_IMPORT +# define EXV_EXPORT +# define EXV_DLLLOCAL +# define EXV_DLLPUBLIC +# endif +# else /* ! EXV_WANT_VISIBILITY_SUPPORT */ # define EXV_IMPORT # define EXV_EXPORT # define EXV_DLLLOCAL # define EXV_DLLPUBLIC -# endif /* ! EXV_HAVE_GXXCLASSVISIBILITY */ +# endif /* ! EXV_WANT_VISIBILITY_SUPPORT */ #endif /* ! WIN32 */ /* Define EXIV2API for DLL builds */ diff --git a/config/configure.ac b/config/configure.ac index cceec311..90808110 100644 --- a/config/configure.ac +++ b/config/configure.ac @@ -105,16 +105,25 @@ if test "$USE_TRACKING" = "yes"; then fi AC_SUBST(DEP_TRACKING,$DEP_TRACKING) -AC_MSG_CHECKING([whether to enable g++ visibility support]) +AC_MSG_CHECKING([whether to enable symbol visibility support]) AC_ARG_ENABLE(visibility, - [ --disable-visibility do not use g++ visibility support ], - GXX_VISIBILITY=$enableval, GXX_VISIBILITY=yes) -AC_MSG_RESULT($GXX_VISIBILITY) -if test "$GXX_VISIBILITY" = "yes"; then - AX_CXX_CHECK_FLAG(-fvisibility-inlines-hidden,[],[],[GXX_VISIBILITY=yes],[GXX_VISIBILITY=no]) - if test "$GXX_VISIBILITY" = "yes"; then - CXXFLAGS="${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden" - AC_DEFINE(HAVE_GXXCLASSVISIBILITY,1) + [ --disable-visibility do not use symbol visibility support ], + VISIBILITY_SUPPORT=$enableval, VISIBILITY_SUPPORT=yes) +AC_MSG_RESULT($VISIBILITY_SUPPORT) +if test "$VISIBILITY_SUPPORT" = "yes"; then + # Sun Studio C++ compiler (which apparently ignores -fvisibility-inlines-hidden) + AX_CXX_CHECK_FLAG(-xldscope=hidden,[],[],[VISIBILITY_SUPPORT=yes],[VISIBILITY_SUPPORT=no]) + if test "$VISIBILITY_SUPPORT" = "yes"; then + CXXFLAGS="${CXXFLAGS} -xldscope=hidden" + else + # GNU g++ + AX_CXX_CHECK_FLAG(-fvisibility-inlines-hidden,[],[],[VISIBILITY_SUPPORT=yes],[VISIBILITY_SUPPORT=no]) + if test "$VISIBILITY_SUPPORT" = "yes"; then + CXXFLAGS="${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden" + fi + fi + if test "$VISIBILITY_SUPPORT" = "yes"; then + AC_DEFINE(WANT_VISIBILITY_SUPPORT) fi if test "$enable_shared" = "yes"; then AC_DEFINE(HAVE_DLL) @@ -219,9 +228,9 @@ yes) echo "-- Build a shared library......... YES" ;; *) echo "-- Build a shared library......... NO" ;; esac -case "$GXX_VISIBILITY" in -yes) echo "-- Use g++ visibility support..... YES" ;; -*) echo "-- Use g++ visibility support..... NO" ;; +case "$VISIBILITY_SUPPORT" in +yes) echo "-- Use symbol visibility support.. YES" ;; +*) echo "-- Use symbol visibility support.. NO" ;; esac case "x$HAVE_LIBZ" in