-
Notifications
You must be signed in to change notification settings - Fork 48
/
configure.ac
267 lines (231 loc) · 5.77 KB
/
configure.ac
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#
# Copyright (C) 2012 by Jules Colding <[email protected]>.
#
# All Rights Reserved.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
AC_PREREQ([2.68])
AC_INIT([disruptorC],[0.5.0],[[email protected]])
AC_COPYRIGHT([Copyright (C) 2012 Jules Colding. All Rights Reserved.])
# For GCC extensions
AC_USE_SYSTEM_EXTENSIONS
AC_CONFIG_SRCDIR([bootstrap])
AC_CONFIG_HEADERS([ac_config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
dnl Standard checks
AC_LANG([C])
AC_PROG_CXX
dnl Initialize libtool
LT_INIT([disable-shared])
AC_SUBST([LIBTOOL_DEPS])
# unset -g -O2 in CFLAGS unless the user specified otherwise
AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], [CFLAGS=""])
# Checks for programs.
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([unistd.h stdio.h stdlib.h string.h inttypes.h sys/time.h pthread.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT64_T
# Checks for library functions.
AC_CHECK_FUNCS([malloc memset sysconf])
#
# Check implementation details of build host
#
# Check for __atomic* builtins
AC_MSG_CHECKING([for __atomic builtins])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
]],
[[
int n = 1;
int m = 0;
m = __atomic_fetch_add(&n, 1, __ATOMIC_SEQ_CST);
]]
)],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [the compiler supports __atomic builtins])
],
[
AC_MSG_RESULT([no])
AC_MSG_FAILURE([compiler support for __atomic builtins are required])
]
)
# Check for sysconf(_SC_PAGESIZE) - Used by disruptorC
AC_MSG_CHECKING([for sysconf(_SC_PAGESIZE)])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <unistd.h>
]],
[[
return (-1 != sysconf(_SC_PAGESIZE)) ? 0 : 1;
]]
)],
[
AC_MSG_RESULT([ok])
],
[
AC_MSG_RESULT([no])
AC_MSG_FAILURE([platform support for sysconf(_SC_PAGESIZE) is required])
],
[
AC_MSG_RESULT([no])
AC_MSG_FAILURE([platform support for sysconf(_SC_PAGESIZE) is required])
]
)
# Check for cache line size - Used by disruptorC
AC_MSG_CHECKING([for cache line size])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stddef.h>
#if defined __APPLE__
#include <sys/sysctl.h>
#elif defined __linux__
#include <stdio.h>
#elif (defined(__FreeBSD__) || defined(__NetBSD__))
#include <sys/param.h>
#else
#error unrecognized platform
#endif
]],
[[
#if defined __APPLE__
size_t line_size = 0;
size_t sizeof_line_size = sizeof(line_size);
if (sysctlbyname("hw.cachelinesize", &line_size, &sizeof_line_size, 0, 0))
return 1;
return 0;
#elif defined __linux__
FILE *p = 0;
p = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r");
unsigned int i = 0;
if (p) {
if (1 != fscanf(p, "%u", &i))
return 1;
fclose(p);
} else {
return 1;
}
return 0;
#elif defined CACHE_LINE_SIZE
return 0;
#else
return 1;
#endif
]]
)],
[
AC_MSG_RESULT([ok])
],
[
AC_MSG_FAILURE([could not deduce cache line size])
],
[
AC_MSG_FAILURE([could not deduce cache line size])
]
)
target=`uname`
case "x$target" in
xDarwin)
;;
xLinux)
;;
xFreeBSD)
;;
xNetBSD)
;;
*)
AC_MSG_ERROR([disruptorC is not supported on this operating system])
;;
esac
dnl
dnl CPPFLAGS, CFLAGS, LIBS and stuff
dnl
dnl Check for pthread support
AX_PTHREAD(
[
AX_NOOP()
],
[
AC_MSG_ERROR([pthreads are required])
]
)
dnl
dnl LIBS
dnl
LIBS="$PTHREAD_LIBS $LIBS"
AC_SUBST(LIBS)
dnl
dnl Check if the compiler supports -iquote DIR (from ltrace)
dnl
ac_cv_have_iquote=no
AC_MSG_CHECKING(whether compiler accepts -iquote dir)
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -iquote ."
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_have_iquote=yes],[])
CPPFLAGS="$save_CPPFLAGS"
AC_MSG_RESULT($ac_cv_have_iquote)
if test $ac_cv_have_iquote = yes; then
iquote="-iquote "
else
iquote="-I"
fi
dnl Should only be searchable in "" include statements
DISRUPTORC_INCLUDES="$iquote$DISRUPTORC_top_dir"
dnl
dnl CFLAGS
dnl
dnl Now set the preprocessor arguments
DISRUPTORC_CFLAGS="$DISRUPTORC_INCLUDES"
dnl Pthread stuff as needed
DISRUPTORC_CFLAGS="$DISRUPTORC_CFLAGS $PTHREAD_CFLAGS"
dnl Warnings and other compiler options
AX_CFLAGS_GCC_OPTION(-Wall, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Winline, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Werror, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Wundef, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Wpointer-arith, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Werror-implicit-function-declaration, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Wbad-function-cast, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Wcast-align, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-Wmissing-declarations, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-pipe, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-fno-strict-aliasing, DISRUPTORC_CFLAGS)
dnl AX_CFLAGS_GCC_OPTION(-ggdb, DISRUPTORC_CFLAGS)
AX_CFLAGS_GCC_OPTION(-O2, DISRUPTORC_CFLAGS)
dnl Needed to get size of int64 on linux
if test "x$target" = "xLinux"; then
DISRUPTORC_CFLAGS="$DISRUPTORC_CFLAGS -D__STDC_LIMIT_MACROS"
fi
AC_SUBST(DISRUPTORC_CFLAGS)
dnl
dnl LDFLAGS
dnl
if test "x$target" = "xDarwin"; then
LDFLAGS="-flat_namespace $LDFLAGS"
fi
LDFLAGS="-L$DISRUPTORC_top_dir/ $LDFLAGS"
AC_SUBST(LDFLAGS)
dnl ******************************
dnl Makefiles
dnl ******************************
AC_CONFIG_FILES([Makefile
src/Makefile
test/Makefile
])
AC_OUTPUT
echo "\
Target Platform: $target
DISRUPTORC_CFLAGS: $DISRUPTORC_CFLAGS
"