source: configure.in @ cd4e06c

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since cd4e06c was cd4e06c, checked in by Shane Alcock <salcock@…>, 10 years ago
  • Set version number to 3.0.10
  • Fixed bug that was preventing libdl from being correctly detected
  • Property mode set to 100644
File size: 15.4 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],[3.0.10],[contact@wand.net.nz],[libtrace])
7
8LIBTRACE_MAJOR=3
9LIBTRACE_MID=0
10LIBTRACE_MINOR=10
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
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        examples/Makefile examples/skeleton/Makefile examples/rate/Makefile
40        examples/stats/Makefile examples/tutorial/Makefile
41        docs/libtrace.doxygen
42        lib/libtrace.h
43        ])
44
45
46# Function that checks if the C++ compiler actually works - there's a bit of
47# oversight in autoconf that will set the C++ compiler to g++ if no compiler
48# is found, even if g++ is not present! So we need an extra test to make sure
49# that the compiler works :(
50
51AC_DEFUN([rw_PROG_CXX_WORKS],
52[AC_REQUIRE([AC_PROG_CXX])dnl
53AC_CACHE_CHECK([whether the C++ compiler works],
54        [rw_cv_prog_cxx_works],
55        [AC_LANG_PUSH([C++])
56        AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
57                [rw_cv_prog_cxx_works=yes],
58                [rw_cv_prog_cxx_works=no])
59        AC_LANG_POP([C++])])
60])
61
62# Put all our automake definitions in config.h
63AM_CONFIG_HEADER([config.h])
64
65# Checks for C and C++ compilers
66AC_PROG_CC
67AC_PROG_CXX
68rw_PROG_CXX_WORKS
69
70if test "$rw_cv_prog_cxx_works" = "no"; then
71        AC_MSG_ERROR("Failed to find working C++ compiler")
72fi
73
74# Checking for 'install'
75AC_PROG_INSTALL
76
77# Checking for bison and flex
78AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc)
79AM_PROG_LEX
80
81# All our source files for function replacements are in lib/
82AC_CONFIG_LIBOBJ_DIR(lib)
83
84# Check for various "replacement" functions
85AC_FUNC_MALLOC
86AC_FUNC_REALLOC
87
88# *BSD doesn't have strndup. Currently provide our own.
89AC_REPLACE_FUNCS(strndup)
90
91
92# Checks for typedefs, structures, and compiler characteristics.
93AC_C_CONST
94AC_C_INLINE
95AC_C_BIGENDIAN
96AC_TYPE_SIZE_T
97AC_HEADER_TIME
98AC_SYS_LARGEFILE
99
100# Set our C compiler flags based on the gcc version
101if test "$GCC" = "yes"; then
102       
103        gcc_version=`gcc -dumpversion`
104
105        # This is probably not the most reliable way to test whether our
106        # compiler supports visibility, but it's better than nothing
107        #
108        # According to the gcc wiki - http://gcc.gnu.org/wiki/Visibility -
109        # visibility is supported in gcc 4.0 or later, so we just need to
110        # check the major version number
111
112        major=${gcc_version%\.*\.*}
113
114        if test "$major" -lt 4; then
115                vis=no
116        else
117                vis=yes
118        fi
119       
120        CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
121        CXXFLAGS="$CXXFLAGS -Wall"
122        LIBCFLAGS="$CFLAGS"
123        LIBCFLAGS="$LIBCFLAGS -DLT_BUILDING_DLL=1"
124        LIBCXXFLAGS="$CXXFLAGS"
125        LIBCXXFLAGS="$CXXFLAGS -DLT_BUILDING_DLL=1"
126       
127        if test "$vis" = "yes"; then
128                LIBCFLAGS="$LIBCFLAGS -Wextra -fvisibility=hidden"
129                LIBCXXFLAGS="$CXXFLAGS -Wextra -fvisibility=hidden"
130        fi
131fi
132
133# Check for libtool
134AC_PROG_LIBTOOL
135
136# Checks for library functions.
137AC_PROG_GCC_TRADITIONAL
138
139# Fail if any of these functions are missing
140AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf vsnprintf)
141
142AC_CHECK_SIZEOF([long int])
143
144
145# Checks for header files.
146AC_HEADER_STDC
147AC_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)
148
149
150# OpenSolaris puts ncurses.h in /usr/include/ncurses rather than /usr/include,
151# so check for that
152AC_CHECK_HEADERS(ncurses.h,,[missing_ncurses=true])
153
154if test "x$missing_ncurses" = xtrue; then
155        if test -f "/usr/include/ncurses/ncurses.h"; then
156                AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Has nested ncurses header])
157        fi
158fi
159
160
161# Check for the presence of various networking headers and define appropriate
162# macros
163AC_CHECK_HEADERS(netinet/in.h)
164AC_CHECK_HEADERS(netpacket/packet.h,[
165        libtrace_netpacket_packet_h=true
166        AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net])
167])
168AC_CHECK_HEADER(net/if.h,
169        AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[
170 #include <sys/types.h>
171 #include <sys/socket.h>
172])
173
174AC_CHECK_HEADER(netinet/ether.h,
175        AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[
176 #include <sys/types.h>
177 #include <sys/socket.h>
178 #include <netinet/in.h>
179 #include <net/if.h>
180])
181
182AC_CHECK_HEADER(netinet/if_ether.h,
183        AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[
184 #include <sys/types.h>
185 #include <sys/socket.h>
186 #include <netinet/in.h>
187 #include <net/if.h>
188])
189
190AC_CHECK_HEADER(net/if_arp.h,
191        AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[
192 #include <sys/types.h>
193 #include <sys/socket.h>
194 #include <netinet/in.h>
195 #include <net/if.h>
196])
197
198# Check for sdl_len in sockaddr_dl - sockaddr_dl is used on BSD systems
199if test "$libtrace_netpacket_packet_h" != "true"; then
200        AC_CHECK_MEMBER([struct sockaddr_dl.sdl_len],
201                AC_DEFINE(HAVE_SDL_LEN,1,[Has sdl_len in sockaddr_dl]),,[
202 #include <sys/types.h>
203 #include <sys/socket.h>
204 #include <net/if_dl.h>
205                ])
206fi
207
208# Checking for the right bpf header to include
209AC_CHECK_HEADER(pcap-bpf.h)
210AC_CHECK_HEADER(net/bpf.h)
211
212# Checking for libgdc
213AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h]))
214
215# Check to see if we have libdl - *BSD has built-in libdl
216AC_SEARCH_LIBS(dlopen,dl, dlfound=1,dlfound=0 )
217
218if test "$dlfound" = 0; then
219        AC_MSG_ERROR("Unable to find dlopen. Please use LDFLAGS to specify the location of libdl and re-run configure")
220fi
221
222# Check for libpcap
223AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0)
224AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock)
225AC_CHECK_DECLS([BIOCSETIF],,,[
226#include <sys/types.h>
227#include <sys/time.h>
228#include <sys/ioctl.h>
229#include <net/bpf.h>
230])
231
232# Configure options for man pages
233AC_ARG_WITH(man,
234            AS_HELP_STRING(--with-man,install man pages by default),[
235             if test "$withval" = yes
236             then
237                     MANPAGES="docs/man/man3/[a-zA-Z]*.3"
238             else
239                     MANPAGES=""
240             fi
241])
242
243# Complain if we didn't find a suitable libpcap
244if test "$pcapfound" = 0; then
245        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)
246else
247        ADD_LIBS="$ADD_LIBS -lpcap"
248        AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
249        AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support])
250fi
251
252# Configure options for use of DAG cards
253# Originally borrowed from libpcap, but extended quite a bit :)
254# More details on how this check works:
255#       http://wand.net.nz/trac/libtrace/wiki/DAGNotes
256
257AC_ARG_WITH(dag,
258            AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)),
259[
260        if test "$withval" = no
261        then
262                want_dag=no
263        elif test "$withval" = yes
264        then
265                want_dag=yes
266                dag_root=/usr/local/dag
267        else
268                want_dag=yes
269                dag_root=$withval
270        fi
271],[
272        #
273        # Use DAG API if present, otherwise don't
274        #
275        want_dag=ifpresent
276        dag_root=/usr/local/dag
277])
278
279# DAG 3.0 actually puts header files and shared libraries into sensible
280# places now, so we should be able to do a simple CHECK_LIB to see if
281# they're there!
282
283# Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here
284# also. This isn't such a bad thing, the DAG2.5 API is essentially the same as
285# DAG 3.0 and libtrace will use the same format_dagXX source for both
286libtrace_dag=false
287libtrace_dag_version=none
288
289if test "$with_dag" != no; then
290        AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0)
291        if test "$dag_found" = 1; then
292                ADD_LIBS="$ADD_LIBS -ldag"
293                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
294                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
295                libtrace_dag=true
296               
297                AC_DEFINE(DAG_VERSION,25,[defines the DAG driver version])
298                libtrace_dag_version=25
299        fi
300fi
301
302# TODO: turn the test part of the next block into a function, so it can be
303# called multiple times for $dag_root, /root/dag, /usr/local/lib
304dag_drv_v="DAG not present"
305
306# Now check for 2.4 DAG drivers which don't install as cleanly!
307if test "$with_dag" != no -a "$libtrace_dag" = false; then
308        AC_MSG_CHECKING(whether we have DAG 2.4 API instead)
309
310        if test -r "$dag_root/lib"; then
311                dag_lib_dir="$dag_root/lib"
312        else
313                dag_lib_dir="$dag_root"
314        fi
315       
316        if test -r "$dag_root/include"; then
317                dag_tools_dir="$dag_root/tools"
318                dag_include_dir="$dag_root/include"
319        else
320                dag_tools_dir="$dag_root"
321                dag_include_dir="$dag_root"
322        fi
323
324        if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a";
325        then
326                ADD_INCLS="$ADD_INCLS -I $dag_include_dir"
327                ADD_LIBS="$ADD_LIBS -ldag"
328                ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir"
329                DAG_TOOLS_DIR=$dag_tools_dir
330                AC_SUBST([DAG_TOOLS_DIR])
331                libtrace_dag=true
332               
333                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
334                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
335                AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version])
336                libtrace_dag_version=24
337        else
338                if test "$want_dag" = yes; then
339                        AC_MSG_ERROR(DAG API not found under directory $dag_root
340; use --without-dag)
341                fi
342                libtrace_dag=false
343        fi
344        AC_MSG_RESULT($libtrace_dag)
345
346fi
347
348# Try to determine the DAG driver version
349#if test x"$libtrace_dag" = xtrue; then
350#       dag_drv_v="Unknown"
351#       files=`locate /usr/*dag*/VERSION`
352#       file_count=0
353#
354#       for i in $files; do
355#                if $file_count > 0; then
356#                        dag_drv_v="Indeterminate"
357#                        break
358#                fi
359#                dag_drv_v=`cat $i`
360#                file_count=$file_count+1
361#        done
362#fi
363#DAG_VERSION_NUM=$dag_drv_v
364
365have_ncurses=yes
366
367# Checks for various "optional" libraries
368AC_CHECK_LIB(z, deflate)
369AC_CHECK_LIB(bz2, BZ2_bzDecompressInit)
370AC_CHECK_LIB(lzo2, lzo1x_1_compress)
371AC_CHECK_LIB(pthread, pthread_create)
372
373# Check for ncurses
374AC_SEARCH_LIBS(mvprintw, ncurses, , have_ncurses=no)
375
376# These libraries have to be explicitly linked in OpenSolaris
377AC_SEARCH_LIBS(getservent, socket, [], [], -lnsl)               
378AC_SEARCH_LIBS(inet_ntop, nsl, [], [], -lsocket)
379
380# For now, the user has to explicitly ask for the LLVM stuff, as it's a bit
381# rough around the edges :(
382AC_ARG_WITH([llvm],
383        [AC_HELP_STRING([--with-llvm],
384                [support Just In Time compiler])],
385        use_llvm="yes",
386        use_llvm="no")
387JIT=no
388
389# Search for LLVM and the libraries that it requires
390if (test "$use_llvm" != "no"); then
391        AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
392
393        # XXX Hard coding the path is REALLY bad.
394        # llvm-gcc is installed in a stupid place in Debian / Ubuntu. Hard luck
395        # if you've installed it somewhere custom.
396        # Hopefully in future we can replace this with clang, which may or may
397        # not be installed somewhere intelligent.
398        AC_PATH_PROG(LLVM_GCC, llvm-gcc, no, /usr/lib/llvm/llvm/gcc-4.2/bin)
399
400        AC_LANG_PUSH([C++])
401        AC_CHECK_HEADERS([boost/lexical_cast.hpp], boost="yes", boost="no")
402        AC_LANG_POP([C++])
403
404               
405        if test "$boost" = "no"; then
406                AC_MSG_NOTICE([Unabled to find boost libraries.  JIT support disabled.])
407                JIT=no
408        elif test "$LLVM_CONFIG" = "no" ; then
409                AC_MSG_NOTICE([Unable to find llvm-config.  JIT support disabled.])
410                JIT=no
411        elif test "$LLVM_GCC" = "no"; then
412                AC_MSG_NOTICE([Unable to find llvm-gcc.  JIT support disabled.])
413                JIT=no
414        else
415                LIBCXXFLAGS="`$LLVM_CONFIG --cxxflags` $CXXFLAGS"
416                ADD_LIBS="$ADD_LIBS `$LLVM_CONFIG --libs all`";
417                LDFLAGS="`$LLVM_CONFIG --ldflags` $LDFLAGS";
418                JIT=yes
419                AC_DEFINE(HAVE_LLVM, 1, [Set to 1 if you have LLVM installed])
420        fi
421fi
422
423
424# Define automake conditionals for use in our Makefile.am files
425AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ])
426AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
427AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
428AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
429AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_deflate" = yes])
430AM_CONDITIONAL([HAVE_BZLIB], [test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" = yes])
431AM_CONDITIONAL([HAVE_LZO], [test "$ac_cv_lib_lzo2_lzo1x_1_compress" = yes])
432AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
433AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes])
434AM_CONDITIONAL([HAVE_LLVM], [test "x$JIT" != "xno" ])
435AM_CONDITIONAL([HAVE_NCURSES], [test "x$have_ncurses" = "xyes"])
436
437# Check for miscellaneous programs
438AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false])
439
440AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue])
441
442# Set all our output variables
443AC_SUBST([ADD_LIBS])
444AC_SUBST([ADD_LDFLAGS])
445AC_SUBST([ADD_INCLS])
446AC_SUBST([LTLIBOBJS])
447AC_SUBST([MANPAGES])
448AC_SUBST([PACKAGE_VERSION])
449AC_SUBST([LIBTRACE_MAJOR])
450AC_SUBST([LIBTRACE_MID])
451AC_SUBST([LIBTRACE_MINOR])
452AC_SUBST([DAG_VERSION_NUM])
453AC_SUBST([HAVE_BPF_CAPTURE])
454AC_SUBST([HAVE_LIBGDC])
455AC_SUBST([HAVE_LLVM])
456AC_SUBST([HAVE_NCURSES])
457AC_SUBST([LIBCFLAGS])
458AC_SUBST([LIBCXXFLAGS])
459
460
461# Finally, output our Makefiles
462AC_OUTPUT
463
464# Function for reporting whether an option was set or not
465reportopt() {
466        if test x"$2" = xtrue -o x"$2" = xyes; then
467                AC_MSG_NOTICE([$1: Yes])
468        else
469                AC_MSG_NOTICE([$1: No])
470        fi
471}
472
473
474# Report which configure options were set
475echo
476AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION])
477reportopt "Compiled with PCAP 0.8 support" $ac_cv_lib_pcap_pcap_next_ex
478reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_deflate
479reportopt "Compiled with compressed trace (bz2) support" $ac_cv_lib_bz2_BZ2_bzDecompressInit
480reportopt "Compiled with compressed trace (lzo write only) support" $ac_cv_lib_lzo2_lzo1x_1_compress
481if test x"$libtrace_dag" = xtrue; then
482        if test "$libtrace_dag_version" = 24; then
483                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4])
484        elif test "$libtrace_dag_version" = 30; then
485                AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0])
486        else
487                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5])
488        fi     
489else
490        AC_MSG_NOTICE([Compiled with DAG live capture support: No])
491fi
492reportopt "Compiled with LLVM BPF JIT support" $JIT
493reportopt "Building man pages/documentation" $libtrace_doxygen
494reportopt "Building tracetop (requires libncurses)" $have_ncurses
495
496# Report any errors relating to missing bison, flex, etc.
497echo
498ac_cv_errcount=0;
499if test -z "$YACC"; then
500        AC_MSG_WARN(bison or yacc not found. Please install bison before continuing)
501        ac_cv_errcount=$((ac_cv_errcount + 1))
502fi
503
504if test -z "$LEXLIB"; then
505        AC_MSG_WARN(flex or lex not found. Please install flex before continuing)
506        ac_cv_errcount=$((ac_cv_errcount + 1))
507fi
508
509if test $ac_cv_errcount -gt 0; then
510        AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure)
511fi
512
Note: See TracBrowser for help on using the repository browser.