source: configure.in @ 19aa8d5

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 19aa8d5 was 19aa8d5, checked in by Shane Alcock <salcock@…>, 10 years ago
  • Update version numbering to 3.0.9
  • Don't explicitly require libdl, as dlopen is provided by libc on some systems
  • Property mode set to 100644
File size: 15.3 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.9],[contact@wand.net.nz],[libtrace])
7
8LIBTRACE_MAJOR=3
9LIBTRACE_MID=0
10LIBTRACE_MINOR=9
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(dl, dlopen)
217
218# Check for libpcap
219AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0)
220AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock)
221AC_CHECK_DECLS([BIOCSETIF],,,[
222#include <sys/types.h>
223#include <sys/time.h>
224#include <sys/ioctl.h>
225#include <net/bpf.h>
226])
227
228# Configure options for man pages
229AC_ARG_WITH(man,
230            AS_HELP_STRING(--with-man,install man pages by default),[
231             if test "$withval" = yes
232             then
233                     MANPAGES="docs/man/man3/[a-zA-Z]*.3"
234             else
235                     MANPAGES=""
236             fi
237])
238
239# Complain if we didn't find a suitable libpcap
240if test "$pcapfound" = 0; then
241        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)
242else
243        ADD_LIBS="$ADD_LIBS -lpcap"
244        AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
245        AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support])
246fi
247
248# Configure options for use of DAG cards
249# Originally borrowed from libpcap, but extended quite a bit :)
250# More details on how this check works:
251#       http://wand.net.nz/trac/libtrace/wiki/DAGNotes
252
253AC_ARG_WITH(dag,
254            AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)),
255[
256        if test "$withval" = no
257        then
258                want_dag=no
259        elif test "$withval" = yes
260        then
261                want_dag=yes
262                dag_root=/usr/local/dag
263        else
264                want_dag=yes
265                dag_root=$withval
266        fi
267],[
268        #
269        # Use DAG API if present, otherwise don't
270        #
271        want_dag=ifpresent
272        dag_root=/usr/local/dag
273])
274
275# DAG 3.0 actually puts header files and shared libraries into sensible
276# places now, so we should be able to do a simple CHECK_LIB to see if
277# they're there!
278
279# Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here
280# also. This isn't such a bad thing, the DAG2.5 API is essentially the same as
281# DAG 3.0 and libtrace will use the same format_dagXX source for both
282libtrace_dag=false
283libtrace_dag_version=none
284
285if test "$with_dag" != no; then
286        AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0)
287        if test "$dag_found" = 1; then
288                ADD_LIBS="$ADD_LIBS -ldag"
289                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
290                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
291                libtrace_dag=true
292               
293                AC_DEFINE(DAG_VERSION,25,[defines the DAG driver version])
294                libtrace_dag_version=25
295        fi
296fi
297
298# TODO: turn the test part of the next block into a function, so it can be
299# called multiple times for $dag_root, /root/dag, /usr/local/lib
300dag_drv_v="DAG not present"
301
302# Now check for 2.4 DAG drivers which don't install as cleanly!
303if test "$with_dag" != no -a "$libtrace_dag" = false; then
304        AC_MSG_CHECKING(whether we have DAG 2.4 API instead)
305
306        if test -r "$dag_root/lib"; then
307                dag_lib_dir="$dag_root/lib"
308        else
309                dag_lib_dir="$dag_root"
310        fi
311       
312        if test -r "$dag_root/include"; then
313                dag_tools_dir="$dag_root/tools"
314                dag_include_dir="$dag_root/include"
315        else
316                dag_tools_dir="$dag_root"
317                dag_include_dir="$dag_root"
318        fi
319
320        if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a";
321        then
322                ADD_INCLS="$ADD_INCLS -I $dag_include_dir"
323                ADD_LIBS="$ADD_LIBS -ldag"
324                ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir"
325                DAG_TOOLS_DIR=$dag_tools_dir
326                AC_SUBST([DAG_TOOLS_DIR])
327                libtrace_dag=true
328               
329                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
330                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
331                AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version])
332                libtrace_dag_version=24
333        else
334                if test "$want_dag" = yes; then
335                        AC_MSG_ERROR(DAG API not found under directory $dag_root
336; use --without-dag)
337                fi
338                libtrace_dag=false
339        fi
340        AC_MSG_RESULT($libtrace_dag)
341
342fi
343
344# Try to determine the DAG driver version
345#if test x"$libtrace_dag" = xtrue; then
346#       dag_drv_v="Unknown"
347#       files=`locate /usr/*dag*/VERSION`
348#       file_count=0
349#
350#       for i in $files; do
351#                if $file_count > 0; then
352#                        dag_drv_v="Indeterminate"
353#                        break
354#                fi
355#                dag_drv_v=`cat $i`
356#                file_count=$file_count+1
357#        done
358#fi
359#DAG_VERSION_NUM=$dag_drv_v
360
361have_ncurses=yes
362
363# Checks for various "optional" libraries
364AC_CHECK_LIB(z, deflate)
365AC_CHECK_LIB(bz2, BZ2_bzDecompressInit)
366AC_CHECK_LIB(lzo2, lzo1x_1_compress)
367AC_CHECK_LIB(pthread, pthread_create)
368
369# Check for ncurses
370AC_SEARCH_LIBS(mvprintw, ncurses, , have_ncurses=no)
371
372# These libraries have to be explicitly linked in OpenSolaris
373AC_SEARCH_LIBS(getservent, socket, [], [], -lnsl)               
374AC_SEARCH_LIBS(inet_ntop, nsl, [], [], -lsocket)
375
376# For now, the user has to explicitly ask for the LLVM stuff, as it's a bit
377# rough around the edges :(
378AC_ARG_WITH([llvm],
379        [AC_HELP_STRING([--with-llvm],
380                [support Just In Time compiler])],
381        use_llvm="yes",
382        use_llvm="no")
383JIT=no
384
385# Search for LLVM and the libraries that it requires
386if (test "$use_llvm" != "no"); then
387        AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
388
389        # XXX Hard coding the path is REALLY bad.
390        # llvm-gcc is installed in a stupid place in Debian / Ubuntu. Hard luck
391        # if you've installed it somewhere custom.
392        # Hopefully in future we can replace this with clang, which may or may
393        # not be installed somewhere intelligent.
394        AC_PATH_PROG(LLVM_GCC, llvm-gcc, no, /usr/lib/llvm/llvm/gcc-4.2/bin)
395
396        AC_LANG_PUSH([C++])
397        AC_CHECK_HEADERS([boost/lexical_cast.hpp], boost="yes", boost="no")
398        AC_LANG_POP([C++])
399
400               
401        if test "$boost" = "no"; then
402                AC_MSG_NOTICE([Unabled to find boost libraries.  JIT support disabled.])
403                JIT=no
404        elif test "$LLVM_CONFIG" = "no" ; then
405                AC_MSG_NOTICE([Unable to find llvm-config.  JIT support disabled.])
406                JIT=no
407        elif test "$LLVM_GCC" = "no"; then
408                AC_MSG_NOTICE([Unable to find llvm-gcc.  JIT support disabled.])
409                JIT=no
410        else
411                LIBCXXFLAGS="`$LLVM_CONFIG --cxxflags` $CXXFLAGS"
412                ADD_LIBS="$ADD_LIBS `$LLVM_CONFIG --libs all`";
413                LDFLAGS="`$LLVM_CONFIG --ldflags` $LDFLAGS";
414                JIT=yes
415                AC_DEFINE(HAVE_LLVM, 1, [Set to 1 if you have LLVM installed])
416        fi
417fi
418
419
420# Define automake conditionals for use in our Makefile.am files
421AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ])
422AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
423AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
424AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
425AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_deflate" = yes])
426AM_CONDITIONAL([HAVE_BZLIB], [test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" = yes])
427AM_CONDITIONAL([HAVE_LZO], [test "$ac_cv_lib_lzo2_lzo1x_1_compress" = yes])
428AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
429AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes])
430AM_CONDITIONAL([HAVE_LLVM], [test "x$JIT" != "xno" ])
431AM_CONDITIONAL([HAVE_NCURSES], [test "x$have_ncurses" = "xyes"])
432
433# Check for miscellaneous programs
434AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false])
435
436AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue])
437
438# Set all our output variables
439AC_SUBST([ADD_LIBS])
440AC_SUBST([ADD_LDFLAGS])
441AC_SUBST([ADD_INCLS])
442AC_SUBST([LTLIBOBJS])
443AC_SUBST([MANPAGES])
444AC_SUBST([PACKAGE_VERSION])
445AC_SUBST([LIBTRACE_MAJOR])
446AC_SUBST([LIBTRACE_MID])
447AC_SUBST([LIBTRACE_MINOR])
448AC_SUBST([DAG_VERSION_NUM])
449AC_SUBST([HAVE_BPF_CAPTURE])
450AC_SUBST([HAVE_LIBGDC])
451AC_SUBST([HAVE_LLVM])
452AC_SUBST([HAVE_NCURSES])
453AC_SUBST([LIBCFLAGS])
454AC_SUBST([LIBCXXFLAGS])
455
456
457# Finally, output our Makefiles
458AC_OUTPUT
459
460# Function for reporting whether an option was set or not
461reportopt() {
462        if test x"$2" = xtrue -o x"$2" = xyes; then
463                AC_MSG_NOTICE([$1: Yes])
464        else
465                AC_MSG_NOTICE([$1: No])
466        fi
467}
468
469
470# Report which configure options were set
471echo
472AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION])
473reportopt "Compiled with PCAP 0.8 support" $ac_cv_lib_pcap_pcap_next_ex
474reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_deflate
475reportopt "Compiled with compressed trace (bz2) support" $ac_cv_lib_bz2_BZ2_bzDecompressInit
476reportopt "Compiled with compressed trace (lzo write only) support" $ac_cv_lib_lzo2_lzo1x_1_compress
477if test x"$libtrace_dag" = xtrue; then
478        if test "$libtrace_dag_version" = 24; then
479                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4])
480        elif test "$libtrace_dag_version" = 30; then
481                AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0])
482        else
483                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5])
484        fi     
485else
486        AC_MSG_NOTICE([Compiled with DAG live capture support: No])
487fi
488reportopt "Compiled with LLVM BPF JIT support" $JIT
489reportopt "Building man pages/documentation" $libtrace_doxygen
490reportopt "Building tracetop (requires libncurses)" $have_ncurses
491
492# Report any errors relating to missing bison, flex, etc.
493echo
494ac_cv_errcount=0;
495if test -z "$YACC"; then
496        AC_MSG_WARN(bison or yacc not found. Please install bison before continuing)
497        ac_cv_errcount=$((ac_cv_errcount + 1))
498fi
499
500if test -z "$LEXLIB"; then
501        AC_MSG_WARN(flex or lex not found. Please install flex before continuing)
502        ac_cv_errcount=$((ac_cv_errcount + 1))
503fi
504
505if test $ac_cv_errcount -gt 0; then
506        AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure)
507fi
508
Note: See TracBrowser for help on using the repository browser.