[mm-common] Add new MM_PROG_GCC_VISIBILITY Autoconf macro
- From: Daniel Elstner <daniel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [mm-common] Add new MM_PROG_GCC_VISIBILITY Autoconf macro
- Date: Thu, 24 Dec 2009 18:36:50 +0000 (UTC)
commit 2c7da3b80d49be384f87ba16f2a8668d3084ebb1
Author: Daniel Elstner <daniel kitta gmail com>
Date: Thu Dec 24 17:21:12 2009 +0100
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.
README | 1 +
macros/mm-dietlib.m4 | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/README b/README
index 070405e..928f688 100644
--- a/README
+++ b/README
@@ -111,6 +111,7 @@ macros/mm-pkg.m4:
macros/mm-dietlib.m4:
Implements Autoconf macros which provide options intended to reduce the
binary size of the generated binding library, typically for embedded use.
+ The MM_PROG_GCC_VISIBILITY macro is defined in this file as well.
Automake include files
----------------------
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
##
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]