source: configure.in @ 4a605a9

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 4a605a9 was 4a605a9, checked in by Daniel Lawson <dlawson@…>, 16 years ago

added --disable-libpacketdump and --disable-tools configure options.

tools/tracedump will only get built if libpacketdump is also being built
libpacketdump will fail to build (and generate an error) if there is no c++ compiler installed.

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