Autofoo macro cleanups.

- Eliminate use of obsolete AC_TRY_COMPILE.
- Changes names AC_/ac_ to EC_/ec_ to stay out of autoconf namespace.
This commit is contained in:
Kim Woelders 2013-08-09 08:31:57 +02:00
parent a6c5d24810
commit b42aa48304
4 changed files with 34 additions and 25 deletions

View File

@ -44,8 +44,8 @@ AC_CHECK_HEADERS(alloca.h locale.h stdarg.h wctype.h)
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_C_CONST AC_C_CONST
AC_C_INLINE AC_C_INLINE
AC_C___ATTRIBUTE__ EC_C___ATTRIBUTE__
AC_C___FUNC__ EC_C___FUNC__
AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4) AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(wchar_t, 4) AC_CHECK_SIZEOF(wchar_t, 4)
@ -437,9 +437,9 @@ AC_ARG_ENABLE(gcc-cpp,
if test "x$enable_gcc_cpp" = "xyes"; then if test "x$enable_gcc_cpp" = "xyes"; then
CC="g++" CC="g++"
CPPFLAGS="$CPPFLAGS -x c++" CPPFLAGS="$CPPFLAGS -x c++"
AC_C_WARNFLAGS([cpp]) EC_C_WARNINGS([cpp])
else else
AC_C_WARNFLAGS() EC_C_WARNINGS()
fi fi
AC_DEFINE(_GNU_SOURCE, 1, [Enable extensions]) AC_DEFINE(_GNU_SOURCE, 1, [Enable extensions])

View File

@ -4,7 +4,7 @@ dnl Originally snatched from somewhere...
dnl Macro for checking if the compiler supports __attribute__ dnl Macro for checking if the compiler supports __attribute__
dnl Usage: AC_C___ATTRIBUTE__ dnl Usage: EC_C___ATTRIBUTE__
dnl Call AC_DEFINE for HAVE___ATTRIBUTE__ and __UNUSED__. dnl Call AC_DEFINE for HAVE___ATTRIBUTE__ and __UNUSED__.
dnl If the compiler supports __attribute__, HAVE___ATTRIBUTE__ is dnl If the compiler supports __attribute__, HAVE___ATTRIBUTE__ is
@ -12,18 +12,27 @@ dnl defined to 1 and __UNUSED__ is defined to __attribute__((unused))
dnl otherwise, HAVE___ATTRIBUTE__ is not defined and __UNUSED__ is dnl otherwise, HAVE___ATTRIBUTE__ is not defined and __UNUSED__ is
dnl defined to nothing. dnl defined to nothing.
AC_DEFUN([AC_C___ATTRIBUTE__], AC_DEFUN([EC_C___ATTRIBUTE__],
[ [
AC_MSG_CHECKING(for __attribute__) AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [ AC_CACHE_VAL(ec_cv___attribute__, [
AC_TRY_COMPILE([#include <stdlib.h>], AC_COMPILE_IFELSE([
[int func(int x); int foo(int x __attribute__ ((unused))) { exit(1); }], AC_LANG_PROGRAM(
ac_cv___attribute__=yes, ac_cv___attribute__=no)]) [[
if test "$ac_cv___attribute__" = "yes"; then #include <stdlib.h>
]], [[
int foo(int x __attribute__ ((unused))) { exit(1); }
]])
],
ec_cv___attribute__=yes,
ec_cv___attribute__=no)
])
if test "$ec_cv___attribute__" = "yes"; then
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [Define to 1 if your compiler has __attribute__]) AC_DEFINE(HAVE___ATTRIBUTE__, 1, [Define to 1 if your compiler has __attribute__])
AC_DEFINE(__UNUSED__, __attribute__((unused)), [Macro declaring a function argument to be unused]) AC_DEFINE(__UNUSED__, __attribute__((unused)), [Macro declaring a function argument to be unused])
else else
AC_DEFINE(__UNUSED__, , [Macro declaring a function argument to be unused]) AC_DEFINE(__UNUSED__, , [Macro declaring a function argument to be unused])
fi fi
AC_MSG_RESULT($ac_cv___attribute__) AC_MSG_RESULT($ec_cv___attribute__)
]) ])

View File

@ -3,33 +3,33 @@ dnl This code is public domain and can be freely used or copied.
dnl Macro for defining __func__ if not already defined dnl Macro for defining __func__ if not already defined
dnl Usage: AC_C___FUNC__ dnl Usage: EC_C___FUNC__
dnl If __func__ is not defined and __FUNCTION__ is, __func__ is defined dnl If __func__ is not defined and __FUNCTION__ is, __func__ is defined
dnl to __FUNCTION__. If __FUNCTION__ isn't defined either, __func__ is dnl to __FUNCTION__. If __FUNCTION__ isn't defined either, __func__ is
dnl defined to "FUNC". dnl defined to "FUNC".
AC_DEFUN([AC_C___FUNC__], AC_DEFUN([EC_C___FUNC__],
[ [
AC_CACHE_CHECK([for __func__], ac_cv___func__, [ AC_CACHE_CHECK([for __func__], ec_cv___func__, [
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [[const char *s = __func__;]]) AC_LANG_PROGRAM([], [[const char *s = __func__;]])
], [ ], [
ac_cv___func__=yes ec_cv___func__=yes
], [ ], [
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [[const char *s = __FUNCTION__;]]) AC_LANG_PROGRAM([], [[const char *s = __FUNCTION__;]])
], [ ], [
ac_cv___func__=function ec_cv___func__=function
], [ ], [
ac_cv___func__=no ec_cv___func__=no
]) ])
]) ])
]) ])
if test $ac_cv___func__ = function; then if test $ec_cv___func__ = function; then
AC_DEFINE(__func__, __FUNCTION__, [Define __func__ appropriately if missing]) AC_DEFINE(__func__, __FUNCTION__, [Define __func__ appropriately if missing])
elif test $ac_cv___func__ = no; then elif test $ec_cv___func__ = no; then
AC_DEFINE(__func__, "FUNC", [Define __func__ appropriately if missing]) AC_DEFINE(__func__, "FUNC", [Define __func__ appropriately if missing])
fi fi
]) ])

View File

@ -1,15 +1,15 @@
dnl Copyright (C) 2008 Kim Woelders dnl Copyright (C) 2008 Kim Woelders
dnl This code is public domain and can be freely used or copied. dnl This code is public domain and can be freely used or copied.
dnl Macro to set compiler warning flags dnl Macro to set compiler warning flags in CWARNFLAGS
dnl Provides configure argument --enable-werror to stop compilation on warnings dnl Provides configure argument --enable-werror to stop compilation on warnings
dnl Usage: AC_C_WARNFLAGS([LANG]) dnl Usage: EC_C_WARNINGS([LANG])
dnl Set LANG to 'cpp' when compiling for C++ dnl Set LANG to 'cpp' when compiling for C++
AC_DEFUN([AC_C_WARNFLAGS], [ AC_DEFUN([EC_C_WARNINGS], [
define(ac_c_compile_cpp, ifelse([$1], [cpp], [yes], [no])) define(ec_c_compile_cpp, ifelse([$1], [cpp], [yes], [no]))
AC_ARG_ENABLE(werror, AC_ARG_ENABLE(werror,
[ --enable-werror treat compiler warnings as errors @<:@default=no@:>@],, [ --enable-werror treat compiler warnings as errors @<:@default=no@:>@],,
@ -17,7 +17,7 @@ AC_DEFUN([AC_C_WARNFLAGS], [
if test "x$GCC" = "xyes"; then if test "x$GCC" = "xyes"; then
CWARNFLAGS="-W -Wall -Waggregate-return -Wcast-align -Wpointer-arith -Wshadow -Wwrite-strings" CWARNFLAGS="-W -Wall -Waggregate-return -Wcast-align -Wpointer-arith -Wshadow -Wwrite-strings"
ifelse(ac_c_compile_cpp, no, [ ifelse(ec_c_compile_cpp, no, [
CWARNFLAGS="$CWARNFLAGS -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes" CWARNFLAGS="$CWARNFLAGS -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes"
],) ],)