source: configure.in @ 4bbe9bd

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 4bbe9bd was 4bbe9bd, checked in by Shane Alcock <salcock@…>, 10 years ago
  • Add check for the presence of sdl_len in the sockaddr_dl structure - OpenSolaris? doesn't seem to believe in length fields, which creates obvious issues
  • Property mode set to 100644
File size: 13.4 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
167if test "$libtrace_netpacket_packet_h" != "true"; then
168# Check for sdl_len in sockaddr_dl
169        AC_CHECK_MEMBER([struct sockaddr_dl.sdl_len],
170                AC_DEFINE(HAVE_SDL_LEN,1,[Has sdl_len in sockaddr_dl]),,[
171 #include <sys/types.h>
172 #include <sys/socket.h>
173 #include <net/if_dl.h>
174                ])
175fi
176
177               
178
179
180# Checking for the right bpf header to include
181AC_CHECK_HEADER(pcap-bpf.h)
182AC_CHECK_HEADER(net/bpf.h)
183AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h]))
184
185# Check to see if we have libdl - *BSD has built-in libdl
186AC_CHECK_LIB(dl, dlopen)
187# check pcap
188AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0)
189#AC_CHECK_LIB(pcap,pcap_next_ex)
190#AC_REPLACE_FUNCS(pcap_open_dead)
191#AC_REPLACE_FUNCS(pcap_dump_flush)
192#AC_REPLACE_FUNCS(pcap_next_ex)
193AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock)
194AC_CHECK_DECLS([BIOCSETIF],,,[
195#include <sys/types.h>
196#include <sys/time.h>
197#include <sys/ioctl.h>
198#include <net/bpf.h>
199])
200
201# configure time options for man pages
202AC_ARG_WITH(man,
203            AS_HELP_STRING(--with-man,install man pages by default),[
204             if test "$withval" = yes
205             then
206                     MANPAGES="docs/man/man3/[a-zA-Z]*.3"
207             else
208                     MANPAGES=""
209             fi
210])
211
212AC_PROG_CXX
213
214if test "$pcapfound" = 0; then
215        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)
216else
217        ADD_LIBS="$ADD_LIBS -lpcap"
218        AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
219        AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support])
220fi
221
222# configure time options for use of DAG cards
223# borrowed from libpcap!
224AC_ARG_WITH(dag,
225            AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)),
226[
227        if test "$withval" = no
228        then
229                want_dag=no
230        elif test "$withval" = yes
231        then
232                want_dag=yes
233                dag_root=/usr/local/dag
234        else
235                want_dag=yes
236                dag_root=$withval
237        fi
238],[
239        #
240        # Use DAG API if present, otherwise don't
241        #
242        want_dag=ifpresent
243        dag_root=/usr/local/dag
244])
245
246# DAG 3.0 actually puts header files and shared libraries into sensible
247# places now, so we should be able to do a simple CHECK_LIB to see if
248# they're there!
249
250# Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here
251# also. This isn't such a bad thing, the DAG2.5 API is essentially the same as
252# DAG 3.0 and libtrace will use the same format_dagXX source for both
253libtrace_dag=false
254libtrace_dag_version=none
255
256if test "$with_dag" != no; then
257        AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0)
258        if test "$dag_found" = 1; then
259                ADD_LIBS="$ADD_LIBS -ldag"
260                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
261                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
262                libtrace_dag=true
263               
264                AC_DEFINE(DAG_VERSION,25,[defines the DAG driver version])
265                libtrace_dag_version=25
266        fi
267fi
268
269# turn the test part of the next block into a function, so it can be
270# called multiple times for $dag_root, /root/dag, /usr/local/lib
271dag_drv_v="DAG not present"
272
273# Now check for 2.4 DAG drivers which don't install as cleanly!
274if test "$with_dag" != no -a "$libtrace_dag" = false; then
275        AC_MSG_CHECKING(whether we have DAG 2.4 API instead)
276
277        if test -r "$dag_root/lib"; then
278                dag_lib_dir="$dag_root/lib"
279        else
280                dag_lib_dir="$dag_root"
281        fi
282       
283        if test -r "$dag_root/include"; then
284                dag_tools_dir="$dag_root/tools"
285                dag_include_dir="$dag_root/include"
286        else
287                dag_tools_dir="$dag_root"
288                dag_include_dir="$dag_root"
289        fi
290
291        if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a";
292        then
293                ADD_INCLS="$ADD_INCLS -I $dag_include_dir"
294                ADD_LIBS="$ADD_LIBS -ldag"
295                ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir"
296                DAG_TOOLS_DIR=$dag_tools_dir
297                AC_SUBST([DAG_TOOLS_DIR])
298                libtrace_dag=true
299               
300                AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
301                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support])
302                AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version])
303                libtrace_dag_version=24
304        else
305                if test "$want_dag" = yes; then
306                        AC_MSG_ERROR(DAG API not found under directory $dag_root
307; use --without-dag)
308                fi
309                libtrace_dag=false
310        fi
311        AC_MSG_RESULT($libtrace_dag)
312
313fi
314
315# Try to determine the DAG driver version
316if test x"$libtrace_dag" = xtrue; then
317        dag_drv_v="Unknown"
318        files=`locate /usr/*dag*/VERSION`
319        file_count=0
320
321        for i in $files; do
322                if $file_count > 0; then
323                        dag_drv_v="Indeterminate"
324                        break
325                fi
326                dag_drv_v=`cat $i`
327                file_count=$file_count+1
328        done
329fi
330DAG_VERSION_NUM=$dag_drv_v
331
332
333AC_CHECK_LIB(z, deflate)
334AC_CHECK_LIB(bz2, BZ2_bzDecompressInit)
335AC_CHECK_LIB(lzo2, lzo1x_1_compress)
336AC_CHECK_LIB(pthread, pthread_create)
337AC_SEARCH_LIBS(mvprintw, ncurses, [], [ AC_MSG_ERROR([NCurses library not available]) ])
338
339
340# For now, the user has to explicitly ask for the LLVM stuff, as it's a bit
341# rough around the edges :(
342AC_ARG_WITH([llvm],
343        [AC_HELP_STRING([--with-llvm],
344                [support Just In Time compiler])],
345        use_llvm="yes",
346        use_llvm="no")
347JIT=no
348
349if (test "$use_llvm" != "no"); then
350        AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
351
352        # XXX Hard coding the path is REALLY bad.
353        # llvm-gcc is installed in a stupid place in Debian / Ubuntu. Hard luck
354        # if you've installed it somewhere custom.
355        # Hopefully in future we can replace this with clang, which may or may
356        # not be installed somewhere intelligent.
357        AC_PATH_PROG(LLVM_GCC, llvm-gcc, no, /usr/lib/llvm/llvm/gcc-4.2/bin)
358
359        AC_LANG_PUSH([C++])
360        AC_CHECK_HEADERS([boost/lexical_cast.hpp], boost="yes", boost="no")
361        AC_LANG_POP([C++])
362
363               
364        if test "$boost" = "no"; then
365                AC_MSG_NOTICE([Unabled to find boost libraries.  JIT support disabled.])
366                JIT=no
367        elif test "$LLVM_CONFIG" = "no" ; then
368                AC_MSG_NOTICE([Unable to find llvm-config.  JIT support disabled.])
369                JIT=no
370        elif test "$LLVM_GCC" = "no"; then
371                AC_MSG_NOTICE([Unable to find llvm-gcc.  JIT support disabled.])
372                JIT=no
373        else
374                LIBCXXFLAGS="`$LLVM_CONFIG --cxxflags` $CXXFLAGS"
375                ADD_LIBS="$ADD_LIBS `$LLVM_CONFIG --libs all`";
376                LDFLAGS="`$LLVM_CONFIG --ldflags` $LDFLAGS";
377                JIT=yes
378                AC_DEFINE(HAVE_LLVM, 1, [Set to 1 if you have LLVM installed])
379        fi
380fi
381
382
383AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ])
384AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
385AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
386AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
387#AM_CONDITIONAL([DAG3_0], [test "$libtrace_dag_version" = 30])
388AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_deflate" = yes])
389AM_CONDITIONAL([HAVE_BZLIB], [test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" = yes])
390AM_CONDITIONAL([HAVE_LZO], [test "$ac_cv_lib_lzo2_lzo1x_1_compress" = yes])
391AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
392AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes])
393AM_CONDITIONAL([HAVE_LLVM], [test "x$JIT" != "xno" ])
394
395# Check for miscellaneous programs
396AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false])
397
398AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue])
399
400AC_SUBST([ADD_LIBS])
401AC_SUBST([ADD_LDFLAGS])
402AC_SUBST([ADD_INCLS])
403AC_SUBST([LTLIBOBJS])
404AC_SUBST([MANPAGES])
405AC_SUBST([PACKAGE_VERSION])
406AC_SUBST([LIBTRACE_MAJOR])
407AC_SUBST([LIBTRACE_MID])
408AC_SUBST([LIBTRACE_MINOR])
409AC_SUBST([DAG_VERSION_NUM])
410AC_SUBST([HAVE_BPF_CAPTURE])
411AC_SUBST([HAVE_LIBGDC])
412AC_SUBST([HAVE_LLVM])
413AC_SUBST([LIBCFLAGS])
414AC_SUBST([LIBCXXFLAGS])
415dnl and finally, output our Makefiles
416AC_OUTPUT
417
418reportopt() {
419        if test x"$2" = xtrue -o x"$2" = xyes; then
420                AC_MSG_NOTICE([$1: Yes])
421        else
422                AC_MSG_NOTICE([$1: No])
423        fi
424}
425
426echo
427AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION])
428reportopt "Compiled with PCAP 0.8 support" $ac_cv_lib_pcap_pcap_next_ex
429reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_deflate
430reportopt "Compiled with compressed trace (bz2) support" $ac_cv_lib_bz2_BZ2_bzDecompressInit
431reportopt "Compiled with compressed trace (lzo write only) support" $ac_cv_lib_lzo2_lzo1x_1_compress
432if test x"$libtrace_dag" = xtrue; then
433        if test "$libtrace_dag_version" = 24; then
434                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4])
435        elif test "$libtrace_dag_version" = 30; then
436                AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0])
437        else
438                AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5])
439        fi     
440else
441        AC_MSG_NOTICE([Compiled with DAG live capture support: No])
442fi
443reportopt "Compiled with LLVM BPF JIT support" $JIT
444reportopt "Building man pages/documentation" $libtrace_doxygen
445
446echo
447ac_cv_errcount=0;
448if test -z "$YACC"; then
449        AC_MSG_WARN(bison or yacc not found. Please install bison before continuing)
450        ac_cv_errcount=$((ac_cv_errcount + 1))
451fi
452
453if test -z "$LEXLIB"; then
454        AC_MSG_WARN(flex or lex not found. Please install flex before continuing)
455        ac_cv_errcount=$((ac_cv_errcount + 1))
456fi
457
458if test $ac_cv_errcount -gt 0; then
459        AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure)
460fi
461
Note: See TracBrowser for help on using the repository browser.