source: configure.in @ bfd9a45

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