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