source: configure.in @ ba2263a

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