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 Canonicalize a variable name: upper case, and fold non-C characters
43 dnl --------------------------------------------------------------------------
44 AC_DEFUN(PA_VAR, [patsubst(m4_toupper([$1]),[[^A-Za-z0-9_]],[_])])
46 dnl --------------------------------------------------------------------------
49 dnl Look for a function with the specified arguments which could be
50 dnl a builtin/intrinsic function.
51 dnl --------------------------------------------------------------------------
52 AC_DEFUN(PA_HAVE_FUNC,
53 [AC_MSG_CHECKING([for $1])
54 AC_TRY_LINK(AC_INCLUDES_DEFAULT, [(void)$1$2;],
56 AC_DEFINE(PA_VAR([HAVE_$1]), [1],
57 [Define to 1 if you have the `$1' intrinsic function.]),
58 AC_MSG_RESULT([no]))])
60 dnl --------------------------------------------------------------------------
63 dnl Guess the library extension based on the object extension
64 dnl --------------------------------------------------------------------------
66 [AC_MSG_CHECKING([for suffix of library files])
67 if test x"$LIBEXT" = x; then
77 AC_MSG_RESULT([$LIBEXT])
80 dnl --------------------------------------------------------------------------
83 dnl See if this compiler supports the equivalent of a specific gcc
84 dnl attribute on a function, using the __attribute__(()) syntax.
85 dnl All arguments except the attribute name are optional.
86 dnl PA_FUNC_ATTRIBUTE(attribute, attribute_opts, return_type,
87 dnl prototype_args, call_args)
88 dnl --------------------------------------------------------------------------
89 AC_DEFUN(PA_FUNC_ATTRIBUTE,
90 [AC_MSG_CHECKING([if $CC supports the $1 function attribute])
91 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
93 extern ifelse([$3],[],[void *],[$3]) __attribute__(($1$2))
94 bar(ifelse([$4],[],[int],[$4]));
98 return bar(ifelse([$5],[],[1],[$5]));
101 [AC_MSG_RESULT([yes])
102 AC_DEFINE(PA_VAR([HAVE_FUNC_ATTRIBUTE_$1]), 1,
103 [Define to 1 if your compiler supports __attribute__(($1)) on functions])],
104 [AC_MSG_RESULT([no])])
107 dnl --------------------------------------------------------------------------
108 dnl PA_FUNC_ATTRIBUTE_ERROR
110 dnl See if this compiler supports __attribute__((error("foo")))
111 dnl The generic version of this doesn't work as it makes the compiler
112 dnl throw an error by design.
113 dnl --------------------------------------------------------------------------
114 AC_DEFUN(PA_FUNC_ATTRIBUTE_ERROR,
115 [AC_MSG_CHECKING([if $CC supports the error function attribute])
116 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
118 extern void __attribute__((error("message"))) barf(void);
126 [AC_MSG_RESULT([yes])
127 AC_DEFINE(PA_VAR([HAVE_FUNC_ATTRIBUTE_ERROR]), 1,
128 [Define to 1 if your compiler supports __attribute__((error)) on functions])],
129 [AC_MSG_RESULT([no])])
132 dnl --------------------------------------------------------------------------
136 dnl Simpler-to-use versions of AC_ARG_ENABLED, that include the
137 dnl test for $enableval and the AS_HELP_STRING definition
138 dnl --------------------------------------------------------------------------
139 AC_DEFUN(PA_ARG_ENABLED,
140 [AC_ARG_ENABLE([$1], [AS_HELP_STRING([--enable-$1],[$2])], [], [enableval=no])
141 AS_IF([test x"$enableval" != xno], [$3], [$4])
144 AC_DEFUN(PA_ARG_DISABLED,
145 [AC_ARG_ENABLE([$1],[AS_HELP_STRING([--disable-$1],[$2])], [], [enableval=yes])
146 AS_IF([test x"$enableval" = xno], [$3], [$4])
149 dnl --------------------------------------------------------------------------
152 dnl Call AC_CHECK_HEADERS(), and add to ac_includes_default if found
153 dnl --------------------------------------------------------------------------
154 AC_DEFUN(_PA_ADD_HEADER,
155 [AC_CHECK_HEADERS([$1],[ac_includes_default="$ac_includes_default
158 AC_DEFUN(PA_ADD_HEADERS,
159 [m4_map_args_w([$1],[_PA_ADD_HEADER(],[)])])