forked from uperf/uperf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
397 lines (367 loc) · 11.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# uperf configure file
AC_INIT([uperf],[1.0.8],[[email protected]])
AC_CONFIG_SRCDIR([src/flowops.c])
AC_CONFIG_HEADERS([config.h])
CFLAGS="${CFLAGS=}"
UPERF_LIBS="${UPERF_LIBS=}"
#UPERF_LIBS="$UPERF_LIBS -lpthread -lrt -lm"
# Checks for programs.
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_MAKE_SET
if test "x$CC" = "xcc" -a "x$(uname -s)" = "xSunOS"; then
AC_MSG_NOTICE([*** Setting flags for Sun Compiler ***])
CFLAGS="$CFLAGS -mt -xO3"
else
AC_MSG_NOTICE([*** Setting flags for gcc ***])
CFLAGS="$CFLAGS -O2 -D_REENTRANT"
fi
AM_CONDITIONAL([HAVE_PROCESSES], [true])
AM_CONDITIONAL([HAVE_CPC], [false])
AM_CONDITIONAL([HAVE_KSTAT], [false])
#enable these by default
netstat_default="yes"
udp_default="yes"
rds_default="no"
sctp_default="yes"
vsock_default="yes"
ssl_default="yes"
cpc_default="yes"
good_os="yes"
case "$(uname -s)" in
FreeBSD)
AC_MSG_NOTICE([*** FreeBSD Machine ***])
AC_DEFINE([UPERF_FREEBSD],[1],[Setting machine os to FreeBSD])
good_os="no"
sctp_default="yes"
ssl_default="yes"
UPERF_LIBS="$UPERF_LIBS -lrt -lm -pthread"
CFLAGS="-D_GNU_SOURCE $CFLAGS"
;;
Linux)
AC_MSG_NOTICE([*** Linux Machine ***])
AC_DEFINE([UPERF_LINUX],[1],[Setting machine os to Linux])
good_os="no"
sctp_default="yes"
ssl_default="no"
cpc_default="no"
UPERF_LIBS="$UPERF_LIBS -lrt -lm -lpthread"
CFLAGS="-D_GNU_SOURCE $CFLAGS"
;;
SunOS)
AC_MSG_NOTICE([*** Solaris Machine ***])
AC_DEFINE([UPERF_SOLARIS],[1],[Setting machine os to Solaris])
UPERF_LIBS="$UPERF_LIBS -lrt -lm -lsocket -lnsl -lumem -lkstat -lsendfile"
LIBS=$UPERF_LIBS
;;
Darwin)
AC_MSG_NOTICE([*** Darwin Machine ***])
AC_DEFINE([UPERF_DARWIN],[1],[Setting machine os to Darwin])
good_os="no"
sctp_default="no"
ssl_default="no"
UPERF_LIBS="$UPERF_LIBS -lm"
CFLAGS="-D_GNU_SOURCE -Wno-deprecated-declarations $CFLAGS"
;;
esac
AC_CHECK_TYPES([hrtime_t], [], [], [[#include <sys/time.h>]])
AC_CHECK_TYPES([uint64_t, uint32_t], [], [], [[#include <stdint.h>]])
# Solaris 9 and below do not support RUSAGE_LWP with getrusage
# fallback to using /proc if not defined
AC_MSG_CHECKING(if we can use getrusage)
AC_COMPILE_IFELSE([AC_LANG_SOURCE[#include <sys/resource.h>
int i=RUSAGE_LWP;]],
[AC_MSG_RESULT(yes)
AC_DEFINE([USE_GETRUSAGE],[1],[Have getrusage])
],
[
AC_MSG_RESULT(no)
## AC_DEFINE([USE_PROC], [1], [Use proc])
])
# Some solaris versions do not define BSWAP_* macros
AC_MSG_CHECKING(BSWAP_ macros)
AC_LINK_IFELSE([AC_LANG_SOURCE[#include <sys/byteorder.h>
int main(int argc, char *argv[]){int i=BSWAP_32(1);}]],
[AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_BSWAP],[1],[Have BSWAP_ macros])
],
[AC_MSG_RESULT(no)
])
# Linux 2.6 does not have sendfilev
AC_MSG_CHECKING(sendfilev)
AC_LINK_IFELSE([AC_LANG_SOURCE[#include <sys/sendfile.h>
int main() {int i=sendfilev(1,0, 1, 0);}]],
[AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_SENDFILEV],[1],[Have sendfilev])
],
[AC_MSG_RESULT(no)
])
# Check for PTHREAD_PROCESS_SHARED. Have to run it to see if it works
# as its declared, but does not work on FreeBSD
LIBS="$UPERF_LIBS"
AC_MSG_CHECKING(if we can have working PTHREAD_PROCESS_SHARED)
process_shared_works=yes
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <pthread.h>
#include <sys/types.h>
int
main(int argc, char *argv[])
{
pthread_rwlockattr_t rwattr;
pthread_rwlock_t barrier;
pthread_mutexattr_t attr;
pthread_mutex_t lock;
if (pthread_mutexattr_init(&attr)) {
return (1);
}
if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) {
return (1);
}
if (pthread_mutex_init(&lock, &attr)) {
return (1);
}
if (pthread_mutex_lock(&lock)) {
return (1);
}
if (pthread_mutex_unlock(&lock)) {
return (1);
}
if (pthread_rwlockattr_init(&rwattr))
return (1);
if (pthread_rwlockattr_setpshared(&rwattr, PTHREAD_PROCESS_SHARED))
return (1);
if (pthread_rwlock_init(&barrier, &rwattr))
return (1);
if (pthread_rwlock_wrlock(&barrier))
return (1);
if (pthread_rwlock_unlock(&barrier))
return (1);
return (0);
}]])],[AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
AC_DEFINE([STRAND_THREAD_ONLY], [1], [Use only threads])
AM_CONDITIONAL([HAVE_PROCESSES], [false])
],[])
# Checks for libraries.
AC_MSG_CHECKING(whether to enable cpu performance counters support?)
AC_ARG_ENABLE(cpc,
AS_HELP_STRING([--enable-cpc],[Turn on cpu counter support ]),,
enable_cpc=$cpc_default)
if test "x$enable_cpc" = "xyes"; then
AC_MSG_RESULT(yes)
AC_CHECK_LIB([cpc], [cpc_open],
[
#AC_MSG_RESULT(yes)
AC_DEFINE([USE_CPC],[1],[Have cpu perf counters?])
AC_DEFINE([USE_CPCv2],[1],[Have version2 cpu perf counters?])
UPERF_LIBS="$UPERF_LIBS -lcpc -lintl"
cpc="CPC version 2"
AM_CONDITIONAL([HAVE_CPC], [true])
AC_DEFINE([HAVE_CPC],[1],[Have libcpc ])
],
[ #check for v1
AC_CHECK_LIB([cpc], [cpc_version],
[AC_DEFINE([USE_CPC],[1],[Have cpu perf counters?])
AC_DEFINE([USE_CPCv1],[1],[Have version1 cpu perf counters?])
UPERF_LIBS="$UPERF_LIBS -lcpc"
AM_CONDITIONAL([HAVE_CPC], [true])
AC_DEFINE([HAVE_CPC],[1],[Have libcpc ])
cpc="CPC version 1"
#AC_MSG_RESULT(yes)
],
[ AM_CONDITIONAL([HAVE_CPC], [false])
cpc="Not supported"
AC_DEFINE([HAVE_CPC],[0],[Have libcpc ])
]
)
]
)
else
cpc="Not enabled"
HAVE_CPC=
AM_CONDITIONAL([HAVE_CPC], [false])
AC_MSG_RESULT(no)
fi
AC_CHECK_LIB([kstat], [kstat_open],
[ AC_DEFINE([HAVE_LIBKSTAT], [1], [Have libkstat])
UPERF_LIBS="$UPERF_LIBS -lkstat"
AM_CONDITIONAL([ENABLE_NETSTAT], [true])
],
[ AM_CONDITIONAL([ENABLE_NETSTAT], [false])
]
)
AC_MSG_CHECKING(whether to enable netstat support)
AC_ARG_ENABLE(netstat,
AS_HELP_STRING([--enable-netstat],[Collect network stats? default=yes]),,
enable_netstat=$netstat_default)
if test "x$enable_netstat" = "xyes"; then
AM_CONDITIONAL([ENABLE_NETSTAT], [true])
AC_DEFINE([ENABLE_NETSTAT],[1],[collect nw stats])
AC_MSG_RESULT(yes)
else
ENABLE_NETSTAT=
AM_CONDITIONAL([ENABLE_NETSTAT], [false])
AC_MSG_RESULT(no)
fi
AC_CHECK_HEADERS([stdatomic.h atomic.h siginfo.h sys/int_limits.h sys/lwp.h signal.h sys/byteorder.h poll.h sys/poll.h sys/varargs.h stdint.h termio.h stropts.h sys/ttycom.h wait.h alloca.h sys/sendfile.h sys/types.h linux/unistd.h sys/ioctl.h sys/uio.h])
LIBS="$UPERF_LIBS"
AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([pthread_self])
AC_CHECK_FUNCS([_lwp_self])
AC_CHECK_FUNCS([strncpy])
AC_CHECK_FUNCS([strncat])
AC_CHECK_FUNCS([strlcpy])
AC_CHECK_FUNCS([strlcat])
AC_CHECK_FUNCS([gethrvtime])
AC_CHECK_FUNCS([gethrtime],[],
[AC_CHECK_FUNCS([clock_gettime],[],
[AC_CHECK_FUNCS([mach_absolute_time],[],
[AC_MSG_ERROR([Could not find either gethrtime nor clock_gettime nor mach_absolute_time])])])])
AC_MSG_CHECKING(whether to enable debug mode)
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],[Turn on debugging]),
[case "${enableval}" in
yes) debug=true
AC_DEFINE([DEBUG],[1],[Debug])
CFLAGS="$CFLAGS -g"
AC_MSG_RESULT(yes)
;;
no) debug=false
AC_MSG_RESULT(no)
;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[debug=false; AC_MSG_RESULT(no)])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
#check for udp
AC_MSG_CHECKING(whether to enable udp support)
AC_ARG_ENABLE(udp,
AS_HELP_STRING([--enable-udp],[Turn on udp support]),,
enable_udp=$udp_default)
if test "x$enable_udp" = "xyes"; then
AM_CONDITIONAL([UDP_C], [true])
AC_DEFINE([HAVE_UDP],[1],[Have udp])
AC_MSG_RESULT(yes)
else
UDP_C=
AM_CONDITIONAL([UDP_C], [false])
AC_MSG_RESULT(no)
fi
#check for rds
AC_MSG_CHECKING(whether to enable rds support)
AC_ARG_ENABLE(rds,
AS_HELP_STRING([--enable-rds],[Turn on rds support]),,
enable_rds=$rds_default)
if test "x$enable_rds" = "xyes"; then
AM_CONDITIONAL([RDS_C], [true])
AC_DEFINE([HAVE_RDS],[1],[Have rds])
AC_MSG_RESULT(yes)
else
RDS_C=
AM_CONDITIONAL([RDS_C], [false])
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(whether to enable sctp support)
AC_ARG_ENABLE(sctp,
AS_HELP_STRING([--enable-sctp],[Turn on sctp support ]),,
enable_sctp=$sctp_default)
if test "x$enable_sctp" = "xyes"; then
AC_MSG_RESULT(yes)
AC_CHECK_FUNC(sctp_sendv,
[AC_DEFINE([HAVE_SCTP_SENDV],[1], [Have sctp_sendv()])],
[AC_CHECK_LIB(sctp,
sctp_sendv,
[AC_DEFINE([HAVE_SCTP_SENDV],[1], [Have sctp_sendv()])
UPERF_LIBS="$UPERF_LIBS -lsctp"])])
AC_CHECK_FUNC(sctp_sendmsg,
[AC_DEFINE([HAVE_SCTP_SENDMSG],[1], [Have sctp_sendmsg()])],
[AC_CHECK_LIB(sctp,
sctp_sendmsg,
[AC_DEFINE([HAVE_SCTP_SENDMSG],[1], [Have sctp_sendmsg()])
UPERF_LIBS="$UPERF_LIBS -lsctp"])])
AM_CONDITIONAL([SCTP_C], [true])
AC_DEFINE([HAVE_SCTP],[1], [Have sctp])
else
SCTP_C=
AM_CONDITIONAL([SCTP_C], [false])
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(whether to enable vsock support)
AC_ARG_ENABLE(vsock,
AS_HELP_STRING([--enable-vsock],[Turn on vsock support]),,
enable_vsock=$vsock_default)
if test "x$enable_vsock" = "xyes"; then
AC_MSG_RESULT(yes)
AC_CHECK_HEADERS([linux/vm_sockets.h],
[AC_DEFINE([HAVE_VSOCK], [1], [Have vsock])
AM_CONDITIONAL([VSOCK_C], [true])],
[enable_vsock="no"
AM_CONDITIONAL([VSOCK_C], [false])],
[#include <sys/socket.h>]
)
else
AC_MSG_RESULT(no)
VSOCK_C=
AM_CONDITIONAL([VSOCK_C], [false])
fi
AC_ARG_WITH(ssl-includes,
AS_HELP_STRING([--with-ssl-includes=DIR],[Specify location of ssl headers]),
[CFLAGS="$CFLAGS -I$withval"],
[])
AC_ARG_WITH(ssl-libs,
AS_HELP_STRING([--with-ssl-libs=DIR],[Specify location of ssl libraries]),
[LDFLAGS="$LDFLAGS -L$withval"],
[])
##[LDFLAGS="$LDFLAGS -L$withval -R$withval"],
##[LDFLAGS="$LDFLAGS -L/usr/sfw/lib -R/usr/sfw/lib"])
AC_MSG_CHECKING(whether to enable ssl support)
AC_ARG_ENABLE(ssl,
AS_HELP_STRING([--enable-ssl],[Turn on ssl support ]),,
enable_ssl=$ssl_default)
if test "x$enable_ssl" = "xyes"; then
AC_MSG_RESULT(yes)
AC_CHECK_LIB([ssl], [SSL_CTX_new],[],
[echo Error: Cannot find libssl. Try with --disable-ssl; exit -1])
AM_CONDITIONAL([SSL_C], [true])
AC_DEFINE([HAVE_SSL],[1],[Have ssl ])
UPERF_LIBS="$UPERF_LIBS -lcrypto -lssl"
else
SSL_C=
AM_CONDITIONAL([SSL_C], [false])
AC_MSG_RESULT(no)
fi
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-`date +%s`}"
timestamp=`date -u -d "@$SOURCE_DATE_EPOCH" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" 2>/dev/null || date -u`
AC_DEFINE_UNQUOTED([CONFIGURED_ON],["$timestamp"],[Configured on])
AC_DEFINE_UNQUOTED([BUILD_DATE],["$timestamp"],[Built on])
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(UPERF_LIBS)
#AC_CONFIG_FILES([Makefile
AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile
workloads/Makefile])
AC_OUTPUT
echo "CC=$CC"
echo " "
echo " "
echo "+------------------------------------------------+"
if test x$build_master = xfalse; then
echo "| Warning: Will build only the slave |"
else
echo "| Will build combined binary (master + slave) |"
fi
echo "+------------------------------------------------+"
echo "| Supported Protocols: |"
printf "|%20s:%5s%22s|\n" "TCP" "yes" " "
printf "|%20s:%5s%22s|\n" "UDP" "${enable_udp}" " "
printf "|%20s:%5s%22s|\n" "RDS" "${enable_rds}" " "
printf "|%20s:%5s%22s|\n" "SSL" "${enable_ssl}" " "
printf "|%20s:%5s%22s|\n" "SCTP" "${enable_sctp}" " "
printf "|%20s:%5s%22s|\n" "VSOCK" "${enable_vsock}" " "
echo "+------------------------------------------------+"
printf "|%33s:%14s|\n" "Network stats collection enabled?" "$enable_netstat"
printf "|%33s:%14s|\n" "CPU Performance counters?" "$cpc"
echo "+------------------------------------------------+"