source: configure.in @ 77285d9

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 77285d9 was 77285d9, checked in by Shane Alcock <salcock@…>, 14 years ago

OpenBSD compatibility fixes - adding in various #defines and #includes that are needed to compile under OpenBSD
Added a replacement pcap_next_ex function for systems that aren't running pcap-0.8 or better

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