-
Notifications
You must be signed in to change notification settings - Fork 33
/
configure.ac
494 lines (426 loc) · 13.4 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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(extFilter, 0.99.4, [email protected])
DPDK_HOME=
DPDK_TARGET=
PEAFOWL_HOME=./peafowl
PEAFOWL_BRANCH="-b exp"
MARISA_HOME=./marisa
AM_INIT_AUTOMAKE()
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(no)])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([include/config.h])
AC_LANG([C++])
AC_LANG_PUSH([C++])
# store current user given compiler flags to avoid default setup via AC_PROG_CXX
OLD_CXXFLAGS=$CXXFLAGS
OLD_CFLAGS=$CFLAGS
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
CXXFLAGS=$OLD_CXXFLAGS
CFLAGS=$OLD_CFLAGS
CFLAGS="$CFLAGS --pedantic -Wall -O2"
AC_ARG_ENABLE(debug,
AS_HELP_STRING(
[--enable-debug],
[enable debugging, default: no]),
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],
[debug=false])
AC_MSG_CHECKING([for debug enabled])
if test x"$debug" = x"true"; then
CXXFLAGS="$CXXFLAGS -std=c++11 -O0 -g -Wall -pthread"
else
CXXFLAGS="$CXXFLAGS -std=c++11 -O3 -Wall -fno-stack-protector -pthread"
fi
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);]])],,
AC_MSG_FAILURE(['$CXX $CXXFLAGS' does not accept ISO C++11]))
# Macros for SSE availability check.
AC_DEFUN([EXTFILTER_ENABLE_SSE2],
[AC_EGREP_CPP([yes], [
#ifdef __SSE2__
yes
#endif
], [enable_sse2="yes"], [enable_sse2="no"])])
AC_DEFUN([EXTFILTER_ENABLE_SSE3],
[AC_EGREP_CPP([yes], [
#ifdef __SSE3__
yes
#endif
], [enable_sse3="yes"], [enable_sse3="no"])])
AC_DEFUN([EXTFILTER_ENABLE_SSSE3],
[AC_EGREP_CPP([yes], [
#ifdef __SSSE3__
yes
#endif
], [enable_ssse3="yes"], [enable_ssse3="no"])])
AC_DEFUN([EXTFILTER_ENABLE_SSE4_1],
[AC_EGREP_CPP([yes], [
#ifdef __SSE4_1__
yes
#endif
], [enable_sse4_1="yes"], [enable_sse4_1="no"])])
AC_DEFUN([EXTFILTER_ENABLE_SSE4_2],
[AC_EGREP_CPP([yes], [
#ifdef __SSE4_2__
yes
#endif
], [enable_sse4_2="yes"], [enable_sse4_2="no"])])
AC_DEFUN([EXTFILTER_ENABLE_SSE4],
[AC_EGREP_CPP([yes], [
#if defined(__POPCNT__) && defined(__SSE4_2__)
yes
#endif
], [enable_sse4="yes"], [enable_sse4="no"])])
AC_DEFUN([EXTFILTER_ENABLE_SSE4A],
[AC_EGREP_CPP([yes], [
#ifdef __SSE4A__
yes
#endif
], [enable_sse4a="yes"], [enable_sse4a="no"])])
AC_DEFUN([EXTFILTER_ENABLE_AVX],
[AC_EGREP_CPP([yes], [
#ifdef __AVX__
yes
#endif
], [enable_avx="yes"], [enable_avx="no"])])
AC_DEFUN([EXTFILTER_ENABLE_AVX2],
[AC_EGREP_CPP([yes], [
#ifdef __AVX2__
yes
#endif
], [enable_avx2="yes"], [enable_avx2="no"])])
AC_DEFUN([EXTFILTER_ENABLE_POPCNT],
[AC_EGREP_CPP([yes], [
#ifdef __POPCNT__
yes
#endif
], [enable_popcnt="yes"], [enable_popcnt="no"])])
# Enable native cpu instructions.
AC_MSG_CHECKING([whether to enable optimization for native cpu])
AC_ARG_ENABLE([native-code],
[AS_HELP_STRING([--enable-native-code],
[generate instructions for native cpu [default=no]])],
[],
[enable_native_code="no"])
AS_IF([test "x${enable_native_code}" != "xno"], [
CFLAGS="$CPPFLAGS -march=native -mtune=native"
CPPFLAGS="$CPPFLAGS -march=native -mtune=native"
CXXFLAGS="$CXXFLAGS -march=native -mtune=native"
EXTFILTER_ENABLE_SSE2
EXTFILTER_ENABLE_SSE3
EXTFILTER_ENABLE_SSE4_1
EXTFILTER_ENABLE_SSE4_2
EXTFILTER_ENABLE_SSE4
EXTFILTER_ENABLE_SSE4A
EXTFILTER_ENABLE_AVX
EXTFILTER_ENABLE_AVX2
EXTFILTER_ENABLE_POPCNT
])
AC_MSG_RESULT([${enable_native_code}])
# Checks for SSE availability.
AC_MSG_CHECKING([whether to use SSE2])
AC_ARG_ENABLE([sse2],
[AS_HELP_STRING([--enable-sse2],
[use SSE2 [default=no]])],
[],
[enable_sse2="no"])
AS_IF([test "x${enable_sse2}" != "xno"], [EXTFILTER_ENABLE_SSE2])
AC_MSG_RESULT([${enable_sse2}])
AC_MSG_CHECKING([whether to use SSE3])
AC_ARG_ENABLE([sse3],
[AS_HELP_STRING([--enable-sse3],
[use SSE3 [default=no]])],
[],
[enable_sse3="no"])
AS_IF([test "x${enable_sse3}" != "xno"], [EXTFILTER_ENABLE_SSE3])
AC_MSG_RESULT([${enable_sse3}])
AC_MSG_CHECKING([whether to use SSSE3])
AC_ARG_ENABLE([ssse3],
[AS_HELP_STRING([--enable-ssse3],
[use SSSE3 [default=no]])],
[],
[enable_ssse3="no"])
AS_IF([test "x${enable_ssse3}" != "xno"], [EXTFILTER_ENABLE_SSSE3])
AC_MSG_RESULT([${enable_ssse3}])
AC_MSG_CHECKING([whether to use SSE4.1])
AC_ARG_ENABLE([sse4.1],
[AS_HELP_STRING([--enable-sse4.1],
[use SSE4.1 [default=no]])],
[],
[enable_sse4_1="no"])
AS_IF([test "x${enable_sse4_1}" != "xno"], [EXTFILTER_ENABLE_SSE4_1])
AC_MSG_RESULT([${enable_sse4_1}])
AC_MSG_CHECKING([whether to use SSE4.2])
AC_ARG_ENABLE([sse4.2],
[AS_HELP_STRING([--enable-sse4.2],
[use SSE4.2 [default=no]])],
[],
[enable_sse4_2="no"])
AS_IF([test "x${enable_sse4_2}" != "xno"], [EXTFILTER_ENABLE_SSE4_2])
AC_MSG_RESULT([${enable_sse4_2}])
AC_MSG_CHECKING([whether to use SSE4])
AC_ARG_ENABLE([sse4],
[AS_HELP_STRING([--enable-sse4],
[use SSE4 [default=no]])],
[],
[enable_sse4="no"])
AS_IF([test "x${enable_sse4}" != "xno"], [EXTFILTER_ENABLE_SSE4])
AC_MSG_RESULT([${enable_sse4}])
AC_MSG_CHECKING([whether to use SSE4a])
AC_ARG_ENABLE([sse4a],
[AS_HELP_STRING([--enable-sse4a],
[use SSE4a [default=no]])],
[],
[enable_sse4a="no"])
AS_IF([test "x${enable_sse4a}" != "xno"], [EXTFILTER_ENABLE_SSE4A])
AC_MSG_RESULT([${enable_sse4a}])
AC_MSG_CHECKING([whether to use AVX])
AC_ARG_ENABLE([avx],
[AS_HELP_STRING([--enable-avx],
[use AVX [default=no]])],
[],
[enable_avx="no"])
AS_IF([test "x${enable_avx}" != "xno"], [EXTFILTER_ENABLE_AVX])
AC_MSG_RESULT([${enable_avx}])
AC_MSG_CHECKING([whether to use AVX2])
AC_ARG_ENABLE([avx2],
[AS_HELP_STRING([--enable-avx2],
[use AVX2 [default=no]])],
[],
[enable_avx2="no"])
AS_IF([test "x${enable_avx2}" != "xno"], [EXTFILTER_ENABLE_AVX2])
AC_MSG_RESULT([${enable_avx2}])
AC_MSG_CHECKING([whether to use popcnt])
AC_ARG_ENABLE([popcnt],
[AS_HELP_STRING([--enable-popcnt],
[use POPCNT [default=no]])],
[],
[enable_popcnt="no"])
AS_IF([test "x${enable_popcnt}" != "xno"], [EXTFILTER_ENABLE_POPCNT])
AC_MSG_RESULT([${enable_popcnt}])
AS_IF([test "x${enable_popcnt}" != "xno"], [
enable_sse3="yes"
])
AS_IF([test "x${enable_avx2}" != "xno"], [
enable_popcnt="yes"
enable_avx2="yes"
])
AS_IF([test "x${enable_avx}" != "xno"], [
enable_popcnt="yes"
enable_avx="yes"
])
AS_IF([test "x${enable_sse4a}" != "xno"], [
enable_popcnt="yes"
enable_sse3="yes"
])
AS_IF([test "x${enable_sse4}" != "xno"], [
enable_popcnt="yes"
enable_sse4_2="yes"
])
AS_IF([test "x${enable_sse4_2}" != "xno"], [
enable_popcnt="yes"
enable_sse4_1="yes"
])
AS_IF([test "x${enable_sse4_1}" != "xno"], [
enable_ssse3="yes"
])
AS_IF([test "x${enable_ssse3}" != "xno"], [
enable_sse3="yes"
])
AS_IF([test "x${enable_sse3}" != "xno"], [
enable_sse2="yes"
])
AS_IF([test "x${enable_popcnt}" != "xno"], [
CXXFLAGS="$CXXFLAGS -mpopcnt"
])
if test "x${enable_avx2}" != "xno"; then
CXXFLAGS="$CXXFLAGS -mavx2"
elif test "x${enable_avx}" != "xno"; then
CXXFLAGS="$CXXFLAGS -mavx"
elif test "x${enable_sse4a}" != "xno"; then
CXXFLAGS="$CXXFLAGS -msse4a"
elif test "x${enable_sse4}" != "xno"; then
CXXFLAGS="$CXXFLAGS -msse4"
elif test "x${enable_sse4_2}" != "xno"; then
CXXFLAGS="$CXXFLAGS -msse4.2"
elif test "x${enable_sse4_1}" != "xno"; then
CXXFLAGS="$CXXFLAGS -msse4.1"
elif test "x${enable_ssse3}" != "xno"; then
CXXFLAGS="$CXXFLAGS -mssse3"
elif test "x${enable_sse3}" != "xno"; then
CXXFLAGS="$CXXFLAGS -msse3"
elif test "x${enable_sse2}" != "xno"; then
CXXFLAGS="$CXXFLAGS -msse2"
fi
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([netinet/in.h stdint.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_CHECK_FUNCS([strerror])
# Check for methods in library and check for header files
AC_CHECK_HEADERS([Poco/Foundation.h Poco/Net/HTTPCookie.h Poco/Util/Timer.h],
[],
AC_MSG_ERROR([Poco include files not found.])
)
AC_CHECK_LIB([PocoFoundation],[main],[HAVE_POCOFOUNDATION=1],AC_MSG_ERROR([PocoFoundation library not found.]))
if test "$HAVE_POCOFOUNDATION"; then
save_libs="${LIBS}"
LIBS="-lPocoFoundation"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "Poco/UnicodeConverter.h"],
[std::wstring wstr; Poco::UnicodeConverter::toUTF16("hello", wstr);]
)],
[LIBS="$LIBS $save_libs"],
[AC_MSG_ERROR([linking with PocoFoundation failed.])]
)
fi
AC_CHECK_LIB([PocoUtil],[main],[HAVE_POCOUTIL=1],AC_MSG_ERROR([PocoUtil library not found.]))
if test "$HAVE_POCOUTIL"; then
save_libs="${LIBS}"
LIBS="-lPocoUtil"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "Poco/Util/Option.h"],
[Poco::Util::Option();]
)],
[LIBS="$LIBS $save_libs"],
[AC_MSG_ERROR([linking with PocoUtil failed.])]
)
fi
AC_CHECK_LIB([PocoNet],[main],[HAVE_POCONET=1],AC_MSG_ERROR([PocoNet library not found.]))
if test "$HAVE_POCONET"; then
save_libs="${LIBS}"
LIBS="-lPocoNet"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "Poco/Net/HTTPClientSession.h"],
[Poco::Net::HTTPClientSession();]
)],
[LIBS="$LIBS $save_libs"],
[AC_MSG_ERROR([linking with PocoNET failed.])]
)
fi
AC_ARG_WITH(
[dpdk_home],
AS_HELP_STRING(
[--with-dpdk_home=DIR],
[Path to DPDK library]
),
[DPDK_HOME="$withval"]
)
AC_ARG_WITH(
[dpdk_target],
AS_HELP_STRING(
[--with-dpdk_target=target],
[DPDK target]
),
[DPDK_TARGET="$withval"]
)
if test -z "$DPDK_TARGET"; then
AC_MSG_ERROR([dpdk_target must be set])
fi
if test -z "$DPDK_HOME"; then
AC_MSG_ERROR([dpdk_home must be set])
fi
AC_SUBST(DPDK_LIB,$DPDK_HOME/$DPDK_TARGET/lib)
AC_SUBST(DPDK_INCLUDE,$DPDK_HOME/$DPDK_TARGET/include)
dnl peafowl checks...
AC_MSG_CHECKING(for peafowl $PEAFOWL_HOME)
if test -d "$PEAFOWL_HOME" ; then :
AC_MSG_RESULT(found in $PEAFOWL_HOME)
else
AC_MSG_RESULT(not found)
AC_MSG_NOTICE(Getting peafowl from git)
git clone $PEAFOWL_BRANCH https://github.com/max197616/Peafowl.git $PEAFOWL_HOME
AC_MSG_CHECKING(for peafowl $PEAFOWL_HOME)
if test -d "$PEAFOWL_HOME" ; then :
AC_MSG_RESULT(found in $PEAFOWL_HOME)
else
AC_MSG_ERROR(Install peafowl manually)
fi
fi
PEAFOWL_LIB=$PEAFOWL_HOME/lib/libdpi.a
AC_MSG_CHECKING(for $PEAFOWL_LIB)
if test -f "$PEAFOWL_LIB" ; then :
else
AC_MSG_RESULT([not found, compiling...])
cd $PEAFOWL_HOME; make; cd -
if test -f "$PEAFOWL_LIB" ; then :
else
AC_MSG_ERROR([Peafowl library not found!])
fi
fi
AC_MSG_RESULT(yes)
AC_SUBST(PEAFOWL_INCLUDE, $PEAFOWL_HOME/src)
AC_SUBST(PEAFOWL_LIB, $PEAFOWL_LIB)
dnl marisa-trie checks...
AC_MSG_CHECKING(for marisa-trie $MARISA_HOME)
if test -d "$MARISA_HOME" ; then :
AC_MSG_RESULT(found in $MARISA_HOME)
else
AC_MSG_RESULT(not found)
AC_MSG_NOTICE(Getting marisa-trie from git)
git clone https://github.com/max197616/marisa-trie.git $MARISA_HOME
AC_MSG_CHECKING(for marisa-trie $MARISA_HOME)
if test -d "$MARISA_HOME" ; then :
AC_MSG_RESULT(found in $MARISA_HOME)
else
AC_MSG_ERROR(Install marisa-trie manually)
fi
fi
MARISA_LIB=$MARISA_HOME/lib/marisa/.libs/libmarisa.a
AC_MSG_CHECKING(for $MARISA_LIB)
if test -f "$MARISA_LIB" ; then :
else
AC_MSG_RESULT([not found, compiling...])
cd $MARISA_HOME; autoreconf -i; ./configure --enable-native-code; make; cd -
if test -f "$MARISA_LIB" ; then :
else
AC_MSG_ERROR([Marisa-trie library not found!])
fi
fi
AC_MSG_RESULT(yes)
AC_SUBST(MARISA_INCLUDE, $MARISA_HOME/include)
AC_SUBST(MARISA_LIB, $MARISA_LIB)
AC_OUTPUT(Makefile src/Makefile include/Makefile)
AS_ECHO([])
AS_ECHO(["${PACKAGE_NAME} ${PACKAGE_VERSION} configuration:"])
AS_ECHO(["-------------------------------"])
AS_ECHO([" HOST: ${HOST}"])
AS_ECHO([" CXX: ${CXX}"])
AS_ECHO([" CXXFLAGS: ${CXXFLAGS}"])
AS_ECHO([" LDFLAGS: ${LDFLAGS}"])
AS_ECHO([" PREFIX: ${prefix}"])
AS_ECHO([])
AS_ECHO([" NATIVE: ${enable_native_code}"])
AS_ECHO([" SSE2: ${enable_sse2}"])
AS_ECHO([" SSE3: ${enable_sse3}"])
AS_ECHO([" SSSE3: ${enable_ssse3}"])
AS_ECHO([" SSE4.1: ${enable_sse4_1}"])
AS_ECHO([" SSE4.2: ${enable_sse4_2}"])
AS_ECHO([" SSE4a: ${enable_sse4a}"])
AS_ECHO([" AVX: ${enable_avx}"])
AS_ECHO([" AVX2: ${enable_avx2}"])
AS_ECHO([" POPCNT: ${enable_popcnt}"])
AS_ECHO([])