sgpemv2/m4/sgpemv2-visibility.m4

88 lines
3.3 KiB
Plaintext

dnl m4/sgpemv2-visibility.m4 - Copyright 2005, 2006, University
dnl of Padova, dept. of Pure and Applied
dnl Mathematics
dnl
dnl This file is part of SGPEMv2.
dnl
dnl This is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl SGPEMv2 is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with SGPEMv2; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
dnl ---------- AC_PROG_SGPEMV2 ---------------------
dnl
dnl Synopsis: AC_PROG_SGPEMV2([min_version])
dnl
dnl This macro enables the new DSO visibility
dnl support for compilers that supports it, defining
dnl the following preprocessor macros:
dnl SG_DLLEXPORT : for objects exported by the DSO
dnl SG_DLLIMPORT : for objects imported by the DSO
dnl SG_DLLLOCAL : for objects local to the DSO
dnl SG_DLLPUBLIC : for objects public outside the DSO
dnl
dnl Example of usage: SGPEMV2_VISIBILITY_SUPPORT
dnl ------------------------------------------------
AC_DEFUN([SGPEMV2_VISIBILITY_SUPPORT],
[
dnl use DSO visibility tags for systems that supports it correctly
dnl (for example, GCC 4.0 and above)
dnl see http://gcc.gnu.org/wiki/Visibility for more informations
AH_TEMPLATE([SG_DLLEXPORT],[Attribute for objects to be exported from DSOs])
AH_TEMPLATE([SG_DLLIMPORT],[Attribute for objects to be imported from DSOs])
AH_TEMPLATE([SG_DLLLOCAL], [Attribute for objects local to current DSO])
AH_TEMPLATE([SG_DLLPUBLIC],[Attribute for DSO public objects])
AC_ARG_ENABLE([visibility-support],
AS_HELP_STRING([--disable-visibility-support],
[disable the new GCC visibility support]),
[enable_gcc_visibility="$enableval"],
[enable_gcc_visibility="yes"])
AC_MSG_CHECKING([whether to use new GCC visibility attributes])
dnl for now it works only with GCC >= 4.0.0
AC_LANG_PUSH([C++])
if test "x$enable_gcc_visibility" = "xyes"; then
AC_COMPILE_IFELSE(
AC_LANG_PROGRAM([], [
#if defined __GNUC__ && (__GNUC__) >= 4
return 0;
#else
bails out with a compilation error.
#endif
]),
:,
[enable_gcc_visibility="no"])
fi
AC_LANG_POP
if test "x$enable_gcc_visibility" = "xyes"; then
AC_MSG_RESULT([yes])
AC_DEFINE([SG_DLLIMPORT],[/* intentionally left with no value */])
AC_DEFINE([SG_DLLEXPORT],[__attribute__ ((visibility("default")))])
AC_DEFINE([SG_DLLLOCAL],[__attribute__ ((visibility("hidden")))])
AC_DEFINE([SG_DLLPUBLIC],[__attribute__ ((visibility("default")))])
AC_CHECK_CXXFLAG([VISIB_HIDDEN], [fvisibility=hidden])
AC_SUBST([VISIB_HIDDEN])
AC_CHECK_CXXFLAG([CXXFLAGS],[fvisibility-inlines-hidden])
else
AC_MSG_RESULT([no])
AC_DEFINE([SG_DLLIMPORT],[/* unsupported */])
AC_DEFINE([SG_DLLEXPORT],[/* unsupported */])
AC_DEFINE([SG_DLLLOCAL],[/* unsupported */])
AC_DEFINE([SG_DLLPUBLIC],[/* unsupported */])
fi
])dnl ------- SGPEMV2_VISIBILITY_SUPPORT ---------------------