forked from appneta/tcpreplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1986 lines (1753 loc) · 60.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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
dnl $Id$
AC_PREREQ([2.69])
dnl Set version info here!
AC_INIT([tcpreplay],[4.3.3],
[https://github.com/appneta/tcpreplay/issues],
[tcpreplay],
[http://tcpreplay.sourceforge.net/])
AC_CONFIG_SRCDIR([src/tcpreplay.c])
AM_CONFIG_HEADER([src/config.h])
AC_CONFIG_AUX_DIR(config)
AM_MAINTAINER_MODE([enable])
AM_WITH_DMALLOC
dnl People building from GitHub need the same version of Autogen as I'm using
dnl or specify --disable-local-libopts to force using the locally-installed
dnl copy of libopts rather than the source in the `./liopts/` directory.
MAINTAINER_AUTOGEN_VERSION=5.18.12
AC_CONFIG_MACRO_DIR([m4])
TCPREPLAY_VERSION=$PACKAGE_VERSION
dnl Release is only used for the RPM spec file
TCPREPLAY_RELEASE=1
AC_SUBST(TCPREPLAY_VERSION)
AC_SUBST(TCPREPLAY_RELEASE)
dnl Determine OS
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AC_SUBST(host)
AC_SUBST(build)
AC_SUBST(target)
CROSS_ARCH=
CROSS_LD=
build_arch=$(echo $MACHTYPE | cut -d'-' -f1)
if test "$cross_compiling" = "yes" ; then
CROSS_ARCH="ARCH=$host_cpu"
CROSS_LD="LD=$LD"
fi
AC_SUBST(CROSS_ARCH)
AC_SUBST(CROSS_LD)
dnl ============================================
dnl MacOSX build and runtime environment options
dnl ============================================
AC_ARG_WITH(macosx-sdk,
AS_HELP_STRING([--with-macosx-sdk],
[Use a specific SDK for building.])
[
Usage: --with-macosx-sdk=<version>
e. g.: --with-macosx-sdk=10.8
],
,)
dnl ===========================
dnl Check OS X SDK and compiler
dnl ===========================
case "$host_os" in
darwin*) # Mac OS X or iOS
# If no --with-macosx-sdk option is given, look for one
# The intent is that for "most" Mac-based developers, a suitable
# SDK will be found automatically without any configure options.
# For developers with a current Xcode, the lowest-numbered SDK
# higher than or equal to the minimum required should be found.
# To find a list of available version run `xcodebuild -showsdks`
MULTIARCH=${host_cpu}-${host_os}
AC_MSG_CHECKING([what macOS compiler to use])
for _macosx_sdk in $with_macosx_sdk 10.8 10.9 10.10 10.11 10.12 10.13 10.14 10.15 10.16 10.17 10.18 10.19 10.20 11.0 11.1 11.2 11.3 11.4 11.5; do
MACOSX_SDK_PATH=$(xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null)
if test -d "$MACOSX_SDK_PATH"; then
with_macosx_sdk="${_macosx_sdk}"
break
else
MACOSX_SDK_PATH=$(xcode-select -print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk
if test -d "$MACOSX_SDK_PATH"; then
with_macosx_sdk="${_macosx_sdk}"
break
fi
fi
done
if test -d "$MACOSX_SDK_PATH"; then
CC="$(xcrun -find clang) -m64 -isysroot $MACOSX_SDK_PATH"
INSTALL_NAME_TOOL=$(xcrun -find install_name_tool)
AR=$(xcrun -find ar)
NM=$(xcrun -find nm)
STRIP=$(xcrun -find strip)
LIBTOOL=$(xcrun -find libtool)
RANLIB=$(xcrun -find ranlib)
AC_MSG_RESULT([$CC])
else
AC_MSG_RESULT([legacy])
fi
;;
Linux*)
dnl ============================================
dnl Some libraries are in /usr/lib/i386-linux-gnu
dnl but host is i686-linux-gnu
dnl ============================================
MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) 2> /dev/null || ${host_cpu}-${host_os}
;;
*)
MULTIARCH=${host_cpu}-${host_os}
;;
esac
AC_SUBST(MACOSX_SDK_PATH)
AC_SUBST(LIBTOOL) # Note that the OS X libtool command is unrelated to GNU libtool
dnl ============================================
dnl PF_RING library option
dnl ============================================
AC_ARG_WITH(pfring-lib,
AS_HELP_STRING([--with-pfring-lib],
[Use a specific PF_RING static library when using PF_RING libpcap.])
[
Usage: --with-pfring-lib=<library>
e. g.: --with-pfring-lib=/usr/lib/libpfring_zc_x86_64.a
],
,)
have_cygwin=no
AC_MSG_CHECKING([for cygwin development environment])
if test $(echo $target | grep -c cygwin) -gt 0 ; then
AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
AC_MSG_RESULT(yes)
have_cygwin=yes
else
AC_MSG_RESULT(no)
fi
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Wno-override])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl Checks for programs.
AM_PROG_AR
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_CC
# for compat with old systems.
# deprecated in favor of AC_PROG_CC since automake 1.14 and is now no-op
AM_PROG_CC_C_O
AC_PROG_CC_STDC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LN_S
LT_INIT
AC_PROG_AWK
AC_PROG_SED
AC_PROG_MAKE_SET
AC_EXEEXT
AC_PATH_PROG(PRINTF, printf)
AC_PATH_PROG(ECHO, echo)
AC_PATH_PROG(CUT, cut)
AC_PATH_PROG(AUTOGEN, autogen)
AC_PATH_PROG(GROFF, groff)
AC_PATH_PROG(depmod, depmod, /sbin/depmod, $PATH:/sbin)
AC_PATH_PROG(insmod, insmod, /sbin/insmod, $PATH:/sbin)
AC_PATH_PROG(rmmod, rmmod, /sbin/rmmod, $PATH:/sbin)
dnl tcpreplay has (so far) been relying on leading-edge autogen.
dnl Therefore, by default:
dnl - use the version we ship with
dnl - do not install it
dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier)
case "${enable_local_libopts+set}" in
set) ;;
*) enable_local_libopts=yes ;;
esac
case "${enable_libopts_install+set}" in
set) ;;
*) enable_libopts_install=no ;;
esac
dnl check autogen version
AUTOGEN_VERSION="unknown - man pages will not be built"
if test -n "${AUTOGEN}" ; then
AC_MSG_CHECKING(for autogen version >= ${MAINTAINER_AUTOGEN_VERSION})
AUTOGEN_VERSION=$(${AUTOGEN} -v | ${CUT} -d' ' -f 4)
AUTOGEN_MAJOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1)
AUTOGEN_MINOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2)
AUTOGEN_BUILD=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 3)
if test -z "$AUTOGEN_BUILD"; then
AUTOGEN_BUILD=0
fi
if (test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -eq 18 && test ${AUTOGEN_BUILD} -lt 4) ||
(test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 18) ||
test ${AUTOGEN_MAJOR} -lt 5 ; then
AC_MSG_RESULT(no)
if test "x$enable_local_libopts" == "xno"; then
AC_MSG_ERROR([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from source code. Upgrade to 5.18.4 or higher])
fi
AUTOGEN_VERSION="${AUTOGEN_VERSION} - downlevel"
else
AC_MSG_RESULT(yes)
fi
dnl Compare the installed version with the maintainer version if building from GitHub and not using system libopts
if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then
if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
AC_MSG_ERROR([Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION) Either install the correct version or specify --disable-local-libopts])
fi
fi
else
if test ! -f src/tcpreplay_opts.c ; then
AC_MSG_ERROR([Please install GNU autogen $MAINTAINER_AUTOGEN_VERSION or higher if you are building from GitHub. To avoid this message download source from http://tcpreplay.appneta.com/wiki/installation.html])
fi
fi
AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
if test "x$enable_local_libopts" = "xyes" ; then
AC_MSG_NOTICE([Using included libopts tearoff])
else
AC_MSG_NOTICE([Using system libopts])
fi
AC_HEADER_STDC
AC_HEADER_MAJOR
dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INT8_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
AC_HEADER_TIME
AC_C_CONST
AC_C_INLINE
AC_SYS_LARGEFILE
dnl Check for functions
AC_FUNC_FSEEKO
dnl Check for types.
AC_CHECK_TYPE(u_int8_t, uint8_t)
AC_CHECK_TYPE(u_int16_t, uint16_t)
AC_CHECK_TYPE(u_int32_t, uint32_t)
AC_CHECK_TYPE(u_int64_t, uint64_t)
dnl OS X SDK 10.11 throws lots of unnecessary macro warnings
wno_format=""
wno_macro_redefined=""
case $host in
*-apple-darwin*)
AC_MSG_CHECKING(for $CC -Wno-macro-redefined)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wno-macro-redefined -Werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
int main(int argc, char *argv[]) { return(0); }]])],
[ AC_MSG_RESULT(yes)
wno_macro_redefined="-Wno-macro-redefined" ],
[ AC_MSG_RESULT(no) ])
CFLAGS="$OLD_CFLAGS $wno_macro_redefined"
CFLAGS="$CFLAGS -Wno-format -Werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
int main(int argc, char *argv[]) { return(0); }]])],
[ AC_MSG_RESULT(yes)
wno_format="-Wno-format" ],
[ AC_MSG_RESULT(no) ])
CFLAGS="$OLD_CFLAGS $wno_format"
;;
esac
dnl Older versions of GCC don't support these options
AC_MSG_CHECKING(for $CC -Wextra support)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wextra -Werror"
wextra=""
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
int main(int argc, char *argv[]) { return(0); }]])],
[ AC_MSG_RESULT(yes)
wextra="-Wextra" ],
[ AC_MSG_RESULT(no) ])
CFLAGS="$OLD_CFLAGS $wextra"
AC_MSG_CHECKING(for $CC -Wno-variadic-macros support)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wno-variadic-macros -Werror"
wno_variadic_macros=""
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
int main(int argc, char *argv[]) { return(0); }]])],
[ AC_MSG_RESULT(yes)
wno_variadic_macros="-Wno-variadic-macros" ],
[ AC_MSG_RESULT(no) ])
CFLAGS="$OLD_CFLAGS $wno_variadic_macros"
AC_MSG_CHECKING(for $CC -Wfatal-errors support)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wfatal-errors -Werror"
wfatal_errors=""
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
int main(int argc, char *argv[]) { return(0); }]])],
[ AC_MSG_RESULT(yes)
wfatal_errors="-Wfatal-errors" ],
[ AC_MSG_RESULT(no) ])
CFLAGS="$OLD_CFLAGS $wfatal_errors"
AC_MSG_CHECKING(for $CC -Wno-format-contains-nul support)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wno-format-contains-nul -Werror"
wno_format_contains_nul=""
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
int main(int argc, char *argv[]) { return(0); }]])],
[ AC_MSG_RESULT(yes)
wno_format_contains_nul="-Wno-format-contains-nul" ],
[ AC_MSG_RESULT(no) ])
CFLAGS="$OLD_CFLAGS $wno_format_contains_nul"
dnl Check for other header files
AC_CHECK_HEADERS([fcntl.h stddef.h sys/socket.h arpa/inet.h sys/time.h])
AC_CHECK_HEADERS([signal.h string.h strings.h sys/types.h stdint.h sys/select.h])
AC_CHECK_HEADERS([netinet/in.h netinet/in_systm.h poll.h sys/poll.h unistd.h sys/param.h])
AC_CHECK_HEADERS([inttypes.h libintl.h sys/file.h sys/ioctl.h sys/systeminfo.h])
AC_CHECK_HEADERS([sys/io.h architecture/i386/pio.h sched.h])
AC_HEADER_STDBOOL
dnl OpenBSD has special requirements
AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [
[#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
]])
dnl Checks for libraries.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(rt, nanosleep)
AC_CHECK_LIB(resolv, resolv)
dnl Checks for library functions.
AC_FUNC_FORK
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_FUNC_MKTIME
AC_FUNC_MMAP
AC_FUNC_REALLOC
AC_CHECK_MEMBERS([struct timeval.tv_sec])
AC_CHECK_FUNCS([alarm atexit bzero dup2 gethostbyname getpagesize gettimeofday])
AC_CHECK_FUNCS([ctime inet_ntoa memmove memset munmap pow putenv realpath])
AC_CHECK_FUNCS([regcomp strdup select socket strcasecmp strchr strcspn strdup])
AC_CHECK_FUNCS([strerror strtol strncpy strtoull poll ntohll mmap snprintf])
AC_CHECK_FUNCS([vsnprintf strsignal strpbrk strrchr strspn strstr strtoul])
AC_CHECK_FUNCS([ioperm])
dnl Look for strlcpy since some BSD's have it
AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
AC_C_BIGENDIAN
AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
AC_ARG_ENABLE([asan],
AC_HELP_STRING([--enable-asan], [Enable Address Sanitizer support]))
if test "x$enable_asan" = "xyes"; then
build_asan=yes
AC_CHECK_LIB([asan], [__asan_report_error], ,
[AC_MSG_ERROR([libasan.so not found, this is required for --enable-asan])])
CFLAGS="${CFLAGS} -O1 -g -fsanitize=address -fno-omit-frame-pointer"
dnl -lasan always need to be the first library
LDFLAGS="-lasan ${LDFLAGS}"
else
build_asan=no
fi
AC_SUBST(build_asan)
dnl Enable debugging in code/compiler options
debug=no
debug_flag=NDEBUG
debug_run_time_flag=
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
[ if test x$enableval = xyes; then
debug=yes
dnl replace '-0X' and add '-g' flags
changequote({,})
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
changequote([,])
CFLAGS="${CFLAGS} -g -O0 -Wall $wextra $wfatal_errors $wno_variadic_macros $wno_format_contains_nul $wno_format"
# We may also want to add:
# -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
debug_flag=DEBUG
debug_run_time_flag=--dbug=1
AC_DEFINE([DEBUG], [1], [Enable debugging code and support for the -d option])
fi])
AC_SUBST(debug_flag)
AC_SUBST(debug_run_time_flag)
dnl Enable extra debugging in code/compiler options - may slow down performance
extra_debug=no
extra_debug_flag=NEXTRA_DBUG
AC_ARG_ENABLE(extra-debug,
AC_HELP_STRING([--enable-extra-debug], [Enable additional debugging code (may affect performance)]),
[ if test x$enableval = xyes; then
extra_debug=yes
extra_debug_flag=EXTRA_DEBUG
AC_DEFINE([EXTRA_DEBUG], [1], [Enable additional debugging code (may affect performance)])
fi])
AC_SUBST(extra_debug_flag)
dnl Enable timestamp_trace in code/compiler options
timestamp_trace=no
AC_ARG_ENABLE(timestamp-trace,
AC_HELP_STRING([--timestamp-trace], [Enable dumping of trace timestamps at the end of a test]),
[ if test x$enableval = xyes; then
timestamp_trace=yes
CFLAGS="${CFLAGS} -DTIMESTAMP_TRACE"
AC_DEFINE([TIMESTAMP_TRACE], [1], [Enable dumping of trace timestamps at the end of a test])
fi])
AC_SUBST(timestamp_trace_flag)
AC_ARG_ENABLE(dmalloc,
AC_HELP_STRING([--enable-dmalloc], [Enable linking to dmalloc for better memory debugging]),
[ if test x$enableval = xyes ; then
dmalloc=yes
AC_DEFINE([ENABLE_DMALLOC], [1], [Enable dmalloc])
AC_DEFINE([DMALLOC_FUNC_CHECK], [1], [Enable dmalloc function arg checking])
CFLAGS="${CFLAGS} -I/opt/local/include"
DMALLOC_LIB="/opt/local/lib/libdmalloc.a"
AC_SUBST(DMALLOC_LIB)
fi])
AC_ARG_ENABLE(pedantic,
AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
[ if test x$enableval = xyes; then
CFLAGS="$CFLAGS -pedantic"
fi ])
dnl Enable Efense
AC_ARG_ENABLE(efence,
AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
[ if test x$enableval = xyes; then
CFLAGS="$CFLAGS -lefence"
AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
fi])
dnl Enable Gprof
AC_ARG_ENABLE(gprof,
AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
[ if test x$enableval = xyes; then
if test $debug = yes; then
CFLAGS="$CFLAGS -pg"
else
# GPROF requires gdb
CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
fi
AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
fi])
dnl Enable libpcap auto discovery via pcap-config
enable_pcap_config=no
AC_ARG_ENABLE(pcapconfig,
AC_HELP_STRING([--enable-pcapconfig], [Enable automatic libpcap config, reverting to system scanning]),
[
if test $enableval = yes; then
enable_pcap_config=yes
AC_MSG_NOTICE([Enabling libpcap discovery via pcap_config])
else
enable_pcap_config=no
AC_MSG_NOTICE([Disabling libpcap discovery via pcap_config])
fi
],
[
AC_MSG_NOTICE([Bypassing libpcap discovery via pcap_config])
])
dnl Use 64bits for packet counters
use64bit_counters=yes
AC_ARG_ENABLE(64bits,
AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]),
[
AC_MSG_NOTICE([Using u_int32_t for packet counters])
],
[
AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
AC_MSG_NOTICE([Using u_int64_t for packet counters])
])
# If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
# so we can use _U_ to flag unused function arguments and not get warnings
# about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
# function argument will compile with non-GCC compilers.
#
if test "x$GCC" = "xyes" ; then
CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
else
CFLAGS="-D_U_=\"\" $CFLAGS"
fi
AC_ARG_ENABLE(force-bpf,
AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
[ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
AC_ARG_ENABLE(force-pf,
AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
[ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
AC_ARG_ENABLE(force-libdnet,
AC_HELP_STRING([--enable-force-libdnet], [Force using libdnet for sending packets]),
[ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
AC_ARG_ENABLE(force-inject,
AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
[ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
AC_ARG_ENABLE(force-sendpacket,
AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
[ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
dnl Static link libraries
static_link=no
dynamic_link=yes
AC_ARG_ENABLE(static-link,
AC_HELP_STRING([--enable-static-link], [Use static libraries ( .a or .A.tbd ) - default no]),
[
if test $enableval = yes; then
static_link=yes
dynamic_link=no
fi
])
dnl Dynamic link libraries
AC_ARG_ENABLE(dynamic-link,
AC_HELP_STRING([--enable-dynamic-link], [Use shared libraries ( .so .dylib or .tbd ) - default yes]),
[
if test $enableval = no; then
dynamic_link=no
static_link=yes
elif test $static_link = yes; then
AC_MSG_ERROR([Cannot specify both --enable-dynamic-link and --enable-static-link])
fi
])
if test $static_link = yes; then
AC_DEFINE([ENABLE_STATIC_LINK], [1], [Use static libraries ( .a or .A.tbd )])
else
AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Use shared libraries ( .so .dylib or .tbd )])
fi
dnl Check for inet_aton and inet_pton
AC_CHECK_FUNC(inet_aton,
AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
inet_aton=yes,
inet_aton=no)
AC_CHECK_FUNC(inet_pton,
AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
inet_pton=yes,
inet_pton=no)
AC_CHECK_FUNC(inet_ntop,
AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
inet_ntop=yes,
inet_ntop=no)
if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
AC_MSG_ERROR([We need either inet_ntop or inet_pton])
fi
AC_CHECK_FUNC(inet_addr,
AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
inet_addr=yes,
inet_addr=no)
if test x$inet_addr = no ; then
AC_MSG_ERROR([We need inet_addr. See bug 26])
fi
dnl #####################################################
dnl Checks for tuntap device support
dnl #####################################################
have_tuntap=no
AC_ARG_ENABLE([tuntap],
AS_HELP_STRING([--disable-tuntap], [Disable tuntap support]), [:],
[case "$build_os" in
linux*)
AC_CHECK_HEADER([linux/if_tun.h], [have_tuntap=yes])
;;
*)
AC_CHECK_HEADER([net/if_tun.h], [have_tuntap=yes])
;;
esac])
if test $have_tuntap = yes ; then
AC_DEFINE([HAVE_TUNTAP], [1],
[Do we have TUNTAP device support?])
fi
dnl #####################################################
dnl Checks for libpcap
dnl #####################################################
foundpcap=no
pf_ring_found=no
pf_ring_lib=${with_pfring_lib}
using_pcap_config=no
AC_MSG_CHECKING(for libpcap)
AC_ARG_WITH(libpcap,
AC_HELP_STRING([--with-libpcap=DIR],
[Use libpcap in DIR]),
[
testdir=$withval
for incl in ${testdir}/include/pcap.h ${testdir}/pcap.h ${testdir}/pcap/pcap.h; do
if ! test -f "${incl}"; then
continue
fi
LPCAPINC=${incl}
LPCAPINCDIR=${testdir}
if test $dynamic_link = yes; then
for ext in .dylib .so .tbd ; do
for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
sharefile=$(ls ${testdir}/$dir/libpcap${ext}* 2> /dev/null | sort | head -n1)
if test -n "${sharefile}"; then
LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
foundpcap=$testdir
break
fi
done
if ! test $foundpcap = no; then
break
fi
done
else
dnl
dnl If dynamic library not found, try static
dnl
for ext in ${libext} .a .A.tbd ; do
for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
staticfile=$(ls ${testdir}/$dir/libpcap${ext} 2> /dev/null | sort | head -n1)
if test -n "${staticfile}"; then
LPCAPLIB="${staticfile}"
foundpcap=${testdir}
break
fi
done
if ! test $foundpcap = no; then
## could be PF_RING
#
# library is static and in PF_RING build tree
#
# Need access to libpfring library
# and must find an associated libpfring.a
if test -n "${with_pfring_lib}"; then
if test -f ${with_pfring_lib}; then
pf_ring_lib=${with_pfring_lib}
pf_ring_found=yes
else
AC_MSG_ERROR(["Unable to find PF_RING library ${with_pfring_lib}"])
fi
else
## search locally for most likely PF_RING library
for lib in ${foundpcap}/../lib/libs/libpfring_zc_${host_cpu}.a \
${foundpcap}/../lib/libs/libpfring_dna_${host_cpu}.a \
${foundpcap}/../lib/libs/libpfring_zero_${host_cpu}.a \
${foundpcap}/../lib/libs/libpfring_nt_${host_cpu}.a \
${foundpcap}/../lib/libpfring.a; do
if test -f "${lib}"; then
pf_ring_lib=${lib}
pf_ring_found=yes
break
fi
done
fi
break
fi
done
fi
if test $foundpcap = no; then
AC_ERROR(["Unable to find matching library for header file in ${testdir}"])
fi
break
done
],[
#
# Look for pcap-config.
#
# I wish this option could be the default, but it is only enabled with --enable-pcapconfig
#
# The issue is that libpcap is one of those libraries that is nearly impossible to set up
# properly across all platforms. The 'pcap-config' script is shipped with new versions of libpcap,
# and was created to address portability issues. Unfortunately, the script is not updated properly
# outside of the base distribution. Examples: PF_RING requires 'pthreads', 'numa' and 'rt', but
# this is not reflect that in the script. OS X Xcode 10.11 SDK creates its own very broken
# 'pcap-config' script that only occasionally works for dynamic definitions, and defintely
# does not work for static.
#
# The ability to enable this script exists for corner cases where libpcap distributions starts
# using even more libraries than I am currently not aware of. Originally, you only had to worry
# about 'nl', but now we have to be prepared to add 'nl-3', 'nl-genl-3' and 'dbus-1' to make
# libpcap fucntional. In the future, there may be more.
#
# (sigh)
#
# So, in the future if libpcap changes and stops working, try setting --enable-pcapconfig. It
# it may work for you.
if test $enable_pcap_config = yes; then
AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
if test -n "$PCAP_CONFIG"; then
#
# Found - use it to get the include flags for
# libpcap and the flags to link with libpcap.
#
# Please read section 11.6 "Shell Substitutions"
# in the autoconf manual before doing anything
# to this that involves quoting. Especially note
# the statement "There is just no portable way to use
# double-quoted strings inside double-quoted back-quoted
# expressions (pfew!)."
#
if test $dynamic_link = yes; then
LPCAPLIB=$($PCAP_CONFIG --libs)
else
LPCAPLIB=$($PCAP_CONFIG --libs --static)
fi
CFLAGS="$CFLAGS $($PCAP_CONFIG --cflags)"
if test -n "$LPCAPLIB"; then
foundpcap=yes
using_pcap_config=yes
else
AC_WARN([Unable to find libpcap using pcap-config])
fi
fi
fi
if test ! $foundpcap = yes; then
#
# Not found; look for pcap.
#
for testdir in /usr/local /opt/local /usr /wpdpack $MACOSX_SDK_PATH/usr /usr/local/opt/libpcap ; do
if test -f "${testdir}/include/pcap.h"; then
LPCAPINC="${testdir}/include/pcap.h"
LPCAPINCDIR="${testdir}/include"
if test $dynamic_link = yes; then
for ext in .dylib .so .tbd; do
for dir in . lib lib64 ${host_cpu} lib/${host_cpu} ${host_cpu}-${host_os} lib/${host_cpu}-${host_os} ${MULTIARCH} lib/${MULTIARCH}; do
sharefile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
if test -n "${sharefile}"; then
LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
foundpcap=$testdir
break
fi
done
if ! test $foundpcap = no; then
break
fi
done
fi
if test $foundpcap = no ; then
dnl
dnl If dynamic library not found, try static
dnl
for ext in ${libext} .a .A.tbd ; do
for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
staticfile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
if test -n "${staticfile}"; then
LPCAPLIB="${staticfile}"
foundpcap=$testdir
break
fi
done
if ! test $foundpcap = no; then
break
fi
done
fi
if test $foundpcap = no -a -f "${testdir}/lib/libwpcap.${libext}" ; then
LPCAPLIB="${testdir}/lib/libwpcap.${libext}"
AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
foundpcap=$testdir
fi
fi
if ! test $foundpcap = no; then
break
fi
done
fi
])
if test $foundpcap = no ; then
AC_MSG_RESULT(no)
AC_ERROR(libpcap not found)
else
AC_MSG_RESULT($foundpcap)
fi
# libpcap can require libnl
AC_SEARCH_LIBS([nl_handle_alloc], [nl],
[AC_MSG_NOTICE([Unable to find nl library - may be needed by libpcap])])
##
## If not automatically configured,
## check for newer and full-featured libpcap's
##
if ! test $using_pcap_config = yes; then
## newer libpcap requires dbus and latest nl (e.g. -lnl-genl-3 -lnl-3 -ldbus-1)
AC_CHECK_LIB(nl, nl_cache_alloc, [nl_found=yes])
AC_CHECK_LIB(nl-genl-3, genl_connect, [nl_genl_3_found=yes])
AC_CHECK_LIB(nl-3, nl_cache_alloc, [nl_3_found=yes])
AC_CHECK_LIB(dbus-1, dbus_malloc, [dbus_1_found=yes])
if test "$nl_found" = "yes"; then
LPCAPLIB="$LPCAPLIB -lnl"
fi
if test "$nl_genl_3_found" = "yes"; then
LPCAPLIB="$LPCAPLIB -lnl-genl-3"
fi
if test "$nl_3_found" = "yes"; then
LPCAPLIB="$LPCAPLIB -lnl-3"
fi
if test "$dbus_1_found" = "yes"; then
LPCAPLIB="$LPCAPLIB -ldbus-1"
fi
## See if prereqs for PF_RING exist
AC_CHECK_LIB(numa, numa_available, [numa_found=yes])
AC_CHECK_LIB(pthread, pthread_create, [pthread_found=yes])
if test $pf_ring_found = yes; then
if ! test "${numa_found}" = "yes"; then
AC_MSG_ERROR([PF_RING requires libnuma and/or libnuma-dev])
fi
if ! test "${pthread_found}" = "yes"; then
AC_MSG_ERROR([PF_RING requires libpthread])
fi
LPCAPLIB="$LPCAPLIB ${pf_ring_lib} -lnuma -lpthread -lrt"
fi
fi
OLDLIBS="$LIBS"
if test -n "$LPCAPINCDIR"; then
OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
CFLAGS="$CFLAGS -I$LPCAPINCDIR"
else
OLDCFLAGS="$CFLAGS"
LPCAPINCDIR=$(echo $CFLAGS | sed -e 's/^\-I//')
LPCAPINC="$LPCAPINCDIR/pcap.h"
fi
LIBS="$LPCAPLIB"
AC_SEARCH_LIBS([pcap_get_pfring_id], [pcap], AC_DEFINE([HAVE_PF_RING_PCAP], [1], [Do we have PF_RING libpcap support?]))
## Does libpcap work with selected libraries?
AC_SEARCH_LIBS([pcap_close], [pcap],
, AC_ERROR([Unable to link libpcap in ${foundpcap}]),)
AC_SUBST(LPCAPINC)
AC_SUBST(LPCAPLIB)
dnl Check to see what version of libpcap
dnl this code has been reduced a lot, but probably still could be
dnl reduced quite a bit more if we chose too
AC_MSG_CHECKING(for libpcap version)
dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
dnl fix for OSX. See: http://tcpreplay.synfin.net/trac/ticket/167
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "$LPCAPINC"
#define PCAP_TEST "0.9.6"
]], [[
/*
* simple proggy to test the version of libpcap
* returns zero if version >= 0.9.6
* or one otherwise
*/
if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
exit(0);
if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0) {
printf("%s ", pcap_lib_version());
exit(0);
}
exit(1);
]])],
[libpcap_version_096=yes],
[libpcap_version_096=no],
[libpcap_version_096=yes]
)
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "$LPCAPINC"
#define PCAP_TEST "0.8"
]], [[
/*
* simple proggy to test the version of libpcap
* returns zero if version >= 0.8.0
* or one otherwise
*/
if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
exit(0);
/* winpcap? */
if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
exit(0);
exit(1);
]])],
[libpcap_ver8=yes],
[libpcap_ver8=no],
[libpcap_ver8=yes]
)
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "$LPCAPINC"
#define PCAP_TEST "0.7.2"
extern const char pcap_version[[]]; /* double up since autoconf escapes things */
]], [[
/*
* simple proggy to test the version of libpcap
* returns zero if version >= 0.7.2
* or one otherwise
*/
if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
exit(0);
if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
exit(0);
exit(1);
]])],
[libpcap_ver7=yes],
[libpcap_ver7=no],
[libpcap_ver7=yes]
)
if test x$libpcap_ver8 = xyes ; then
AC_MSG_RESULT(>= 0.8.0)
elif test x$libpcap_ver7 = xyes ; then
AC_MSG_RESULT(>= 0.7.2)
else
AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
Please upgrade to version 0.7.2 or better])
fi
libpcap_version=unknown
if test x$libpcap_version_096 = xyes ; then
libpcap_version=">= 0.9.6"
elif test x$libpcap_ver8 = xyes ; then
libpcap_version=">= 0.8.0"
elif test x$libcap_ver7 = xyes ; then
libpcap_version=">= 0.7.0"
fi
dnl Check for pcap_setnonblock()
AC_MSG_CHECKING(for pcap_setnonblock)