source: configure.in @ 7b29593

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