source: configure.in @ 61a9096

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 61a9096 was 61a9096, checked in by Brendon Jones <brendonj@…>, 14 years ago

Updated to include the Makefile in libpacketdump/parser as well as checking for flex and bison

  • 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.0,[contact@wand.net.nz],libtrace)
7
8LIBTRACE_MAJOR=3
9LIBTRACE_MID=0
10LIBTRACE_MINOR=0
11
12AC_CONFIG_SRCDIR(lib/trace.c)
13AM_INIT_AUTOMAKE
14
15AC_DEFINE([LIBTRACE_MAJOR],${LIBTRACE_MAJOR},[libtrace major version])
16AC_DEFINE([LIBTRACE_MID],${LIBTRACE_MID},[libtrace mid version])
17AC_DEFINE([LIBTRACE_MINOR],${LIBTRACE_MINOR},[libtrace minor version])
18
19AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile
20        libpacketdump/parser/Makefile
21        tools/Makefile tools/traceanon/Makefile tools/tracedump/Makefile
22        tools/tracemerge/Makefile tools/tracereport/Makefile
23        tools/tracertstats/Makefile tools/tracesplit/Makefile
24        tools/tracestats/Makefile docs/libtrace.doxygen lib/libtrace.h])
25dnl GNU C library
26dnl AC_GNU_SOURCE
27
28
29AM_CONFIG_HEADER(config.h)
30#AC_CONFIG_HEADERS([config.h])
31dnl Checks for programs.
32AC_PROG_CC
33AC_PROG_CXX
34AC_PROG_INSTALL
35#AC_LIBTOOL_DLOPEN
36AC_PROG_LIBTOOL
37AC_PROG_YACC
38AC_PROG_LEX
39
40AC_CONFIG_LIBOBJ_DIR(lib)
41
42# Checks for typedefs, structures, and compiler characteristics.
43AC_C_CONST
44AC_C_INLINE
45AC_C_BIGENDIAN
46AC_TYPE_SIZE_T
47AC_HEADER_TIME
48AC_SYS_LARGEFILE
49
50# Checks for library functions.
51AC_PROG_GCC_TRADITIONAL
52AC_CHECK_FUNCS(socket strdup strlcpy)
53
54AC_CHECK_SIZEOF([long int])
55
56
57
58# Check for various broken functions
59AC_FUNC_MALLOC
60AC_FUNC_REALLOC
61
62# *BSD doesn't have strndup. Currently provide our own.
63AC_REPLACE_FUNCS(strndup)
64
65# Checks for header files.
66AC_HEADER_STDC
67dnl AC_CHECK_HEADERS(errno.h stdlib.h stdio.h assert.h string.h netinet/in.h assert.h errno.h fcntl.h net/ethernet.h netdb.h pcap.h stdio.h stdlib.h string.h sys/stat.h sys/types.h sys/socket.h sys/un.h unistd.h time.h sys/ioctl.h net/bpf.h pcap.h zlib.h pcap-bpf.h)
68AC_CHECK_HEADERS(pcap.h pcap-int.h pcap-bpf.h net/bpf.h zlib.h sys/limits.h stddef.h inttypes.h limits.h net/ethernet.h )
69
70AC_CHECK_HEADERS(netinet/in.h)
71AC_CHECK_HEADER(netpacket/packet.h,
72                libtrace_netpacket_packet_h=true
73                AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[We have netpacket/packet.h]),
74                [libtrace_netpacket_packet_h=false])
75
76AC_CHECK_HEADER(net/if.h,
77                AC_DEFINE(HAVE_NET_IF_H,1,[We have net/if.h]), [],
78[#include <sys/types.h>
79 #include <sys/socket.h>
80])
81
82
83AC_CHECK_HEADER(netinet/ether.h,
84                AC_DEFINE(HAVE_NETINET_ETHER_H,1,[We have netinet/ether.h]
85), [],
86[
87 #include <sys/types.h>
88 #include <sys/socket.h>
89 #include <netinet/in.h>
90 #include <net/if.h>
91])
92
93AC_CHECK_HEADER(netinet/if_ether.h,
94                AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[We have netinet/if_ether.h]), [],
95[
96 #include <sys/types.h>
97 #include <sys/socket.h>
98 #include <netinet/in.h>
99 #include <net/if.h>
100])
101
102AC_CHECK_HEADER(net/if_arp.h,
103                AC_DEFINE(HAVE_NET_IF_ARP_H,1,[We have net/if_arp.h]), [],
104[
105 #include <sys/types.h>
106 #include <sys/socket.h>
107 #include <netinet/in.h>
108 #include <net/if.h>
109])
110
111       
112# Checking for the right bpf header to include
113AC_MSG_CHECKING([where the bpf headers are kept])
114echo ""
115bpfh=no
116AC_CHECK_HEADER(pcap-bpf.h,
117        [AC_DEFINE([HAVE_PCAP_BPF_H]) bpfh=pcap-bpf.h])
118if test $bpfh = no; then
119AC_CHECK_HEADER(net/bpf.h,
120        [AC_DEFINE([HAVE_NET_BPF_H]) bpfh=net/bpf.h])
121fi
122
123if test $bpfh = no; then
124  AC_MSG_RESULT([No BPF headers, compiling without support for BPF filters])
125  AC_DEFINE(HAVE_BPF,0,[Conditional for building bpf support])
126  libtrace_bpf=false
127else
128  AC_MSG_RESULT([Using $bpfh])
129  AC_DEFINE(HAVE_BPF,1,[Conditional for building bpf support])
130  libtrace_bpf=true
131fi
132
133
134AC_CHECK_HEADER(gdc.h,
135             [AC_DEFINE(HAVE_GDC_H,1,[Conditional for building with libGDC support]) libtrace_gdc=true],
136             [AC_DEFINE(HAVE_GDC_H,0,[Conditional for building with libGDC support]) libtrace_gdc=false])
137
138# Check to see if we have libdl - *BSD has built-in libdl
139AC_CHECK_LIB(dl, dlopen, libtrace_dl=true, libtrace_dl=false)
140if test "$libtrace_dl" = true; then
141        AC_DEFINE(HAVE_LIBDL,1,[Conditional for building with dynamic library support])
142        ADD_LIBS="$ADD_LIBS -ldl"
143else
144        AC_DEFINE(HAVE_LIBDL,0,[Conditional for building with dynamic library support])
145fi
146
147
148# Check to see if we have libpcap
149AC_CHECK_LIB(pcap,pcap_open_live,
150             libtrace_pcap=true,
151             libtrace_pcap=false)
152
153if test "$libtrace_pcap" = true; then
154    AC_DEFINE(HAVE_PCAP,1,[Conditional for building PCAP support])
155    ADD_LIBS="$ADD_LIBS  -lpcap"
156else
157    AC_DEFINE(HAVE_PCAP,0,[Conditional for building PCAP support])
158fi     
159
160# Only test for these functions if we have PCAP installed
161        if test "$libtrace_pcap" = true; then
162        # Earlier versions of pcap don't have pcap_open_dead. EG: the one
163        # OpenBSD ships with. Even Debian Woody is more up to date.
164        AC_CHECK_LIB(pcap,pcap_open_dead,
165                have_pcap_open_dead=true,
166                have_pcap_open_dead=false)
167
168        if test "$have_pcap_open_dead" = false; then
169                AC_REPLACE_FUNCS(pcap_open_dead)
170        fi
171   
172        # Versions of libpcap earlier than 0.8 don't have pcap_dump_flush or
173        # pcap_next_ex
174        AC_CHECK_LIB(pcap,pcap_dump_flush,
175                     have_pcap_dump_flush=true,
176                     have_pcap_dump_flush=false)
177
178        if test "$have_pcap_dump_flush" = false; then
179                AC_REPLACE_FUNCS(pcap_dump_flush)
180        fi
181       
182        AC_CHECK_LIB(pcap,pcap_next_ex,
183                     have_pcap_next_ex=true,
184                     have_pcap_next_ex=false)
185
186        if test "$have_pcap_next_ex" = false; then
187                AC_REPLACE_FUNCS(pcap_next_ex)
188        fi
189
190        AC_CHECK_LIB(pcap,pcap_inject,
191                        AC_DEFINE(HAVE_PCAP_INJECT,1,[pcap has pcap_inject]),
192                        have_pcap_inject=false)
193
194        AC_CHECK_LIB(pcap,pcap_sendpacket,
195                        AC_DEFINE(HAVE_PCAP_SENDPACKET,1,[pcap has pcap_sendpacket]),
196                        have_pcap_sendpacket=false)
197
198        AC_CHECK_LIB(pcap,pcap_setnonblock,
199                        AC_DEFINE(HAVE_PCAP_SETNONBLOCK,1,[pcap has pcap_setnonblock]),
200                        have_pcap_setnonblock=false)
201fi
202
203
204# configure time options for man pages
205AC_ARG_WITH(man,
206            AC_HELP_STRING([--with-man],
207                           [install man pages by default]),
208
209             if test "$withval" = yes
210             then
211                     MANPAGES="docs/man/man3/[a-zA-Z]*.3]"
212             else
213                     MANPAGES=""
214             fi
215)
216
217# configure time option for building libpacketdump
218# libpacketdump needs a C++ compiler to build, so we should do some tests
219# at this point to see if one is installed
220libtrace_libpacketdump=true
221AC_ARG_ENABLE(libpacketdump,
222              AC_HELP_STRING([--disable-libpacketdump],
223                             [disable building of libpacketdump (enabled by default). libpacketdump needs a c++ compiler to build] ),
224[
225        if test "$enableval" = no -o "$enableval" = false
226        then
227                libtrace_libpacketdump=false
228        else
229                libtrace_libpacketdump=true
230        fi
231],
232[
233        libtrace_libpacketdump=true
234])
235
236if test "$libtrace_libpacketdump" = true; then
237        AC_LANG_PUSH(C++)
238        AC_MSG_CHECKING([if we can compile C++ ])
239        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
240                           [[
241#include <iostream>
242                           ]])],
243                [AC_DEFINE(HAVE_CXX,1,[define to test for presence of a working C++ compiler]) libtrace_cxx=true],
244                [AC_DEFINE(HAVE_CXX,0,[define to test for presence of a working C++ compiler]) libtrace_cxx=false])
245
246        AC_MSG_RESULT($libtrace_cxx)   
247        AC_LANG_POP(C++)
248
249        if test "$libtrace_cxx" = false; then
250                AC_MSG_ERROR([libpacketdump requested, but no C++ compiler found. Build with --disable-libpacketdump if you wish to continue anyway ])
251        fi
252fi
253
254# configure time option for building the libtrace tools
255# one of the tools requires libpacketdump, so won't build if libpacketdump
256# hasn't also been built
257libtrace_tools=true
258AC_ARG_ENABLE(tools,
259              AC_HELP_STRING([--disable-tools],
260                             [disable building of the tools contained in the tools/ directory]),
261[
262        if test "$enableval" = no -o "$enableval" = false
263        then
264                libtrace_tools=false
265        else
266                libtrace_tools=true
267        fi
268       
269],
270[
271        libtrace_tools=true
272])
273
274# configure time options for use of DAG cards
275# borrowed from libpcap!
276AC_ARG_WITH(dag,
277            AC_HELP_STRING([--with-dag[=DIR]],
278                           [include DAG support (located in directory DIR, if supplied)]),
279[
280        if test "$withval" = no
281        then
282                want_dag=no
283        elif test "$withval" = yes
284        then
285                want_dag=yes
286                dag_root=/root/dag
287        else
288                want_dag=yes
289                dag_root=$withval
290        fi
291],[
292        #
293        # Use DAG API if present, otherwise don't
294        #
295        want_dag=ifpresent
296        dag_root=/root/dag/
297])
298
299# turn the test part of the next block into a function, so it can be
300# called multiple times for $dag_root, /root/dag, /usr/local/lib
301libtrace_dag=false
302libtrace_dag2_4=false
303if test "$with_dag" != no; then
304        AC_MSG_CHECKING(whether we have DAG API)
305
306        if test -r "$dag_root/lib"; then
307                dag_lib_dir="$dag_root/lib"
308        else
309                dag_lib_dir="$dag_root"
310        fi
311       
312        if test -r "$dag_root/tools" -a -r "$dag_root/include"; then
313                dag_tools_dir="$dag_root/tools"
314                dag_include_dir="$dag_root/include"
315        else
316                dag_tools_dir="$dag_root"
317                dag_include_dir="$dag_root"
318        fi
319
320        if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a";
321        then
322                ADD_INCLS="$ADD_INCLS -I $dag_include_dir"
323                ADD_LIBS="$ADD_LIBS -ldag"
324                ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir"
325                DAG_TOOLS_DIR=$dag_tools_dir
326                AC_SUBST([DAG_TOOLS_DIR])
327                libtrace_dag=true
328               
329                AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API])
330                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support])
331        else
332                if test "$want_dag" = yes; then
333                        AC_MSG_ERROR(DAG API not found under directory $dag_root
334; use --without-dag)
335                fi
336                libtrace_dag=false
337        fi
338        AC_MSG_RESULT($libtrace_dag)
339       
340        AC_MSG_CHECKING(if we are using DAG 2.4)
341        if grep '2.4.' $dag_root/VERSION > /dev/null 2>&1; then
342                libtrace_dag2_4=true
343                AC_DEFINE(DAG_VERSION_2_4, 1, [define if using DAG 2.4])
344        else
345                libtrace_dag2_4=false
346        fi
347        AC_MSG_RESULT($libtrace_dag2_4)
348else
349        AC_DEFINE(HAVE_DAG,0,[conditional for building with DAG support])
350fi
351
352
353
354
355
356AC_ARG_WITH([zlib],
357    AC_HELP_STRING([--with-zlib],
358                               [name of zlib library (default is z)]),
359        [ac_cv_use_zlib=$withval],
360    [ac_cv_use_zlib=z])
361
362AC_ARG_WITH([zlib-path],
363    AC_HELP_STRING([--with-zlib-path],
364                   [location of zlib library (default is /usr/lib)]),
365    [ac_cv_use_zlib_path=$withval],
366    [ac_cv_use_zlib_path=/usr/lib])
367
368libtrace_zlib=false
369if test "$ac_cv_use_zlib" != no; then
370   
371    zlib_lib_file="${ac_cv_use_zlib_path}/lib${ac_cv_use_zlib}.so"
372
373    # if the library is in /usr/lib/, then just use AC_CHECK_LIB
374    if test x"${ac_cv_use_zlib_path}" == x"/usr/lib"; then
375            AC_CHECK_LIB(${ac_cv_use_zlib}, gzopen,
376                         libtrace_zlib=true,
377                         libtrace_zlib=false)
378    else
379        ADD_LDFLAGS="$ADD_LDFLAGS -L$ac_cv_use_zlib_path"
380        # if it's not in /usr/lib/, check manually. This isn't nice
381        # and will probably break.
382        if test ! -r "$ac_cv_use_zlib_path" -o ! -r "$zlib_lib_file"; then
383                AC_MSG_NOTICE([Cannot find zlib library $zlib_lib_file.])
384                AC_MSG_ERROR([Exiting]);
385        else
386                libtrace_zlib=true
387        fi
388    fi
389fi
390
391if test $libtrace_zlib = true; then
392        ADD_LIBS="$ADD_LIBS -l$ac_cv_use_zlib"
393        AC_DEFINE(HAVE_ZLIB,1,[Conditional for building zlib support])
394else
395        AC_DEFINE(HAVE_ZLIB,0,[Conditional for building zlib support])   
396fi
397
398AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
399AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag2_4" = true])
400AM_CONDITIONAL([HAVE_CXX], [test "$libtrace_cxx" = true])
401AM_CONDITIONAL([HAVE_ZLIB], [test "$libtrace_zlib" = true])
402AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
403AM_CONDITIONAL([LIBPACKETDUMP], [test "$libtrace_libpacketdump" = true])
404AM_CONDITIONAL([LIBTRACE_TOOLS], [test "$libtrace_tools" = true])
405AM_CONDITIONAL([LIBGDC], [test "$libtrace_gdc" = true])
406
407
408# Check for miscellaneous programs
409AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false])
410
411AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue])
412
413
414AC_SUBST([ADD_LIBS])
415AC_SUBST([ADD_LDFLAGS])
416AC_SUBST([ADD_INCLS])
417AC_SUBST([LTLIBOBJS])
418AC_SUBST([MANPAGES])
419AC_SUBST([PACKAGE_VERSION])
420AC_SUBST([LIBTRACE_MAJOR])
421AC_SUBST([LIBTRACE_MID])
422AC_SUBST([LIBTRACE_MINOR])
423
424dnl and finally, output our Makefiles
425AC_OUTPUT
426
427reportopt() {
428        if test x"$2" = xtrue -o x"$2" = xyes; then
429                AC_MSG_NOTICE([$1: Yes])
430        else
431                AC_MSG_NOTICE([$1: No])
432        fi
433}
434
435AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION])
436reportopt "Compiled with BPF filter support" $libtrace_bpf
437reportopt "Compiled with PCAP support" $libtrace_pcap
438reportopt "Compiled with compressed trace (zlib) support" $libtrace_zlib
439reportopt "Compiled with DAG support (libdag)" $libtrace_dag
440reportopt "Compiled with DAG support (DAG 2.4)" $libtrace_dag2_4
441reportopt "Building man pages/documentation" $libtrace_doxygen
442reportopt "Building libpacketdump" $libtrace_libpacketdump
443reportopt "Building tools/ directory" $libtrace_tools
444
Note: See TracBrowser for help on using the repository browser.