source: configure.in @ a1e177d

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