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