forked from riboseinc/retrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
276 lines (244 loc) · 9 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
268
269
270
271
272
273
274
275
276
AC_PREREQ(2.60)
AC_INIT([retrace], [2.0.1], [https://github.com/riboseinc/retrace/issues])
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_HOST
AC_PROG_CC([egcc gcc cl cc])
AM_PROG_CC_C_O
AC_USE_SYSTEM_EXTENSIONS
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AM_PROG_AS
LT_INIT
AC_ENABLE_SHARED
AC_ENABLE_STATIC(no)
AC_PREFIX_DEFAULT([/usr/local])
AC_SEARCH_LIBS(socket, [socket network])
AC_SEARCH_LIBS(dlopen, [dl])
AC_SEARCH_LIBS(inet_aton, [resolv])
AC_SEARCH_LIBS([pthread_create], [pthread])
# list all used system headers for checking
AC_CHECK_HEADERS_ONCE(m4_flatten([
ctype.h
dlfcn.h
dirent.h
lwp.h
pthread.h
pthread_np.h
pwd.h
runetype.h
string.h
stdio.h
string.h
stdarg.h
stdlib.h
syscall.h
stdarg.h
time.h
unistd.h
execinfo.h
sys/stat.h
sys/utsname.h
sys/time.h
sys/types.h
]))
# add more host definitions if needed.
islinux=no
isdarwin=no
isfreebsd=no
isopenbsd=no
case $host_os in
linux* )
islinux=yes
;;
darwin* )
isdarwin=yes
;;
*freebsd* )
isfreebsd=yes
;;
openbsd* )
isopenbsd=yes
;;
esac
AM_CONDITIONAL([LINUX], [test "x$islinux" = "xyes"])
AM_CONDITIONAL([DARWIN], [test "x$isdarwin" = "xyes"])
AM_CONDITIONAL([FREEBSD], [test "x$isfreebsd" = "xyes"])
AM_CONDITIONAL([OPENBSD], [test "x$isopenbsd" = "xyes"])
# Linux specific configuration
#if test "x$islinux" = "xyes"; then
#fi
# MacOS specific configuration
if test "x$isdarwin" = "xyes"; then
CFLAGS="$CFLAGS -mmacosx-version-min=10.12 -D_DARWIN_C_SOURCE"
LDFLAGS="$LDFLAGS -mmacosx-version-min=10.12"
fi
# FreeBSD specific configuration
#if test "x$isfreebsd" = "xyes"; then
#fi
# OpenBSD specific configuration
if test "x$isopenbsd" = "xyes"; then
AC_DEFINE([STAILQ_INIT], [SIMPLEQ_INIT], [Define to SIMPLEQ_ for OpenBSD])
AC_DEFINE([STAILQ_ENTRY], [SIMPLEQ_ENTRY], [Define to SIMPLEQ_ for OpenBSD])
AC_DEFINE([STAILQ_HEAD], [SIMPLEQ_HEAD], [Define to SIMPLEQ_ for OpenBSD])
AC_DEFINE([STAILQ_INSERT_TAIL], [SIMPLEQ_INSERT_TAIL], [Define to SIMPLEQ_ for OpenBSD])
AC_DEFINE([STAILQ_FIRST], [SIMPLEQ_FIRST], [Define to SIMPLEQ_ for OpenBSD])
AC_DEFINE([STAILQ_NEXT], [SIMPLEQ_NEXT], [Define to SIMPLEQ_ for OpenBSD])
AC_DEFINE([STAILQ_FOREACH], [SIMPLEQ_FOREACH], [Define to SIMPLEQ_ for OpenBSD])
fi
# Test for __atomic support
AC_MSG_CHECKING([for gcc __atomic builtins])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([int i;],
[__atomic_load_n (&i, __ATOMIC_ACQUIRE);
__atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
[have_atomic_builtins=yes],
[have_atomic_builtins=no])
if test "x$have_atomic_builtins" = "xyes"; then
AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1],
[Define to 1 if gcc __atomic builtins are available])
fi
AC_MSG_RESULT([$have_atomic_builtins])
AC_CHECK_DECLS([O_TMPFILE], [], [], [#include <fcntl.h>])
# Check for PTRACE features
AC_CHECK_DECLS([PTRACE_GETREGS, PTRACE_GETREGSET, PTRACE_SETREGSET], [], [], [#include <sys/ptrace.h.h>])
AC_CHECK_DECLS([PTRACE_SEIZE], [], [], [#include <sys/ptrace.h.h>])
AC_CHECK_DECLS([PTRACE_INTERRUPT], [], [], [#include <sys/ptrace.h.h>])
AC_CHECK_DECLS([PTRACE_LISTEN], [], [], [#include <sys/ptrace.h.h>])
AC_CHECK_DECLS([PTRACE_PEEKSIGINFO], [], [], [#include <sys/ptrace.h.h>])
# Check fcntl features
AC_CHECK_DECLS([F_DUPFD_CLOEXEC], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_SETOWN, F_GETOWN], [], [], [#include <fcntl.h>])
AC_CHECK_TYPES([struct flock], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_SETLKW], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_GETPATH], , [], [#include <fcntl.h>])
AC_CHECK_TYPES([struct fstore], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_PREALLOCATE], [], [], [#include <fcntl.h>])
AC_CHECK_TYPES([struct fpunchhole], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_PUNCHHOLE], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_SETSIZE], [], [], [#include <fcntl.h>])
AC_CHECK_TYPES([struct radvisory], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_RDADVISE], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_RDAHEAD], [], [], [#include <fcntl.h>])
AC_CHECK_TYPES([struct fbootstraptransfer], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_READBOOTSTRAP, F_WRITEBOOTSTRAP], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_NOCACHE], [], [], [#include <fcntl.h>])
AC_CHECK_TYPES([struct log2phys], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_LOG2PHYS, F_LOG2PHYS_EXT], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_FULLFSYNC], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_SETNOSIGPIPE, F_GETNOSIGPIPE], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_OFD_SETLK, F_OFD_SETLKW, F_OFD_GETLK], [], [], [#include <fcntl.h>])
AC_CHECK_TYPES([struct f_owner_ex], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_GETOWN_EX, F_SETOWN_EX], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_GETSIG, F_SETSIG], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_SETLEASE, F_GETLEASE], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_NOTIFY], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_SETPIPE_SZ, F_GETPIPE_SZ], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([F_ADD_SEALS, F_GET_SEALS], [], [], [#include <fcntl.h>])
AC_CHECK_DECLS([SOCK_PACKET], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_BINDTODEVICE], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_BSDCOMPAT], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_DOMAIN], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_MARK], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_PASSCRED], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_PEERCRED], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_PRIORITY], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_PROTOCOL], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_RXQ_OVFL], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_SNDBUFFORCE], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_RCVBUFFORCE], [], [], [#include <sys/socket.h>])
AC_CHECK_DECLS([SO_BUSY_POLL], [], [], [#include <sys/socket.h>])
TESTS_CFLAGS=""
AC_MSG_CHECKING(whether to run tests)
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--enable-tests], [enable running tests on make check (default is NO)])],
[enable_tests=${enableval}],
[enable_tests=no])
AC_MSG_RESULT($enable_test)
AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"])
if test "x$enable_tests" = "xyes" ; then
AC_MSG_NOTICE([yes])
TESTS_CFLAGS="$TESTS_CFLAGS -fno-builtin"
else
AC_MSG_NOTICE([no])
fi
AC_SUBST([TESTS_CFLAGS])
AX_CHECK_CMOCKA([cmocka=true], )
AX_CHECK_OPENSSL([], AC_MSG_ERROR([]))
AM_CONDITIONAL([CMOCKA], [test "x$cmocka" = "xtrue"])
if test "x$cmocka" = "xtrue" ; then
AC_DEFINE(USE_CMOCKA, [1], [Define to use cmocka])
else
AC_DEFINE(USE_CMOCKA, [0], [Define to use cmocka])
fi
AC_ARG_ENABLE(debug,
AS_HELP_STRING(--enable-debug, turn on debugging (disabled by default)),
[], [enable_debug=no]
)
# Disable optimizations always for now as -O2 is crashing v2
CFLAGS="$CFLAGS -O0"
if test "x$enable_debug" = "xyes" ; then
CFLAGS="$CFLAGS -g3 -O0 -DDEBUG"
fi
AC_ARG_ENABLE(profiling,
AS_HELP_STRING(--enable-profiling, turn on profiling (disabled by default)),
[], [enable_profiling=no]
)
if test "x$enable_profiling" = "xyes" ; then
CFLAGS="$CFLAGS -pg"
fi
AC_MSG_CHECKING(whether to enable retrace v2)
AC_ARG_ENABLE(
[v2],
[AS_HELP_STRING([--enable-v2], [enable retrace version 2 @<:@default=no@:>@])],
,
[enable_v2="no"]
)
AC_MSG_RESULT($enable_v2)
AM_CONDITIONAL([RTR_V2], [test "x$enable_v2" = "xyes"])
if test "x$enable_v2" = "xyes" ; then
AC_DEFINE(RTR_V2, [1], [Define to use retrace v2])
else
AC_DEFINE(RTR_V2, [0], [Define to use retrace v2])
fi
AC_MSG_RESULT($enable_v2_wrapper)
AM_CONDITIONAL([RTR_V2_WRAPPER], [test "x$enable_v2_wrapper" = "xyes"])
if test "x$enable_v2_wrapper" = "xyes" ; then
AX_CHECK_NEREON([], AC_MSG_ERROR([]))
AC_DEFINE(RTR_V2_WRAPPER, [1], [Define to use retrace v2 wrapper])
else
AC_DEFINE(RTR_V2_WRAPPER, [0], [Define to use retrace v2 wrapper])
fi
AC_MSG_CHECKING(whether to enable rpc)
AC_ARG_ENABLE(rpc,
AS_HELP_STRING(--enable-rpc, turn on rpc (disabled by default)),
[], [enable_rpc=no]
)
AC_MSG_RESULT($enable_rpc)
AM_CONDITIONAL([RTR_RPC], [test "x$enable_rpc" = "xyes"])
if test "x$enable_rpc" = "xyes" ; then
AC_DEFINE(RTR_RPC, [1], [Define to use rpc])
else
AC_DEFINE(RTR_RPC, [0], [Define to use rpc])
fi
backtrace=false
AC_CHECK_HEADERS([execinfo.h], [backtrace=true], [AC_MSG_NOTICE([execinfo.h not found, backtrace disabled])])
if test "x$backtrace" = "xtrue" ; then
AC_DEFINE(BACKTRACE, [1], [Define to enable backtrace])
else
AC_DEFINE(BACKTRACE, [0], [Define to enable backtrace])
fi
AC_CONFIG_FILES([Makefile
src/Makefile
src/v1/Makefile
src/v2/Makefile
test/Makefile
rpc/Makefile
tools/Makefile
tools/stringinjector/Makefile
tools/spawn/Makefile
])
AC_OUTPUT