diff options
Diffstat (limited to 'm4')
-rw-r--r-- | m4/attributes.m4 | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 56cdd51d1..2b7175b1c 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -32,9 +32,8 @@ dnl distribute a modified version of the Autoconf Macro, you may extend dnl this special exception to the GPL to apply to your modified version as dnl well. -AC_DEFUN([CC_CHECK_CFLAGS], [ - AC_CACHE_CHECK([if $CC supports $1 flag], - AS_TR_SH([cc_cv_cflags_$1]), +AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ + AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]), [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $1" AC_COMPILE_IFELSE([int a;], @@ -50,6 +49,19 @@ AC_DEFUN([CC_CHECK_CFLAGS], [ fi ]) +AC_DEFUN([CC_CHECK_CFLAGS], [ + AC_CACHE_CHECK([if $CC supports $1 flag], + AS_TR_SH([cc_cv_cflags_$1]), + CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! + ) + + if eval test [x$]AS_TR_SH([cc_cv_cflags_$1]) = xyes; then + ifelse([$2], , [:], [$2]) + else + ifelse([$3], , [:], [$3]) + fi +]) + dnl Check for a -Werror flag or equivalent. -Werror is the GCC dnl and ICC flag that tells the compiler to treat all the warnings dnl as fatal. We usually need this option to make sure that some @@ -175,28 +187,22 @@ AC_DEFUN([CC_ATTRIBUTE_PACKED], [ ]) AC_DEFUN([CC_FLAG_VISIBILITY], [ - AC_REQUIRE([CC_CHECK_WERROR]) - ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $cc_cv_werror" - AC_CACHE_CHECK([if compiler supports -fvisibility=hidden], - [cc_cv_flag_visibility], - [ - save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -fvisibility=hidden" - AC_COMPILE_IFELSE([int a;], - [cc_cv_flag_visibility=yes], - [cc_cv_flag_visibility=no]) - CFLAGS="$save_CFLAGS" - ]) - CFLAGS="$ac_save_CFLAGS" - - if test "x$cc_cv_flag_visibility" = "xyes"; then - AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, [Define this if the compiler supports the -fvisibility flag]) - $1 - else - true - $2 - fi + AC_REQUIRE([CC_CHECK_WERROR]) + AC_CACHE_CHECK([if $CC supports -fvisibility=hidden], + [cc_cv_flag_visibility], + [ac_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $cc_cv_werror" + CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], + cc_cv_flag_visibility='yes', + cc_cv_flag_visibility='no') + CFLAGS="$ac_save_CFLAGS"]) + + if test "x$cc_cv_flag_visibility" = "xyes"; then + AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, [Define this if the compiler supports the -fvisibility flag]) + ifelse([$1], , [:], [$1]) + else + ifelse([$2], , [:], [$2]) + fi ]) AC_DEFUN([CC_FUNC_EXPECT], [ |