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