10554
|
1 dnl --------------------------------------------------------------------------
|
|
2 dnl PA_ADD_CFLAGS()
|
|
3 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"
|
|
9 CFLAGS="$CFLAGS $1"
|
|
10 AC_TRY_LINK([#include <stdio.h>],
|
|
11 [printf("Hello, World!\n");],
|
|
12 AC_MSG_RESULT([yes])
|
|
13 CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])",
|
|
14 AC_MSG_RESULT([no])
|
|
15 CFLAGS="$pa_add_cflags__old_cflags")])
|
|
16
|
|
17 dnl --------------------------------------------------------------------------
|
|
18 dnl PA_ADD_CLDFLAGS()
|
|
19 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"
|
|
26 CFLAGS="$CFLAGS $1"
|
|
27 pa_add_cldflags__old_ldflags="$LDFLAGS"
|
|
28 LDFLAGS="$LDFLAGS $1"
|
|
29 AC_TRY_LINK([#include <stdio.h>],
|
|
30 [printf("Hello, World!\n");],
|
|
31 AC_MSG_RESULT([yes])
|
|
32 CFLAGS="$pa_add_cldflags__old_cflags ifelse([$2],[],[$1],[$2])"
|
|
33 LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])",
|
|
34 AC_MSG_RESULT([no])
|
|
35 CFLAGS="$pa_add_cldflags__old_cflags"
|
|
36 LDFLAGS="$pa_add_cldflags__old_ldflags")])
|
|
37
|
|
38 dnl --------------------------------------------------------------------------
|
|
39 dnl PA_HAVE_FUNC
|
|
40 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;],
|
|
47 AC_MSG_RESULT([yes])
|
|
48 AC_DEFINE(m4_toupper([HAVE_$1]), [1],
|
|
49 [Define to 1 if you have the `$1' intrinsic function.]),
|
|
50 AC_MSG_RESULT([no]))])
|
|
51
|
|
52 dnl --------------------------------------------------------------------------
|
|
53 dnl PA_LIBEXT
|
|
54 dnl
|
|
55 dnl Guess the library extension based on the object extension
|
|
56 dnl --------------------------------------------------------------------------
|
|
57 AC_DEFUN(PA_LIBEXT,
|
|
58 [AC_MSG_CHECKING([for suffix of library files])
|
|
59 if test x"$LIBEXT" = x; then
|
|
60 case "$OBJEXT" in
|
|
61 obj )
|
|
62 LIBEXT=lib
|
|
63 ;;
|
|
64 *)
|
|
65 LIBEXT=a
|
|
66 ;;
|
|
67 esac
|
|
68 fi
|
|
69 AC_MSG_RESULT([$LIBEXT])
|
|
70 AC_SUBST([LIBEXT])])
|
|
71
|
|
72 dnl --------------------------------------------------------------------------
|
|
73 dnl PA_FUNC_ATTRIBUTE
|
|
74 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([
|
|
84 #include <stdarg.h>
|
|
85 extern ifelse([$3],[],[void *],[$3]) __attribute__(($1$2))
|
|
86 bar(ifelse([$4],[],[int],[$4]));
|
|
87 void *foo(void);
|
|
88 void *foo(void)
|
|
89 {
|
|
90 return bar(ifelse([$5],[],[1],[$5]));
|
|
91 }
|
|
92 ])],
|
|
93 [AC_MSG_RESULT([yes])
|
|
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])])
|
|
97 ])
|
|
98
|
|
99 dnl --------------------------------------------------------------------------
|
|
100 dnl PA_FUNC_ATTRIBUTE_ERROR
|
|
101 dnl
|
|
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([
|
|
109 #include <stdarg.h>
|
|
110 extern void __attribute__((error("message"))) barf(void);
|
|
111 void foo(void);
|
|
112 void foo(void)
|
|
113 {
|
|
114 if (0)
|
|
115 barf();
|
|
116 }
|
|
117 ])],
|
|
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])])
|
|
122 ])
|