]> The Tcpdump Group git mirrors - libpcap/blob - configure.in
Merge pull request #358 from bonsaiviking/config-packet-ring
[libpcap] / configure.in
1 dnl
2 dnl Copyright (c) 1994, 1995, 1996, 1997
3 dnl The Regents of the University of California. All rights reserved.
4 dnl
5 dnl Process this file with autoconf to produce a configure script.
6 dnl
7
8 #
9 # See
10 #
11 # http://ftp.gnu.org/gnu/config/README
12 #
13 # for the URLs to use to fetch new versions of config.guess and
14 # config.sub.
15 #
16
17 AC_PREREQ(2.61)
18 AC_INIT(pcap.c)
19
20 AC_CANONICAL_SYSTEM
21
22 AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
23 AC_PROG_CC
24 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
25 AC_LBL_SHLIBS_INIT
26 AC_LBL_C_INLINE
27 AC_C___ATTRIBUTE__
28 if test "$ac_cv___attribute__" = "yes"; then
29 AC_C___ATTRIBUTE___UNUSED
30 AC_C___ATTRIBUTE___FORMAT
31 fi
32
33 AC_CHECK_HEADERS(sys/bitypes.h)
34
35 AC_CHECK_TYPE([int8_t], ,
36 [AC_DEFINE([int8_t], [signed char],
37 [Define to `signed char' if int8_t not defined.])],
38 [AC_INCLUDES_DEFAULT
39 #ifdef HAVE_SYS_BITYPES_H
40 #include <sys/bitypes.h>
41 #endif])
42 AC_CHECK_TYPE([u_int8_t], ,
43 [AC_DEFINE([u_int8_t], [unsigned char],
44 [Define to `unsigned char' if u_int8_t not defined.])],
45 [AC_INCLUDES_DEFAULT
46 #ifdef HAVE_SYS_BITYPES_H
47 #include <sys/bitypes.h>
48 #endif])
49 AC_CHECK_TYPE([int16_t], ,
50 [AC_DEFINE([int16_t], [short],
51 [Define to `short' if int16_t not defined.])]
52 [AC_INCLUDES_DEFAULT
53 #ifdef HAVE_SYS_BITYPES_H
54 #include <sys/bitypes.h>
55 #endif])
56 AC_CHECK_TYPE([u_int16_t], ,
57 [AC_DEFINE([u_int16_t], [unsigned short],
58 [Define to `unsigned short' if u_int16_t not defined.])],
59 [AC_INCLUDES_DEFAULT
60 #ifdef HAVE_SYS_BITYPES_H
61 #include <sys/bitypes.h>
62 #endif])
63 AC_CHECK_TYPE([int32_t], ,
64 [AC_DEFINE([int32_t], [int],
65 [Define to `int' if int32_t not defined.])],
66 [AC_INCLUDES_DEFAULT
67 #ifdef HAVE_SYS_BITYPES_H
68 #include <sys/bitypes.h>
69 #endif])
70 AC_CHECK_TYPE([u_int32_t], ,
71 [AC_DEFINE([u_int32_t], [unsigned int],
72 [Define to `unsigned int' if u_int32_t not defined.])],
73 [AC_INCLUDES_DEFAULT
74 #ifdef HAVE_SYS_BITYPES_H
75 #include <sys/bitypes.h>
76 #endif])
77 AC_CHECK_TYPE([int64_t], ,
78 [AC_DEFINE([int64_t], [long long],
79 [Define to `long long' if int64_t not defined.])],
80 [AC_INCLUDES_DEFAULT
81 #ifdef HAVE_SYS_BITYPES_H
82 #include <sys/bitypes.h>
83 #endif])
84 AC_CHECK_TYPE([u_int64_t], ,
85 [AC_DEFINE([u_int64_t], [unsigned long long],
86 [Define to `unsigned long long' if u_int64_t not defined.])],
87 [AC_INCLUDES_DEFAULT
88 #ifdef HAVE_SYS_BITYPES_H
89 #include <sys/bitypes.h>
90 #endif])
91
92 #
93 # Try to arrange for large file support.
94 #
95 AC_SYS_LARGEFILE
96 AC_FUNC_FSEEKO
97
98 dnl
99 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
100 dnl include <sys/ioccom.h>, and we were to drop support for older
101 dnl releases without that fix, so that pcap-bpf.c doesn't need to
102 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
103 dnl in "aclocal.m4" uses it, so we would still have to test for it
104 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
105 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
106 dnl
107 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
108 AC_CHECK_HEADERS(linux/types.h)
109 AC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h)
110 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
111 #include <sys/socket.h>
112 #include <net/if.h>])
113 if test "$ac_cv_header_net_pfvar_h" = yes; then
114 #
115 # Check for various PF actions.
116 #
117 AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
118 AC_TRY_COMPILE(
119 [#include <sys/types.h>
120 #include <sys/socket.h>
121 #include <net/if.h>
122 #include <net/pfvar.h>],
123 [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
124 [
125 AC_MSG_RESULT(yes)
126 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
127 [define if net/pfvar.h defines PF_NAT through PF_NORDR])
128 ],
129 AC_MSG_RESULT(no))
130 fi
131 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
132 #include <sys/socket.h>])
133 if test "$ac_cv_header_netinet_if_ether_h" != yes; then
134 #
135 # The simple test didn't work.
136 # Do we need to include <net/if.h> first?
137 # Unset ac_cv_header_netinet_if_ether_h so we don't
138 # treat the previous failure as a cached value and
139 # suppress the next test.
140 #
141 AC_MSG_NOTICE([Rechecking with some additional includes])
142 unset ac_cv_header_netinet_if_ether_h
143 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
144 #include <sys/socket.h>
145 #include <netinet/in.h>
146 struct mbuf;
147 struct rtentry;
148 #include <net/if.h>])
149 fi
150
151 AC_LBL_FIXINCLUDES
152
153 AC_CHECK_FUNCS(strerror strlcpy)
154
155 needsnprintf=no
156 AC_CHECK_FUNCS(vsnprintf snprintf,,
157 [needsnprintf=yes])
158 if test $needsnprintf = yes; then
159 AC_LIBOBJ([snprintf])
160 fi
161
162 #
163 # Do this before checking for ether_hostton(), as it's a
164 # "gethostbyname() -ish function".
165 #
166 AC_LBL_LIBRARY_NET
167
168 #
169 # You are in a twisty little maze of UN*Xes, all different.
170 # Some might not have ether_hostton().
171 # Some might have it, but not declare it in any header file.
172 # Some might have it, but declare it in <netinet/if_ether.h>.
173 # Some might have it, but declare it in <netinet/ether.h>
174 # (And some might have it but document it as something declared in
175 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
176 #
177 # Before you is a C compiler.
178 #
179 AC_CHECK_FUNCS(ether_hostton)
180 if test "$ac_cv_func_ether_hostton" = yes; then
181 #
182 # OK, we have ether_hostton(). Do we have <netinet/if_ether.h>?
183 #
184 if test "$ac_cv_header_netinet_if_ether_h" = yes; then
185 #
186 # Yes. Does it declare ether_hostton()?
187 #
188 AC_CHECK_DECL(ether_hostton,
189 [
190 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
191 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
192 ],,
193 [
194 #include <sys/types.h>
195 #include <sys/socket.h>
196 #include <netinet/in.h>
197 #include <arpa/inet.h>
198 struct mbuf;
199 struct rtentry;
200 #include <net/if.h>
201 #include <netinet/if_ether.h>
202 ])
203 fi
204 #
205 # Did that succeed?
206 #
207 if test "$ac_cv_have_decl_ether_hostton" != yes; then
208 #
209 # No, how about <netinet/ether.h>, as on Linux?
210 #
211 AC_CHECK_HEADERS(netinet/ether.h)
212 if test "$ac_cv_header_netinet_ether_h" = yes; then
213 #
214 # We have it - does it declare ether_hostton()?
215 # Unset ac_cv_have_decl_ether_hostton so we don't
216 # treat the previous failure as a cached value and
217 # suppress the next test.
218 #
219 unset ac_cv_have_decl_ether_hostton
220 AC_CHECK_DECL(ether_hostton,
221 [
222 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
223 [Define to 1 if netinet/ether.h declares `ether_hostton'])
224 ],,
225 [
226 #include <netinet/ether.h>
227 ])
228 fi
229 fi
230 #
231 # Is ether_hostton() declared?
232 #
233 if test "$ac_cv_have_decl_ether_hostton" != yes; then
234 #
235 # No, we'll have to declare it ourselves.
236 # Do we have "struct ether_addr"?
237 #
238 AC_CHECK_TYPES(struct ether_addr,,,
239 [
240 #include <sys/types.h>
241 #include <sys/socket.h>
242 #include <netinet/in.h>
243 #include <arpa/inet.h>
244 struct mbuf;
245 struct rtentry;
246 #include <net/if.h>
247 #include <netinet/if_ether.h>
248 ])
249 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 0,
250 [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
251 don't.])
252 else
253 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
254 [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
255 don't.])
256 fi
257 fi
258
259 dnl to pacify those who hate protochain insn
260 AC_MSG_CHECKING(if --disable-protochain option is specified)
261 AC_ARG_ENABLE(protochain,
262 AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
263 case "x$enable_protochain" in
264 xyes) enable_protochain=enabled ;;
265 xno) enable_protochain=disabled ;;
266 x) enable_protochain=enabled ;;
267 esac
268
269 if test "$enable_protochain" = "disabled"; then
270 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
271 fi
272 AC_MSG_RESULT(${enable_protochain})
273
274 #
275 # SITA support is mutually exclusive with native capture support;
276 # "--with-sita" selects SITA support.
277 #
278 AC_ARG_WITH(sita,
279 AC_HELP_STRING([--with-sita],[include SITA support]),
280 [
281 if test ! "x$withval" = "xno" ; then
282 AC_DEFINE(SITA,1,[include ACN support])
283 AC_MSG_NOTICE(Enabling SITA ACN support)
284 V_PCAP=sita
285 V_FINDALLDEVS=sita
286 fi
287 ],
288 [
289 dnl
290 dnl Not all versions of test support -c (character special) but it's a
291 dnl better way of testing since the device might be protected. So we
292 dnl check in our normal order using -r and then check the for the /dev
293 dnl guys again using -c.
294 dnl
295 dnl XXX This could be done for cross-compiling, but for now it's not.
296 dnl
297 if test -z "$with_pcap" && test "$cross_compiling" = yes; then
298 AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...)
299 fi
300 AC_ARG_WITH(pcap,
301 AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
302 AC_MSG_CHECKING(packet capture type)
303 if test ! -z "$with_pcap" ; then
304 V_PCAP="$withval"
305 elif test -r /dev/bpf -o -h /dev/bpf ; then
306 #
307 # Cloning BPF device.
308 #
309 V_PCAP=bpf
310 AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
311 elif test -r /dev/bpf0 ; then
312 V_PCAP=bpf
313 elif test -r /usr/include/net/pfilt.h ; then
314 V_PCAP=pf
315 elif test -r /dev/enet ; then
316 V_PCAP=enet
317 elif test -r /dev/nit ; then
318 V_PCAP=snit
319 elif test -r /usr/include/sys/net/nit.h ; then
320 V_PCAP=nit
321 elif test -r /usr/include/linux/socket.h ; then
322 V_PCAP=linux
323 elif test -r /usr/include/net/raw.h ; then
324 V_PCAP=snoop
325 elif test -r /usr/include/odmi.h ; then
326 #
327 # On AIX, the BPF devices might not yet be present - they're
328 # created the first time libpcap runs after booting.
329 # We check for odmi.h instead.
330 #
331 V_PCAP=bpf
332 elif test -c /dev/bpf0 ; then # check again in case not readable
333 V_PCAP=bpf
334 elif test -r /usr/include/sys/dlpi.h ; then
335 V_PCAP=dlpi
336 elif test -c /dev/enet ; then # check again in case not readable
337 V_PCAP=enet
338 elif test -c /dev/nit ; then # check again in case not readable
339 V_PCAP=snit
340 else
341 V_PCAP=null
342 fi
343 AC_MSG_RESULT($V_PCAP)
344
345 #
346 # Do capture-mechanism-dependent tests.
347 #
348 case "$V_PCAP" in
349 dlpi)
350 #
351 # Needed for common functions used by pcap-[dlpi,libdlpi].c
352 #
353 SSRC="dlpisubs.c"
354
355 #
356 # Checks for some header files.
357 #
358 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
359
360 #
361 # Checks to see if Solaris has the public libdlpi(3LIB) library.
362 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
363 # public libdlpi(3LIB) version. Before libdlpi was made public, a
364 # private version also existed, which did not have the same APIs.
365 # Due to a gcc bug, the default search path for 32-bit libraries does
366 # not include /lib, we add it explicitly here.
367 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
368 # Also, due to the bug above applications that link to libpcap with
369 # libdlpi will have to add "-L/lib" option to "configure".
370 #
371 saved_ldflags=$LDFLAGS
372 LDFLAGS="$LIBS -L/lib"
373 AC_CHECK_LIB(dlpi, dlpi_walk,
374 [
375 LIBS="-ldlpi $LIBS"
376 V_PCAP=libdlpi
377 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
378 ],
379 V_PCAP=dlpi)
380 LDFLAGS=$saved_ldflags
381
382 #
383 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
384 # versions of DLPI.
385 #
386 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
387 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
388 AC_TRY_COMPILE(
389 [
390 #include <sys/types.h>
391 #include <sys/time.h>
392 #include <sys/dlpi.h>
393 ],
394 [int i = DL_PROMISC_PHYS;],
395 ac_cv_sys_dlpi_usable=yes,
396 ac_cv_sys_dlpi_usable=no))
397 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
398 if test $ac_cv_sys_dlpi_usable = no ; then
399 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
400 fi
401
402 #
403 # Check whether we have a /dev/dlpi device or have multiple devices.
404 #
405 AC_MSG_CHECKING(for /dev/dlpi device)
406 if test -c /dev/dlpi ; then
407 AC_MSG_RESULT(yes)
408 AC_DEFINE(HAVE_DEV_DLPI, 1, [define if you have a /dev/dlpi])
409 else
410 AC_MSG_RESULT(no)
411 dir="/dev/dlpi"
412 AC_MSG_CHECKING(for $dir directory)
413 if test -d $dir ; then
414 AC_MSG_RESULT(yes)
415 AC_DEFINE_UNQUOTED(PCAP_DEV_PREFIX, "$dir", [/dev/dlpi directory])
416 else
417 AC_MSG_RESULT(no)
418 fi
419 fi
420
421 #
422 # This check is for Solaris with DLPI support for passive modes.
423 # See dlpi(7P) for more details.
424 #
425 AC_LBL_DL_PASSIVE_REQ_T
426 ;;
427
428 linux)
429 #
430 # Do we have the wireless extensions?
431 #
432 AC_CHECK_HEADERS(linux/wireless.h, [], [],
433 [
434 #include <sys/socket.h>
435 #include <linux/if.h>
436 #include <linux/types.h>
437 ])
438
439 #
440 # Do we have libnl?
441 #
442 AC_ARG_WITH(libnl,
443 AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
444 with_libnl=$withval,,)
445
446 if test x$with_libnl != xno ; then
447 have_any_nl="no"
448
449 #
450 # Try libnl 3.x first.
451 #
452 AC_CHECK_LIB(nl-3, nl_socket_alloc,
453 [
454 #
455 # Yes, we have libnl 3.x.
456 #
457 LIBS="-lnl-genl-3 -lnl-3 $LIBS"
458 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
459 AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
460 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
461 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
462 V_INCLS="$V_INCLS -I/usr/include/libnl3"
463 have_any_nl="yes"
464 ])
465
466 if test x$have_any_nl = xno ; then
467 #
468 # Try libnl 2.x
469 #
470 AC_CHECK_LIB(nl, nl_socket_alloc,
471 [
472 #
473 # Yes, we have libnl 2.x.
474 #
475 LIBS="-lnl-genl -lnl $LIBS"
476 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
477 AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
478 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
479 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
480 have_any_nl="yes"
481 ])
482 fi
483
484 if test x$have_any_nl = xno ; then
485 #
486 # No, we don't; do we have libnl 1.x?
487 #
488 AC_CHECK_LIB(nl, nl_handle_alloc,
489 [
490 #
491 # Yes.
492 #
493 LIBS="-lnl $LIBS"
494 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
495 have_any_nl="yes"
496 ])
497 fi
498
499 if test x$have_any_nl = xno ; then
500 #
501 # No, we don't have libnl at all.
502 #
503 if test x$with_libnl = xyes ; then
504 AC_MSG_ERROR([libnl support requested but libnl not found])
505 fi
506 fi
507 fi
508
509 AC_CHECK_HEADERS(linux/ethtool.h,,,
510 [
511 AC_INCLUDES_DEFAULT
512 #include <linux/types.h>
513 ])
514 AC_LBL_TPACKET_STATS
515 AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
516 ;;
517
518 bpf)
519 #
520 # Check whether we have the *BSD-style ioctls.
521 #
522 AC_CHECK_HEADERS(net/if_media.h)
523
524 AC_MSG_CHECKING(whether the system supports zerocopy BPF)
525 AC_TRY_COMPILE(
526 [#include <sys/socket.h>
527 #include <sys/ioctl.h>
528 #include <net/if.h>
529 #include <net/bpf.h>],
530 [return (BIOCROTZBUF + BPF_BUFMODE_ZBUF);],
531 [
532 AC_MSG_RESULT(yes)
533 AC_DEFINE(HAVE_ZEROCOPY_BPF, 1,
534 [define if the system supports zerocopy BPF])
535 ],
536 AC_MSG_RESULT(no))
537
538 #
539 # Check whether we have struct BPF_TIMEVAL.
540 #
541 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
542 [
543 #include <sys/types.h>
544 #include <sys/ioctl.h>
545 #ifdef HAVE_SYS_IOCCOM_H
546 #include <sys/ioccom.h>
547 #endif
548 #include <net/bpf.h>
549 ])
550 ;;
551
552 dag)
553 V_DEFS="$V_DEFS -DDAG_ONLY"
554 ;;
555
556 septel)
557 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
558 ;;
559
560 snf)
561 V_DEFS="$V_DEFS -DSNF_ONLY"
562 ;;
563
564 null)
565 AC_MSG_WARN(cannot determine packet capture interface)
566 AC_MSG_WARN((see the INSTALL doc for more info))
567 ;;
568 esac
569
570 dnl
571 dnl Now figure out how we get a list of interfaces and addresses,
572 dnl if we support capturing. Don't bother if we don't support
573 dnl capturing.
574 dnl
575 if test "$V_PCAP" = null
576 then
577 #
578 # We can't capture, so we can't open any capture
579 # devices, so we won't return any interfaces.
580 #
581 V_FINDALLDEVS=null
582 else
583 AC_CHECK_FUNC(getifaddrs,[
584 #
585 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
586 # as well, just in case some platform is really weird.
587 #
588 AC_CHECK_HEADER(ifaddrs.h,[
589 #
590 # We have the header, so we use "getifaddrs()" to
591 # get the list of interfaces.
592 #
593 V_FINDALLDEVS=getad
594 ],[
595 #
596 # We don't have the header - give up.
597 # XXX - we could also fall back on some other
598 # mechanism, but, for now, this'll catch this
599 # problem so that we can at least try to figure
600 # out something to do on systems with "getifaddrs()"
601 # but without "ifaddrs.h", if there is something
602 # we can do on those systems.
603 #
604 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
605 ])
606 ],[
607 #
608 # Well, we don't have "getifaddrs()", so we have to use
609 # some other mechanism; determine what that mechanism is.
610 #
611 # The first thing we use is the type of capture mechanism,
612 # which is somewhat of a proxy for the OS we're using.
613 #
614 case "$V_PCAP" in
615
616 dlpi|libdlpi)
617 #
618 # This might be Solaris 8 or later, with
619 # SIOCGLIFCONF, or it might be some other OS
620 # or some older version of Solaris, with
621 # just SIOCGIFCONF.
622 #
623 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
624 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
625 AC_TRY_COMPILE(
626 [#include <sys/param.h>
627 #include <sys/file.h>
628 #include <sys/ioctl.h>
629 #include <sys/socket.h>
630 #include <sys/sockio.h>],
631 [ioctl(0, SIOCGLIFCONF, (char *)0);],
632 ac_cv_lbl_have_siocglifconf=yes,
633 ac_cv_lbl_have_siocglifconf=no))
634 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
635 if test $ac_cv_lbl_have_siocglifconf = yes ; then
636 V_FINDALLDEVS=glifc
637 else
638 V_FINDALLDEVS=gifc
639 fi
640 ;;
641
642 *)
643 #
644 # Assume we just have SIOCGIFCONF.
645 # (XXX - on at least later Linux kernels, there's
646 # another mechanism, and we should be using that
647 # instead.)
648 #
649 V_FINDALLDEVS=gifc
650 ;;
651 esac])
652 fi
653 ])
654
655 AC_MSG_CHECKING(for socklen_t)
656 AC_TRY_COMPILE([
657 #include <sys/types.h>
658 #include <sys/socket.h>
659 ],
660 [ socklen_t x; ],
661 have_socklen_t=yes,
662 have_socklen_t=no)
663 if test "x$have_socklen_t" = "xyes"; then
664 AC_DEFINE(HAVE_SOCKLEN_T, 1, [define if socklen_t is defined])
665 fi
666 AC_MSG_RESULT($have_socklen_t)
667
668 AC_ARG_ENABLE(ipv6,
669 AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@]),
670 [],
671 [enable_ipv6=ifavailable])
672 if test "$enable_ipv6" != "no"; then
673 AC_CHECK_FUNC(getaddrinfo,
674 [
675 AC_DEFINE(INET6,1,[IPv6])
676 ],
677 [
678 if test "$enable_ipv6" != "ifavailable"; then
679 AC_MSG_FAILURE([--enable-ipv6 was given, but getaddrinfo isn't available])
680 fi
681 ])
682 fi
683
684 AC_MSG_CHECKING(whether to build optimizer debugging code)
685 AC_ARG_ENABLE(optimizer-dbg,
686 AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
687 if test "$enable_optimizer_dbg" = "yes"; then
688 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
689 fi
690 AC_MSG_RESULT(${enable_optimizer_dbg-no})
691
692 AC_MSG_CHECKING(whether to build parser debugging code)
693 AC_ARG_ENABLE(yydebug,
694 AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
695 if test "$enable_yydebug" = "yes"; then
696 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
697 fi
698 AC_MSG_RESULT(${enable_yydebug-no})
699
700 # Check for Endace DAG card support.
701 AC_ARG_WITH([dag],
702 AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
703 [
704 if test "$withval" = no
705 then
706 # User doesn't want DAG support.
707 want_dag=no
708 elif test "$withval" = yes
709 then
710 # User wants DAG support but hasn't specified a directory.
711 want_dag=yes
712 else
713 # User wants DAG support and has specified a directory, so use the provided value.
714 want_dag=yes
715 dag_root=$withval
716 fi
717 ],[
718 #
719 # Use DAG API if present, otherwise don't
720 #
721 want_dag=ifpresent
722 ])
723
724 AC_ARG_WITH([dag-includes],
725 AC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
726 [
727 # User wants DAG support and has specified a header directory, so use the provided value.
728 want_dag=yes
729 dag_include_dir=$withval
730 ],[])
731
732 AC_ARG_WITH([dag-libraries],
733 AC_HELP_STRING([--with-dag-libraries=DIR],[Endace DAG library directory]),
734 [
735 # User wants DAG support and has specified a library directory, so use the provided value.
736 want_dag=yes
737 dag_lib_dir=$withval
738 ],[])
739
740 case "$V_PCAP" in
741 linux|bpf|dag)
742 #
743 # We support the DAG API if we're on Linux or BSD, or if we're
744 # building a DAG-only libpcap.
745 #
746 ;;
747 *)
748 #
749 # If the user explicitly requested DAG, tell them it's not
750 # supported.
751 #
752 # If they expressed no preference, don't include it.
753 #
754 if test $want_dag = yes; then
755 AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types])
756 elif test $want_dag = yes; then
757 want_dag=no
758 fi
759 ;;
760 esac
761
762 ac_cv_lbl_dag_api=no
763 if test "$want_dag" != no; then
764
765 AC_MSG_CHECKING([whether we have DAG API headers])
766
767 # If necessary, set default paths for DAG API headers and libraries.
768 if test -z "$dag_root"; then
769 dag_root=/usr/local
770 fi
771
772 if test -z "$dag_include_dir"; then
773 dag_include_dir="$dag_root/include"
774 fi
775
776 if test -z "$dag_lib_dir"; then
777 dag_lib_dir="$dag_root/lib"
778 fi
779
780 if test -z "$dag_tools_dir"; then
781 dag_tools_dir="$dag_root/tools"
782 fi
783
784 if test -r $dag_include_dir/dagapi.h; then
785 ac_cv_lbl_dag_api=yes
786 fi
787 AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
788 fi
789
790 if test $ac_cv_lbl_dag_api = yes; then
791 V_INCLS="$V_INCLS -I$dag_include_dir"
792
793 if test $V_PCAP != dag ; then
794 SSRC="pcap-dag.c"
795 fi
796
797 # See if we can find a general version string.
798 # Don't need to save and restore LIBS to prevent -ldag being
799 # included if there's a found-action (arg 3).
800 saved_ldflags=$LDFLAGS
801 LDFLAGS="-L$dag_lib_dir"
802 AC_CHECK_LIB([dag], [dag_attach_stream], [dag_streams="1"], [dag_streams="0"])
803 AC_CHECK_LIB([dag],[dag_get_erf_types], [
804 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
805 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
806 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
807
808 LDFLAGS=$saved_ldflags
809
810 if test "$dag_streams" = 1; then
811 AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
812 LIBS="$LIBS -ldag"
813 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
814
815 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
816 if test "$ac_dag_have_vdag" = 1; then
817 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
818 LIBS="$LIBS -lpthread"
819 fi
820 fi
821
822 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
823 fi
824
825 AC_MSG_CHECKING(whether we have the DAG API)
826
827 if test $ac_cv_lbl_dag_api = no; then
828 AC_MSG_RESULT(no)
829 if test "$want_dag" = yes; then
830 # User wanted DAG support but we couldn't find it.
831 AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag])
832 fi
833
834 if test "$V_PCAP" = dag; then
835 # User requested "dag" capture type but the DAG API wasn't
836 # found.
837 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.)])
838 fi
839 else
840 AC_MSG_RESULT(yes)
841 fi
842
843 AC_ARG_WITH(septel,
844 AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, on Linux, if present@:>@]),
845 [
846 if test "$withval" = no
847 then
848 want_septel=no
849 elif test "$withval" = yes
850 then
851 want_septel=yes
852 septel_root=
853 else
854 want_septel=yes
855 septel_root=$withval
856 fi
857 ],[
858 #
859 # Use Septel API if present, otherwise don't
860 #
861 want_septel=ifpresent
862 septel_root=./../septel
863 ])
864 ac_cv_lbl_septel_api=no
865 case "$V_PCAP" in
866 linux|septel)
867 #
868 # We support the Septel API if we're on Linux, or if we're building
869 # a Septel-only libpcap.
870 #
871 ;;
872 *)
873 #
874 # If the user explicitly requested Septel, tell them it's not
875 # supported.
876 #
877 # If they expressed no preference, don't include it.
878 #
879 if test $want_septel = yes; then
880 AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types)
881 elif test $want_septel = yes; then
882 want_septel=no
883 fi
884 ;;
885 esac
886
887 if test "$with_septel" != no; then
888 AC_MSG_CHECKING(whether we have Septel API)
889
890 if test -z "$septel_root"; then
891 septel_root=$srcdir/../septel
892 fi
893
894 septel_tools_dir="$septel_root"
895 septel_include_dir="$septel_root/INC"
896
897 ac_cv_lbl_septel_api=no
898 if test -r "$septel_include_dir/msg.h"; then
899 V_INCLS="$V_INCLS -I$septel_include_dir"
900 ADDLOBJS="$ADDLOBJS $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"
901 ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $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"
902
903 if test "$V_PCAP" != septel ; then
904 SSRC="pcap-septel.c"
905 fi
906 ac_cv_lbl_septel_api=yes
907 fi
908
909 AC_MSG_RESULT($ac_cv_lbl_septel_api)
910 if test $ac_cv_lbl_septel_api = no; then
911 if test "$want_septel" = yes; then
912 AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel)
913 fi
914 else
915 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API])
916 fi
917 fi
918
919 if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
920 AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
921 fi
922
923 # Check for Myricom SNF support.
924 AC_ARG_WITH([snf],
925 AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
926 [
927 if test "$withval" = no
928 then
929 # User explicitly doesn't want SNF
930 want_snf=no
931 elif test "$withval" = yes
932 then
933 # User wants SNF support but hasn't specific a directory.
934 want_snf=yes
935 else
936 # User wants SNF support with a specified directory.
937 want_snf=yes
938 snf_root=$withval
939 fi
940 ],[
941 #
942 # Use Sniffer API if present, otherwise don't
943 #
944 want_snf=ifpresent
945 ])
946
947 AC_ARG_WITH([snf-includes],
948 AC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
949 [
950 # User wants SNF with specific header directory
951 want_snf=yes
952 snf_include_dir=$withval
953 ],[])
954
955 AC_ARG_WITH([snf-libraries],
956 AC_HELP_STRING([--with-snf-libraries=DIR],[Myricom SNF library directory]),
957 [
958 # User wants SNF with specific lib directory
959 want_snf=yes
960 snf_lib_dir=$withval
961 ],[])
962
963 case "$V_PCAP" in
964 bpf|linux|snf)
965 #
966 # We support the Sniffer API if we're on BSD, Linux, or if we're
967 # building a Sniffer-only libpcap.
968 #
969 ;;
970 *)
971 #
972 # If the user explicitly requested Sniffer, tell them it's not
973 # supported.
974 #
975 # If they expressed no preference, don't include it.
976 #
977 if test $want_snf = yes; then
978 AC_MSG_ERROR(Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types)
979 elif test $want_snf = yes; then
980 want_snf=no
981 fi
982 ;;
983 esac
984
985 ac_cv_lbl_snf_api=no
986 if test "$with_snf" != no; then
987
988 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
989
990 if test -z "$snf_root"; then
991 snf_root=/opt/snf
992 fi
993
994 if test -z "$snf_include_dir"; then
995 snf_include_dir="$snf_root/include"
996 fi
997
998 if test -z "$snf_lib_dir"; then
999 snf_lib_dir="$snf_root/lib"
1000 fi
1001
1002 if test -f "$snf_include_dir/snf.h"; then
1003 ac_cv_lbl_snf_api=yes
1004 fi
1005 AC_MSG_RESULT([$ac_cv_lbl_snf_api ($snf_root)])
1006
1007 if test $ac_cv_lbl_snf_api = no; then
1008 if test "$want_snf" = yes; then
1009 AC_MSG_ERROR(SNF API headers not found under $snf_include_dir; use --without-snf)
1010 fi
1011 else
1012 saved_ldflags=$LDFLAGS
1013 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1014 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"], [ac_cv_lbl_snf_api="no"])
1015 LDFLAGS="$saved_ldflags"
1016
1017 if test $ac_cv_lbl_snf_api = no; then
1018 if test "$want_snf" = yes; then
1019 AC_MSG_ERROR(SNF API cannot correctly be linked check config.log; use --without-snf)
1020 fi
1021 else
1022 V_INCLS="$V_INCLS -I$snf_include_dir"
1023 LIBS="$LIBS -lsnf"
1024 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1025 if test "$V_PCAP" != snf ; then
1026 SSRC="pcap-snf.c"
1027 fi
1028 AC_DEFINE(HAVE_SNF_API, 1, [define if you have Myricom SNF API])
1029 fi
1030 fi
1031 fi
1032
1033 if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
1034 AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR)
1035 fi
1036
1037 AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
1038 if test "$V_LEX" = lex ; then
1039 # Some versions of lex can't handle the definitions section of scanner.l .
1040 # Try lexing it and complain if it can't deal.
1041 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1042 if lex -t scanner.l > /dev/null 2>&1; then
1043 tcpdump_cv_capable_lex=yes
1044 else
1045 tcpdump_cv_capable_lex=insufficient
1046 fi)
1047 if test $tcpdump_cv_capable_lex = insufficient ; then
1048 AC_MSG_ERROR([Your operating system's lex is insufficient to compile
1049 libpcap. flex is a lex replacement that has many advantages, including
1050 being able to compile libpcap. For more information, see
1051 http://www.gnu.org/software/flex/flex.html .])
1052 fi
1053 fi
1054
1055 #
1056 # Assume, by default, no support for shared libraries and V7/BSD convention
1057 # for man pages (file formats in section 5, miscellaneous info in section 7).
1058 # Individual cases can override this.
1059 #
1060 DYEXT="none"
1061 MAN_FILE_FORMATS=5
1062 MAN_MISC_INFO=7
1063 case "$host_os" in
1064
1065 aix*)
1066 dnl Workaround to enable certain features
1067 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1068
1069 #
1070 # AIX makes it fun to build shared and static libraries,
1071 # because they're *both* ".a" archive libraries. We
1072 # build the static library for the benefit of the traditional
1073 # scheme of building libpcap and tcpdump in subdirectories of
1074 # the same directory, with tcpdump statically linked with the
1075 # libpcap in question, but we also build a shared library as
1076 # "libpcap.shareda" and install *it*, rather than the static
1077 # library, as "libpcap.a".
1078 #
1079 DYEXT="shareda"
1080
1081 case "$V_PCAP" in
1082
1083 dlpi)
1084 #
1085 # If we're using DLPI, applications will need to
1086 # use /lib/pse.exp if present, as we use the
1087 # STREAMS routines.
1088 #
1089 pseexe="/lib/pse.exp"
1090 AC_MSG_CHECKING(for $pseexe)
1091 if test -f $pseexe ; then
1092 AC_MSG_RESULT(yes)
1093 LIBS="-I:$pseexe"
1094 fi
1095 ;;
1096
1097 bpf)
1098 #
1099 # If we're using BPF, we need "-lodm" and "-lcfg", as
1100 # we use them to load the BPF module.
1101 #
1102 LIBS="-lodm -lcfg"
1103 ;;
1104 esac
1105 ;;
1106
1107 darwin*)
1108 DYEXT="dylib"
1109 V_CCOPT="$V_CCOPT -fno-common"
1110 AC_ARG_ENABLE(universal,
1111 AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
1112 if test "$enable_universal" != "no"; then
1113 case "$host_os" in
1114
1115 darwin[0-7].*)
1116 #
1117 # Pre-Tiger. Build only for 32-bit PowerPC; no
1118 # need for any special compiler or linker flags.
1119 #
1120 ;;
1121
1122 darwin8.[0123]*)
1123 #
1124 # Tiger, prior to Intel support. Build for 32-bit
1125 # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
1126 # first. (I'm guessing that's what Apple does.)
1127 #
1128 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
1129 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
1130 ;;
1131
1132 darwin8.[456]*)
1133 #
1134 # Tiger, subsequent to Intel support but prior to
1135 # x86-64 support. Build for 32-bit PowerPC, 64-bit
1136 # PowerPC, and x86, with 32-bit PowerPC first.
1137 # (I'm guessing that's what Apple does.)
1138 #
1139 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
1140 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
1141 ;;
1142
1143 darwin8.*)
1144 #
1145 # All other Tiger, so subsequent to x86-64
1146 # support. Build for 32-bit PowerPC, 64-bit
1147 # PowerPC, x86, and x86-64, and with 32-bit PowerPC
1148 # first. (I'm guessing that's what Apple does.)
1149 #
1150 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1151 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1152 ;;
1153
1154 darwin9.*)
1155 #
1156 # Leopard. Build for 32-bit PowerPC, 64-bit
1157 # PowerPC, x86, and x86-64, with 32-bit PowerPC
1158 # first. (That's what Apple does.)
1159 #
1160 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1161 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1162 ;;
1163
1164 darwin10.*)
1165 #
1166 # Snow Leopard. Build for x86-64, x86, and
1167 # 32-bit PowerPC, with x86-64 first. (That's
1168 # what Apple does, even though Snow Leopard
1169 # doesn't run on PPC, so PPC libpcap runs under
1170 # Rosetta, and Rosetta doesn't support BPF
1171 # ioctls, so PPC programs can't do live
1172 # captures.)
1173 #
1174 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
1175 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
1176 ;;
1177
1178 darwin*)
1179 #
1180 # Post-Snow Leopard. Build for x86-64 and
1181 # x86, with x86-64 first. (That's probably what
1182 # Apple does, given that Rosetta is gone.)
1183 # XXX - update if and when Apple drops support
1184 # for 32-bit x86 code.
1185 #
1186 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
1187 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
1188 ;;
1189 esac
1190 fi
1191 ;;
1192
1193 hpux9*)
1194 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1195
1196 #
1197 # Use System V conventions for man pages.
1198 #
1199 MAN_FILE_FORMATS=4
1200 MAN_MISC_INFO=5
1201 ;;
1202
1203 hpux10.0*)
1204
1205 #
1206 # Use System V conventions for man pages.
1207 #
1208 MAN_FILE_FORMATS=4
1209 MAN_MISC_INFO=5
1210 ;;
1211
1212 hpux10.1*)
1213
1214 #
1215 # Use System V conventions for man pages.
1216 #
1217 MAN_FILE_FORMATS=4
1218 MAN_MISC_INFO=5
1219 ;;
1220
1221 hpux*)
1222 dnl HPUX 10.20 and above is similar to HPUX 9, but
1223 dnl not the same....
1224 dnl
1225 dnl XXX - DYEXT should be set to "sl" if this is building
1226 dnl for 32-bit PA-RISC, but should be left as "so" for
1227 dnl 64-bit PA-RISC or, I suspect, IA-64.
1228 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1229 if test "`uname -m`" = "ia64"; then
1230 DYEXT="so"
1231 else
1232 DYEXT="sl"
1233 fi
1234
1235 #
1236 # "-b" builds a shared library; "+h" sets the soname.
1237 #
1238 SHLIB_OPT="-b"
1239 SONAME_OPT="+h"
1240
1241 #
1242 # Use System V conventions for man pages.
1243 #
1244 MAN_FILE_FORMATS=4
1245 MAN_MISC_INFO=5
1246 ;;
1247
1248 irix*)
1249 #
1250 # Use System V conventions for man pages.
1251 #
1252 MAN_FILE_FORMATS=4
1253 MAN_MISC_INFO=5
1254 ;;
1255
1256 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
1257 DYEXT="so"
1258
1259 #
1260 # Compiler assumed to be GCC; run-time linker may require a -R
1261 # flag.
1262 #
1263 if test "$libdir" != "/usr/lib"; then
1264 V_RFLAGS=-Wl,-R$libdir
1265 fi
1266 ;;
1267
1268 osf*)
1269 DYEXT="so"
1270
1271 #
1272 # Use System V conventions for man pages.
1273 #
1274 MAN_FILE_FORMATS=4
1275 MAN_MISC_INFO=5
1276 ;;
1277
1278 sinix*)
1279 AC_MSG_CHECKING(if SINIX compiler defines sinix)
1280 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
1281 AC_TRY_COMPILE(
1282 [],
1283 [int i = sinix;],
1284 ac_cv_cc_sinix_defined=yes,
1285 ac_cv_cc_sinix_defined=no))
1286 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
1287 if test $ac_cv_cc_sinix_defined = no ; then
1288 AC_DEFINE(sinix,1,[on sinix])
1289 fi
1290 ;;
1291
1292 solaris*)
1293 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1294
1295 DYEXT="so"
1296 #
1297 # Use System V conventions for man pages.
1298 #
1299 MAN_FILE_FORMATS=4
1300 MAN_MISC_INFO=5
1301 ;;
1302 esac
1303
1304 AC_ARG_ENABLE(shared,
1305 AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1306 test "x$enable_shared" = "xno" && DYEXT="none"
1307
1308 AC_PROG_RANLIB
1309 AC_CHECK_TOOL([AR], [ar])
1310
1311 AC_PROG_LN_S
1312 AC_SUBST(LN_S)
1313
1314 AC_LBL_DEVEL(V_CCOPT)
1315
1316 AC_LBL_SOCKADDR_SA_LEN
1317
1318 AC_LBL_SOCKADDR_STORAGE
1319
1320 AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
1321
1322 AC_LBL_UNALIGNED_ACCESS
1323
1324 #
1325 # Makefile.in includes rules to generate version.h, so we assume
1326 # that it will be generated if autoconf is used.
1327 #
1328 AC_DEFINE(HAVE_VERSION_H, 1, [define if version.h is generated in the build procedure])
1329
1330 rm -f net
1331 ln -s ${srcdir}/bpf/net net
1332
1333 AC_SUBST(V_CCOPT)
1334 AC_SUBST(V_DEFS)
1335 AC_SUBST(V_FINDALLDEVS)
1336 AC_SUBST(V_INCLS)
1337 AC_SUBST(V_LEX)
1338 AC_SUBST(V_PCAP)
1339 AC_SUBST(V_SHLIB_CMD)
1340 AC_SUBST(V_SHLIB_OPT)
1341 AC_SUBST(V_SONAME_OPT)
1342 AC_SUBST(V_RPATH_OPT)
1343 AC_SUBST(V_YACC)
1344 AC_SUBST(ADDLOBJS)
1345 AC_SUBST(ADDLARCHIVEOBJS)
1346 AC_SUBST(SSRC)
1347 AC_SUBST(DYEXT)
1348 AC_SUBST(MAN_FILE_FORMATS)
1349 AC_SUBST(MAN_MISC_INFO)
1350
1351 AC_ARG_ENABLE([usb],
1352 [AC_HELP_STRING([--enable-usb],[enable nusb support @<:@default=yes, if support available@:>@])],
1353 [],
1354 [enable_usb=yes])
1355
1356 if test "x$enable_usb" != "xno" ; then
1357 dnl check for USB sniffing support
1358 AC_MSG_CHECKING(for USB sniffing support)
1359 case "$host_os" in
1360 linux*)
1361 AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1362 USB_SRC=pcap-usb-linux.c
1363 AC_MSG_RESULT(yes)
1364 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1365 if test $? -ne 0 ; then
1366 ac_usb_dev_name="usbmon"
1367 fi
1368 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1369 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1370 #
1371 # Do we have a version of <linux/compiler.h> available?
1372 # If so, we might need it for <linux/usbdevice_fs.h>.
1373 #
1374 AC_CHECK_HEADERS(linux/compiler.h)
1375 if test "$ac_cv_header_linux_compiler_h" = yes; then
1376 #
1377 # Yes - include it when testing for <linux/usbdevice_fs.h>.
1378 #
1379 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
1380 else
1381 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
1382 fi
1383 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
1384 #
1385 # OK, does it define bRequestType? Older versions of the kernel
1386 # define fields with names like "requesttype, "request", and
1387 # "value", rather than "bRequestType", "bRequest", and
1388 # "wValue".
1389 #
1390 AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member)
1391 AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType,
1392 AC_TRY_COMPILE([
1393 AC_INCLUDES_DEFAULT
1394 #ifdef HAVE_SYS_BITYPES_H
1395 #include <sys/bitypes.h>
1396 #endif
1397 #ifdef HAVE_LINUX_COMPILER_H
1398 #include <linux/compiler.h>
1399 #endif
1400 #include <linux/usbdevice_fs.h>],
1401 [u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)],
1402 ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes,
1403 ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no))
1404 AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType)
1405 if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then
1406 AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1,
1407 [if struct usbdevfs_ctrltransfer has bRequestType])
1408 fi
1409 fi
1410 ;;
1411 *)
1412 AC_MSG_RESULT(no)
1413 ;;
1414 esac
1415 fi
1416 AC_SUBST(PCAP_SUPPORT_USB)
1417 AC_SUBST(USB_SRC)
1418
1419 dnl check for netfilter sniffing support
1420 AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
1421 case "$host_os" in
1422 linux*)
1423 AC_MSG_RESULT(yes)
1424 #
1425 # Life's too short to deal with trying to get this to compile
1426 # if you don't get the right types defined with
1427 # __KERNEL_STRICT_NAMES getting defined by some other include.
1428 #
1429 # Check whether the includes Just Work. If not, don't turn on
1430 # netfilter support.
1431 #
1432 AC_MSG_CHECKING(whether we can compile the netfilter support)
1433 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
1434 AC_TRY_COMPILE([
1435 AC_INCLUDES_DEFAULT
1436 #include <sys/socket.h>
1437 #include <netinet/in.h>
1438 #include <linux/types.h>
1439
1440 #include <linux/netlink.h>
1441 #include <linux/netfilter.h>
1442 #include <linux/netfilter/nfnetlink.h>
1443 #include <linux/netfilter/nfnetlink_log.h>
1444 #include <linux/netfilter/nfnetlink_queue.h>],
1445 [],
1446 ac_cv_netfilter_can_compile=yes,
1447 ac_cv_netfilter_can_compile=no))
1448 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
1449 if test $ac_cv_netfilter_can_compile = yes ; then
1450 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
1451 [target host supports netfilter sniffing])
1452 NETFILTER_SRC=pcap-netfilter-linux.c
1453 fi
1454 ;;
1455 *)
1456 AC_MSG_RESULT(no)
1457 ;;
1458 esac
1459 AC_SUBST(PCAP_SUPPORT_NETFILTER)
1460 AC_SUBST(NETFILTER_SRC)
1461
1462 AC_ARG_ENABLE([bluetooth],
1463 [AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
1464 [],
1465 [enable_bluetooth=ifsupportavailable])
1466
1467 if test "x$enable_bluetooth" != "xno" ; then
1468 dnl check for Bluetooth sniffing support
1469 case "$host_os" in
1470 linux*)
1471 AC_CHECK_HEADER(bluetooth/bluetooth.h,
1472 [
1473 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
1474 BT_SRC=pcap-bt-linux.c
1475 AC_MSG_NOTICE(Bluetooth sniffing is supported)
1476
1477 #
1478 # OK, does struct sockaddr_hci have an hci_channel
1479 # member?
1480 #
1481 AC_MSG_CHECKING(if struct sockaddr_hci has hci_channel member)
1482 AC_CACHE_VAL(ac_cv_lbl_sockaddr_hci_has_hci_channel,
1483 AC_TRY_COMPILE(
1484 [
1485 #include <bluetooth/bluetooth.h>
1486 #include <bluetooth/hci.h>
1487 ],
1488 [u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel)],
1489 ac_cv_lbl_sockaddr_hci_has_hci_channel=yes,
1490 ac_cv_lbl_sockaddr_hci_has_hci_channel=no))
1491 AC_MSG_RESULT($ac_cv_lbl_sockaddr_hci_has_hci_channel)
1492 if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then
1493 AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,,
1494 [if struct sockaddr_hci has hci_channel member])
1495
1496 #
1497 # OK, is HCI_CHANNEL_MONITOR defined?
1498 #
1499 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
1500 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
1501 AC_TRY_COMPILE(
1502 [
1503 #include <bluetooth/bluetooth.h>
1504 #include <bluetooth/hci.h>
1505 ],
1506 [u_int i = HCI_CHANNEL_MONITOR],
1507 ac_cv_lbl_hci_channel_monitor_is_defined=yes,
1508 ac_cv_lbl_hci_channel_monitor_is_defined=no))
1509 AC_MSG_RESULT($ac_cv_lbl_hci_channel_monitor_is_defined)
1510 if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then
1511 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
1512 [target host supports Bluetooth Monitor])
1513 BT_MONITOR_SRC=pcap-bt-monitor-linux.c
1514 fi
1515 fi
1516 ac_lbl_bluetooth_available=yes
1517 ],
1518 ac_lbl_bluetooth_available=no
1519 )
1520 if test "x$ac_lbl_bluetooth_available" == "xno" ; then
1521 if test "x$enable_bluetooth" = "xyes" ; then
1522 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1523 else
1524 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1525 fi
1526 fi
1527 ;;
1528 *)
1529 if test "x$enable_bluetooth" = "xyes" ; then
1530 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
1531 else
1532 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
1533 fi
1534 ;;
1535 esac
1536 AC_SUBST(PCAP_SUPPORT_BT)
1537 AC_SUBST(BT_SRC)
1538 AC_SUBST(BT_MONITOR_SRC)
1539 fi
1540
1541 AC_ARG_ENABLE([canusb],
1542 [AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])],
1543 [],
1544 [enable_canusb=ifsupportavailable])
1545
1546 if test "x$enable_canusb" != "xno" ; then
1547 dnl check for canusb support
1548 case "$host_os" in
1549 linux*)
1550 AC_CHECK_HEADER(libusb-1.0/libusb.h,
1551 [
1552 AC_CHECK_LIB(usb-1.0, libusb_init,
1553 [
1554 AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb])
1555 CANUSB_SRC=pcap-canusb-linux.c
1556 LIBS="-lusb-1.0 -lpthread $LIBS"
1557 ac_lbl_has_libusb=yes
1558 ],
1559 ac_lbl_has_libusb=no
1560 )
1561 ],
1562 ac_lbl_has_libusb=no
1563 )
1564 if test "x$ac_lbl_has_libusb" = "xyes" ; then
1565 AC_MSG_NOTICE(canusb sniffing is supported)
1566 else
1567 if test "x$enable_canusb" = "xyes" ; then
1568 AC_MSG_ERROR(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
1569 else
1570 AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
1571 fi
1572 fi
1573 ;;
1574 *)
1575 if test "x$enable_canusb" = "xyes" ; then
1576 AC_MSG_ERROR(no canusb support implemented for $host_os)
1577 else
1578 AC_MSG_NOTICE(no canusb support implemented for $host_os)
1579 fi
1580 ;;
1581 esac
1582 AC_SUBST(PCAP_SUPPORT_CANUSB)
1583 AC_SUBST(CANUSB_SRC)
1584 fi
1585
1586 AC_ARG_ENABLE([can],
1587 [AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])],
1588 [],
1589 [enable_can=ifsupportavailable])
1590
1591 if test "x$enable_can" != "xno" ; then
1592 dnl check for CAN sniffing support
1593 case "$host_os" in
1594 linux*)
1595 AC_CHECK_HEADER(linux/can.h,
1596 [
1597 AC_DEFINE(PCAP_SUPPORT_CAN, 1, [target host supports CAN sniffing])
1598 CAN_SRC=pcap-can-linux.c
1599 AC_MSG_NOTICE(CAN sniffing is supported)
1600 ],
1601 [
1602 if test "x$enable_can" = "xyes" ; then
1603 AC_MSG_ERROR(CAN sniffing is not supported)
1604 else
1605 AC_MSG_NOTICE(CAN sniffing is not supported)
1606 fi
1607 ],
1608 [#include <sys/socket.h>]
1609 )
1610 ;;
1611 *)
1612 if test "x$enable_can" = "xyes" ; then
1613 AC_MSG_ERROR(no CAN sniffing support implemented for $host_os)
1614 else
1615 AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os)
1616 fi
1617 ;;
1618 esac
1619 AC_SUBST(PCAP_SUPPORT_CAN)
1620 AC_SUBST(CAN_SRC)
1621 fi
1622
1623 AC_ARG_ENABLE([dbus],
1624 [AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
1625 [],
1626 [enable_dbus=ifavailable])
1627
1628 if test "x$enable_dbus" != "xno"; then
1629 if test "x$enable_dbus" = "xyes"; then
1630 case "$host_os" in
1631
1632 darwin*)
1633 #
1634 # We don't support D-Bus sniffing on OS X; see
1635 #
1636 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
1637 #
1638 # The user requested it, so fail.
1639 #
1640 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X])
1641 esac
1642 else
1643 case "$host_os" in
1644
1645 darwin*)
1646 #
1647 # We don't support D-Bus sniffing on OS X; see
1648 #
1649 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
1650 #
1651 # The user dind't explicitly request it, so just
1652 # silently refuse to enable it.
1653 #
1654 enable_dbus="no"
1655 ;;
1656 esac
1657 fi
1658 fi
1659
1660 if test "x$enable_dbus" != "xno"; then
1661 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
1662 if test "x$PKGCONFIG" != "xno"; then
1663 AC_MSG_CHECKING([for D-Bus])
1664 if "$PKGCONFIG" dbus-1; then
1665 AC_MSG_RESULT([yes])
1666 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
1667 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
1668 save_CFLAGS="$CFLAGS"
1669 save_LIBS="$LIBS"
1670 CFLAGS="$CFLAGS $DBUS_CFLAGS"
1671 LIBS="$LIBS $DBUS_LIBS"
1672 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
1673 AC_TRY_LINK(
1674 [#include <string.h>
1675
1676 #include <time.h>
1677 #include <sys/time.h>
1678
1679 #include <dbus/dbus.h>],
1680 [return dbus_connection_read_write(NULL, 0);],
1681 [
1682 AC_MSG_RESULT([yes])
1683 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
1684 DBUS_SRC=pcap-dbus.c
1685 V_INCLS="$V_INCLS $DBUS_CFLAGS"
1686 ],
1687 [
1688 AC_MSG_RESULT([no])
1689 if test "x$enable_dbus" = "xyes"; then
1690 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
1691 fi
1692 LIBS="$save_LIBS"
1693 ])
1694 CFLAGS="$save_CFLAGS"
1695 else
1696 AC_MSG_RESULT([no])
1697 if test "x$enable_dbus" = "xyes"; then
1698 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
1699 fi
1700 fi
1701 fi
1702 AC_SUBST(PCAP_SUPPORT_DBUS)
1703 AC_SUBST(DBUS_SRC)
1704 fi
1705
1706 dnl check for hardware timestamp support
1707 case "$host_os" in
1708 linux*)
1709 AC_CHECK_HEADERS([linux/net_tstamp.h])
1710 ;;
1711 *)
1712 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1713 ;;
1714 esac
1715
1716 dnl The packet ring capture facility of Linux, described in
1717 dnl Documentation/networking/packet_mmap.txt, is not 32/64-bit compatible before
1718 dnl version 2.6.27. A 32-bit kernel requires a 32-bit userland, and likewise for
1719 dnl 64-bit. The effect of this is that a 32-bit libpcap binary will not run
1720 dnl correctly on a 64-bit kernel (the binary will use the wrong offsets into a
1721 dnl kernel struct). This problem was solved in Linux 2.6.27. Use
1722 dnl --disable-packet-ring whenever a 32-bit application must run on a 64-bit
1723 dnl target host, and either the build host or the target host run Linux 2.6.26
1724 dnl or earlier.
1725 AC_ARG_ENABLE([packet-ring],
1726 [AC_HELP_STRING([--enable-packet-ring],[enable Linux packet ring support @<:@default=yes@:>@])],
1727 ,enable_packet_ring=yes)
1728
1729 if test "x$enable_packet_ring" != "xno" ; then
1730 AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use Linux packet ring capture if available])
1731 AC_SUBST(PCAP_SUPPORT_PACKET_RING)
1732 fi
1733
1734 AC_PROG_INSTALL
1735
1736 AC_CONFIG_HEADER(config.h)
1737
1738 AC_OUTPUT_COMMANDS([if test -f .devel; then
1739 echo timestamp > stamp-h
1740 cat Makefile-devel-adds >> Makefile
1741 make depend
1742 fi])
1743 AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
1744 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
1745 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
1746 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
1747 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
1748 pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap
1749 pcap_set_tstamp_type.3pcap)
1750 exit 0