summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorDaniel Elstner <daniel.kitta@gmail.com>2009-12-24 17:21:12 +0100
committerDaniel Elstner <daniel.kitta@gmail.com>2009-12-24 19:22:19 +0100
commit2c7da3b80d49be384f87ba16f2a8668d3084ebb1 (patch)
tree31451b57a0f08420c549e3f1e20e4e89bbdd9bfb /macros
parenta7741eed07bfc69c514a5fa64df5f5710a7039bf (diff)
downloadmm-common-2c7da3b80d49be384f87ba16f2a8668d3084ebb1.tar.gz
Add new MM_PROG_GCC_VISIBILITY Autoconf macro
* macros/mm-dietlib.m4 (MM_PROG_GCC_VISIBILITY): New Autoconf macro to check whether the compiler supports the GNU C++ symbol visibility attributes. * README: Mention MM_PROG_GCC_VISIBILITY in the M4 file description.
Diffstat (limited to 'macros')
-rw-r--r--macros/mm-dietlib.m450
1 files changed, 49 insertions, 1 deletions
diff --git a/macros/mm-dietlib.m4 b/macros/mm-dietlib.m4
index 890ed62..4a2b360 100644
--- a/macros/mm-dietlib.m4
+++ b/macros/mm-dietlib.m4
@@ -15,7 +15,55 @@
## You should have received a copy of the GNU General Public License
## along with mm-common. If not, see <http://www.gnu.org/licenses/>.
-#serial 20090817
+#serial 20091224
+
+## _MM_PROG_GCC_VISIBILITY_CHECK
+##
+## Implementation helper macro of MM_PROG_GCC_VISIBILITY(). Pulled
+## in through AC_REQUIRE() so that it will only be expanded once.
+##
+m4_define([_MM_PROG_GCC_VISIBILITY_CHECK],
+[dnl
+AC_PROVIDE([$0])[]dnl
+AC_CACHE_CHECK([for GCC symbol visibility options],
+ [mm_cv_gcc_visibility_cxxflags],
+[dnl
+mm_save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
+dnl
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#pragma GCC visibility push(default)
+namespace Mm { void __attribute__((__visibility__("hidden"))) mmfunc(); }
+void Mm::mmfunc() {}
+#pragma GCC visibility pop
+]], [[Mm::mmfunc();]])],
+[mm_cv_gcc_visibility_cxxflags='-fvisibility=hidden -fvisibility-inlines-hidden'],
+[mm_cv_gcc_visibility_cxxflags=none])
+dnl
+CXXFLAGS=$mm_save_CXXFLAGS])[]dnl
+])
+
+## MM_PROG_GCC_VISIBILITY(variable-name)
+##
+## Check whether the compiler supports the GNU C++ symbol visibility
+## attributes and command-line options. If explicit symbol visibility is
+## supported, the compiler command-line options for hiding all symbols by
+## default are made available through the specified substitution variable
+## <variable-name>.
+##
+## See also <http://gcc.gnu.org/wiki/Visibility> for more information on
+## symbol visibility and the attributes supported by GCC.
+##
+AC_DEFUN([MM_PROG_GCC_VISIBILITY],
+[dnl
+m4_assert([$# >= 1])[]dnl
+AC_LANG_ASSERT([C++])[]dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([_MM_PROG_GCC_VISIBILITY_CHECK])[]dnl
+AS_IF([test "x$mm_cv_gcc_visibility_cxxflags" != xnone],
+ [$1=$mm_cv_gcc_visibility_cxxflags], [$1=])
+AC_SUBST([$1])[]dnl
+])
## _MM_ARG_DISABLE_DEPRECATED_API_OPTION
##