Fix problems with new compiler attribute checking in configure script.
[asterisk/asterisk.git] / autoconf / ast_gcc_attribute.m4
1 # Helper function to check for gcc attributes.
2 # AST_GCC_ATTRIBUTE([attribute name], [attribute syntax], [attribute scope])
3
4 AC_DEFUN([AST_GCC_ATTRIBUTE],
5 [
6 AC_MSG_CHECKING(for compiler 'attribute $1' support)
7 saved_CFLAGS="$CFLAGS"
8 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
9
10 if test "x$3" = "x"
11 then
12 attribute_scope="static"
13 else
14 attribute_scope="$3"
15 fi
16
17 if test "x$2" = "x"
18 then
19 AC_COMPILE_IFELSE(
20         AC_LANG_PROGRAM([$attribute_scope void __attribute__(($1)) *test(void *muffin, ...) {return (void *) 0;}],
21                         []),
22         AC_MSG_RESULT(yes)
23         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
24         AC_MSG_RESULT(no)
25 )
26 else
27 AC_COMPILE_IFELSE(
28         AC_LANG_PROGRAM([$attribute_scope void __attribute__(($2)) *test(void *muffin, ...) {return (void *) 0;}],
29                         []),
30         AC_MSG_RESULT(yes)
31         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
32         AC_MSG_RESULT(no)
33 )
34 fi
35
36 CFLAGS="$saved_CFLAGS"
37 ]
38 )