forked from repu1sion/odp_libtrace
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.in
895 lines (747 loc) · 28.5 KB
/
configure.in
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
# Process this file with autoconf to produce a configure script.
# Now you only need to update the version number in two places - below,
# and in the README
AC_INIT([libtrace],[4.0.15],[[email protected]],[libtrace])
LIBTRACE_MAJOR=4
LIBTRACE_MID=0
LIBTRACE_MINOR=15
# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
# searched by default - add it to LDFLAGS so we at least have a chance of
# finding it
if test -d "/usr/gnu/lib"; then
LDFLAGS+=" -L/usr/gnu/lib"
fi
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(lib/trace.c)
AM_INIT_AUTOMAKE([subdir-objects])
# Make sure we use the relatively silent automake output
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# Define our libtrace version number externally so we can use it in the source
# as well, if needed.
AC_DEFINE([LIBTRACE_MAJOR],${LIBTRACE_MAJOR},[libtrace major version])
AC_DEFINE([LIBTRACE_MID],${LIBTRACE_MID},[libtrace mid version])
AC_DEFINE([LIBTRACE_MINOR],${LIBTRACE_MINOR},[libtrace minor version])
# These are all the files we want to be built for us by configure
AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile
tools/Makefile tools/traceanon/Makefile tools/tracepktdump/Makefile
tools/tracemerge/Makefile tools/tracereport/Makefile
tools/tracertstats/Makefile tools/tracesplit/Makefile
tools/tracestats/Makefile tools/tracetop/Makefile
tools/tracereplay/Makefile tools/tracediff/Makefile
tools/traceends/Makefile tools/tracemcast/Makefile
examples/Makefile examples/skeleton/Makefile examples/rate/Makefile
examples/stats/Makefile examples/tutorial/Makefile examples/parallel/Makefile
docs/libtrace.doxygen
lib/libtrace.h
])
# Function that checks if the C++ compiler actually works - there's a bit of
# oversight in autoconf that will set the C++ compiler to g++ if no compiler
# is found, even if g++ is not present! So we need an extra test to make sure
# that the compiler works :(
AC_DEFUN([rw_PROG_CXX_WORKS],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_CACHE_CHECK([whether the C++ compiler works],
[rw_cv_prog_cxx_works],
[AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[rw_cv_prog_cxx_works=yes],
[rw_cv_prog_cxx_works=no])
AC_LANG_POP([C++])])
])
# Put all our automake definitions in config.h
AM_CONFIG_HEADER([config.h])
# Checks for C and C++ compilers
AC_PROG_CC
AC_PROG_CXX
rw_PROG_CXX_WORKS
if test "$rw_cv_prog_cxx_works" = "no"; then
AC_MSG_ERROR("Failed to find working C++ compiler")
fi
# Checking for 'install'
AC_PROG_INSTALL
# Checking for bison and flex
AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc)
AM_PROG_LEX
# All our source files for function replacements are in lib/
AC_CONFIG_LIBOBJ_DIR(lib)
# Check for various "replacement" functions
AC_FUNC_MALLOC
AC_FUNC_REALLOC
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_SYS_LARGEFILE
LIBPKTDUMP_LIBS="-ltrace "
ADD_LDFLAGS="$ADD_LDFLAGS -L\$(abs_top_srcdir)/lib"
#LIBTRACE_LIBS="-lodp-dpdk -lrdkafka -lrte_ring -lrte_pmd_ring"
LIBTRACE_LIBS="-lodp-dpdk -lrdkafka"
TOOLS_LIBS=""
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1"
CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1"
# Check for -fvisibility
gl_VISIBILITY
gcc_PACKED
gcc_DEPRECATED
gcc_UNUSED
gcc_PURE
gcc_FORMAT
# Check for gcc style TLS (__thread)
gcc_TLS
# Check for libtool
AC_PROG_LIBTOOL
# Checks for library functions.
AC_PROG_GCC_TRADITIONAL
# Fail if any of these functions are missing
AC_CHECK_DECLS([strdup, strlcpy, strcasecmp, strncasecmp, snprintf, vsnprintf, strndup])
AC_CHECK_DECLS([socket, recvmmsg], [], [], [[#define _GNU_SOURCE 1
#include <sys/socket.h>]])
AC_CHECK_SIZEOF([long int])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(pcap.h pcap-bpf.h net/bpf.h sys/limits.h stddef.h inttypes.h limits.h net/ethernet.h sys/prctl.h)
# OpenSolaris puts ncurses.h in /usr/include/ncurses rather than /usr/include,
# so check for that
AC_CHECK_HEADERS(ncurses.h,,[missing_ncurses=true])
if test "x$missing_ncurses" = xtrue; then
if test -f "/usr/include/ncurses/ncurses.h"; then
AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Has nested ncurses header])
fi
fi
# Check for the presence of various networking headers and define appropriate
# macros
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(netpacket/packet.h,[
libtrace_netpacket_packet_h=true
AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net])
])
AC_CHECK_HEADER(net/if.h,
AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[
#include <sys/types.h>
#include <sys/socket.h>
])
AC_CHECK_HEADER(netinet/ether.h,
AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
])
AC_CHECK_HEADER(netinet/if_ether.h,
AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
])
AC_CHECK_HEADER(net/if_arp.h,
AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
])
# Check for sdl_len in sockaddr_dl - sockaddr_dl is used on BSD systems
if test "$libtrace_netpacket_packet_h" != "true"; then
AC_CHECK_MEMBER([struct sockaddr_dl.sdl_len],
AC_DEFINE(HAVE_SDL_LEN,1,[Has sdl_len in sockaddr_dl]),,[
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_dl.h>
])
fi
# Checking for the right bpf header to include
AC_CHECK_HEADER(pcap-bpf.h)
AC_CHECK_HEADER(net/bpf.h)
# Checking for libgdc
AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h]))
# Check for libwandio (no longer bundled with libtrace)
AC_CHECK_LIB(wandio,wandio_wflush,wandiofound=1,wandiofound=0)
if test "$wandiofound" = 0; then
AC_MSG_ERROR(libwandio 4.0.0 or better is required to compile this version of libtrace. If you have installed libwandio in a non-standard location please use LDFLAGS to specify the location of the library. WANDIO can be obtained from http://research.wand.net.nz/software/libwandio.php)
else
LIBTRACE_LIBS="$LIBTRACE_LIBS -lwandio"
TOOLS_LIBS="$TOOLS_LIBS -lwandio"
AC_DEFINE([HAVE_LIBWANDIO],1,[compile with libwandio support])
fi
AC_CHECK_LIB(crypto, EVP_EncryptInit_ex, cryptofound=1, cryptofound=0)
if test "$cryptofound" = 1; then
AC_CHECK_HEADER(openssl/evp.h, cryptofound=1, cryptofound=0)
fi
AC_CHECK_LIB(yaml, yaml_parser_initialize, yamlfound=1, yamlfound=0)
AC_CHECK_LIB(tasn1, asn1_array2tree, asn1found=1, asn1found=0)
# check for xdp requirements.
libtrace_xdp=false
build_ebpf=false
AC_CHECK_LIB(elf, elf_begin, elffound=1, elffound=0)
if test "$elffound" == 1; then
# check for libbpf
AC_CHECK_LIB(bpf, xsk_socket__create, bpffound=1, bpffound=0, -lelf)
if test "$bpffound" = 1; then
AC_DEFINE(HAVE_LIBBPF, 1, [Set to 1 if libbpf is available])
ADD_LDFLAGS="$ADD_LDFLAGS -lbpf -lelf"
libtrace_xdp=true
# check for requirements to build XDP eBPF kernel
AC_CHECK_PROG(CLANG, [clang], [clang], [no])
if test "$CLANG" != "no"; then
AC_SUBST(CLANG)
llc_candidates=$($CLANG --version | \
awk '/^clang version/ {
split($3, v, ".");
printf("llc-%s.%s llc-%s llc", v[[1]], v[[2]], v[[1]])
}')
AC_CHECK_PROGS([LLC], [$llc_candidates], [no])
if test "$LLC" != "no"; then
AC_SUBST(LLC)
build_ebpf=true
fi
fi
else
libtrace_xdp=false
fi
fi
# was XDP support explicitly specified and failed
AC_ARG_WITH(xdp,AS_HELP_STRING(--with-xdp, include XDP capture support),
[
if test x"$libtrace_xdp" = xfalse; then
AC_MSG_ERROR([libelf and libbpf are required for XDP support])
fi
],[])
# was ebpf build explicitly specified and failed
AC_ARG_ENABLE(ebpf-build, AS_HELP_STRING(--enable-ebpf-build, Enable compilation of XDP eBPF kernel),
[
if test x"$build_ebpf" = xfalse; then
AC_MSG_ERROR([clang, llvm and libbpf are required to build the XDP eBPF kernel])
fi
],[])
# Check for libpcap
AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0)
AC_CHECK_LIB(pcap,pcap_create,pcapcreate=1,pcapcreate=0)
AC_CHECK_LIB(pcap,pcap_set_immediate_mode,pcapimmediate=1,pcapimmediate=0)
AC_CHECK_DECLS([BIOCSETIF],,,[
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <net/bpf.h>
])
AC_ARG_ENABLE(memory-debugging,
AS_HELP_STRING(--enable-memory-debugging, prints internal memory statistics),[
if test "$HAVE_TLS" = 1
then
AC_DEFINE([ENABLE_MEM_STATS], 1, [print debug memory statistics])
fi
],[])
# Configure options for man pages
AC_ARG_WITH(man,
AS_HELP_STRING(--with-man,install man pages by default),[
if test "$withval" = yes
then
MANPAGES="docs/man/man3/[a-zA-Z]*.3"
else
MANPAGES=""
fi
])
# Complain if we didn't find a suitable libpcap
if test "$pcapfound" = 0; then
AC_MSG_ERROR(libpcap0.8 or greater is required to compile libtrace. If you have installed it in a non-standard location please use LDFLAGS to specify the location of the library)
else
TOOLS_LIBS="$TOOLS_LIBS -lpcap"
LIBTRACE_LIBS="$LIBTRACE_LIBS -lpcap"
AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
LIBS="-lpcap"
AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock)
LIBS=""
fi
if test "$pcapcreate" = 1; then
AC_DEFINE([HAVE_PCAP_CREATE],1,[compile with libpcap 1.0 support])
fi
if test "$pcapimmediate" = 1; then
AC_DEFINE([HAVE_PCAP_IMMEDIATE],1,[able to use pcap_set_immediate_mode])
fi
# Configure options for use of DAG cards
# Originally borrowed from libpcap, but extended quite a bit :)
# More details on how this check works:
# http://wand.net.nz/trac/libtrace/wiki/DAGNotes
AC_ARG_WITH(dag,
AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)),
[
if test "$withval" = no
then
want_dag=no
elif test "$withval" = yes
then
want_dag=yes
dag_root=/usr/local/dag
else
want_dag=yes
dag_root=$withval
fi
],[
#
# Use DAG API if present, otherwise don't
#
want_dag=ifpresent
dag_root=/usr/local/dag
])
# DAG 3.0 actually puts header files and shared libraries into sensible
# places now, so we should be able to do a simple CHECK_LIB to see if
# they're there!
# Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here
# also. This isn't such a bad thing, the DAG2.5 API is essentially the same as
# DAG 3.0 and libtrace will use the same format_dagXX source for both
libtrace_dag=false
libtrace_dag_version=none
if test "$with_dag" != no; then
AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0)
if test "$dag_found" = 1; then
ADD_LIBS="$ADD_LIBS -ldag"
LIBTRACE_LIBS="$LIBTRACE_LIBS -ldag"
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
libtrace_dag=true
AC_DEFINE(DAG_VERSION,25,[defines the DAG driver version])
libtrace_dag_version=25
AC_CHECK_HEADERS(dag_config_api.h,[csapi_found=1],,)
if test "$csapi_found" = 1; then
LIBTRACE_LIBS="$LIBTRACE_LIBS -ldagconf"
fi
fi
fi
# TODO: turn the test part of the next block into a function, so it can be
# called multiple times for $dag_root, /root/dag, /usr/local/lib
dag_drv_v="DAG not present"
# Now check for 2.4 DAG drivers which don't install as cleanly!
if test "$with_dag" != no -a "$libtrace_dag" = false; then
AC_MSG_CHECKING(whether we have DAG 2.4 API instead)
if test -r "$dag_root/lib"; then
dag_lib_dir="$dag_root/lib"
else
dag_lib_dir="$dag_root"
fi
if test -r "$dag_root/include"; then
dag_tools_dir="$dag_root/tools"
dag_include_dir="$dag_root/include"
else
dag_tools_dir="$dag_root"
dag_include_dir="$dag_root"
fi
if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a";
then
ADD_INCLS="$ADD_INCLS -I $dag_include_dir"
ADD_LIBS="$ADD_LIBS -ldag"
ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir"
DAG_TOOLS_DIR=$dag_tools_dir
AC_SUBST([DAG_TOOLS_DIR])
libtrace_dag=true
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version])
libtrace_dag_version=24
else
if test "$want_dag" = yes; then
AC_MSG_ERROR(DAG API not found under directory $dag_root
; use --without-dag)
fi
libtrace_dag=false
fi
AC_MSG_RESULT($libtrace_dag)
fi
# Check for PACKET_FANOUT (borrowed from Suricata)
AC_CHECK_DECL([PACKET_FANOUT],
AC_DEFINE([HAVE_PACKET_FANOUT],[1],
[Recent packet fanout support is available]),
[],
[[#include <linux/if_packet.h>]])
# If we use DPDK we might be able to use libnuma
AC_CHECK_LIB(numa, numa_node_to_cpus, have_numa=1, have_numa=0)
# Need libwandder for ETSI live decoding
AC_CHECK_LIB(wandder, init_wandder_decoder, have_wandder=1, have_wandder=0)
# Checks for various "optional" libraries
AC_CHECK_LIB(pthread, pthread_create, have_pthread=1, have_pthread=0)
AC_CHECK_LIB(pthread, pthread_setname_np, have_pthread_setname_np=1, have_pthread_setname_np=0)
# Try to determine the DAG driver version
#if test x"$libtrace_dag" = xtrue; then
# dag_drv_v="Unknown"
# files=`locate /usr/*dag*/VERSION`
# file_count=0
#
# for i in $files; do
# if $file_count > 0; then
# dag_drv_v="Indeterminate"
# break
# fi
# dag_drv_v=`cat $i`
# file_count=$file_count+1
# done
#fi
#DAG_VERSION_NUM=$dag_drv_v
# Check for ncurses
# These libraries have to be explicitly linked in OpenSolaris
AC_SEARCH_LIBS(getservent, socket, have_socket=1, have_socket=0, -lnsl)
LIBS=
AC_SEARCH_LIBS(inet_ntop, nsl, have_nsl=1, have_nsl=0, -lsocket)
LIBS=
# Check to see if we have libdl - *BSD has built-in libdl
AC_SEARCH_LIBS(dlopen,dl, dlfound=1,dlfound=0 )
LIBS=
# Check for clock_gettime
AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=1, have_clock_gettime=0)
LIBS=
if test "$have_numa" = 1; then
LIBTRACE_LIBS="$LIBTRACE_LIBS -lnuma"
AC_DEFINE(HAVE_LIBNUMA, 1, [Set to 1 if libnuma is supported])
with_numa=yes
else
with_numa=no
fi
if test "$have_wandder" = 1; then
LIBTRACE_LIBS="$LIBTRACE_LIBS -lwandder"
AC_DEFINE(HAVE_WANDDER, 1, [Set to 1 if libwandder is available])
wandder_avail=yes
else
wandder_avail=no
fi
if test "$dlfound" = 0; then
AC_MSG_ERROR("Unable to find dlopen. Please use LDFLAGS to specify the location of libdl and re-run configure")
fi
if test "$ac_cv_search_dlopen" != "none required"; then
LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_dlopen"
if test "$dpdk_found" != 0; then
LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,$ac_cv_search_dlopen"
fi
fi
if test "$have_pthread" = 1; then
AC_DEFINE(HAVE_LIBPTHREAD, 1, [Set to 1 if pthreads are supported])
LIBTRACE_LIBS="$LIBTRACE_LIBS -lpthread"
fi
if test "$have_pthread_setname_np" = 1; then
AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [Set to 1 if pthread_setname_np is found])
fi
if test "$cryptofound" = 1; then
AC_DEFINE(HAVE_LIBCRYPTO, 1, [Set to 1 if libcrypto is available])
TOOLS_LIBS="$TOOLS_LIBS -lcrypto"
have_crypto=yes
else
have_crypto=no
fi
if test "$yamlfound" = 1; then
AC_DEFINE(HAVE_LIBYAML, 1, [Set to 1 if libyaml is available])
TOOLS_LIBS="$TOOLS_LIBS -lyaml"
have_yaml=yes
else
have_yaml=no
fi
if test "$have_nsl" = 1; then
if test "$ac_cv_search_inet_ntop" != "none required"; then
LIBTRACE_LIBS="$LIBTRACE_LIBS $ac_cv_search_inet_ntop"
LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_inet_ntop"
fi
fi
if test "$have_socket" = 1; then
if test "$ac_cv_search_getservent" != "none required"; then
LIBTRACE_LIBS="$LIBTRACE_LIBS $ac_cv_search_getservent"
LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_getservent"
fi
fi
if test "$have_clock_gettime" = 1; then
LIBTRACE_LIBS="$LIBTRACE_LIBS -lrt"
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Set to 1 if clock_gettime is supported])
with_clock_gettime=yes
else
with_clock_gettime=no
fi
# Check for DPDK
AC_ARG_WITH(dpdk,
AS_HELP_STRING(--with-dpdk,include DPDK live capture support (From either the RTE_SDK/_TARGET environment variable or the dpdk-dev package)),
[
if test "$withval" = no
then
want_dpdk=no
else
want_dpdk=ifpresent
fi
],[
# Default to building without DPDK format
want_dpdk=no
])
libtrace_dpdk=false
if test "$want_dpdk" != no; then
dpdk_found=0
# So instead simply check for existence
if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.so", dpdk_found="dpdk", dpdk_found=0)
fi
if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libintel_dpdk.a", dpdk_found=":libintel_dpdk.a", dpdk_found=0)
fi
# DPDK 2.1.0+ renames this to libdpdk from libintel_dpdk
if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.a", dpdk_found=":libdpdk.a", dpdk_found=0)
fi
if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
AC_CHECK_LIB(dpdk, rte_eth_dev_configure, dpdk_found="dpdk", dpdk_found=0)
fi
if test "$dpdk_found" != 0 -a "$RTE_SDK" != ""; then
# Save these now so that they can be re-exported later
AC_SUBST([RTE_TARGET])
AC_SUBST([RTE_SDK])
# Force dpdk library to be statically linked to allow compiler optimisations
LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--whole-archive -Wl,-l$dpdk_found -Wl,--no-whole-archive -Wl,-lm"
fi
# Find the DPDK system package
# We do this last to allow RTE_SDK to override the system library
#
# Dynamic linking against the system's version of DPDK is never easy:
#
# 1) On Ubuntu the linker has --as-needed set by default, this means
# any library which libtrace doesn't directly reference a method from
# is not listed as a dependency to libtrace.so. This causes problems
# for DPDK, DPDK uses .init or .ctors to patch drivers etc into its
# global structures. So libraries need to be loaded simply to register
# themselves.
#
# 2) The answer to this is --no-as-needed, a positional argument, which
# applies to all following arguments/libs. However, libtool *helpfully*
# reorganises the arguments we give it before giving them to the linker.
# To avoid this we need to prefix all libraries with -Wl,-lxxx, so
# libtool leaves them be.
# Hence the ugly sed hack, TODO find something nicer.
#
# 3) The package-cfg for Ubuntu 20.02 (DPDK 19.11) is wrong for dynamic
# libraries and is missing important libraries like rte_bus_pci,
# without which we cannot load PCI devices.
# So we always use pkg-config --static here, even for dynamic linking.
# Note the nicer PKG_CHECK_MODULES_STATIC macro doesn't exist in older
# distributions.
#
if test "$dpdk_found" = 0; then
PKG_PROG_PKG_CONFIG
pkg_config_old="$PKG_CONFIG"
PKG_CONFIG="$PKG_CONFIG --static"
PKG_CHECK_MODULES([DPDK], [libdpdk >= 18], [pkgconf_dpdk_found="yes"],
[pkgconf_dpdk_found="no"])
PKG_CONFIG="$pkg_config_old"
fi
if test "$dpdk_found" = 0 -a "x$pkgconf_dpdk_found" = "xyes"; then
LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--no-as-needed $(echo $DPDK_LIBS | sed 's/ -l/ -Wl,-l/g')"
AC_MSG_NOTICE([Pkg config found DPDK libs = $DPDK_LIBS])
ADD_INCLS="$ADD_INCLS $DPDK_CFLAGS"
AC_MSG_NOTICE([Building against system DPDK])
dpdk_found=pkgconfig
fi
if test "$dpdk_found" = 0 -a "$RTE_SDK" = ""; then
AC_MSG_NOTICE([No RTE_SDK given, checking for system dpdk-dev package])
# Search the system, maybe it is installed? Ethdev is one of the main libraries
# On Ubuntu and Debian we can simply check for dpdk.so
AC_CHECK_LIB(dpdk, rte_eth_dev_configure, dpdk_found="system", dpdk_found=0)
# We also need to check that rte.vars.mk is installed from dpdk-dev (as well as libdpdk-dev)
if test "$dpdk_found" != 0 -a -e /usr/share/dpdk/mk/rte.vars.mk ; then
# This is terrible, but I'm not sure that there is an easier way for us to figure out what RTE_EXEC_ENV is eventually going to be renamed to by the end of the DPDK build process.
for execenv in linuxapp linux bsdapp freebsd; do
if test -d /usr/share/dpdk/$(uname -m)-default-${execenv}-gcc; then
RTE_TARGET=$(uname -m)-default-${execenv}-gcc
break
fi
done
if test RTE_TARGET != ""; then
RTE_SDK="/usr/share/dpdk/"
RTE_INCLUDE="/usr/include/dpdk"
AC_SUBST([RTE_TARGET])
AC_SUBST([RTE_SDK])
AC_SUBST([RTE_INCLUDE])
LIBTRACE_LIBS="$LIBTRACE_LIBS -ldpdk"
AC_MSG_NOTICE([Building against system DPDK])
dpdk_found=system
fi
fi
fi
if test "$dpdk_found" != 0; then
AC_DEFINE(HAVE_DPDK,1,[conditional for building with DPDK live capture support])
libtrace_dpdk=true
fi
if test "$dpdk_found" = 0 -a "$with_dpdk" = "yes"; then
AC_MSG_ERROR("Unable to find DPDK on system. Build halted -- consider re-running configure with '--with-dpdk=no'.")
fi
fi
have_memfd_create=no
AC_RUN_IFELSE([AC_LANG_PROGRAM([
#include <sys/syscall.h>
],[
#ifndef __NR_memfd_create
exit(1)
#endif
])], [have_memfd_create=yes])
if test "$have_memfd_create" = "yes"; then
AC_DEFINE(HAVE_MEMFD_CREATE, 1, [Set to 1 if kernel supports memfd_create syscall])
fi
# Stupid AC_SEARCH_LIB appends stuff to LIBS even when I don't want it to, so
# just set libs to null here to avoid linking against them by default
LIBS=
# For now, the user has to explicitly ask for the LLVM stuff, as it's a bit
# rough around the edges :(
AC_ARG_WITH([llvm],
[AC_HELP_STRING([--with-llvm],
[support Just In Time compiler])],
use_llvm="yes",
use_llvm="no")
JIT=no
# Search for LLVM and the libraries that it requires
if (test "$use_llvm" != "no"); then
AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
# XXX Hard coding the path is REALLY bad.
# llvm-gcc is installed in a stupid place in Debian / Ubuntu. Hard luck
# if you've installed it somewhere custom.
# Hopefully in future we can replace this with clang, which may or may
# not be installed somewhere intelligent.
AC_PATH_PROG(LLVM_GCC, llvm-gcc, no, /usr/lib/llvm/llvm/gcc-4.2/bin)
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([boost/lexical_cast.hpp], boost="yes", boost="no")
AC_LANG_POP([C++])
if test "$boost" = "no"; then
AC_MSG_NOTICE([Unabled to find boost libraries. JIT support disabled.])
JIT=no
elif test "$LLVM_CONFIG" = "no" ; then
AC_MSG_NOTICE([Unable to find llvm-config. JIT support disabled.])
JIT=no
elif test "$LLVM_GCC" = "no"; then
AC_MSG_NOTICE([Unable to find llvm-gcc. JIT support disabled.])
JIT=no
else
LIBCXXFLAGS="`$LLVM_CONFIG --cxxflags` $CXXFLAGS"
LIBTRACE_LIBS="$LIBTRACE_LIBS `$LLVM_CONFIG --libs all`";
LDFLAGS="`$LLVM_CONFIG --ldflags` $LDFLAGS";
JIT=yes
AC_DEFINE(HAVE_LLVM, 1, [Set to 1 if you have LLVM installed])
fi
fi
AC_ARG_WITH([ncurses],
AC_HELP_STRING([--with-ncurses], [build tracetop (requires ncurses)]))
AS_IF([test "x$with_ncurses" != "xno"],
[AC_SEARCH_LIBS(mvprintw, ncurses, have_ncurses=yes, have_ncurses=no)
LIBS=
], [have_ncurses=no])
AS_IF([test "x$have_ncurses" = "xyes"], [
if test "$ac_cv_search_mvprintw" != "none required"; then
TOOLS_LIBS="$TOOLS_LIBS $ac_cv_search_mvprintw"
fi
AC_DEFINE(HAVE_NCURSES, 1, "Compiled with ncurses support")
with_ncurses=yes],
[AS_IF([test "x$with_ncurses" = "xyes"],
[AC_MSG_ERROR([ncurses requested but not found])])
AC_DEFINE(HAVE_NCURSES, 0, "Compiled with ncurses support")
with_ncurses=no]
)
# Define automake conditionals for use in our Makefile.am files
AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ])
AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
AM_CONDITIONAL([HAVE_DPDK], [test "$libtrace_dpdk" = true])
AM_CONDITIONAL([HAVE_WANDDER], [test "x$wandder_avail" = "xyes"])
AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes])
AM_CONDITIONAL([HAVE_LLVM], [test "x$JIT" != "xno" ])
AM_CONDITIONAL([HAVE_NCURSES], [test "x$with_ncurses" != "xno"])
AM_CONDITIONAL([HAVE_YAML], [test "x$have_yaml" != "xno"])
AM_CONDITIONAL([HAVE_DPDK_PKGCONFIG], [test "x$dpdk_found" = "xpkgconfig"])
AM_CONDITIONAL([HAVE_LIBBPF], [test "x$libtrace_xdp" = "xtrue"])
AM_CONDITIONAL([BUILD_EBPF], [test "x$build_ebpf" = "xtrue"])
# Check for miscellaneous programs
AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false])
AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue])
# Set all our output variables
AC_SUBST([LIBTRACE_LIBS])
AC_SUBST([LIBPKTDUMP_LIBS])
AC_SUBST([TOOLS_LIBS])
#AC_SUBST([ADD_LIBS])
AC_SUBST([ADD_LDFLAGS])
AC_SUBST([ADD_INCLS])
AC_SUBST([LTLIBOBJS])
AC_SUBST([MANPAGES])
AC_SUBST([PACKAGE_VERSION])
AC_SUBST([LIBTRACE_MAJOR])
AC_SUBST([LIBTRACE_MID])
AC_SUBST([LIBTRACE_MINOR])
AC_SUBST([DAG_VERSION_NUM])
AC_SUBST([HAVE_BPF_CAPTURE])
AC_SUBST([HAVE_LIBGDC])
AC_SUBST([HAVE_LLVM])
AC_SUBST([HAVE_NCURSES])
AC_SUBST([LIBCFLAGS])
AC_SUBST([LIBCXXFLAGS])
# Finally, output our Makefiles
AC_OUTPUT
# Function for reporting whether an option was set or not
reportopt() {
if test x"$2" = xtrue -o x"$2" = xyes; then
AC_MSG_NOTICE([$1: Yes])
else
AC_MSG_NOTICE([$1: No])
fi
}
# Report which configure options were set
echo
AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION])
if test "$pcapcreate" = 1; then
AC_MSG_NOTICE([Compiled with PCAP support: >= 1.0])
else
AC_MSG_NOTICE([Compiled with PCAP support: < 1.0])
fi
if test x"$libtrace_dag" = xtrue; then
if test "$libtrace_dag_version" = 24; then
AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4])
elif test "$libtrace_dag_version" = 30; then
AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0])
else
AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5])
fi
else
AC_MSG_NOTICE([Compiled with DAG live capture support: No])
fi
# Are we building with XDP support
if test x"$libtrace_xdp" = xtrue; then
AC_MSG_NOTICE([Compiled with XDP capture support: Yes])
else
AC_MSG_NOTICE([Compiled with XDP capture support: No])
fi
# Are we building eBPF XDP program
if test x"$build_ebpf" = xtrue; then
AC_MSG_NOTICE([XDP Libtrace BPF program will be compiled: Yes])
else
AC_MSG_NOTICE([XDP Libtrace BPF program will be compiled: No])
fi
if test x"$libtrace_dpdk" = xtrue; then
AC_MSG_NOTICE([Compiled with DPDK live capture support: Yes])
reportopt "Compiled with DPDK trace NUMA support" $with_numa
reportopt "Compiled with clock_gettime support" $with_clock_gettime
elif test x"$want_dpdk" != "xno"; then
# We don't officially support DPDK so only report failure if the user
# explicitly asked for DPDK. That way, we can hopefully keep it hidden
# from most users for now...
AC_MSG_NOTICE([Compiled with DPDK live capture support: No])
AC_MSG_NOTICE([Note: Requires DPDK v1.5 or newer])
fi
reportopt "Compiled with LLVM BPF JIT support" $JIT
reportopt "Compiled with live ETSI LI support (requires libwandder)" $wandder_avail
reportopt "Building man pages/documentation" $libtrace_doxygen
reportopt "Building tracetop (requires libncurses)" $with_ncurses
reportopt "Building traceanon (requires libyaml)" $have_yaml
if test x"$have_yaml" = xyes; then
reportopt "Building traceanon with CryptoPan (requires libcrypto and openssl/evp.h)" $have_crypto
fi
# Report any errors relating to missing bison, flex, etc.
echo
ac_cv_errcount=0;
if test -z "$YACC"; then
AC_MSG_WARN(bison or yacc not found. Please install bison before continuing)
ac_cv_errcount=$((ac_cv_errcount + 1))
fi
if test "x$LEX" != xflex -a "x$LEX" != xlex; then
AC_MSG_WARN(flex or lex not found. Please install flex before continuing)
ac_cv_errcount=$((ac_cv_errcount + 1))
fi
if test $ac_cv_errcount -gt 0; then
AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure)
fi