]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/libpcap/configure.in
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / libpcap / configure.in
1 dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.138.2.22 2008-10-24 07:30:18 guy Exp $ (LBL)
2 dnl
3 dnl Copyright (c) 1994, 1995, 1996, 1997
4 dnl     The Regents of the University of California.  All rights reserved.
5 dnl
6 dnl Process this file with autoconf to produce a configure script.
7 dnl
8
9 AC_REVISION($Revision: 1.138.2.22 $)
10 AC_PREREQ(2.50)
11 AC_INIT(pcap.c)
12
13 AC_CANONICAL_SYSTEM
14
15 AC_LBL_C_INIT(V_CCOPT, V_INCLS, V_LIBS)
16 AC_LBL_C_INLINE
17 AC_C___ATTRIBUTE__
18
19 AC_LBL_CHECK_TYPE(u_int8_t, u_char)
20 AC_LBL_CHECK_TYPE(u_int16_t, u_short)
21 AC_LBL_CHECK_TYPE(u_int32_t, u_int)
22 AC_LBL_CHECK_TYPE(u_int64_t, unsigned long long)
23
24 #
25 # Try to arrange for large file support.
26 #
27 AC_SYS_LARGEFILE
28 AC_FUNC_FSEEKO
29
30 dnl
31 dnl libpcap doesn't itself use <sys/ioccom.h>; however, the test program
32 dnl in "AC_LBL_FIXINCLUDES" in "aclocal.m4" uses it, so we have to
33 dnl test for it and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
34 dnl "AC_LBL_FIXINCLUDES" won't work on some platforms such as Solaris.
35 dnl
36 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
37 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
38 #include <sys/socket.h>
39 #include <net/if.h>])
40 if test "$ac_cv_header_net_pfvar_h" = yes; then
41         #
42         # Check for various PF actions.
43         #
44         AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
45         AC_TRY_COMPILE(
46             [#include <sys/types.h>
47             #include <sys/socket.h>
48             #include <net/if.h>
49             #include <net/pfvar.h>],
50             [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
51             [
52                 AC_MSG_RESULT(yes)
53                 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
54                     [define if net/pfvar.h defines PF_NAT through PF_NORDR])
55             ],
56             AC_MSG_RESULT(no))
57 fi
58 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
59 #include <sys/socket.h>])
60 if test "$ac_cv_header_netinet_if_ether_h" != yes; then
61         #
62         # The simple test didn't work.
63         # Do we need to include <net/if.h> first?
64         # Unset ac_cv_header_netinet_if_ether_h so we don't
65         # treat the previous failure as a cached value and
66         # suppress the next test.
67         #
68         AC_MSG_NOTICE([Rechecking with some additional includes])
69         unset ac_cv_header_netinet_if_ether_h
70         AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
71 #include <sys/socket.h>
72 #include <netinet/in.h>
73 struct mbuf;
74 struct rtentry;
75 #include <net/if.h>])
76 fi
77
78 AC_LBL_FIXINCLUDES
79
80 AC_CHECK_FUNCS(strerror strlcpy)
81
82 needsnprintf=no
83 AC_CHECK_FUNCS(vsnprintf snprintf,,
84         [needsnprintf=yes])
85 if test $needsnprintf = yes; then
86         AC_LIBOBJ(snprintf)
87 fi
88
89 #
90 # Do this before checking for ether_hostton(), as it's a
91 # "gethostbyname() -ish function".
92 #
93 AC_LBL_LIBRARY_NET
94
95 #
96 # You are in a twisty little maze of UN*Xes, all different.
97 # Some might not have ether_hostton().
98 # Some might have it, but not declare it in any header file.
99 # Some might have it, but declare it in <netinet/if_ether.h>.
100 # Some might have it, but declare it in <netinet/ether.h>
101 # (And some might have it but document it as something declared in
102 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
103 #
104 # Before you is a C compiler.
105 #
106 AC_CHECK_FUNCS(ether_hostton)
107 if test "$ac_cv_func_ether_hostton" = yes; then
108         #
109         # OK, we have ether_hostton().  Do we have <netinet/if_ether.h>?
110         #
111         if test "$ac_cv_header_netinet_if_ether_h" = yes; then
112                 #
113                 # Yes.  Does it declare ether_hostton()?
114                 #
115                 AC_CHECK_DECL(ether_hostton,
116                     [
117                         AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
118                             [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
119                     ],,
120                     [
121 #include <sys/types.h>
122 #include <sys/socket.h>
123 #include <netinet/in.h>
124 #include <arpa/inet.h>
125 struct mbuf;
126 struct rtentry;
127 #include <net/if.h>
128 #include <netinet/if_ether.h>
129                     ])
130         fi
131         #
132         # Did that succeed?
133         #
134         if test "$ac_cv_have_decl_ether_hostton" != yes; then
135                 #
136                 # No, how about <netinet/ether.h>, as on Linux?
137                 #
138                 AC_CHECK_HEADERS(netinet/ether.h)
139                 if test "$ac_cv_header_netinet_ether_h" = yes; then
140                         #
141                         # We have it - does it declare ether_hostton()?
142                         # Unset ac_cv_have_decl_ether_hostton so we don't
143                         # treat the previous failure as a cached value and
144                         # suppress the next test.
145                         #
146                         unset ac_cv_have_decl_ether_hostton
147                         AC_CHECK_DECL(ether_hostton,
148                             [
149                                 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
150                                     [Define to 1 if netinet/ether.h declares `ether_hostton'])
151                             ],,
152                             [
153 #include <netinet/ether.h>
154                             ])
155                 fi
156         fi
157         #
158         # Is ether_hostton() declared?
159         #
160         if test "$ac_cv_have_decl_ether_hostton" != yes; then
161                 #
162                 # No, we'll have to declare it ourselves.
163                 # Do we have "struct ether_addr"?
164                 #
165                 AC_CHECK_TYPES(struct ether_addr,,,
166                     [
167 #include <sys/types.h>
168 #include <sys/socket.h>
169 #include <netinet/in.h>
170 #include <arpa/inet.h>
171 struct mbuf;
172 struct rtentry;
173 #include <net/if.h>
174 #include <netinet/if_ether.h>
175                     ])
176                 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 0,
177                     [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
178 don't.])
179         else
180                 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
181                     [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
182 don't.])
183         fi
184 fi
185
186 dnl to pacify those who hate protochain insn
187 AC_MSG_CHECKING(if --disable-protochain option is specified)
188 AC_ARG_ENABLE(protochain, [  --disable-protochain    disable \"protochain\" insn])
189 case "x$enable_protochain" in
190 xyes)   enable_protochain=enabled       ;;
191 xno)    enable_protochain=disabled      ;;
192 x)      enable_protochain=enabled       ;;
193 esac
194
195 if test "$enable_protochain" = "disabled"; then
196         AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
197 fi
198 AC_MSG_RESULT(${enable_protochain})
199
200 #
201 # SITA support is mutually exclusive with native capture support;
202 # "--with-sita" selects SITA support.
203 #
204 AC_ARG_WITH(sita, [  --with-sita             include SITA support],
205 [
206         AC_DEFINE(SITA,1,[include ACN support])
207         AC_MSG_NOTICE(Enabling SITA ACN support)
208         V_PCAP=sita
209         V_FINDALLDEVS=sita
210 ],
211 [
212 dnl
213 dnl Not all versions of test support -c (character special) but it's a
214 dnl better way of testing since the device might be protected. So we
215 dnl check in our normal order using -r and then check the for the /dev
216 dnl guys again using -c.
217 dnl
218 dnl XXX This could be done for cross-compiling, but for now it's not.
219 dnl
220 if test -z "$with_pcap" && test "$cross_compiling" = yes; then
221         AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...)
222 fi
223 AC_ARG_WITH(pcap, [  --with-pcap=TYPE        use packet capture TYPE])
224 AC_MSG_CHECKING(packet capture type)
225 if test ! -z "$with_pcap" ; then
226         V_PCAP="$withval"
227 elif test -r /dev/bpf ; then
228         #
229         # Cloning BPF device.
230         #
231         V_PCAP=bpf
232         AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
233 elif test -r /dev/bpf0 ; then
234         V_PCAP=bpf
235 elif test -r /usr/include/net/pfilt.h ; then
236         V_PCAP=pf
237 elif test -r /dev/enet ; then
238         V_PCAP=enet
239 elif test -r /dev/nit ; then
240         V_PCAP=snit
241 elif test -r /usr/include/sys/net/nit.h ; then
242         V_PCAP=nit
243 elif test -r /usr/include/linux/socket.h ; then
244         V_PCAP=linux
245 elif test -r /usr/include/net/raw.h ; then
246         V_PCAP=snoop
247 elif test -r /usr/include/odmi.h ; then
248         #
249         # On AIX, the BPF devices might not yet be present - they're
250         # created the first time libpcap runs after booting.
251         # We check for odmi.h instead.
252         #
253         V_PCAP=bpf
254 elif test -r /usr/include/sys/dlpi.h ; then
255         V_PCAP=dlpi
256 elif test -c /dev/bpf0 ; then           # check again in case not readable
257         V_PCAP=bpf
258 elif test -c /dev/enet ; then           # check again in case not readable
259         V_PCAP=enet
260 elif test -c /dev/nit ; then            # check again in case not readable
261         V_PCAP=snit
262 else
263         V_PCAP=null
264 fi
265 AC_MSG_RESULT($V_PCAP)
266
267 #
268 # Do capture-mechanism-dependent tests.
269 #
270 case "$V_PCAP" in
271 dlpi)
272         #
273         # Checks to see if Solaris has the public libdlpi(3LIB) library.
274         # Note: The existence of /usr/include/libdlpi.h does not mean it is the
275         # public libdlpi(3LIB) version. Before libdlpi was made public, a 
276         # private version also existed, which did not have the same APIs. 
277         # Due to a gcc bug, the default search path for 32-bit libraries does
278         # not include /lib, we add it explicitly here.
279         # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485]. 
280         # Also, due to the bug above applications that link to libpcap with
281         # libdlpi will have to add "-L/lib" option to "configure".
282         #
283         saved_ldflags=$LDFLAGS
284         LDFLAGS="$LIBS -L/lib"
285         AC_CHECK_LIB(dlpi, dlpi_walk,
286                 LIBS="-ldlpi $LIBS"
287                 V_PCAP=libdlpi
288                 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists]),
289                 V_PCAP=dlpi)
290         LDFLAGS=$saved_ldflags
291
292         #
293         # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
294         # versions of DLPI.
295         #
296         AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
297         AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
298                 AC_TRY_COMPILE(
299                     [
300                         #include <sys/types.h>
301                         #include <sys/time.h>
302                         #include <sys/dlpi.h>
303                     ],
304                     [int i = DL_PROMISC_PHYS;],
305                     ac_cv_sys_dlpi_usable=yes,
306                     ac_cv_sys_dlpi_usable=no))
307         AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
308         if test $ac_cv_sys_dlpi_usable = no ; then
309                 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
310         fi
311
312         #
313         # Check whether we have a /dev/dlpi device or have multiple devices.
314         #
315         AC_MSG_CHECKING(for /dev/dlpi device)
316         if test -c /dev/dlpi ; then
317                 AC_MSG_RESULT(yes)
318                 AC_DEFINE(HAVE_DEV_DLPI, 1, [define if you have a /dev/dlpi])
319         else
320                 AC_MSG_RESULT(no)
321                 dir="/dev/dlpi"
322                 AC_MSG_CHECKING(for $dir directory)
323                 if test -d $dir ; then
324                         AC_MSG_RESULT(yes)
325                         AC_DEFINE_UNQUOTED(PCAP_DEV_PREFIX, "$dir", [/dev/dlpi directory])
326                 else
327                         AC_MSG_RESULT(no)
328                 fi
329         fi
330
331         #
332         # This check is for Solaris with DLPI support for passive modes.
333         # See dlpi(7P) for more details.
334         #
335         AC_LBL_DL_PASSIVE_REQ_T
336         ;;
337
338 linux)
339         AC_MSG_CHECKING(Linux kernel version)
340         if test "$cross_compiling" = yes; then
341                 AC_CACHE_VAL(ac_cv_linux_vers,
342                     ac_cv_linux_vers=unknown)
343         else
344                 AC_CACHE_VAL(ac_cv_linux_vers,
345                     ac_cv_linux_vers=`uname -r 2>&1 | \
346                         sed -n -e '$s/.* //' -e '$s/\..*//p'`)
347         fi
348         AC_MSG_RESULT($ac_cv_linux_vers)
349         if test $ac_cv_linux_vers = unknown ; then
350                 AC_MSG_ERROR(cannot determine linux version when cross-compiling)
351         fi
352         if test $ac_cv_linux_vers -lt 2 ; then
353                 AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
354         fi
355         AC_CHECK_HEADERS(linux/wireless.h, [], [],
356         [
357 #include <sys/socket.h>
358 #include <net/if.h>
359 #include <linux/types.h>
360         ])
361         AC_CHECK_HEADERS()
362         AC_LBL_TPACKET_STATS
363         AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
364         ;;
365
366 bpf)
367         #
368         # Check whether we have the *BSD-style ioctls.
369         #
370         AC_CHECK_HEADERS(net/if_media.h)
371
372         AC_MSG_CHECKING(whether the system supports zerocopy BPF)
373         AC_TRY_COMPILE(
374             [#include <sys/socket.h>
375             #include <sys/ioctl.h>
376             #include <net/if.h>
377             #include <net/bpf.h>],
378             [return (BIOCROTZBUF + BPF_BUFMODE_ZBUF);],
379             [  
380                 AC_MSG_RESULT(yes)
381                 AC_DEFINE(HAVE_ZEROCOPY_BPF, 1,
382                 [define if the system supports zerocopy BPF])
383             ],
384             AC_MSG_RESULT(no))
385         ;;
386
387 dag)
388         V_DEFS="$V_DEFS -DDAG_ONLY"
389         ;;
390
391 septel)
392         V_DEFS="$V_DEFS -DSEPTEL_ONLY"
393         ;;
394
395 null)
396         AC_MSG_WARN(cannot determine packet capture interface)
397         AC_MSG_WARN((see the INSTALL doc for more info))
398         ;;
399 esac
400
401 dnl
402 dnl Now figure out how we get a list of interfaces and addresses,
403 dnl if we support capturing.  Don't bother if we don't support
404 dnl capturing.
405 dnl
406 if test "$V_PCAP" = null
407 then
408         #
409         # We can't capture, so we can't open any capture
410         # devices, so we won't return any interfaces.
411         #
412         V_FINDALLDEVS=null
413 else
414         AC_CHECK_FUNC(getifaddrs,[
415                 #
416                 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
417                 # as well, just in case some platform is really weird.
418                 #
419                 AC_CHECK_HEADER(ifaddrs.h,[
420                     #
421                     # We have the header, so we use "getifaddrs()" to
422                     # get the list of interfaces.
423                     #
424                     V_FINDALLDEVS=getad
425                 ],[
426                     #
427                     # We don't have the header - give up.
428                     # XXX - we could also fall back on some other
429                     # mechanism, but, for now, this'll catch this
430                     # problem so that we can at least try to figure
431                     # out something to do on systems with "getifaddrs()"
432                     # but without "ifaddrs.h", if there is something
433                     # we can do on those systems.
434                     #
435                     AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
436                 ])
437         ],[
438                 #
439                 # Well, we don't have "getifaddrs()", so we have to use
440                 # some other mechanism; determine what that mechanism is.
441                 #
442                 # The first thing we use is the type of capture mechanism,
443                 # which is somewhat of a proxy for the OS we're using.
444                 #
445                 case "$V_PCAP" in
446
447                 dlpi|libdlpi)
448                         AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
449                         #
450                         # This might be Solaris 8 or later, with
451                         # SIOCGLIFCONF, or it might be some other OS
452                         # or some older version of Solaris, with
453                         # just SIOCGIFCONF.
454                         #
455                         AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
456                         AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
457                             AC_TRY_COMPILE(
458                                 [#include <sys/param.h>
459                                 #include <sys/file.h>
460                                 #include <sys/ioctl.h>
461                                 #include <sys/socket.h>
462                                 #include <sys/sockio.h>],
463                                 [ioctl(0, SIOCGLIFCONF, (char *)0);],
464                                 ac_cv_lbl_have_siocglifconf=yes,
465                                 ac_cv_lbl_have_siocglifconf=no))
466                         AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
467                         if test $ac_cv_lbl_have_siocglifconf = yes ; then
468                                 V_FINDALLDEVS=glifc
469                         else
470                                 V_FINDALLDEVS=gifc
471                         fi
472                         #
473                         # Needed for common functions used by pcap-[dlpi,libdlpi].c
474                         #
475                         SSRC="dlpisubs.c"
476                         ;;
477
478                 *)
479                         #
480                         # Assume we just have SIOCGIFCONF.
481                         # (XXX - on at least later Linux kernels, there's
482                         # another mechanism, and we should be using that
483                         # instead.)
484                         #
485                         V_FINDALLDEVS=gifc
486                         ;;
487                 esac])
488 fi
489 ])
490
491 AC_MSG_CHECKING(for socklen_t)
492 AC_TRY_COMPILE([
493         #include <sys/types.h>
494         #include <sys/socket.h>
495         ],
496         [ socklen_t x; ],
497         have_socklen_t=yes,
498         have_socklen_t=no)
499 if test "x$have_socklen_t" = "xyes"; then
500         AC_DEFINE(HAVE_SOCKLEN_T, 1, [define if socklen_t is defined])
501 fi
502 AC_MSG_RESULT($have_socklen_t)
503
504 AC_ARG_ENABLE(ipv6, [  --enable-ipv6           build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@],
505     [],
506     [enable_ipv6=ifavailable])
507 if test "$enable_ipv6" != "no"; then
508         AC_CHECK_FUNC(getaddrinfo,
509             [
510                 AC_DEFINE(INET6,1,[IPv6])
511             ],
512             [
513                 if test "$enable_ipv6" != "ifavailable"; then
514                         AC_MSG_FAILURE([--enable-ipv6 was given, but getaddrinfo isn't available])
515                 fi
516             ])
517 fi
518
519 AC_MSG_CHECKING(whether to build optimizer debugging code)
520 AC_ARG_ENABLE(optimizer-dbg, [  --enable-optimizer-dbg  build optimizer debugging code])
521 if test "$enable_optimizer_dbg" = "yes"; then
522         AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
523 fi
524 AC_MSG_RESULT(${enable_optimizer_dbg-no})
525
526 AC_MSG_CHECKING(whether to build parser debugging code)
527 AC_ARG_ENABLE(yydebug, [  --enable-yydebug        build parser debugging code])
528 if test "$enable_yydebug" = "yes"; then
529         AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
530 fi
531 AC_MSG_RESULT(${enable_yydebug-no})
532
533 AC_MSG_CHECKING(whether we have /proc/net/dev)
534 if test -r /proc/net/dev ; then
535         ac_cv_lbl_proc_net_dev=yes
536 else
537         ac_cv_lbl_proc_net_dev=no
538 fi
539 if test $ac_cv_lbl_proc_net_dev = yes; then
540         AC_DEFINE(HAVE_PROC_NET_DEV, 1, [define if you have a /proc/net/dev])
541 fi
542 AC_MSG_RESULT($ac_cv_lbl_proc_net_dev)
543
544 # Check for Endace DAG card support.
545 AC_ARG_WITH([dag], [  --with-dag[[=DIR]]        include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)],
546 [
547         if test "$withval" = no
548         then
549                 # User doesn't want DAG support.
550                 want_dag=no
551         elif test "$withval" = yes
552         then
553                 # User wants DAG support but hasn't specified a directory.
554                 want_dag=yes
555         else
556                 # User wants DAG support and has specified a directory, so use the provided value.
557                 want_dag=yes
558                 dag_root=$withval
559         fi
560 ],[
561         #
562         # Use DAG API if present, otherwise don't
563         #
564         want_dag=ifpresent
565 ])
566
567 AC_ARG_WITH([dag-includes], [  --with-dag-includes=DIR   Endace DAG include directory],
568 [
569         # User wants DAG support and has specified a header directory, so use the provided value.
570         want_dag=yes
571         dag_include_dir=$withval
572 ],[])
573
574 AC_ARG_WITH([dag-libraries], [  --with-dag-libraries=DIR  Endace DAG library directory],
575 [
576         # User wants DAG support and has specified a library directory, so use the provided value.
577         want_dag=yes
578         dag_lib_dir=$withval
579 ],[])
580
581 case "$V_PCAP" in
582 linux|bpf|dag)
583         #
584         # We support the DAG API if we're on Linux or BSD, or if we're
585         # building a DAG-only libpcap.
586         #
587         ;;
588 *)
589         #
590         # If the user explicitly requested DAG, tell them it's not
591         # supported.
592         #
593         # If they expressed no preference, don't include it.
594         #
595         if test $want_dag = yes; then
596                 AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types])
597         elif test $want_dag = yes; then
598                 want_dag=no
599         fi
600         ;;
601 esac
602
603 ac_cv_lbl_dag_api=no
604 if test "$want_dag" != no; then
605
606         AC_MSG_CHECKING([whether we have DAG API headers])
607
608         # If necessary, set default paths for DAG API headers and libraries.
609         if test -z "$dag_root"; then
610             dag_root=/usr/local
611         fi
612
613         if test -z "$dag_include_dir"; then
614                 dag_include_dir="$dag_root/include"
615         fi
616
617         if test -z "$dag_lib_dir"; then
618             dag_lib_dir="$dag_root/lib"
619         fi
620         
621         if test -z "$dag_tools_dir"; then
622             dag_tools_dir="$dag_root/tools"
623                 fi
624
625         if test -r $dag_include_dir/dagapi.h; then
626                 ac_cv_lbl_dag_api=yes
627         fi
628         AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
629 fi
630
631 if test $ac_cv_lbl_dag_api = yes; then
632
633         AC_MSG_CHECKING([dagapi.o])     
634         dagapi_obj=no
635         if test -r $dag_tools_dir/dagapi.o; then
636                 # 2.4.x.
637                 dagapi_obj=$dag_tools_dir/dagapi.o
638         elif test -r $dag_lib_dir/dagapi.o; then
639                 # 2.5.x.
640                 dagapi_obj=$dag_lib_dir/dagapi.o
641         elif test -r $dag_lib_dir/libdag.a; then
642                 # 2.5.x.
643                 ar x $dag_lib_dir/libdag.a dagapi.o 2>/dev/null
644                 if test -r ./dagapi.o; then
645                     dagapi_obj=./dagapi.o
646                 else
647                     ar x $dag_lib_dir/libdag.a libdag_la-dagapi.o 2>/dev/null
648                     if test -r ./libdag_la-dagapi.o; then
649                        dagapi_obj=./libdag_la-dagapi.o
650                     fi          
651                 fi
652         fi
653
654         if test $dagapi_obj = no; then
655                 AC_MSG_RESULT([no (checked $dag_lib_dir  $dag_tools_dir  $dag_lib_dir/libdag.a)])
656                         ac_cv_lbl_dag_api=no
657         else
658                 AC_MSG_RESULT([yes ($dagapi_obj)])
659         fi
660 fi
661
662 if test $ac_cv_lbl_dag_api = yes; then
663
664         AC_MSG_CHECKING([dagopts.o])    
665         dagopts_obj=no
666         if test -r $dag_tools_dir/dagopts.o; then
667                 # 2.4.x.
668                 dagopts_obj=$dag_tools_dir/dagopts.o
669         elif test -r $dag_lib_dir/dagopts.o; then
670                 # 2.5.x.
671                 dagopts_obj=$dag_lib_dir/dagopts.o
672         elif test -r $dag_lib_dir/libdag.a; then
673                 # 2.5.x.
674                 ar x $dag_lib_dir/libdag.a dagopts.o 2>/dev/null
675                 if test -r ./dagopts.o; then
676                     dagopts_obj=./dagopts.o
677                 else
678                     ar x $dag_lib_dir/libdag.a libdag_la-dagopts.o 2>/dev/null
679                     if test -r ./libdag_la-dagopts.o; then
680                        dagopts_obj=./libdag_la-dagopts.o
681                     fi
682                 fi
683         fi
684
685         if test $dagopts_obj = no; then
686                 AC_MSG_RESULT([no (checked $dag_lib_dir  $dag_tools_dir  $dag_lib_dir/libdag.a)])
687                 ac_cv_lbl_dag_api=no
688         else
689                 AC_MSG_RESULT([yes ($dagopts_obj)])
690         fi
691 fi
692
693 if test $ac_cv_lbl_dag_api = yes; then
694         # Under 2.5.x only we need to add dagreg.o.
695         if test -r $dag_include_dir/dagreg.h; then
696                 AC_MSG_CHECKING([dagreg.o])     
697                 dagreg_obj=no
698                 if test -r $dag_lib_dir/dagreg.o; then
699                         # Object file is ready and waiting.
700                         dagreg_obj=$dag_lib_dir/dagreg.o
701                 elif test -r $dag_lib_dir/libdag.a; then
702                         # Extract from libdag.a.
703                         ar x $dag_lib_dir/libdag.a dagreg.o 2>/dev/null
704                         if test -r ./dagreg.o; then
705                                 dagreg_obj=./dagreg.o
706                         else
707                                 ar x $dag_lib_dir/libdag.a libdag_la-dagreg.o 2>/dev/null
708                                 if test -r ./libdag_la-dagreg.o; then
709                                    dagreg_obj=./libdag_la-dagreg.o
710                                 fi
711                         fi
712                 fi
713
714                 if test $dagreg_obj = no; then
715                         AC_MSG_RESULT([no (checked $dag_lib_dir  $dag_lib_dir/libdag.a)])
716                         ac_cv_lbl_dag_api=no
717                 else
718                         AC_MSG_RESULT([yes ($dagreg_obj)])
719                 fi
720         fi
721 fi
722
723 if test $ac_cv_lbl_dag_api = yes; then
724         V_INCLS="$V_INCLS -I$dag_include_dir"
725         V_LIBS="$V_LIBS $dagapi_obj $dagopts_obj $dagreg_obj"
726         if test $V_PCAP != dag ; then
727                  SSRC="pcap-dag.c"
728         fi
729
730         # See if we can find a general version string.
731         # Don't need to save and restore LIBS to prevent -ldag being
732         # included if there's a found-action (arg 3).
733         saved_ldflags=$LDFLAGS
734         LDFLAGS="-L$dag_lib_dir"
735         AC_CHECK_LIB([dag], [dag_attach_stream], [dag_streams="1"], [dag_streams="0"])
736         AC_CHECK_LIB([dag],[dag_get_erf_types], [
737                 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
738         AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
739                 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
740         LDFLAGS=$saved_ldflags
741
742         if test "$dag_streams" = 1; then
743                 AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
744                 DAGLIBS="-ldag"
745         fi
746
747         AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
748 fi
749
750 AC_MSG_CHECKING(whether we have the DAG API)
751
752 if test $ac_cv_lbl_dag_api = no; then
753         AC_MSG_RESULT(no)
754         if test "$want_dag" = yes; then
755                 # User wanted DAG support but we couldn't find it.
756                 AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag])
757         fi
758
759         if test "$V_PCAP" = dag; then
760                 # User requested "dag" capture type but the DAG API wasn't
761                 # found.
762                 AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)])
763         fi
764 else
765         AC_MSG_RESULT(yes)
766 fi
767
768 AC_ARG_WITH(septel, [  --with-septel[[=DIR]]     include Septel support (located in directory DIR, if supplied).  [default=yes, on Linux, if present]],
769 [
770         if test "$withval" = no
771         then
772                 want_septel=no
773         elif test "$withval" = yes
774         then
775                 want_septel=yes
776                 septel_root=
777         else
778                 want_septel=yes
779                 septel_root=$withval
780         fi
781 ],[
782         #
783         # Use Septel API if present, otherwise don't
784         #
785         want_septel=ifpresent
786         septel_root=./../septel
787 ])
788 ac_cv_lbl_septel_api=no
789 case "$V_PCAP" in
790 linux|septel)
791         #
792         # We support the Septel API if we're on Linux, or if we're building
793         # a Septel-only libpcap.
794         #
795         ;;
796 *)
797         #
798         # If the user explicitly requested Septel, tell them it's not
799         # supported.
800         #
801         # If they expressed no preference, don't include it.
802         #
803         if test $want_septel = yes; then
804                 AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types)
805         elif test $want_septel = yes; then
806                 want_septel=no
807         fi
808         ;;
809 esac
810
811 if test "$with_septel" != no; then
812         AC_MSG_CHECKING(whether we have Septel API)
813
814         if test -z "$septel_root"; then
815                 septel_root=$srcdir/../septel
816
817         fi
818
819         septel_tools_dir="$septel_root"
820         septel_include_dir="$septel_root/INC"
821         DEF="-DHAVE_SEPTEL_API"
822
823         ac_cv_lbl_septel_api=no
824         if test -r "$septel_include_dir/msg.h"; then
825                 V_INCLS="$V_INCLS -I$septel_include_dir"
826                 V_DEFS="$V_DEFS $DEF"
827                 V_LIBS="$V_LIBS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o "
828
829                 if test "$V_PCAP" != septel ; then
830                          SSRC="pcap-septel.c"
831
832                 fi
833                 ac_cv_lbl_septel_api=yes
834         fi
835
836         AC_MSG_RESULT($ac_cv_lbl_septel_api)
837         if test $ac_cv_lbl_septel_api = no; then
838                 if test "$want_septel" = yes; then
839                         AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel)
840                 fi
841         else
842                 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API])
843         fi
844 fi
845
846 if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
847         AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
848 fi
849
850
851 AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
852 if test "$V_LEX" = lex ; then
853 # Some versions of lex can't handle the definitions section of scanner.l .
854 # Try lexing it and complain if it can't deal.
855         AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
856                 if lex -t scanner.l > /dev/null 2>&1; then
857                         tcpdump_cv_capable_lex=yes
858                 else
859                         tcpdump_cv_capable_lex=insufficient
860                 fi)
861         if test $tcpdump_cv_capable_lex = insufficient ; then
862                 AC_MSG_ERROR([Your operating system's lex is insufficient to compile
863  libpcap.  flex is a lex replacement that has many advantages, including
864  being able to compile libpcap.  For more information, see
865  http://www.gnu.org/software/flex/flex.html .])
866         fi
867 fi
868
869 #
870 # Assume a.out/ELF convention for shared library names (".so"), and
871 # V7/BSD convention for man pages (file formats in section 5,
872 # miscellaneous info in section 7).
873 #
874 DYEXT="so"
875 MAN_FILE_FORMATS=5
876 MAN_MISC_INFO=7
877 case "$host_os" in
878
879 aix*)
880         dnl Workaround to enable certain features
881         AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
882
883         # We need "-lodm" and "-lcfg", as libpcap requires them on
884         # AIX.
885         DEPLIBS="-lodm -lcfg"
886         ;;
887
888 darwin*)
889         DYEXT="dylib"
890         V_CCOPT="$V_CCOPT -fno-common"
891         ;;
892
893 hpux9*)
894         AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
895
896         #
897         # Use System V conventions for man pages.
898         #
899         MAN_FILE_FORMATS=4
900         MAN_MISC_INFO=5
901         ;;
902
903 hpux10.0*)
904
905         #
906         # Use System V conventions for man pages.
907         #
908         MAN_FILE_FORMATS=4
909         MAN_MISC_INFO=5
910         ;;
911
912 hpux10.1*)
913
914         #
915         # Use System V conventions for man pages.
916         #
917         MAN_FILE_FORMATS=4
918         MAN_MISC_INFO=5
919         ;;
920
921 hpux*)
922         dnl HPUX 10.20 and above is similar to HPUX 9, but
923         dnl not the same....
924         dnl
925         dnl XXX - DYEXT should be set to "sl" if this is building
926         dnl for 32-bit PA-RISC, but should be left as "so" for
927         dnl 64-bit PA-RISC or, I suspect, IA-64.
928         AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
929
930         #
931         # Use System V conventions for man pages.
932         #
933         MAN_FILE_FORMATS=4
934         MAN_MISC_INFO=5
935         ;;
936
937 irix*)
938         #
939         # Use System V conventions for man pages.
940         #
941         MAN_FILE_FORMATS=4
942         MAN_MISC_INFO=5
943         ;;
944
945 linux*)
946         V_CCOPT="$V_CCOPT -fPIC"
947         ;;
948
949 osf*)
950         #
951         # Use System V conventions for man pages.
952         #
953         MAN_FILE_FORMATS=4
954         MAN_MISC_INFO=5
955         ;;
956
957 sinix*)
958         AC_MSG_CHECKING(if SINIX compiler defines sinix)
959         AC_CACHE_VAL(ac_cv_cc_sinix_defined,
960                 AC_TRY_COMPILE(
961                     [],
962                     [int i = sinix;],
963                     ac_cv_cc_sinix_defined=yes,
964                     ac_cv_cc_sinix_defined=no))
965             AC_MSG_RESULT($ac_cv_cc_sinix_defined)
966             if test $ac_cv_cc_sinix_defined = no ; then
967                     AC_DEFINE(sinix,1,[on sinix])
968             fi
969         ;;
970
971 solaris*)
972         AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
973
974         #
975         # Use System V conventions for man pages.
976         #
977         MAN_FILE_FORMATS=4
978         MAN_MISC_INFO=5
979         ;;
980 esac
981
982 AC_PROG_RANLIB
983
984 AC_LBL_DEVEL(V_CCOPT)
985
986 AC_LBL_SOCKADDR_SA_LEN
987
988 AC_LBL_SOCKADDR_STORAGE
989
990 AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
991
992 AC_LBL_UNALIGNED_ACCESS
993
994 #
995 # Makefile.in includes rules to generate version.h, so we assume
996 # that it will be generated if autoconf is used.
997 #
998 AC_DEFINE(HAVE_VERSION_H, 1, [define if version.h is generated in the build procedure])
999
1000 rm -f net
1001 ln -s ${srcdir}/bpf/net net
1002
1003 AC_SUBST(V_CCOPT)
1004 AC_SUBST(V_DEFS)
1005 AC_SUBST(V_INCLS)
1006 AC_SUBST(V_LIBS)
1007 AC_SUBST(V_LEX)
1008 AC_SUBST(V_PCAP)
1009 AC_SUBST(V_FINDALLDEVS)
1010 AC_SUBST(V_YACC)
1011 AC_SUBST(SSRC)
1012 AC_SUBST(DYEXT)
1013 AC_SUBST(DAGLIBS)
1014 AC_SUBST(DEPLIBS)
1015 AC_SUBST(MAN_FILE_FORMATS)
1016 AC_SUBST(MAN_MISC_INFO)
1017
1018 dnl check for USB sniffing support
1019 AC_MSG_CHECKING(for USB sniffing support)
1020 case "$host_os" in
1021 linux*)
1022        AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1023        USB_SRC=pcap-usb-linux.c
1024        AC_MSG_RESULT(yes)
1025        ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1026        if test $? -ne 0 ; then
1027                ac_usb_dev_name="usbmon"
1028        fi
1029        AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1030        AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1031        ;;
1032 *)
1033        AC_MSG_RESULT(no)
1034        ;;
1035 esac
1036 AC_SUBST(PCAP_SUPPORT_USB)
1037 AC_SUBST(USB_SRC)
1038
1039 dnl check for bluetooth sniffing support
1040 case "$host_os" in
1041 linux*)
1042        AC_CHECK_HEADER(bluetooth/bluetooth.h,
1043         [
1044           AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
1045           BT_SRC=pcap-bt-linux.c
1046           AC_MSG_NOTICE(Bluetooth sniffing is supported)
1047         ],
1048         AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1049        )
1050        ;;
1051 *)
1052        AC_MSG_NOTICE(no Bluetooth sniffing support)
1053        ;;
1054 esac
1055 AC_SUBST(PCAP_SUPPORT_BT)
1056 AC_SUBST(BT_SRC)
1057
1058 AC_PROG_INSTALL
1059
1060 AC_CONFIG_HEADER(config.h)
1061
1062 AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
1063         pcap-savefile.manfile pcap.3pcap pcap_compile.3pcap
1064         pcap_datalink.3pcap pcap_dump_open.3pcap
1065         pcap_list_datalinks.3pcap pcap_open_dead.3pcap
1066         pcap_open_offline.3pcap)
1067
1068 if test -f .devel ; then
1069         make depend
1070 fi
1071 exit 0