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