source: configure.in @ 31111c7

cachetimestampsdevelopringdecrementfixringperformance
Last change on this file since 31111c7 was 31111c7, checked in by Richard Sanger <rsanger@…>, 2 years ago

Fixes building DPDK with system dpdk-dev packages

Now these packages have settled this is a simple check.
Libtrace with DPDK now builds with dpdk-dev from:
Ubuntu 16.04 (xenial), 17.10 (artful), 18.04(bionic), 18.10(cosmic)
Debian 8 (jessie), 9 (stretch), 10 (buster)

Building with system packages requires installing dpdk-dev and
running ./configure with the --with-dpdk option.

  • Property mode set to 100644
File size: 22.9 KB
Line 
1# Process this file with autoconf to produce a configure script.
2
3# Now you only need to update the version number in two places - below,
4# and in the README
5
6AC_INIT([libtrace],[4.0.4],[contact@wand.net.nz],[libtrace])
7
8LIBTRACE_MAJOR=4
9LIBTRACE_MID=0
10LIBTRACE_MINOR=4
11
12# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
13# searched by default - add it to LDFLAGS so we at least have a chance of
14# finding it
15if test -d "/usr/gnu/lib"; then
16        LDFLAGS+=" -L/usr/gnu/lib"
17fi
18
19AC_CONFIG_MACRO_DIR([m4])
20AC_CONFIG_SRCDIR(lib/trace.c)
21AM_INIT_AUTOMAKE([subdir-objects])
22
23# Make sure we use the relatively silent automake output
24m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
25
26# Define our libtrace version number externally so we can use it in the source
27# as well, if needed.
28AC_DEFINE([LIBTRACE_MAJOR],${LIBTRACE_MAJOR},[libtrace major version])
29AC_DEFINE([LIBTRACE_MID],${LIBTRACE_MID},[libtrace mid version])
30AC_DEFINE([LIBTRACE_MINOR],${LIBTRACE_MINOR},[libtrace minor version])
31
32# These are all the files we want to be built for us by configure
33AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile
34        tools/Makefile tools/traceanon/Makefile tools/tracepktdump/Makefile
35        tools/tracemerge/Makefile tools/tracereport/Makefile
36        tools/tracertstats/Makefile tools/tracesplit/Makefile
37        tools/tracestats/Makefile tools/tracetop/Makefile
38        tools/tracereplay/Makefile tools/tracediff/Makefile
39        tools/traceends/Makefile
40        examples/Makefile examples/skeleton/Makefile examples/rate/Makefile
41        examples/stats/Makefile examples/tutorial/Makefile examples/parallel/Makefile
42        docs/libtrace.doxygen
43        lib/libtrace.h
44        ])
45
46
47# Function that checks if the C++ compiler actually works - there's a bit of
48# oversight in autoconf that will set the C++ compiler to g++ if no compiler
49# is found, even if g++ is not present! So we need an extra test to make sure
50# that the compiler works :(
51
52AC_DEFUN([rw_PROG_CXX_WORKS],
53[AC_REQUIRE([AC_PROG_CXX])dnl
54AC_CACHE_CHECK([whether the C++ compiler works],
55        [rw_cv_prog_cxx_works],
56        [AC_LANG_PUSH([C++])
57        AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
58                [rw_cv_prog_cxx_works=yes],
59                [rw_cv_prog_cxx_works=no])
60        AC_LANG_POP([C++])])
61])
62
63# Put all our automake definitions in config.h
64AM_CONFIG_HEADER([config.h])
65
66# Checks for C and C++ compilers
67AC_PROG_CC
68AC_PROG_CXX
69rw_PROG_CXX_WORKS
70
71if test "$rw_cv_prog_cxx_works" = "no"; then
72        AC_MSG_ERROR("Failed to find working C++ compiler")
73fi
74
75# Checking for 'install'
76AC_PROG_INSTALL
77
78# Checking for bison and flex
79AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc)
80AM_PROG_LEX
81
82# All our source files for function replacements are in lib/
83AC_CONFIG_LIBOBJ_DIR(lib)
84
85# Check for various "replacement" functions
86AC_FUNC_MALLOC
87AC_FUNC_REALLOC
88
89# Checks for typedefs, structures, and compiler characteristics.
90AC_C_CONST
91AC_C_INLINE
92AC_C_BIGENDIAN
93AC_TYPE_SIZE_T
94AC_HEADER_TIME
95AC_SYS_LARGEFILE
96
97LIBPKTDUMP_LIBS="-ltrace "
98ADD_LDFLAGS="$ADD_LDFLAGS -L\$(abs_top_srcdir)/lib"
99LIBTRACE_LIBS=""
100TOOLS_LIBS=""
101
102CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1"
103CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1"
104
105# Check for -fvisibility
106gl_VISIBILITY
107
108gcc_PACKED
109gcc_DEPRECATED
110gcc_UNUSED
111gcc_PURE
112gcc_FORMAT
113
114# Check for gcc style TLS (__thread)
115gcc_TLS
116       
117# Check for libtool
118AC_PROG_LIBTOOL
119
120# Checks for library functions.
121AC_PROG_GCC_TRADITIONAL
122
123# Fail if any of these functions are missing
124AC_CHECK_DECLS([strdup, strlcpy, strcasecmp, strncasecmp, snprintf, vsnprintf, strndup])
125AC_CHECK_DECLS([socket, recvmmsg], [], [], [[#include <sys/socket.h>]])
126AC_CHECK_SIZEOF([long int])
127
128
129# Checks for header files.
130AC_HEADER_STDC
131AC_CHECK_HEADERS(pcap.h pcap-int.h pcap-bpf.h net/bpf.h sys/limits.h stddef.h inttypes.h limits.h net/ethernet.h sys/prctl.h)
132
133
134# OpenSolaris puts ncurses.h in /usr/include/ncurses rather than /usr/include,
135# so check for that
136AC_CHECK_HEADERS(ncurses.h,,[missing_ncurses=true])
137
138if test "x$missing_ncurses" = xtrue; then
139        if test -f "/usr/include/ncurses/ncurses.h"; then
140                AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Has nested ncurses header])
141        fi
142fi
143
144
145# Check for the presence of various networking headers and define appropriate
146# macros
147AC_CHECK_HEADERS(netinet/in.h)
148AC_CHECK_HEADERS(netpacket/packet.h,[
149        libtrace_netpacket_packet_h=true
150        AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net])
151])
152AC_CHECK_HEADER(net/if.h,
153        AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[
154 #include <sys/types.h>
155 #include <sys/socket.h>
156])
157
158AC_CHECK_HEADER(netinet/ether.h,
159        AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[
160 #include <sys/types.h>
161 #include <sys/socket.h>
162 #include <netinet/in.h>
163 #include <net/if.h>
164])
165
166AC_CHECK_HEADER(netinet/if_ether.h,
167        AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[
168 #include <sys/types.h>
169 #include <sys/socket.h>
170 #include <netinet/in.h>
171 #include <net/if.h>
172])
173
174AC_CHECK_HEADER(net/if_arp.h,
175        AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[
176 #include <sys/types.h>
177 #include <sys/socket.h>
178 #include <netinet/in.h>
179 #include <net/if.h>
180])
181
182# Check for sdl_len in sockaddr_dl - sockaddr_dl is used on BSD systems
183if test "$libtrace_netpacket_packet_h" != "true"; then
184        AC_CHECK_MEMBER([struct sockaddr_dl.sdl_len],
185                AC_DEFINE(HAVE_SDL_LEN,1,[Has sdl_len in sockaddr_dl]),,[
186 #include <sys/types.h>
187 #include <sys/socket.h>
188 #include <net/if_dl.h>
189                ])
190fi
191
192# Checking for the right bpf header to include
193AC_CHECK_HEADER(pcap-bpf.h)
194AC_CHECK_HEADER(net/bpf.h)
195
196# Checking for libgdc
197AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h]))
198
199# Check for libwandio (no longer bundled with libtrace)
200AC_CHECK_LIB(wandio,wandio_wflush,wandiofound=1,wandiofound=0)
201if test "$wandiofound" = 0; then
202        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)
203else
204        LIBTRACE_LIBS="$LIBTRACE_LIBS -lwandio"
205        TOOLS_LIBS="$TOOLS_LIBS -lwandio"
206        AC_DEFINE([HAVE_LIBWANDIO],1,[compile with libwandio support])
207fi
208
209AC_CHECK_LIB(crypto, EVP_EncryptInit_ex, cryptofound=1, cryptofound=0)
210if test "$cryptofound" = 1; then
211        AC_CHECK_HEADER(openssl/evp.h, cryptofound=1, cryptofound=0)
212fi
213AC_CHECK_LIB(tasn1, asn1_array2tree, asn1found=1, asn1found=0)
214
215# Check for libpcap
216AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0)
217AC_CHECK_LIB(pcap,pcap_create,pcapcreate=1,pcapcreate=0)
218AC_CHECK_LIB(pcap,pcap_set_immediate_mode,pcapimmediate=1,pcapimmediate=0)
219AC_CHECK_DECLS([BIOCSETIF],,,[
220#include <sys/types.h>
221#include <sys/time.h>
222#include <sys/ioctl.h>
223#include <net/bpf.h>
224])
225
226AC_ARG_ENABLE(memory-debugging,
227                AS_HELP_STRING(--enable-memory-debugging, prints internal memory statistics),[
228                if test "$HAVE_TLS" = 1
229                then
230                    AC_DEFINE([ENABLE_MEM_STATS], 1, [print debug memory statistics])
231                fi
232],[])
233
234# Configure options for man pages
235AC_ARG_WITH(man,
236            AS_HELP_STRING(--with-man,install man pages by default),[
237             if test "$withval" = yes
238             then
239                     MANPAGES="docs/man/man3/[a-zA-Z]*.3"
240             else
241                     MANPAGES=""
242             fi
243])
244
245# Complain if we didn't find a suitable libpcap
246if test "$pcapfound" = 0; then
247        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)
248else
249        TOOLS_LIBS="$TOOLS_LIBS -lpcap"
250        LIBTRACE_LIBS="$LIBTRACE_LIBS -lpcap"
251        AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
252
253        LIBS="-lpcap"
254        AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock)
255        LIBS=""
256
257fi
258
259if test "$pcapcreate" = 1; then
260        AC_DEFINE([HAVE_PCAP_CREATE],1,[compile with libpcap 1.0 support])
261fi
262
263if test "$pcapimmediate" = 1; then
264        AC_DEFINE([HAVE_PCAP_IMMEDIATE],1,[able to use pcap_set_immediate_mode])
265fi       
266
267# Configure options for use of DAG cards
268# Originally borrowed from libpcap, but extended quite a bit :)
269# More details on how this check works:
270#       http://wand.net.nz/trac/libtrace/wiki/DAGNotes
271
272AC_ARG_WITH(dag,
273            AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)),
274[
275        if test "$withval" = no
276        then
277                want_dag=no
278        elif test "$withval" = yes
279        then
280                want_dag=yes
281                dag_root=/usr/local/dag
282        else
283                want_dag=yes
284                dag_root=$withval
285        fi
286],[
287        #
288        # Use DAG API if present, otherwise don't
289        #
290        want_dag=ifpresent
291        dag_root=/usr/local/dag
292])
293
294# DAG 3.0 actually puts header files and shared libraries into sensible
295# places now, so we should be able to do a simple CHECK_LIB to see if
296# they're there!
297
298# Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here
299# also. This isn't such a bad thing, the DAG2.5 API is essentially the same as
300# DAG 3.0 and libtrace will use the same format_dagXX source for both
301libtrace_dag=false
302libtrace_dag_version=none
303
304if test "$with_dag" != no; then
305        AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0)
306        if test "$dag_found" = 1; then
307                ADD_LIBS="$ADD_LIBS -ldag"
308                LIBTRACE_LIBS="$LIBTRACE_LIBS -ldag"
309                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
310                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
311                libtrace_dag=true
312               
313                AC_DEFINE(DAG_VERSION,25,[defines the DAG driver version])
314                libtrace_dag_version=25
315
316                AC_CHECK_HEADERS(dag_config_api.h,[csapi_found=1],,)
317                if test "$csapi_found" = 1; then
318                        LIBTRACE_LIBS="$LIBTRACE_LIBS -ldagconf"
319                fi
320        fi     
321fi
322
323# TODO: turn the test part of the next block into a function, so it can be
324# called multiple times for $dag_root, /root/dag, /usr/local/lib
325dag_drv_v="DAG not present"
326
327# Now check for 2.4 DAG drivers which don't install as cleanly!
328if test "$with_dag" != no -a "$libtrace_dag" = false; then
329        AC_MSG_CHECKING(whether we have DAG 2.4 API instead)
330
331        if test -r "$dag_root/lib"; then
332                dag_lib_dir="$dag_root/lib"
333        else
334                dag_lib_dir="$dag_root"
335        fi
336       
337        if test -r "$dag_root/include"; then
338                dag_tools_dir="$dag_root/tools"
339                dag_include_dir="$dag_root/include"
340        else
341                dag_tools_dir="$dag_root"
342                dag_include_dir="$dag_root"
343        fi
344
345        if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a";
346        then
347                ADD_INCLS="$ADD_INCLS -I $dag_include_dir"
348                ADD_LIBS="$ADD_LIBS -ldag"
349                ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir"
350                DAG_TOOLS_DIR=$dag_tools_dir
351                AC_SUBST([DAG_TOOLS_DIR])
352                libtrace_dag=true
353               
354                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
355                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
356                AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version])
357                libtrace_dag_version=24
358        else
359                if test "$want_dag" = yes; then
360                        AC_MSG_ERROR(DAG API not found under directory $dag_root
361; use --without-dag)
362                fi
363                libtrace_dag=false
364        fi
365        AC_MSG_RESULT($libtrace_dag)
366
367fi
368
369# Try to determine the DAG driver version
370#if test x"$libtrace_dag" = xtrue; then
371#       dag_drv_v="Unknown"
372#       files=`locate /usr/*dag*/VERSION`
373#       file_count=0
374#
375#       for i in $files; do
376#                if $file_count > 0; then
377#                        dag_drv_v="Indeterminate"
378#                        break
379#                fi
380#                dag_drv_v=`cat $i`
381#                file_count=$file_count+1
382#        done
383#fi
384#DAG_VERSION_NUM=$dag_drv_v
385
386# Check for DPDK
387AC_ARG_WITH(dpdk,
388            AS_HELP_STRING(--with-dpdk,include DPDK live capture support (From either the RTE_SDK/_TARGET environment variable or the dpdk-dev package)),
389[
390        if test "$withval" = no
391        then
392            want_dpdk=no
393        else
394            want_dpdk=ifpresent
395        fi
396],[
397        # Default to building without DPDK format
398        want_dpdk=no
399])
400
401libtrace_dpdk=false
402if test "$want_dpdk" != no; then
403        # So instead simply check for existence
404        if test "$RTE_SDK" != ""; then
405                AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libintel_dpdk.a", dpdk_found=":libintel_dpdk.a", dpdk_found=0)
406        fi
407        # DPDK 2.1.0+ renames this to libdpdk from libintel_dpdk
408        if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
409                AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.a", dpdk_found=":libdpdk.a", dpdk_found=0)
410        fi
411        if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
412                AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.so", dpdk_found="dpdk", dpdk_found=0)
413        fi
414        if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
415                AC_CHECK_LIB(dpdk, rte_eth_dev_configure, dpdk_found="dpdk", dpdk_found=0)
416        fi
417        if test "$dpdk_found" != 0 -a "$RTE_SDK" != ""; then
418                # Save these now so that they can be re-exported later
419                AC_SUBST([RTE_TARGET])
420                AC_SUBST([RTE_SDK])
421                # Force dpdk library to be statically linked to allow compiler optimisations
422                LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--whole-archive -Wl,-l$dpdk_found -Wl,--no-whole-archive -Wl,-lm"
423                AC_DEFINE(HAVE_DPDK,1,[conditional for building with DPDK live capture support])
424                libtrace_dpdk=true
425        fi
426        if test "$RTE_SDK" = ""; then
427                AC_MSG_NOTICE([No RTE_SDK given, checking for system dpdk-dev package])
428                # Search the system, maybe it is installed? Ethdev is one of the main libraries
429                # On Ubuntu and Debian we can simply check for dpdk.so
430                AC_CHECK_LIB(dpdk, rte_eth_dev_configure, dpdk_found="system", dpdk_found=0)
431                # We also need to check that rte.vars.mk is installed from dpdk-dev (as well as libdpdk-dev)
432                if test "$dpdk_found" != 0 -a -e /usr/share/dpdk/mk/rte.vars.mk ; then
433                        RTE_TARGET="$(uname -m)-default-linuxapp-gcc"
434                        RTE_SDK="/usr/share/dpdk/"
435                        RTE_INCLUDE="/usr/include/dpdk"
436                        AC_SUBST([RTE_TARGET])
437                        AC_SUBST([RTE_SDK])
438                        AC_SUBST([RTE_INCLUDE])
439                        LIBTRACE_LIBS="$LIBTRACE_LIBS -ldpdk"
440                        AC_MSG_NOTICE([Building against system DPDK])
441
442                        AC_DEFINE(HAVE_DPDK,1,[conditional for building with DPDK live capture support])
443                        libtrace_dpdk=true
444                        dpdk_found=system
445                fi
446        fi
447fi
448
449# Check for PACKET_FANOUT (borrowed from Suricata)
450AC_CHECK_DECL([PACKET_FANOUT],
451        AC_DEFINE([HAVE_PACKET_FANOUT],[1],
452        [Recent packet fanout support is available]),
453        [],
454        [[#include <linux/if_packet.h>]])
455
456# If we use DPDK we might be able to use libnuma
457AC_CHECK_LIB(numa, numa_node_to_cpus, have_numa=1, have_numa=0)
458
459# Need libwandder for ETSI live decoding
460AC_CHECK_LIB(wandder, init_wandder_decoder, have_wandder=1, have_wandder=0)
461
462# Checks for various "optional" libraries
463AC_CHECK_LIB(pthread, pthread_create, have_pthread=1, have_pthread=0)
464
465AC_CHECK_LIB(pthread, pthread_setname_np, have_pthread_setname_np=1, have_pthread_setname_np=0)
466
467# Check for ncurses
468
469# These libraries have to be explicitly linked in OpenSolaris
470AC_SEARCH_LIBS(getservent, socket, have_socket=1, have_socket=0, -lnsl)
471LIBS=
472
473AC_SEARCH_LIBS(inet_ntop, nsl, have_nsl=1, have_nsl=0, -lsocket)
474LIBS=
475
476# Check to see if we have libdl - *BSD has built-in libdl
477AC_SEARCH_LIBS(dlopen,dl, dlfound=1,dlfound=0 )
478LIBS=
479
480# Check for clock_gettime
481AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=1, have_clock_gettime=0)
482LIBS=
483
484if test "$have_numa" = 1; then
485        LIBTRACE_LIBS="$LIBTRACE_LIBS -lnuma"
486        AC_DEFINE(HAVE_LIBNUMA, 1, [Set to 1 if libnuma is supported])
487        with_numa=yes
488else
489        with_numa=no
490fi
491
492if test "$have_wandder" = 1; then
493        LIBTRACE_LIBS="$LIBTRACE_LIBS -lwandder"
494        AC_DEFINE(HAVE_WANDDER, 1, [Set to 1 if libwandder is available])
495        wandder_avail=yes
496else
497        wandder_avail=no
498fi
499
500if test "$dlfound" = 0; then
501        AC_MSG_ERROR("Unable to find dlopen. Please use LDFLAGS to specify the location of libdl and re-run configure")
502fi
503
504if test "$ac_cv_search_dlopen" != "none required"; then
505        LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_dlopen"
506        if test "$dpdk_found" != 0; then
507                LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,$ac_cv_search_dlopen"
508        fi
509fi
510
511if test "$have_pthread" = 1; then
512        AC_DEFINE(HAVE_LIBPTHREAD, 1, [Set to 1 if pthreads are supported])
513fi
514
515if test "$have_pthread_setname_np" = 1; then
516        AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [Set to 1 if pthread_setname_np is found])
517fi
518
519if test "$cryptofound" = 1; then
520        AC_DEFINE(HAVE_LIBCRYPTO, 1, [Set to 1 if libcrypto is available])
521        TOOLS_LIBS="$TOOLS_LIBS -lcrypto"
522        have_crypto=yes
523else
524        have_crypto=no
525fi
526
527if test "$have_nsl" = 1; then
528        if test "$ac_cv_search_inet_ntop" != "none required"; then
529                LIBTRACE_LIBS="$LIBTRACE_LIBS $ac_cv_search_inet_ntop"
530                LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_inet_ntop"
531        fi
532fi
533
534if test "$have_socket" = 1; then
535        if test "$ac_cv_search_getservent" != "none required"; then
536                LIBTRACE_LIBS="$LIBTRACE_LIBS $ac_cv_search_getservent"
537                LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_getservent"
538        fi
539fi
540
541
542if test "$have_clock_gettime" = 1; then
543        LIBTRACE_LIBS="$LIBTRACE_LIBS -lrt"
544        AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Set to 1 if clock_gettime is supported])
545        with_clock_gettime=yes
546else
547        with_clock_gettime=no
548fi
549
550
551have_memfd_create=no
552AC_RUN_IFELSE([AC_LANG_PROGRAM([
553#include <sys/syscall.h>
554],[
555#ifndef __NR_memfd_create
556exit(1)
557#endif
558])], [have_memfd_create=yes])
559
560if test "$have_memfd_create" = "yes"; then
561        AC_DEFINE(HAVE_MEMFD_CREATE, 1, [Set to 1 if kernel supports memfd_create syscall])
562fi
563
564# Stupid AC_SEARCH_LIB appends stuff to LIBS even when I don't want it to, so
565# just set libs to null here to avoid linking against them by default
566LIBS=
567
568# For now, the user has to explicitly ask for the LLVM stuff, as it's a bit
569# rough around the edges :(
570AC_ARG_WITH([llvm],
571        [AC_HELP_STRING([--with-llvm],
572                [support Just In Time compiler])],
573        use_llvm="yes",
574        use_llvm="no")
575JIT=no
576
577# Search for LLVM and the libraries that it requires
578if (test "$use_llvm" != "no"); then
579        AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
580
581        # XXX Hard coding the path is REALLY bad.
582        # llvm-gcc is installed in a stupid place in Debian / Ubuntu. Hard luck
583        # if you've installed it somewhere custom.
584        # Hopefully in future we can replace this with clang, which may or may
585        # not be installed somewhere intelligent.
586        AC_PATH_PROG(LLVM_GCC, llvm-gcc, no, /usr/lib/llvm/llvm/gcc-4.2/bin)
587
588        AC_LANG_PUSH([C++])
589        AC_CHECK_HEADERS([boost/lexical_cast.hpp], boost="yes", boost="no")
590        AC_LANG_POP([C++])
591
592               
593        if test "$boost" = "no"; then
594                AC_MSG_NOTICE([Unabled to find boost libraries.  JIT support disabled.])
595                JIT=no
596        elif test "$LLVM_CONFIG" = "no" ; then
597                AC_MSG_NOTICE([Unable to find llvm-config.  JIT support disabled.])
598                JIT=no
599        elif test "$LLVM_GCC" = "no"; then
600                AC_MSG_NOTICE([Unable to find llvm-gcc.  JIT support disabled.])
601                JIT=no
602        else
603                LIBCXXFLAGS="`$LLVM_CONFIG --cxxflags` $CXXFLAGS"
604                LIBTRACE_LIBS="$LIBRACE_LIBS `$LLVM_CONFIG --libs all`";
605                LDFLAGS="`$LLVM_CONFIG --ldflags` $LDFLAGS";
606                JIT=yes
607                AC_DEFINE(HAVE_LLVM, 1, [Set to 1 if you have LLVM installed])
608        fi
609fi
610
611AC_ARG_WITH([ncurses],
612        AC_HELP_STRING([--with-ncurses], [build tracetop (requires ncurses)]))
613
614AS_IF([test "x$with_ncurses" != "xno"],
615        [AC_SEARCH_LIBS(mvprintw, ncurses, have_ncurses=yes, have_ncurses=no)
616         LIBS=
617        ], [have_ncurses=no])
618
619AS_IF([test "x$have_ncurses" = "xyes"], [
620        if test "$ac_cv_search_mvprintw" != "none required"; then
621                TOOLS_LIBS="$TOOLS_LIBS $ac_cv_search_mvprintw"
622        fi
623        AC_DEFINE(HAVE_NCURSES, 1, "Compiled with ncurses support")
624        with_ncurses=yes],
625
626       
627        [AS_IF([test "x$with_ncurses" = "xyes"],
628                [AC_MSG_ERROR([ncurses requested but not found])])
629        AC_DEFINE(HAVE_NCURSES, 0, "Compiled with ncurses support")
630        with_ncurses=no]
631)
632
633# Define automake conditionals for use in our Makefile.am files
634AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ])
635AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
636AM_CONDITIONAL([HAVE_DPDK], [test "$libtrace_dpdk" = true])
637AM_CONDITIONAL([HAVE_WANDDER], [test "x$wandder_avail" = "xyes"])
638AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
639AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
640AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
641AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes])
642AM_CONDITIONAL([HAVE_LLVM], [test "x$JIT" != "xno" ])
643AM_CONDITIONAL([HAVE_NCURSES], [test "x$with_ncurses" != "xno"])
644
645# Check for miscellaneous programs
646AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false])
647
648AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue])
649
650# Set all our output variables
651AC_SUBST([LIBTRACE_LIBS])
652AC_SUBST([LIBPKTDUMP_LIBS])
653AC_SUBST([TOOLS_LIBS])
654#AC_SUBST([ADD_LIBS])
655AC_SUBST([ADD_LDFLAGS])
656AC_SUBST([ADD_INCLS])
657AC_SUBST([LTLIBOBJS])
658AC_SUBST([MANPAGES])
659AC_SUBST([PACKAGE_VERSION])
660AC_SUBST([LIBTRACE_MAJOR])
661AC_SUBST([LIBTRACE_MID])
662AC_SUBST([LIBTRACE_MINOR])
663AC_SUBST([DAG_VERSION_NUM])
664AC_SUBST([HAVE_BPF_CAPTURE])
665AC_SUBST([HAVE_LIBGDC])
666AC_SUBST([HAVE_LLVM])
667AC_SUBST([HAVE_NCURSES])
668AC_SUBST([LIBCFLAGS])
669AC_SUBST([LIBCXXFLAGS])
670
671
672# Finally, output our Makefiles
673AC_OUTPUT
674
675# Function for reporting whether an option was set or not
676reportopt() {
677        if test x"$2" = xtrue -o x"$2" = xyes; then
678                AC_MSG_NOTICE([$1: Yes])
679        else
680                AC_MSG_NOTICE([$1: No])
681        fi
682}
683
684
685# Report which configure options were set
686echo
687AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION])
688if test "$pcapcreate" = 1; then
689        AC_MSG_NOTICE([Compiled with PCAP support: >= 1.0])
690else
691        AC_MSG_NOTICE([Compiled with PCAP support: < 1.0])
692fi
693
694if test x"$libtrace_dag" = xtrue; then
695        if test "$libtrace_dag_version" = 24; then
696                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4])
697        elif test "$libtrace_dag_version" = 30; then
698                AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0])
699        else
700                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5])
701        fi     
702else
703        AC_MSG_NOTICE([Compiled with DAG live capture support: No])
704fi
705
706if test x"$libtrace_dpdk" = xtrue; then
707        AC_MSG_NOTICE([Compiled with DPDK live capture support: Yes])
708        reportopt "Compiled with DPDK trace NUMA support" $with_numa
709        reportopt "Compiled with clock_gettime support" $with_clock_gettime
710elif test x"$want_dpdk" != "xno"; then
711#   We don't officially support DPDK so only report failure if the user
712#   explicitly asked for DPDK. That way, we can hopefully keep it hidden
713#   from most users for now...
714
715        AC_MSG_NOTICE([Compiled with DPDK live capture support: No])
716        AC_MSG_NOTICE([Note: Requires DPDK v1.5 or newer])
717fi
718reportopt "Compiled with LLVM BPF JIT support" $JIT
719reportopt "Compiled with live ETSI LI support (requires libwandder)" $wandder_avail
720reportopt "Building man pages/documentation" $libtrace_doxygen
721reportopt "Building tracetop (requires libncurses)" $with_ncurses
722reportopt "Building traceanon with CryptoPan (requires libcrypto and openssl/evp.h)" $have_crypto
723
724# Report any errors relating to missing bison, flex, etc.
725echo
726ac_cv_errcount=0;
727if test -z "$YACC"; then
728        AC_MSG_WARN(bison or yacc not found. Please install bison before continuing)
729        ac_cv_errcount=$((ac_cv_errcount + 1))
730fi
731
732if test "x$LEX" != xflex -a "x$LEX" != xlex; then
733        AC_MSG_WARN(flex or lex not found. Please install flex before continuing)
734        ac_cv_errcount=$((ac_cv_errcount + 1))
735fi
736
737if test $ac_cv_errcount -gt 0; then
738        AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure)
739fi
740
Note: See TracBrowser for help on using the repository browser.