diff --git a/configure.ac b/configure.ac index 46975753..34774010 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,7 @@ AC_C_BIGENDIAN AC_C_CONST AC_C_INLINE AC_C___ATTRIBUTE__ +AC_C___FUNC__ AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long, 4) AC_CHECK_SIZEOF(wchar_t, 4) diff --git a/m4/ac_func.m4 b/m4/ac_func.m4 new file mode 100644 index 00000000..6c0b579c --- /dev/null +++ b/m4/ac_func.m4 @@ -0,0 +1,35 @@ +dnl Copyright (C) 2010 Kim Woelders +dnl This code is public domain and can be freely used or copied. + +dnl Macro for defining __func__ if not already defined + +dnl Usage: AC_C___FUNC__ + +dnl If __func__ is not defined and __FUNCTION__ is, __func__ is defined +dnl to __FUNCTION__. If __FUNCTION__ isn't defined either, __func__ is +dnl defined to "FUNC". + +AC_DEFUN([AC_C___FUNC__], +[ + AC_CACHE_CHECK([for __func__], ac_cv___func__, [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([], [[const char *s = __func__;]]) + ], [ + ac_cv___func__=yes + ], [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([], [[const char *s = __FUNCTION__;]]) + ], [ + ac_cv___func__=function + ], [ + ac_cv___func__=no + ]) + ]) + ]) + + if test $ac_cv___func__ = function; then + AC_DEFINE(__func__, __FUNCTION__, [Define __func__ appropriately if missing]) + elif test $ac_cv___func__ = no; then + AC_DEFINE(__func__, "FUNC", [Define __func__ appropriately if missing]) + fi +])