bceaa28a312d61897199b5844e69f49b3f999fe0
[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], [makeopts flag])
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 m4_ifval([$4],$4=0)
10
11 if test "x$2" = "x"
12 then
13 AC_COMPILE_IFELSE(
14         [AC_LANG_PROGRAM([$3 void __attribute__(($1)) *test(void *muffin, ...) {return (void *) 0;}],
15                         [])],
16         AC_MSG_RESULT(yes)
17         m4_ifval([$4],$4=1)
18         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
19         AC_MSG_RESULT(no)
20 )
21 else
22 AC_COMPILE_IFELSE(
23         [AC_LANG_PROGRAM([$3 void __attribute__(($2)) *test(void *muffin, ...) {return (void *) 0;}],
24                         [])],
25         AC_MSG_RESULT(yes)
26         m4_ifval([$4],$4=1)
27         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
28         AC_MSG_RESULT(no)
29 )
30 fi
31
32 m4_ifval([$4],[AC_SUBST($4)])
33 CFLAGS="$saved_CFLAGS"
34 ]
35 )