Formatting changes (coding guidelines) while thinking about something else...
[asterisk/asterisk.git] / acinclude.m4
index 9b84af6..1395241 100644 (file)
@@ -7,13 +7,17 @@
 AC_DEFUN([AST_GCC_ATTRIBUTE],
 [
 AC_MSG_CHECKING(for compiler 'attribute $1' support)
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE(
-       AC_LANG_PROGRAM([static int __attribute__(($1)) test(void) {}],
+       AC_LANG_PROGRAM([static void __attribute__(($1)) *test(void *muffin, ...) {}],
                        []),
        AC_MSG_RESULT(yes)
        AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
        AC_MSG_RESULT(no))
-])
+]
+CFLAGS="$saved_CFLAGS"
+)
 
 # Helper function to setup variables for a package.
 # $1 -> the package name. Used in configure.ac and also as a prefix
@@ -92,7 +96,7 @@ AC_DEFUN([AST_CHECK_MANDATORY],
 # AST_C_DEFINE_CHECK([package], [macro name], [header file], [version])
 AC_DEFUN([AST_C_DEFINE_CHECK],
 [
-    if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
+    if test "x${PBX_$1}" != "x1"; then
        AC_MSG_CHECKING([for $2 in $3])
        saved_cppflags="${CPPFLAGS}"
        if test "x${$1_DIR}" != "x"; then
@@ -114,10 +118,11 @@ AC_DEFUN([AST_C_DEFINE_CHECK],
                AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
                AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
            ],
-           [       AC_MSG_RESULT(no) ] 
+           [   AC_MSG_RESULT(no) ] 
        )
        CPPFLAGS="${saved_cppflags}"
     fi
+    AC_SUBST(PBX_$1)
 ])
 
 
@@ -230,7 +235,10 @@ AC_DEFUN([AST_EXT_TOOL_CHECK],
                fi
                CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
 
-               AC_COMPILE_IFELSE(
+               saved_ldflags="${LDFLAGS}"
+               LDFLAGS="${$1_LIB}"
+
+               AC_LINK_IFELSE(
                    [ AC_LANG_PROGRAM( [ $5 ],
                                       [ $6; ]
                                       )],
@@ -240,6 +248,7 @@ AC_DEFUN([AST_EXT_TOOL_CHECK],
                    []
                )
                CPPFLAGS="${saved_cppflags}"
+               LDFLAGS="${saved_ldflags}"
            else
                PBX_$1=1
                AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 libraries.])