From 7550895309165f01fc03956049d798e1db02b0e0 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Tue, 18 Mar 2008 22:03:04 -0300 Subject: [PATCH] Add XORG_CHECK_SYMBOLS and XORG_WARN_CFLAGS macros. o XORG_CHECK_SYMBOLS doesn't check for gcc but for a compiler that understands _X_EXPORT and _X_HIDDEN macros. Also, it adds the --disable-fvisibility option, to explicitly disable compiling with hidden symbols when it is supported. XORG_CHECK_SYMBOLS sets the variables PUBLIC_SYMBOLS and HIDDEN_SYMBOLS so that they can be used in a by Makefile basis default value when adding either @PUBLIC_SYMBOLS@ or @HIDDEN_SYMBOLS@ to AM_CFLAGS. o XORG_WARN_CFLAGS sets a default value to WARN_CFLAGS. If called with a non empty argument, sets WARN_CFLAGS to that value. To actually use it, add @WARN_CFLAGS@ to AM_CFLAGS. --- xorg-macros.m4.in | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 0 deletions(-) diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in index 0eda9a8..c4bbeb7 100644 --- a/xorg-macros.m4.in +++ b/xorg-macros.m4.in @@ -423,3 +423,77 @@ AC_SUBST(LINTLIB) AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno]) ]) # XORG_LINT_LIBRARY + +# XORG_CHECK_SYMBOLS +# ------------------ +# Minimum version: 1.1.7 +# +# Enable or disable use of -fvisibility=value compiler flag. +# Use --disable-visibility to disable on systems that support it. +# +# Use the XORG_CHECK_SYMBOLS macro and then add either +# @PUBLIC_SYMBOLS@ or @HIDDEN_SYMBOLS@ to AM_CFLAGS +# +# Based on visibility.m4 by Bruno Haible, from gettext package. +# +AC_DEFUN([XORG_CHECK_SYMBOLS],[ + AC_REQUIRE([AC_PROG_CC]) + AC_ARG_ENABLE(fvisibility, + AC_HELP_STRING([--disable-fvisibility], + [disable -fvisibility=(public|hidden) (default: auto)]), + [XORG_FVISIBILITY=$enableval], + [XORG_FVISIBILITY=auto]) + + PUBLIC_SYMBOLS= + HIDDEN_SYMBOLS= + + if test x$XORG_FVISIBILITY != xno; then + AC_MSG_CHECKING([for symbol visibility support]) + AC_CACHE_VAL(xorg_cc_has_visibility, [ + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + AC_TRY_COMPILE( + [#include + extern _X_HIDDEN int hidden_int; + extern _X_EXPORT int public_int; + extern _X_HIDDEN int hidden_int_func(void); + extern _X_EXPORT int public_int_func(void);], + [], + xorg_cc_has_visibility=yes, + xorg_cc_has_visibility=no) + CFLAGS="$save_CFLAGS"]) + + AC_MSG_RESULT([$xorg_cc_has_visibility]) + if test x$xorg_cc_has_visibility = xyes; then + PUBLIC_SYMBOLS="-fvisibility=default" + HIDDEN_SYMBOLS="-fvisibility=hidden" + fi + fi + + AC_SUBST([PUBLIC_SYMBOLS]) + AC_SUBST([HIDDEN_SYMBOLS]) +]) # XORG_CHECK_SYMBOLS + + +# XORG_WARN_CFLAGS() +# ------------------ +# Minimum version: 1.1.7 +# +# Use XORG_WARN_CFLAGS() to set WARN_CFLAGS or check for a default set of +# compiler warning flags +# Use @WARN_CFLAGS@ in AM_CFLAGS to use it. +# +AC_DEFUN([XORG_WARN_CFLAGS],[ + AC_REQUIRE([AC_PROG_CC]) + + WARN_CFLAGS=[$1] + if test x"$WARN_CFLAGS" = x -a x$GCC = xyes; then + WARN_CFLAGS="\ +-Wall -Wpointer-arith -Wstrict-prototypes \ +-Wmissing-prototypes -Wmissing-declarations \ +-Wnested-externs -fno-strict-aliasing \ +-Wold-style-definition" + fi + + AC_SUBST([WARN_CFLAGS]) +]) # XORG_WARN_CFLAGS() -- 1.5.3.2