source: configure.in @ e78e408

develop
Last change on this file since e78e408 was 95ba467, checked in by Shane Alcock <salcock@…>, 2 years ago

Make sure -lpthread is used when linking libtrace.so

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