forked from OpenFastPath/ofp
-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure.ac
459 lines (393 loc) · 15.3 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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
AC_PREREQ([2.69])
AC_INIT([OpenFastPath],
m4_esyscmd(./scripts/git_hash.sh .),
[sorin.vultureanu at enea.com],
[openfastpath],
[http://www.enea.com])
AM_INIT_AUTOMAKE([1.9 tar-pax subdir-objects])
AC_CONFIG_SRCDIR([include/config.h.in])
AM_CONFIG_HEADER([include/config.h])
AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
AC_CONFIG_MACRO_DIR([m4])
AM_SILENT_RULES([yes])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AM_PROG_CC_C_O
# Use libtool
LT_INIT([])
AC_SUBST([LIBTOOL_DEPS])
AM_PROG_LIBTOOL
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h memory.h stdint.h stdlib.h string.h sys/socket.h unistd.h])
AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([fcntl.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_CHECK_SIZEOF([int *])
AX_TLS
##########################################################################
# Set correct platform library version
##########################################################################
LIBOFP_VERSION=0:0:0
AC_SUBST(LIBOFP_VERSION)
##########################################################################
# Set correct pkgconfig version
##########################################################################
PKGCONFIG_VERSION=$(echo $VERSION | awk -F '.git' '{print $1}')
AC_SUBST(PKGCONFIG_VERSION)
##########################################################################
# Check for pthreads availability
##########################################################################
AX_PTHREAD([], [
echo "Error! We require pthreads to be available"
exit -1
])
LIBS="$PTHREAD_LIBS $LIBS"
AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
AM_LDFLAGS="$AM_LDFLAGS $PTHREAD_LDFLAGS"
CC="$PTHREAD_CC"
m4_include([./m4/visibility.m4])
##########################################################################
# Default warning setup
##########################################################################
OFP_CFLAGS="$OFP_CFLAGS -W -Wall -Wstrict-prototypes -Wmissing-prototypes"
OFP_CFLAGS="$OFP_CFLAGS -Wmissing-declarations -Wold-style-definition -Wpointer-arith"
OFP_CFLAGS="$OFP_CFLAGS -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral"
OFP_CFLAGS="$OFP_CFLAGS -Wformat-security -Wundef -Wwrite-strings"
## OFP_CFLAGS="$OFP_CFLAGS -Werror"
OFP_CFLAGS="$OFP_CFLAGS -std=c99 -D_DEFAULT_SOURCE -D_POSIX_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE"
OFP_CXXFLAGS="-std=c++11 $OFP_CXXFLAGS"
OFP_CXXFLAGS="-fno-strict-aliasing $OFP_CXXFLAGS"
OFP_CXXFLAGS="-W -Wall -Wextra $OFP_CXXFLAGS"
OFP_CXXFLAGS="-Wmissing-declarations $OFP_CXXFLAGS"
##########################################################################
# Default include setup
##########################################################################
AM_CFLAGS="$AM_CFLAGS $OFP_CFLAGS"
AM_CXXFLAGS="$AM_CXXFLAGS $OFP_CXXFLAGS"
##########################################################################
# Checks for library functions.
##########################################################################
AC_FUNC_MALLOC
AC_CHECK_FUNCS([inet_ntoa malloc memset socket strerror strrchr])
AC_CONFIG_FILES([
Makefile
src/Makefile
example/Makefile
example/classifier/Makefile
example/fpm/Makefile
example/fpm_burstmode/Makefile
example/ioctl_test/Makefile
example/multicast/Makefile
example/ofp_netwrap_crt/Makefile
example/ofp_netwrap_proc/Makefile
example/socket/Makefile
example/sysctl/Makefile
example/tcpperf/Makefile
example/udp_fwd_socket/Makefile
example/udpecho/Makefile
example/webserver/Makefile
example/webserver2/Makefile
example/ofp_vs/Makefile
pkgconfig/libofp.pc
scripts/Makefile
test/Makefile
test/cunit/Makefile
test/benchmark/Makefile
])
AC_ARG_ENABLE([lto],
[AS_HELP_STRING([--enable-lto],[enable link-time optimization @<:@no@:>@])],
[want_lto="${enableval}"], [want_lto=no])
## FIXME: add a test for gcc >= 4.5.0
if test "x${want_lto}" == xyes; then
AM_CFLAGS="$AM_CFLAGS -flto"
fi
##########################################################################
# adding the ODP library (e.g. with static name 'libodp-linux.a')
##########################################################################
# introduce the optional configure parameter for a non-standard install prefix of XXX
AC_ARG_WITH([odp],
[AS_HELP_STRING([--with-odp=prefix],
[non-standard install prefix of odp])],
[# extend the compiler and linker flags according to the path set
AM_CPPFLAGS="$AM_CPPFLAGS -I$with_odp/include"
AM_LDFLAGS="$AM_LDFLAGS -L$with_odp/lib"
export PKG_CONFIG_PATH="$with_odp/lib/pkgconfig:$PKG_CONFIG_PATH"],
[])
# introduce optional configure parameter for odp library name
ODP_LIB=odp-linux
AC_ARG_WITH([odp-lib],
[AS_HELP_STRING([--with-odp-lib=NAME],
[odp library name])],
[ODP_LIB=$withval],
[])
# introduce optional configure parameter for ofp configuration flavor
OFP_CONFIG_FLV=default
AC_ARG_WITH([config-flv],
[AS_HELP_STRING([--with-config-flv=NAME],
[OFP configuration flavor: default, webserver, netwrap-webserver])],
[OFP_CONFIG_FLV=$withval],
[])
case "${OFP_CONFIG_FLV}" in
default) AM_CFLAGS="$AM_CFLAGS -DOFP_CONFIG_DEFAULT" ;;
webserver) AM_CFLAGS="$AM_CFLAGS -DOFP_CONFIG_WEBSERVER" ;;
netwrap-webserver) AM_CFLAGS="$AM_CFLAGS -DOFP_CONFIG_NETWRAP_WEBSERVER" ;;
*) AC_MSG_ERROR([bad value '${OFP_CONFIG_FLV}' for --with-config-flv]) ;;
esac
##########################################################################
# Save and set temporary compilation flags
##########################################################################
OLD_LDFLAGS=$LDFLAGS
OLD_CPPFLAGS=$CPPFLAGS
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
ODP_VERSION_SUPPORTED="1.11.0.0_monarch"
function check_odp {
AC_CHECK_LIB($ODP_LIB, odp_packet_alloc, [],
[AC_MSG_FAILURE(["OpenDataPlane library ($ODP_LIB) not available"])],[-lrt -lpthread -lcrypto])
AC_CHECK_HEADERS([odp.h], [],
[AC_MSG_FAILURE(["Can't find ODP headers"])])
}
PKG_CHECK_MODULES([ODP], [lib$ODP_LIB >= $ODP_VERSION_SUPPORTED], [], check_odp)
AC_SUBST([ODP_CFLAGS])
AC_SUBST([ODP_LIBS])
PKG_CHECK_MODULES([ODPHELPER], [libodphelper], [],
[ODPHELPER_LIBS="-lodphelper"])
AC_SUBST([ODPHELPER_CFLAGS])
AC_SUBST([ODPHELPER_LIBS])
AM_CPPFLAGS="$AM_CPPFLAGS $ODP_CFLAGS $ODPHELPER_CFLAGS"
# prepending lib to the files to link
LIBS="$ODP_LIBS $ODPHELPER_LIBS $LIBS"
##########################################################################
# Restore old saved variables
##########################################################################
LDFLAGS=$OLD_LDFLAGS
CPPFLAGS=$OLD_CPPFLAGS
AM_CPPFLAGS="$AM_CPPFLAGS -DINET"
# Enable/disable OFP_DEBUG
ofp_debug=no
AC_ARG_ENABLE([debug],
[ --enable-debug Enable OFP debug],
[ofp_debug=$enableval])
if test "$ofp_debug" == "yes" ; then
AM_CFLAGS="$AM_CFLAGS -DOFP_DEBUG"
fi
# Enable/disable INET6 domain
AC_ARG_ENABLE([ipv6],
[ --enable-ipv6 Turn on IPv6 processing],
[case "${enableval}" in
yes) ipv6_support=true ;;
no) ipv6_support=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
esac],[ipv6_support=true])
AM_CONDITIONAL([OFP_IPv6], [test x$ipv6_support = xtrue])
AM_COND_IF([OFP_IPv6], [AM_CPPFLAGS="$AM_CPPFLAGS -DINET6"])
# Enable/disable Slow Path processing
AC_ARG_ENABLE([sp],
[ --enable-sp Turn on Slow Path processing],
[case "${enableval}" in
yes) sp_support=true ;;
no) sp_support=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-sp]) ;;
esac],[sp_support=true])
AM_CONDITIONAL([OFP_SP], [test x$sp_support = xtrue])
AM_COND_IF([OFP_SP], [AM_CPPFLAGS="$AM_CPPFLAGS -DSP"])
# Enable/disable libCK use
AC_ARG_ENABLE([libck],
[ --enable-libck Enable/disable use of libCK],
[case "${enableval}" in
yes) use_ck=true ;;
no) use_ck=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-libck]) ;;
esac],[use_ck=false])
AM_CONDITIONAL([OFP_USE_LIBCK], [test x$use_ck = xtrue])
AM_COND_IF([OFP_USE_LIBCK], [AM_CPPFLAGS="$AM_CPPFLAGS -DOFP_USE_LIBCK"])
# Enable/disable MTRIE IPv4 use
AC_ARG_ENABLE([mtrie],
[ --enable-mtrie Enable/disable use of mtrie route tables],
[case "${enableval}" in
yes) use_mtrie=true ;;
no) use_mtrie=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-mtrie]) ;;
esac],[use_mtrie=true])
AM_CONDITIONAL([OFP_MTRIE], [test x$use_mtrie = xtrue])
AM_COND_IF([OFP_MTRIE], [AM_CPPFLAGS="$AM_CPPFLAGS -DMTRIE"])
# Enable/disable libconfig use
AC_ARG_ENABLE([libconfig],
[ --enable-libconfig Enable/disable use of libconfig],
[case "${enableval}" in
yes) use_libconfig=true ;;
no) use_libconfig=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-libconfig]) ;;
esac],[use_libconfig=true])
AM_CONDITIONAL([OFP_USE_LIBCONFIG], [test x$use_libconfig = xtrue])
AM_COND_IF([OFP_USE_LIBCONFIG], [AM_CPPFLAGS="$AM_CPPFLAGS -DOFP_USE_LIBCONFIG"])
# Enable/disable CLI use
AC_ARG_ENABLE([cli],
[ --enable-cli Enable/disable use of ofp cli],
[case "${enableval}" in
yes) use_cli=true ;;
no) use_cli=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-cli]) ;;
esac],[use_cli=true])
AM_CONDITIONAL([OFP_CLI], [test x$use_cli = xtrue])
AM_COND_IF([OFP_CLI], [AM_CPPFLAGS="$AM_CPPFLAGS -DCLI"])
##########################################################################
# Enable/disable Unit tests
##########################################################################
cunit_support=no
AC_ARG_ENABLE(
[cunit],
[ --enable-cunit Enable/disable cunit],
[if test x$enableval = xyes; then
cunit_support=yes
fi])
AC_ARG_WITH(
[cunit-path],
AC_HELP_STRING(
[--with-cunit-path=DIR Path to Cunit libs and headers],
[(or in the default path if not specified).]),
[cunit_support=yes
have_cunit_path=yes
CUNIT_PATH=$withval],
[AS_IF(
[test x$cunit_support = xyes ],
[AC_CHECK_HEADERS(
[CUnit/Basic.h], [],
[AC_MSG_FAILURE(["can't find cunit headers"])])
])
])
AC_SUBST(CUNIT_PATH)
AM_CONDITIONAL([HAVE_CUNIT_PATH], [test x$have_cunit_path = xyes])
AM_CONDITIONAL([OFP_CUNIT_ENABLED], [test x$cunit_support = xyes ])
##########################################################################
# adding the quagga dir
##########################################################################
# introduce the optional configure parameter for a non-standard install prefix of XXX
AC_ARG_WITH([quagga],
[AS_HELP_STRING([--with-quagga=prefix],
[non-standard path prefix of the quagga source directory])],
[QUAGGAPATHSET=1],
[QUAGGAPATHSET=0])
# if optional parameter used, extend path flags for compliler and linker
if test $QUAGGAPATHSET = 1 ; then
# extend the compiler and linker flags according to the path set
AM_CPPFLAGS="$AM_CPPFLAGS -I$with_quagga"
AC_DEFINE(HAVE_QUAGGA, [1], [Have quagga source dir ?])
else
AC_CHECK_HEADERS([fpm/fpm.h], [
AC_DEFINE(HAVE_QUAGGA, [1], [Have quagga source dir ?])], [])
fi
##########################################################################
# Libconcurrenykit
##########################################################################
# introduce the optional configure parameter for a non-standard install prefix of XXX
AC_ARG_WITH([libck],
[AS_HELP_STRING([--with-libck=prefix],
[non-standard path prefix of the concurrenykit install directory])],
[CKPATHSET=1],
[CKPATHSET=0])
if test x$use_ck = xtrue ; then
# if optional parameter used, extend path flags for compliler and linker
if test $CKPATHSET = 1 ; then
# extend the compiler and linker flags according to the path set
AM_CPPFLAGS="$AM_CPPFLAGS -I$with_libck/include"
AM_LDFLAGS="$AM_LDFLAGS -L$with_libck/lib -L$with_libck/src"
LIBS="-lck $LIBS"
AC_DEFINE(HAVE_LIBCK, [1], [Have libconcurrencykit])
else
AC_CHECK_HEADERS([ck_epoch.h], [
AC_DEFINE(HAVE_LIBCK, [1], [Have concurrentykit])], [])
AC_SEARCH_LIBS([ck_epoch_init],[ck],[], [
AC_MSG_ERROR([Unable to find libck library])])
fi
fi
##########################################################################
# adding the RumpKernel dir
##########################################################################
# introduce the optional configure parameter for a non-standard install prefix of XXX
AC_ARG_WITH([buildrump],
[AS_HELP_STRING([--with-buildrump=prefix],
[non-standard path prefix of the rump source directory])],
[RUMPPATHSET=1],
[RUMPPATHSET=0])
# if optional parameter used, extend path flags for compliler and linker
if test $RUMPPATHSET = 1 ; then
# extend the compiler and linker flags according to the path set
AM_CPPFLAGS="$AM_CPPFLAGS -I$with_buildrump/rump/include"
AM_LDFLAGS="$AM_LDFLAGS -L$with_buildrump/rump/lib/"
AC_DEFINE(HAVE_BUILDRUMP, [1], [Have buildrump libs ?])
LIBS="-lrumpclient -lrumpnet_shmif -lrumpnet_config -lrumpnet_netinet6 -lrumpnet_net -lrumpnet -lrump -lrumpuser $LIBS"
else
AC_CHECK_HEADERS([rump/rump.h], [
AC_DEFINE(HAVE_BUILDRUMP, [1], [Have buildrump libs ?])],
[])
AC_SEARCH_LIBS([rumpclient_init],[rumpclient])
AC_SEARCH_LIBS([rump_pub_shmif_create],[rumpnet_shmif])
AC_SEARCH_LIBS([rumpns_if_init],[rumpnet_config])
AC_SEARCH_LIBS([_init],[rumpnet_netinet6])
AC_SEARCH_LIBS([_init],[rumpnet_netinet])
AC_SEARCH_LIBS([rumpns_rt_init],[rumpnet_net])
AC_SEARCH_LIBS([rumpns_rt_inithead],[rumpnet])
AC_SEARCH_LIBS([rump_init],[rump])
AC_SEARCH_LIBS([rumpuser_init],[rumpuser])
fi
##########################################################################
# libconfig
##########################################################################
# introduce the optional configure parameter for a non-standard install prefix of libconfig
AC_ARG_WITH([libconfig],
[AS_HELP_STRING([--with-libconfig=prefix],
[non-standard path prefix of libconfig install directory])],
[LIBCONFIGPATHSET=1],
[LIBCONFIGPATHSET=0])
if test x$use_libconfig = xtrue ; then
LIBS="-lconfig $LIBS"
if test $LIBCONFIGPATHSET = 1 ; then
# if optional parameter used, provide paths for compiler and linker
AM_CPPFLAGS="$AM_CPPFLAGS -I$with_libconfig/include"
AM_LDFLAGS="$AM_LDFLAGS -L$with_libconfig/lib"
fi
AC_CHECK_HEADERS([libconfig.h], [
AC_DEFINE(HAVE_LIBCONFIG, [1], [Have libconfig])], [])
AC_SEARCH_LIBS([config_init],[config],[], [
AC_MSG_ERROR([Unable to find libconfig library])])
fi
##########################################################################
# distribute the changed variables among the Makefiles
AC_SUBST([LIBS])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_OUTPUT
AC_MSG_RESULT([
$PACKAGE $VERSION
========
Library version: ${LIBOFP_VERSION}
prefix: ${prefix}
sysconfdir: ${sysconfdir}
libdir: ${libdir}
includedir: ${includedir}
cc: ${CC}
cppflags: ${CPPFLAGS}
am_cppflags: ${AM_CPPFLAGS}
cflags: ${CFLAGS}
am_cflags: ${AM_CFLAGS}
am_cxxflags: ${AM_CXXFLAGS}
ldflags: ${LDFLAGS}
am_ldflags: ${AM_LDFLAGS}
odp_library: ${ODP_LIB}
odp_version: $(pkg-config --modversion lib$ODP_LIB)
odp_cflags: ${ODP_CFLAGS}
odp_libs: ${ODP_LIBS}
odphelper_cflags: ${ODPHELPER_CFLAGS}
odphelper_libs: ${ODPHELPER_LIBS}
cunit: ${cunit_support}
])