source: configure.in @ 7876f38

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