1 dnl --------------------------------------------------------------------------
4 dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation
5 dnl --------------------------------------------------------------------------
6 AC_DEFUN(PA_ADD_CFLAGS,
7 [AC_MSG_CHECKING([if $CC accepts $1])
8 pa_add_cflags__old_cflags="$CFLAGS"
10 AC_TRY_LINK([#include <stdio.h>],
11 [printf("Hello, World!\n");],
13 CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])",
15 CFLAGS="$pa_add_cflags__old_cflags")])
17 dnl --------------------------------------------------------------------------
20 dnl Look for a function with the specified arguments which could be
21 dnl a builtin/intrinsic function.
22 dnl --------------------------------------------------------------------------
23 AC_DEFUN(PA_HAVE_FUNC,
24 [AC_MSG_CHECKING([for $1])
25 AC_TRY_LINK([], [(void)$1$2;],
27 AC_DEFINE(m4_toupper([HAVE_$1]), [1],
28 [Define to 1 if you have the `$1' intrinsic function.]),
29 AC_MSG_RESULT([no]))])
31 dnl --------------------------------------------------------------------------
34 dnl Guess the library extension based on the object extension
35 dnl --------------------------------------------------------------------------
37 [AC_MSG_CHECKING([for suffix of library files])
38 if test x"$LIBEXT" = x; then
48 AC_MSG_RESULT([$LIBEXT])
51 dnl --------------------------------------------------------------------------
54 dnl See if this compiler supports the equivalent of a specific gcc
55 dnl attribute on a function, using the __attribute__(()) syntax.
56 dnl All arguments except the attribute name are optional.
57 dnl PA_FUNC_ATTRIBUTE(attribute, attribute_opts, return_type,
58 dnl prototype_args, call_args)
59 dnl --------------------------------------------------------------------------
60 AC_DEFUN(PA_FUNC_ATTRIBUTE,
61 [AC_MSG_CHECKING([if $CC supports the $1 function attribute])
62 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
64 extern ifelse([$3],[],[void *],[$3]) __attribute__(($1$2))
65 bar(ifelse([$4],[],[int],[$4]));
69 return bar(ifelse([$5],[],[1],[$5]));
73 AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_$1]), 1,
74 [Define to 1 if your compiler supports __attribute__(($1)) on functions])],
75 [AC_MSG_RESULT([no])])
78 dnl --------------------------------------------------------------------------
79 dnl PA_FUNC_ATTRIBUTE_ERROR
81 dnl See if this compiler supports __attribute__((error("foo")))
82 dnl The generic version of this doesn't work as it makes the compiler
83 dnl throw an error by design.
84 dnl --------------------------------------------------------------------------
85 AC_DEFUN(PA_FUNC_ATTRIBUTE_ERROR,
86 [AC_MSG_CHECKING([if $CC supports the error function attribute])
87 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
89 extern void __attribute__((error("message"))) barf(void);
98 AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_ERROR]), 1,
99 [Define to 1 if your compiler supports __attribute__((error)) on functions])],
100 [AC_MSG_RESULT([no])])