-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacinclude.m4
167 lines (153 loc) · 4.16 KB
/
acinclude.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# AC_CHECK_FASTCALL([if-ok],[if-notok])
# Test if the compiler recognizes __attribute__((regparm(3))) - we don't
# currently check if it actually works correctly, but probably should...
# -----------------------
AC_DEFUN([AC_CHECK_FASTCALL], [
AC_MSG_CHECKING([support for fastcall calling conventions]);
save_CFLAGS="$CFLAGS"
CFLAGS="-Werror $save_CFLAGS"
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
int __attribute__((regparm(3))) foo(int a, int b) { return a+b; }
int main(int argc, char *argv[])
{
return foo( 1, 2 ) == 3 ? 0 : 1;
}]])], [
AC_MSG_RESULT([yes])
$1 ], [
AC_MSG_RESULT([no])
$2 ], [
AC_MSG_RESULT([no])
$2 ])
CFLAGS="$save_CFLAGS"
])
# AC_CHECK_FORCEINLINE([if-ok],[if-notok])
# Test if the compiler recognizes __attribute__((always_inline))
# -----------------------
AC_DEFUN([AC_CHECK_FORCEINLINE], [
AC_MSG_CHECKING([support for force inlining]);
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[
static int __attribute__((always_inline)) foo(int a, int b) { return a+b; }
int main(int argc, char *argv[])
{
return foo( 1, 2 ) == 3 ? 0 : 1;
}]])], [
FORCEINLINE="__attribute__((always_inline))"
AC_MSG_RESULT([$FORCEINLINE])
$1 ], [
FORCEINLINE=""
AC_MSG_RESULT([no])
$2 ])
])
# AC_CHECK_FRAME_ADDRESS([if-ok],[if-notok])
# Test if the compiler will let us modify the return address on the stack
# via __builtin_frame_address()
# -----------------------
AC_DEFUN([AC_CHECK_FRAME_ADDRESS], [
AC_MSG_CHECKING([if we have a working __builtin_frame_address()]);
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
void * __attribute__((noinline)) first_arg( void *x, void *y ) { return x; }
int __attribute__((noinline)) foo( int arg, void *exc )
{
if( arg < 2 ) {
*(((void * volatile *)__builtin_frame_address(0))+1) = exc;
}
return 0;
}
int main(int argc, char *argv[])
{
goto *first_arg(&&start, &&except);
start:
return foo( argc, &&except ) + 1;
except:
return 0;
}]])], [
AC_MSG_RESULT([yes])
$1 ], [
AC_MSG_RESULT([no])
$2 ], [
AC_MSG_RESULT([no])
$2 ] )
])
# AC_CC_VERSION([if-gcc], [if-icc],[if-other])
# Check which C compiler we're using and branch accordingly, eg to set
# different optimization flags. Currently recognizes gcc and icc
# ---------------
AC_DEFUN([AC_CC_VERSION], [
_GCC_VERSION=`$CC --version | $SED -ne '/gcc/p'`
_ICC_VERSION=`$CC --version | $SED -ne '/(ICC)/p'`
AC_MSG_CHECKING([CC version])
if test -n "$_ICC_VERSION"; then
AC_MSG_RESULT([ICC])
[ $2 ]
elif test -n "$_GCC_VERSION"; then
AC_MSG_RESULT([GCC])
[ $1 ]
else
AC_MSG_RESULT([Unknown])
[ $3 ]
fi
]);
# AC_OBJC_VERSION([if-gcc],[if-other], [if-none])
# Check which objective C compiler we're using and branch accordingly.
AC_DEFUN([AC_OBJC_VERSION], [
AC_MSG_CHECKING([OBJC version])
if test -n "$OBJC"; then
_GOBJC_VERSION=`$OBJC --version | $SED -ne '/(GCC)/p'`
if test -n "$_GOBJC_VERSION"; then
AC_MSG_RESULT([GCC])
[ $1 ]
else
AC_MSG_RESULT([Unknown])
[ $2 ]
fi
else
AC_MSG_RESULT([None])
[ $3 ]
fi
]);
# Check if the given C compiler flag is supported, and if so add it to CFLAGS
AC_DEFUN([AC_CHECK_CFLAG], [
AC_LANG_PUSH([C])
AC_MSG_CHECKING([if $CC supports $1])
save_CFLAGS="$CFLAGS"
CFLAGS="$1 $CFLAGS"
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([int main() { return 0; }])], [
AC_MSG_RESULT([yes])
$2 ], [
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT([no])
$3 ])
AC_LANG_POP([C])
])
# Check if the given OBJC compiler flag is supported, and if so add it to OBJCFLAGS
AC_DEFUN([AC_CHECK_OBJCFLAG], [
AC_LANG_PUSH([Objective C])
AC_MSG_CHECKING([if $OBJC supports $1])
save_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$1 $OBJCFLAGS"
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([int main() { return 0; }])], [
AC_MSG_RESULT([yes])
$2 ], [
OBJCFLAGS="$save_OBJCFLAGS"
AC_MSG_RESULT([no])
$3 ])
AC_LANG_POP([Objective C])
])
# AC_HAVE_OBJC([if-present],[if-not-present])
# Check if we have a working Objective-C compiler
AC_DEFUN([AC_HAVE_OBJC], [
AC_PROG_OBJC
AC_MSG_CHECKING([for a working Objective-C compiler])
AC_LANG_PUSH([Objective C])dnl
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@interface Foo @end]], [])],
[AC_MSG_RESULT([yes])
$1 ],
[AC_MSG_RESULT([No])
$2 ]);
AC_LANG_POP([Objective C])
]);