source: configure.in @ 7aebb85

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