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(AC_INCLUDES_DEFAULT,
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 Attempt to add the given option to CFLAGS and LDFLAGS,
21 dnl if it doesn't break compilation
22 dnl --------------------------------------------------------------------------
23 AC_DEFUN(PA_ADD_CLDFLAGS,
24 [AC_MSG_CHECKING([if $CC accepts $1])
25 pa_add_cldflags__old_cflags="$CFLAGS"
27 pa_add_cldflags__old_ldflags="$LDFLAGS"
29 AC_TRY_LINK(AC_INCLUDES_DEFAULT,
30 [printf("Hello, World!\n");],
32 CFLAGS="$pa_add_cldflags__old_cflags ifelse([$2],[],[$1],[$2])"
33 LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])"],
35 CFLAGS="$pa_add_cldflags__old_cflags"
36 LDFLAGS="$pa_add_cldflags__old_ldflags"])])
38 dnl --------------------------------------------------------------------------
41 dnl Look for a function with the specified arguments which could be
42 dnl a builtin/intrinsic function.
43 dnl --------------------------------------------------------------------------
44 AC_DEFUN(PA_HAVE_FUNC,
45 [AC_MSG_CHECKING([for $1])
46 AC_TRY_LINK([], [(void)$1$2;],
48 AC_DEFINE(m4_toupper([HAVE_$1]), [1],
49 [Define to 1 if you have the `$1' intrinsic function.]),
50 AC_MSG_RESULT([no]))])
52 dnl --------------------------------------------------------------------------
55 dnl Guess the library extension based on the object extension
56 dnl --------------------------------------------------------------------------
58 [AC_MSG_CHECKING([for suffix of library files])
59 if test x"$LIBEXT" = x; then
69 AC_MSG_RESULT([$LIBEXT])
72 dnl --------------------------------------------------------------------------
75 dnl See if this compiler supports the equivalent of a specific gcc
76 dnl attribute on a function, using the __attribute__(()) syntax.
77 dnl All arguments except the attribute name are optional.
78 dnl PA_FUNC_ATTRIBUTE(attribute, attribute_opts, return_type,
79 dnl prototype_args, call_args)
80 dnl --------------------------------------------------------------------------
81 AC_DEFUN(PA_FUNC_ATTRIBUTE,
82 [AC_MSG_CHECKING([if $CC supports the $1 function attribute])
83 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
85 extern ifelse([$3],[],[void *],[$3]) __attribute__(($1$2))
86 bar(ifelse([$4],[],[int],[$4]));
90 return bar(ifelse([$5],[],[1],[$5]));
94 AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_$1]), 1,
95 [Define to 1 if your compiler supports __attribute__(($1)) on functions])],
96 [AC_MSG_RESULT([no])])
99 dnl --------------------------------------------------------------------------
100 dnl PA_FUNC_ATTRIBUTE_ERROR
102 dnl See if this compiler supports __attribute__((error("foo")))
103 dnl The generic version of this doesn't work as it makes the compiler
104 dnl throw an error by design.
105 dnl --------------------------------------------------------------------------
106 AC_DEFUN(PA_FUNC_ATTRIBUTE_ERROR,
107 [AC_MSG_CHECKING([if $CC supports the error function attribute])
108 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
110 extern void __attribute__((error("message"))) barf(void);
118 [AC_MSG_RESULT([yes])
119 AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_ERROR]), 1,
120 [Define to 1 if your compiler supports __attribute__((error)) on functions])],
121 [AC_MSG_RESULT([no])])
124 dnl --------------------------------------------------------------------------
128 dnl Simpler-to-use versions of AC_ARG_ENABLED, that include the
129 dnl test for $enableval and the AS_HELP_STRING definition
130 dnl --------------------------------------------------------------------------
131 AC_DEFUN(PA_ARG_ENABLED,
132 [AC_ARG_ENABLE([$1], [AS_HELP_STRING([--enable-$1],[$2])], [], [enableval=no])
133 AS_IF([test x"$enableval" != xno], [$3], [$4])
136 AC_DEFUN(PA_ARG_DISABLED,
137 [AC_ARG_ENABLE([$1],[AS_HELP_STRING([--disable-$1],[$2])], [], [enableval=yes])
138 AS_IF([test x"$enableval" = xno], [$3], [$4])