]> The Tcpdump Group git mirrors - libpcap/blob - configure.ac
Make sure asprintf() is declared if it's present.
[libpcap] / configure.ac
1 dnl
2 dnl Copyright (c) 1994, 1995, 1996, 1997
3 dnl The Regents of the University of California. All rights reserved.
4 dnl
5 dnl Process this file with autoconf to produce a configure script.
6 dnl
7
8 #
9 # See
10 #
11 # http://ftp.gnu.org/gnu/config/README
12 #
13 # for the URLs to use to fetch new versions of config.guess and
14 # config.sub.
15 #
16
17 AC_PREREQ(2.64)
18
19 AC_INIT(pcap, m4_esyscmd_s([cat VERSION]))
20 AC_CONFIG_SRCDIR(pcap.c)
21 AC_SUBST(PACKAGE_NAME)
22
23 AC_CANONICAL_SYSTEM
24
25 AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
26 #
27 # Try to enable as many C99 features as we can.
28 # At minimum, we want C++/C99-style // comments.
29 #
30 AC_PROG_CC_C99
31 if test "$ac_cv_prog_cc_c99" = "no"; then
32 AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
33 fi
34 case "$host_os" in
35 haiku*)
36 #
37 # Haiku's platform file is in C++.
38 #
39 AC_PROG_CXX
40 ;;
41 esac
42
43 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
44 AC_LBL_SHLIBS_INIT
45 AC_LBL_C_INLINE
46
47 #
48 # Try to arrange for large file support.
49 #
50 AC_SYS_LARGEFILE
51 AC_FUNC_FSEEKO
52
53 dnl
54 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
55 dnl include <sys/ioccom.h>, and we were to drop support for older
56 dnl releases without that fix, so that pcap-bpf.c doesn't need to
57 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
58 dnl in "aclocal.m4" uses it, so we would still have to test for it
59 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
60 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
61 dnl
62 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
63 AC_CHECK_HEADERS(netpacket/packet.h)
64 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
65 #include <sys/socket.h>
66 #include <net/if.h>])
67 if test "$ac_cv_header_net_pfvar_h" = yes; then
68 #
69 # Check for various PF actions.
70 #
71 AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
72 AC_TRY_COMPILE(
73 [#include <sys/types.h>
74 #include <sys/socket.h>
75 #include <net/if.h>
76 #include <net/pfvar.h>],
77 [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
78 [
79 AC_MSG_RESULT(yes)
80 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
81 [define if net/pfvar.h defines PF_NAT through PF_NORDR])
82 ],
83 AC_MSG_RESULT(no))
84 fi
85
86 case "$host_os" in
87 linux*|uclinux*)
88 #
89 # linux/if_bonding.h requires sys/socket.h.
90 #
91 AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
92 [
93 #include <sys/socket.h>
94 #include <linux/if.h>
95 ])
96
97 #
98 # Check for the eventfd header.
99 #
100 AC_CHECK_HEADERS(sys/eventfd.h)
101 ;;
102
103 haiku*)
104 #
105 # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them.
106 #
107 CFLAGS="$CFLAGS -D_BSD_SOURCE"
108 ;;
109 esac
110
111 AC_LBL_FIXINCLUDES
112
113 AC_CHECK_FUNCS(strerror)
114 AC_CHECK_FUNC(strerror_r,
115 [
116 #
117 # We have strerror_r; if we define _GNU_SOURCE, is it a
118 # POSIX-compliant strerror_r() or a GNU strerror_r()?
119 #
120 AC_MSG_CHECKING(whether strerror_r is GNU-style)
121 AC_COMPILE_IFELSE(
122 [
123 AC_LANG_SOURCE(
124 #define _GNU_SOURCE
125 #include <string.h>
126
127 /* Define it GNU-style; that will cause an error if it's not GNU-style */
128 extern char *strerror_r(int, char *, size_t);
129
130 int
131 main(void)
132 {
133 return 0;
134 }
135 )
136 ],
137 [
138 # GNU-style
139 AC_MSG_RESULT(yes)
140 AC_DEFINE(HAVE_GNU_STRERROR_R,,
141 [Define to 1 if you have a GNU-style `strerror_r' function.])
142 ],
143 [
144 AC_MSG_RESULT(no)
145 AC_DEFINE(HAVE_POSIX_STRERROR_R,,
146 [Define to 1 if you have a POSIX-style `strerror_r' function.])
147 ])
148 ],
149 [
150 #
151 # We don't have strerror_r; do we have strerror_s?
152 #
153 AC_CHECK_FUNCS(strerror_s)
154 ])
155
156 #
157 # Thanks, IBM, for not providing vsyslog() in AIX!
158 #
159 AC_CHECK_FUNCS(vsyslog)
160
161 #
162 # Either:
163 #
164 # we have snprintf() and vsnprintf(), and have asprintf() and
165 # vasprintf();
166 #
167 # we have snprintf() and vsnprintf(), but don't have asprintf()
168 # or vasprintf();
169 #
170 # we have neither snprintf() nor vsnprintf(), and don't have
171 # asprintf() or vasprintf(), either.
172 #
173 # We assume that if we have asprintf() we have vasprintf(), as well
174 # as snprintf() and vsnprintf(), and that if we have snprintf() we
175 # have vsnprintf().
176 #
177 # For the first case, we don't need any replacement routines.
178 # For the second case, we need replacement asprintf()/vasprintf()
179 # routines.
180 # For the third case, we need replacement snprintf()/vsnprintf() and
181 # asprintf()/vasprintf() routines.
182 #
183 needsnprintf=no
184 AC_CHECK_FUNCS(vsnprintf snprintf,,
185 [needsnprintf=yes])
186 needasprintf=no
187 AC_CHECK_FUNCS(vasprintf asprintf,,
188 [needasprintf=yes])
189 if test $needsnprintf = yes; then
190 #
191 # We assume we have none of them; missing/snprintf.c supplies
192 # all of them.
193 #
194 AC_LIBOBJ([snprintf])
195 elif test $needasprintf = yes; then
196 #
197 # We assume we have snprintf()/vsnprintf() but lack
198 # asprintf()/vasprintf(); missing/asprintf.c supplies
199 # the latter (using vsnprintf()).
200 #
201 AC_LIBOBJ([asprintf])
202 fi
203
204 needstrlcat=no
205 AC_CHECK_FUNCS(strlcat,,
206 [needstrlcat=yes])
207 if test $needstrlcat = yes; then
208 AC_LIBOBJ([strlcat])
209 fi
210
211 needstrlcpy=no
212 AC_CHECK_FUNCS(strlcpy,,
213 [needstrlcpy=yes])
214 if test $needstrlcpy = yes; then
215 AC_LIBOBJ([strlcpy])
216 fi
217
218 needstrtok_r=no
219 AC_CHECK_FUNCS(strtok_r,,
220 [needstrtok_r=yes])
221 if test $needstrtok_r = yes; then
222 AC_LIBOBJ([strtok_r])
223 fi
224
225 #
226 # Do we have ffs(), and is it declared in <strings.h>?
227 #
228 AC_CHECK_FUNCS(ffs)
229 if test "$ac_cv_func_ffs" = yes; then
230 #
231 # We have ffs(); is it declared in <strings.h>?
232 #
233 # This test fails if we don't have <strings.h> or if we do
234 # but it doesn't declare ffs().
235 #
236 AC_CHECK_DECL(ffs,
237 [
238 AC_DEFINE(STRINGS_H_DECLARES_FFS,,
239 [Define to 1 if strings.h declares `ffs'])
240 ],,
241 [
242 #include <strings.h>
243 ])
244 fi
245
246 #
247 # Do this before checking for ether_hostton(), as it's a
248 # "getaddrinfo()-ish function".
249 #
250 AC_LBL_LIBRARY_NET
251
252 #
253 # Check for reentrant versions of getnetbyname_r(), as provided by
254 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
255 # If we don't find one, we just use getnetbyname(), which uses
256 # thread-specific data on many platforms, but doesn't use it on
257 # NetBSD or OpenBSD, and may not use it on older versions of other
258 # platforms.
259 #
260 # Only do the check if we have a declaration of getnetbyname_r();
261 # without it, we can't check which API it has. (We assume that
262 # if there's a declaration, it has a prototype, so that the API
263 # can be checked.)
264 #
265 AC_CHECK_DECL(getnetbyname_r,
266 [
267 AC_MSG_CHECKING([for the Linux getnetbyname_r()])
268 AC_TRY_LINK(
269 [#include <netdb.h>],
270 [
271 struct netent netent_buf;
272 char buf[1024];
273 struct netent *resultp;
274 int h_errnoval;
275
276 return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
277 ],
278 [
279 AC_MSG_RESULT(yes)
280 AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
281 [define if we have the Linux getnetbyname_r()])
282 ],
283 [
284 AC_MSG_RESULT(no)
285
286 AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
287 AC_TRY_LINK(
288 [#include <netdb.h>],
289 [
290 struct netent netent_buf;
291 char buf[1024];
292
293 return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
294 ],
295 [
296 AC_MSG_RESULT(yes)
297 AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
298 [define if we have the Solaris/IRIX getnetbyname_r()])
299 ],
300 [
301 AC_MSG_RESULT(no)
302
303 AC_MSG_CHECKING([for AIX getnetbyname_r()])
304 AC_TRY_LINK(
305 [#include <netdb.h>],
306 [
307 struct netent netent_buf;
308 struct netent_data net_data;
309
310 return getnetbyname_r((const char *)0, &netent_buf, &net_data);
311 ],
312 [
313 AC_MSG_RESULT(yes)
314 AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
315 [define if we have the AIX getnetbyname_r()])
316 ],
317 [
318 AC_MSG_RESULT(no)
319 ])
320 ])
321 ])
322 ],,[#include <netdb.h>])
323
324 #
325 # Check for reentrant versions of getprotobyname_r(), as provided by
326 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
327 # If we don't find one, we just use getprotobyname(), which uses
328 # thread-specific data on many platforms, but doesn't use it on
329 # NetBSD or OpenBSD, and may not use it on older versions of other
330 # platforms.
331 #
332 # Only do the check if we have a declaration of getprotobyname_r();
333 # without it, we can't check which API it has. (We assume that
334 # if there's a declaration, it has a prototype, so that the API
335 # can be checked.)
336 #
337 AC_CHECK_DECL(getprotobyname_r,
338 [
339 AC_MSG_CHECKING([for the Linux getprotobyname_r()])
340 AC_TRY_LINK(
341 [#include <netdb.h>],
342 [
343 struct protoent protoent_buf;
344 char buf[1024];
345 struct protoent *resultp;
346
347 return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
348 ],
349 [
350 AC_MSG_RESULT(yes)
351 AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
352 [define if we have the Linux getprotobyname_r()])
353 ],
354 [
355 AC_MSG_RESULT(no)
356
357 AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
358 AC_TRY_LINK(
359 [#include <netdb.h>],
360 [
361 struct protoent protoent_buf;
362 char buf[1024];
363
364 return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
365 ],
366 [
367 AC_MSG_RESULT(yes)
368 AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
369 [define if we have the Solaris/IRIX getprotobyname_r()])
370 ],
371 [
372 AC_MSG_RESULT(no)
373
374 AC_MSG_CHECKING([for AIX getprotobyname_r()])
375 AC_TRY_LINK(
376 [#include <netdb.h>],
377 [
378 struct protoent protoent_buf;
379 struct protoent_data proto_data;
380
381 return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
382 ],
383 [
384 AC_MSG_RESULT(yes)
385 AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
386 [define if we have the AIX getprotobyname_r()])
387 ],
388 [
389 AC_MSG_RESULT(no)
390 ])
391 ])
392 ])
393 ],,[#include <netdb.h>])
394
395 #
396 # You are in a twisty little maze of UN*Xes, all different.
397 # Some might not have ether_hostton().
398 # Some might have it and declare it in <net/ethernet.h>.
399 # Some might have it and declare it in <netinet/ether.h>
400 # Some might have it and declare it in <sys/ethernet.h>.
401 # Some might have it and declare it in <arpa/inet.h>.
402 # Some might have it and declare it in <netinet/if_ether.h>.
403 # Some might have it and not declare it in any header file.
404 #
405 # Before you is a C compiler.
406 #
407 AC_CHECK_FUNCS(ether_hostton)
408 if test "$ac_cv_func_ether_hostton" = yes; then
409 #
410 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
411 #
412 # This test fails if we don't have <net/ethernet.h> or if we do
413 # but it doesn't declare ether_hostton().
414 #
415 AC_CHECK_DECL(ether_hostton,
416 [
417 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
418 [Define to 1 if net/ethernet.h declares `ether_hostton'])
419 ],,
420 [
421 #include <net/ethernet.h>
422 ])
423 #
424 # Did that succeed?
425 #
426 if test "$ac_cv_have_decl_ether_hostton" != yes; then
427 #
428 # No, how about <netinet/ether.h>, as on Linux?
429 #
430 # This test fails if we don't have <netinet/ether.h>
431 # or if we do but it doesn't declare ether_hostton().
432 #
433 # Unset ac_cv_have_decl_ether_hostton so we don't
434 # treat the previous failure as a cached value and
435 # suppress the next test.
436 #
437 unset ac_cv_have_decl_ether_hostton
438 AC_CHECK_DECL(ether_hostton,
439 [
440 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
441 [Define to 1 if netinet/ether.h declares `ether_hostton'])
442 ],,
443 [
444 #include <netinet/ether.h>
445 ])
446 fi
447 #
448 # Did that succeed?
449 #
450 if test "$ac_cv_have_decl_ether_hostton" != yes; then
451 #
452 # No, how about <sys/ethernet.h>, as on Solaris 10
453 # and later?
454 #
455 # This test fails if we don't have <sys/ethernet.h>
456 # or if we do but it doesn't declare ether_hostton().
457 #
458 # Unset ac_cv_have_decl_ether_hostton so we don't
459 # treat the previous failure as a cached value and
460 # suppress the next test.
461 #
462 unset ac_cv_have_decl_ether_hostton
463 AC_CHECK_DECL(ether_hostton,
464 [
465 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
466 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
467 ],,
468 [
469 #include <sys/ethernet.h>
470 ])
471 fi
472 #
473 # Did that succeed?
474 #
475 if test "$ac_cv_have_decl_ether_hostton" != yes; then
476 #
477 # No, how about <arpa/inet.h>, as in AIX?
478 #
479 # This test fails if we don't have <arpa/inet.h>
480 # (if we have ether_hostton(), we should have
481 # networking, and if we have networking, we should
482 # have <arapa/inet.h>) or if we do but it doesn't
483 # declare ether_hostton().
484 #
485 # Unset ac_cv_have_decl_ether_hostton so we don't
486 # treat the previous failure as a cached value and
487 # suppress the next test.
488 #
489 unset ac_cv_have_decl_ether_hostton
490 AC_CHECK_DECL(ether_hostton,
491 [
492 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
493 [Define to 1 if arpa/inet.h declares `ether_hostton'])
494 ],,
495 [
496 #include <arpa/inet.h>
497 ])
498 fi
499 #
500 # Did that succeed?
501 #
502 if test "$ac_cv_have_decl_ether_hostton" != yes; then
503 #
504 # No, how about <netinet/if_ether.h>?
505 # On some platforms, it requires <net/if.h> and
506 # <netinet/in.h>, and we always include it with
507 # both of them, so test it with both of them.
508 #
509 # This test fails if we don't have <netinet/if_ether.h>
510 # and the headers we include before it, or if we do but
511 # <netinet/if_ether.h> doesn't declare ether_hostton().
512 #
513 # Unset ac_cv_have_decl_ether_hostton so we don't
514 # treat the previous failure as a cached value and
515 # suppress the next test.
516 #
517 unset ac_cv_have_decl_ether_hostton
518 AC_CHECK_DECL(ether_hostton,
519 [
520 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
521 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
522 ],,
523 [
524 #include <sys/types.h>
525 #include <sys/socket.h>
526 #include <net/if.h>
527 #include <netinet/in.h>
528 #include <netinet/if_ether.h>
529 ])
530 fi
531 #
532 # After all that, is ether_hostton() declared?
533 #
534 if test "$ac_cv_have_decl_ether_hostton" = yes; then
535 #
536 # Yes.
537 #
538 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
539 [Define to 1 if you have the declaration of `ether_hostton'])
540 else
541 #
542 # No, we'll have to declare it ourselves.
543 # Do we have "struct ether_addr" if we include
544 # <netinet/if_ether.h>?
545 #
546 AC_CHECK_TYPES(struct ether_addr,,,
547 [
548 #include <sys/types.h>
549 #include <sys/socket.h>
550 #include <net/if.h>
551 #include <netinet/in.h>
552 #include <netinet/if_ether.h>
553 ])
554 fi
555 fi
556
557 #
558 # For various things that might use pthreads.
559 #
560 AC_CHECK_HEADER(pthread.h,
561 [
562 #
563 # OK, we have pthread.h. Do we have pthread_create in the
564 # system libraries?
565 #
566 AC_CHECK_FUNC(pthread_create,
567 [
568 #
569 # Yes.
570 #
571 ac_lbl_have_pthreads="found"
572 ],
573 [
574 #
575 # No - do we have it in -lpthreads?
576 #
577 AC_CHECK_LIB(pthreads, pthread_create,
578 [
579 #
580 # Yes - add -lpthreads.
581 #
582 ac_lbl_have_pthreads="found"
583 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
584 ],
585 [
586 #
587 # No - do we have it in -lpthread?
588 #
589 AC_CHECK_LIB(pthread, pthread_create,
590 [
591 #
592 # Yes - add -lpthread.
593 #
594 ac_lbl_have_pthreads="found"
595 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
596 ],
597 [
598 #
599 # No.
600 #
601 ac_lbl_have_pthreads="not found"
602 ])
603 ])
604 ])
605 ],
606 [
607 #
608 # We didn't find pthread.h.
609 #
610 ac_lbl_have_pthreads="not found"
611 ]
612 )
613
614 dnl to pacify those who hate protochain insn
615 AC_MSG_CHECKING(if --disable-protochain option is specified)
616 AC_ARG_ENABLE(protochain,
617 AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
618 case "x$enable_protochain" in
619 xyes) enable_protochain=enabled ;;
620 xno) enable_protochain=disabled ;;
621 x) enable_protochain=enabled ;;
622 esac
623
624 if test "$enable_protochain" = "disabled"; then
625 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
626 fi
627 AC_MSG_RESULT(${enable_protochain})
628
629 #
630 # valgrindtest directly uses the native capture mechanism, but
631 # only tests with BPF and PF_PACKET sockets; only enable it if
632 # we have BPF or PF_PACKET sockets.
633 #
634 VALGRINDTEST_SRC=
635
636 AC_ARG_WITH(pcap,
637 AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
638 if test ! -z "$with_pcap" ; then
639 V_PCAP="$withval"
640 else
641 #
642 # Check for a bunch of headers for various packet
643 # capture mechanisms.
644 #
645 AC_CHECK_HEADERS(net/bpf.h)
646 if test "$ac_cv_header_net_bpf_h" = yes; then
647 #
648 # Does it define BIOCSETIF?
649 # I.e., is it a header for an LBL/BSD-style capture
650 # mechanism, or is it just a header for a BPF filter
651 # engine? Some versions of Arch Linux, for example,
652 # have a net/bpf.h that doesn't define BIOCSETIF;
653 # as it's a Linux, it should use packet sockets,
654 # instead.
655 #
656 # We need:
657 #
658 # sys/types.h, because FreeBSD 10's net/bpf.h
659 # requires that various BSD-style integer types
660 # be defined;
661 #
662 # sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
663 # doesn't include it but does use struct timeval
664 # in ioctl definitions;
665 #
666 # sys/ioctl.h and, if we have it, sys/ioccom.h,
667 # because net/bpf.h defines ioctls;
668 #
669 # net/if.h, because it defines some structures
670 # used in ioctls defined by net/bpf.h;
671 #
672 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
673 # defines some structure fields as being
674 # struct sockaddrs;
675 #
676 # and net/bpf.h doesn't necessarily include all
677 # of those headers itself.
678 #
679 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
680 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
681 AC_TRY_COMPILE(
682 [
683 #include <sys/types.h>
684 #include <sys/time.h>
685 #include <sys/ioctl.h>
686 #include <sys/socket.h>
687 #ifdef HAVE_SYS_IOCCOM_H
688 #include <sys/ioccom.h>
689 #endif
690 #include <net/bpf.h>
691 #include <net/if.h>
692 ],
693 [u_int i = BIOCSETIF;],
694 ac_cv_lbl_bpf_h_defines_biocsetif=yes,
695 ac_cv_lbl_bpf_h_defines_biocsetif=no))
696 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
697 fi
698 AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
699 AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
700 AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
701 AC_CHECK_HEADERS(config/HaikuConfig.h)
702
703 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
704 #
705 # BPF.
706 # Check this before DLPI, so that we pick BPF on
707 # Solaris 11 and later.
708 #
709 V_PCAP=bpf
710
711 #
712 # We have BPF, so build valgrindtest with "make test"
713 # on macOS and FreeBSD (add your OS once there's a
714 # valgrind for it).
715 #
716 case "$host_os" in
717
718 freebsd*|darwin*|linux*)
719 VALGRINDTEST_SRC=valgrindtest.c
720 ;;
721 esac
722 elif test "$ac_cv_header_linux_socket_h" = yes; then
723 #
724 # No prizes for guessing this one.
725 #
726 V_PCAP=linux
727
728 #
729 # XXX - this won't work with older kernels that have
730 # SOCK_PACKET sockets but not PF_PACKET sockets.
731 #
732 VALGRINDTEST_SRC=valgrindtest.c
733 elif test "$ac_cv_header_net_pfilt_h" = yes; then
734 #
735 # DEC OSF/1, Digital UNIX, Tru64 UNIX
736 #
737 V_PCAP=pf
738 elif test "$ac_cv_header_net_enet_h" = yes; then
739 #
740 # Stanford Enetfilter.
741 #
742 V_PCAP=enet
743 elif test "$ac_cv_header_net_nit_h" = yes; then
744 #
745 # SunOS 4.x STREAMS NIT.
746 #
747 V_PCAP=snit
748 elif test "$ac_cv_header_sys_net_nit_h" = yes; then
749 #
750 # Pre-SunOS 4.x non-STREAMS NIT.
751 #
752 V_PCAP=nit
753 elif test "$ac_cv_header_net_raw_h" = yes; then
754 #
755 # IRIX snoop.
756 #
757 V_PCAP=snoop
758 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
759 #
760 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
761 #
762 V_PCAP=dlpi
763 elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then
764 #
765 # Haiku.
766 #
767 V_PCAP=haiku
768 else
769 #
770 # Nothing we support.
771 #
772 V_PCAP=null
773 AC_MSG_WARN(cannot determine packet capture interface)
774 AC_MSG_WARN((see the INSTALL doc for more info))
775 fi
776 fi
777 AC_MSG_CHECKING(packet capture type)
778 AC_MSG_RESULT($V_PCAP)
779 AC_SUBST(VALGRINDTEST_SRC)
780
781 #
782 # Handle each capture type.
783 #
784 case "$V_PCAP" in
785 dlpi)
786 #
787 # Checks for some header files.
788 #
789 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
790
791 #
792 # Checks to see if Solaris has the public libdlpi(3LIB) library.
793 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
794 # public libdlpi(3LIB) version. Before libdlpi was made public, a
795 # private version also existed, which did not have the same APIs.
796 # Due to a gcc bug, the default search path for 32-bit libraries does
797 # not include /lib, we add it explicitly here.
798 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
799 # Also, due to the bug above applications that link to libpcap with
800 # libdlpi will have to add "-L/lib" option to "configure".
801 #
802 saved_ldflags=$LDFLAGS
803 LDFLAGS="$LIBS -L/lib"
804 AC_CHECK_LIB(dlpi, dlpi_walk,
805 [
806 LIBS="-ldlpi $LIBS"
807 V_PCAP=libdlpi
808
809 #
810 # Capture module plus common code needed for
811 # common functions used by pcap-[dlpi,libdlpi].c
812 #
813 PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c"
814 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
815 ],
816 [
817 V_PCAP=dlpi
818
819 #
820 # Capture module plus common code needed for
821 # common functions used by pcap-[dlpi,libdlpi].c
822 #
823 PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c"
824 ])
825 LDFLAGS=$saved_ldflags
826
827 #
828 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
829 # versions of DLPI.
830 #
831 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
832 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
833 AC_TRY_COMPILE(
834 [
835 #include <sys/types.h>
836 #include <sys/time.h>
837 #include <sys/dlpi.h>
838 ],
839 [int i = DL_PROMISC_PHYS;],
840 ac_cv_sys_dlpi_usable=yes,
841 ac_cv_sys_dlpi_usable=no))
842 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
843 if test $ac_cv_sys_dlpi_usable = no ; then
844 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
845 fi
846
847 #
848 # Check to see if Solaris has the dl_passive_req_t struct defined
849 # in <sys/dlpi.h>.
850 # This check is for DLPI support for passive modes.
851 # See dlpi(7P) for more details.
852 #
853 AC_CHECK_TYPES(dl_passive_req_t,,,
854 [
855 #include <sys/types.h>
856 #include <sys/dlpi.h>
857 ])
858 ;;
859
860 enet)
861 #
862 # Capture module
863 #
864 PLATFORM_C_SRC="pcap-enet.c"
865 ;;
866
867 haiku)
868 #
869 # Capture module
870 #
871 PLATFORM_CXX_SRC="pcap-haiku.cpp"
872
873 #
874 # Just for the sake of it.
875 #
876 AC_CHECK_HEADERS(net/if.h net/if_dl.h net/if_types.h)
877 ;;
878
879 linux)
880 #
881 # Capture module
882 #
883 PLATFORM_C_SRC="pcap-linux.c"
884
885 #
886 # Do we have the wireless extensions?
887 #
888 AC_CHECK_HEADERS(linux/wireless.h, [], [],
889 [
890 #include <sys/socket.h>
891 #include <linux/if.h>
892 #include <linux/types.h>
893 ])
894
895 #
896 # Do we have libnl?
897 #
898 AC_ARG_WITH(libnl,
899 AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
900 with_libnl=$withval,with_libnl=if_available)
901
902 if test x$with_libnl != xno ; then
903 have_any_nl="no"
904
905 incdir=-I/usr/include/libnl3
906 libnldir=
907 case "$with_libnl" in
908
909 yes|if_available)
910 ;;
911
912 *)
913 if test -d $withval; then
914 libnldir=-L${withval}/lib/.libs
915 incdir=-I${withval}/include
916 fi
917 ;;
918 esac
919
920 #
921 # Try libnl 3.x first.
922 #
923 AC_CHECK_LIB(nl-3, nl_socket_alloc,
924 [
925 #
926 # Yes, we have libnl 3.x.
927 #
928 LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
929 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
930 AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
931 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
932 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
933 V_INCLS="$V_INCLS ${incdir}"
934 have_any_nl="yes"
935 ],[], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
936
937 if test x$have_any_nl = xno ; then
938 #
939 # Try libnl 2.x
940 #
941 AC_CHECK_LIB(nl, nl_socket_alloc,
942 [
943 #
944 # Yes, we have libnl 2.x.
945 #
946 LIBS="${libnldir} -lnl-genl -lnl $LIBS"
947 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
948 AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
949 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
950 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
951 have_any_nl="yes"
952 ])
953 fi
954
955 if test x$have_any_nl = xno ; then
956 #
957 # No, we don't; do we have libnl 1.x?
958 #
959 AC_CHECK_LIB(nl, nl_handle_alloc,
960 [
961 #
962 # Yes.
963 #
964 LIBS="${libnldir} -lnl $LIBS"
965 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
966 have_any_nl="yes"
967 ])
968 fi
969
970 if test x$have_any_nl = xno ; then
971 #
972 # No, we don't have libnl at all.
973 #
974 if test x$with_libnl = xyes ; then
975 AC_MSG_ERROR([libnl support requested but libnl not found])
976 fi
977 fi
978 fi
979
980 AC_CHECK_HEADERS(linux/ethtool.h,,,
981 [
982 AC_INCLUDES_DEFAULT
983 #include <linux/types.h>
984 ])
985
986 #
987 # Check to see if struct tpacket_stats is defined in
988 # <linux/if_packet.h>. If so, then pcap-linux.c can use this
989 # to report proper statistics.
990 #
991 # -Scott Barron
992 #
993 AC_CHECK_TYPES(struct tpacket_stats,,,
994 [
995 #include <linux/if_packet.h>
996 ])
997
998 #
999 # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
1000 #
1001 # NOTE: any failure means we conclude that it doesn't have that
1002 # member, so if we don't have tpacket_auxdata, we conclude it
1003 # doesn't have that member (which is OK, as either we won't be
1004 # using code that would use that member, or we wouldn't compile
1005 # in any case).
1006 AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
1007 [
1008 #include <sys/types.h>
1009 #include <linux/if_packet.h>
1010 ])
1011 ;;
1012
1013 bpf)
1014 #
1015 # Capture module
1016 #
1017 PLATFORM_C_SRC="pcap-bpf.c"
1018
1019 #
1020 # Check whether we have the *BSD-style ioctls.
1021 #
1022 AC_CHECK_HEADERS(net/if_media.h)
1023
1024 #
1025 # Check whether we have struct BPF_TIMEVAL.
1026 #
1027 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
1028 [
1029 #include <sys/types.h>
1030 #include <sys/ioctl.h>
1031 #ifdef HAVE_SYS_IOCCOM_H
1032 #include <sys/ioccom.h>
1033 #endif
1034 #include <net/bpf.h>
1035 ])
1036 ;;
1037
1038 pf)
1039 #
1040 # Capture module
1041 #
1042 PLATFORM_C_SRC="pcap-pf.c"
1043 ;;
1044
1045 snit)
1046 #
1047 # Capture module
1048 #
1049 PLATFORM_C_SRC="pcap-snit.c"
1050 ;;
1051
1052 snoop)
1053 #
1054 # Capture module
1055 #
1056 PLATFORM_C_SRC="pcap-snoop.c"
1057 ;;
1058
1059 dag)
1060 #
1061 # --with-pcap=dag is the only way to get here, and it means
1062 # "DAG support but nothing else"
1063 #
1064 V_DEFS="$V_DEFS -DDAG_ONLY"
1065 PLATFORM_C_SRC="pcap-dag.c"
1066 xxx_only=yes
1067 ;;
1068
1069 dpdk)
1070 #
1071 # --with-pcap=dpdk is the only way to get here, and it means
1072 # "DPDK support but nothing else"
1073 #
1074 V_DEFS="$V_DEFS -DDPDK_ONLY"
1075 PLATFORM_C_SRC="pcap-dpdk.c"
1076 xxx_only=yes
1077 ;;
1078
1079 septel)
1080 #
1081 # --with-pcap=septel is the only way to get here, and it means
1082 # "Septel support but nothing else"
1083 #
1084 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
1085 PLATFORM_C_SRC="pcap-septel.c"
1086 xxx_only=yes
1087 ;;
1088
1089 snf)
1090 #
1091 # --with-pcap=snf is the only way to get here, and it means
1092 # "SNF support but nothing else"
1093 #
1094 V_DEFS="$V_DEFS -DSNF_ONLY"
1095 PLATFORM_C_SRC="pcap-snf.c"
1096 xxx_only=yes
1097 ;;
1098
1099 null)
1100 #
1101 # Capture module
1102 #
1103 PLATFORM_C_SRC="pcap-null.c"
1104 ;;
1105
1106 *)
1107 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
1108 ;;
1109 esac
1110
1111 dnl
1112 dnl Now figure out how we get a list of interfaces and addresses,
1113 dnl if we support capturing. Don't bother if we don't support
1114 dnl capturing.
1115 dnl
1116 if test "$V_PCAP" != null
1117 then
1118 AC_CHECK_FUNC(getifaddrs,[
1119 #
1120 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
1121 # as well, just in case some platform is really weird.
1122 #
1123 AC_CHECK_HEADER(ifaddrs.h,[
1124 #
1125 # We have the header, so we use "getifaddrs()" to
1126 # get the list of interfaces.
1127 #
1128 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c"
1129 ],[
1130 #
1131 # We don't have the header - give up.
1132 # XXX - we could also fall back on some other
1133 # mechanism, but, for now, this'll catch this
1134 # problem so that we can at least try to figure
1135 # out something to do on systems with "getifaddrs()"
1136 # but without "ifaddrs.h", if there is something
1137 # we can do on those systems.
1138 #
1139 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
1140 ])
1141 ],[
1142 #
1143 # Well, we don't have "getifaddrs()", at least not with the
1144 # libraries with which we've decided we need to link
1145 # libpcap with, so we have to use some other mechanism.
1146 #
1147 # Note that this may happen on Solaris, which has
1148 # getifaddrs(), but in -lsocket, not in -lxnet, so we
1149 # won't find it if we link with -lxnet, which we want
1150 # to do for other reasons.
1151 #
1152 # For now, we use either the SIOCGIFCONF ioctl or the
1153 # SIOCGLIFCONF ioctl, preferring the latter if we have
1154 # it; the latter is a Solarisism that first appeared
1155 # in Solaris 8. (Solaris's getifaddrs() appears to
1156 # be built atop SIOCGLIFCONF; using it directly
1157 # avoids a not-all-that-useful middleman.)
1158 #
1159 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
1160 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
1161 AC_TRY_COMPILE(
1162 [#include <sys/param.h>
1163 #include <sys/file.h>
1164 #include <sys/ioctl.h>
1165 #include <sys/socket.h>
1166 #include <sys/sockio.h>],
1167 [ioctl(0, SIOCGLIFCONF, (char *)0);],
1168 ac_cv_lbl_have_siocglifconf=yes,
1169 ac_cv_lbl_have_siocglifconf=no))
1170 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
1171 if test $ac_cv_lbl_have_siocglifconf = yes ; then
1172 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c"
1173 else
1174 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-gifc.c"
1175 fi
1176 ])
1177 fi
1178
1179 dnl check for hardware timestamp support
1180 case "$host_os" in
1181 linux*)
1182 AC_CHECK_HEADERS([linux/net_tstamp.h])
1183 ;;
1184 *)
1185 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1186 ;;
1187 esac
1188
1189 AC_ARG_ENABLE([packet-ring],
1190 [AC_HELP_STRING([--enable-packet-ring],[enable packet ring support on Linux @<:@default=yes@:>@])],
1191 ,enable_packet_ring=yes)
1192
1193 if test "x$enable_packet_ring" != "xno" ; then
1194 AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use packet ring capture support on Linux if available])
1195 AC_SUBST(PCAP_SUPPORT_PACKET_RING)
1196 fi
1197
1198 #
1199 # Check for socklen_t.
1200 #
1201 AC_CHECK_TYPES(socklen_t,,,
1202 [
1203 #include <sys/types.h>
1204 #include <sys/socket.h>
1205 ])
1206
1207 AC_ARG_ENABLE(ipv6,
1208 AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1209 [],
1210 [enable_ipv6=yes])
1211 if test "$enable_ipv6" != "no"; then
1212 #
1213 # We've already made sure we have getaddrinfo above in
1214 # AC_LBL_LIBRARY_NET.
1215 #
1216 AC_DEFINE(INET6,1,[IPv6])
1217 fi
1218
1219 #
1220 # Do we have pkg-config?
1221 #
1222 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
1223
1224 # Check for Endace DAG card support.
1225 AC_ARG_WITH([dag],
1226 AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1227 [
1228 if test "$withval" = no
1229 then
1230 # User doesn't want DAG support.
1231 want_dag=no
1232 elif test "$withval" = yes
1233 then
1234 # User wants DAG support but hasn't specified a directory.
1235 want_dag=yes
1236 else
1237 # User wants DAG support and has specified a directory, so use the provided value.
1238 want_dag=yes
1239 dag_root=$withval
1240 fi
1241 ],[
1242 if test "$V_PCAP" = dag; then
1243 # User requested DAG-only libpcap, so we'd better have
1244 # the DAG API.
1245 want_dag=yes
1246 elif test "xxx_only" = yes; then
1247 # User requested something-else-only pcap, so they don't
1248 # want DAG support.
1249 want_dag=no
1250 else
1251 #
1252 # Use DAG API if present, otherwise don't
1253 #
1254 want_dag=ifpresent
1255 fi
1256 ])
1257
1258 AC_ARG_WITH([dag-includes],
1259 AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1260 [
1261 # User wants DAG support and has specified a header directory, so use the provided value.
1262 want_dag=yes
1263 dag_include_dir=$withval
1264 ],[])
1265
1266 AC_ARG_WITH([dag-libraries],
1267 AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1268 [
1269 # User wants DAG support and has specified a library directory, so use the provided value.
1270 want_dag=yes
1271 dag_lib_dir=$withval
1272 ],[])
1273
1274 if test "$want_dag" != no; then
1275
1276 # If necessary, set default paths for DAG API headers and libraries.
1277 if test -z "$dag_root"; then
1278 dag_root=/usr/local
1279 fi
1280
1281 if test -z "$dag_include_dir"; then
1282 dag_include_dir="$dag_root/include"
1283 fi
1284
1285 if test -z "$dag_lib_dir"; then
1286 dag_lib_dir="$dag_root/lib"
1287 fi
1288
1289 V_INCLS="$V_INCLS -I$dag_include_dir"
1290
1291 AC_CHECK_HEADERS([dagapi.h])
1292
1293 if test "$ac_cv_header_dagapi_h" = yes; then
1294
1295 if test $V_PCAP != dag ; then
1296 MODULE_C_SRC="$MODULE_C_SRC pcap-dag.c"
1297 fi
1298
1299 # Check for various DAG API functions.
1300 # Don't need to save and restore LIBS to prevent -ldag being
1301 # included if there's a found-action (arg 3).
1302 saved_ldflags=$LDFLAGS
1303 LDFLAGS="-L$dag_lib_dir"
1304 AC_CHECK_LIB([dag], [dag_attach_stream],
1305 [],
1306 [AC_MSG_ERROR(DAG library lacks streams support)])
1307 AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1308 AC_CHECK_LIB([dag],[dag_get_erf_types], [
1309 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1310 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1311 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1312
1313 LDFLAGS=$saved_ldflags
1314
1315 #
1316 # We assume that if we have libdag we have libdagconf,
1317 # as they're installed at the same time from the same
1318 # package.
1319 #
1320 LIBS="$LIBS -ldag -ldagconf"
1321 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1322
1323 if test "$dag_large_streams" = 1; then
1324 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1325 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1326 if test "$ac_dag_have_vdag" = 1; then
1327 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1328 if test "$ac_lbl_have_pthreads" != "found"; then
1329 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1330 fi
1331 LIBS="$LIBS $PTHREAD_LIBS"
1332 fi
1333 fi
1334
1335 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1336 else
1337
1338 if test "$V_PCAP" = dag; then
1339 # User requested "dag" capture type but we couldn't
1340 # find the DAG API support.
1341 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])
1342 fi
1343
1344 if test "$want_dag" = yes; then
1345 # User wanted DAG support but we couldn't find it.
1346 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])
1347 fi
1348 fi
1349 fi
1350
1351 AC_ARG_WITH(septel,
1352 AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1353 [
1354 if test "$withval" = no
1355 then
1356 want_septel=no
1357 elif test "$withval" = yes
1358 then
1359 want_septel=yes
1360 septel_root=
1361 else
1362 want_septel=yes
1363 septel_root=$withval
1364 fi
1365 ],[
1366 if test "$V_PCAP" = septel; then
1367 # User requested Septel-only libpcap, so we'd better have
1368 # the Septel API.
1369 want_septel=yes
1370 elif test "xxx_only" = yes; then
1371 # User requested something-else-only pcap, so they don't
1372 # want Septel support.
1373 want_septel=no
1374 else
1375 #
1376 # Use Septel API if present, otherwise don't
1377 #
1378 want_septel=ifpresent
1379 fi
1380 ])
1381
1382 ac_cv_lbl_septel_api=no
1383 if test "$with_septel" != no; then
1384
1385 AC_MSG_CHECKING([whether we have Septel API headers])
1386
1387 # If necessary, set default paths for Septel API headers and libraries.
1388 if test -z "$septel_root"; then
1389 septel_root=$srcdir/../septel
1390 fi
1391
1392 septel_tools_dir="$septel_root"
1393 septel_include_dir="$septel_root/INC"
1394
1395 if test -r "$septel_include_dir/msg.h"; then
1396 ac_cv_lbl_septel_api=yes
1397 fi
1398
1399 if test "$ac_cv_lbl_septel_api" = yes; then
1400 AC_MSG_RESULT([yes ($septel_include_dir)])
1401
1402 V_INCLS="$V_INCLS -I$septel_include_dir"
1403 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"
1404 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"
1405
1406 if test "$V_PCAP" != septel ; then
1407 MODULE_C_SRC="$MODULE_C_SRC pcap-septel.c"
1408 fi
1409
1410 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1411 else
1412 AC_MSG_RESULT(no)
1413
1414 if test "$V_PCAP" = septel; then
1415 # User requested "septel" capture type but
1416 # we couldn't find the Septel API support.
1417 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])
1418 fi
1419
1420 if test "$want_septel" = yes; then
1421 # User wanted Septel support but we couldn't find it.
1422 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])
1423 fi
1424 fi
1425 fi
1426
1427 # Check for Myricom SNF support.
1428 AC_ARG_WITH([snf],
1429 AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1430 [
1431 if test "$withval" = no
1432 then
1433 # User explicitly doesn't want SNF
1434 want_snf=no
1435 elif test "$withval" = yes
1436 then
1437 # User wants SNF support but hasn't specified a directory.
1438 want_snf=yes
1439 else
1440 # User wants SNF support with a specified directory.
1441 want_snf=yes
1442 snf_root=$withval
1443 fi
1444 ],[
1445 if test "$V_PCAP" = snf; then
1446 # User requested Sniffer-only libpcap, so we'd better have
1447 # the Sniffer API.
1448 want_snf=yes
1449 elif test "xxx_only" = yes; then
1450 # User requested something-else-only pcap, so they don't
1451 # want SNF support.
1452 want_snf=no
1453 else
1454 #
1455 # Use Sniffer API if present, otherwise don't
1456 #
1457 want_snf=ifpresent
1458 fi
1459 ])
1460
1461 AC_ARG_WITH([snf-includes],
1462 AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1463 [
1464 # User wants SNF with specific header directory
1465 want_snf=yes
1466 snf_include_dir=$withval
1467 ],[])
1468
1469 AC_ARG_WITH([snf-libraries],
1470 AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1471 [
1472 # User wants SNF with specific lib directory
1473 want_snf=yes
1474 snf_lib_dir=$withval
1475 ],[])
1476
1477 ac_cv_lbl_snf_api=no
1478 if test "$with_snf" != no; then
1479
1480 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1481
1482 # If necessary, set default paths for Sniffer headers and libraries.
1483 if test -z "$snf_root"; then
1484 snf_root=/opt/snf
1485 fi
1486
1487 if test -z "$snf_include_dir"; then
1488 snf_include_dir="$snf_root/include"
1489 fi
1490
1491 if test -z "$snf_lib_dir"; then
1492 snf_lib_dir="$snf_root/lib"
1493 fi
1494
1495 if test -f "$snf_include_dir/snf.h"; then
1496 # We found a header; make sure we can link with the library
1497 saved_ldflags=$LDFLAGS
1498 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1499 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1500 LDFLAGS="$saved_ldflags"
1501 if test "$ac_cv_lbl_snf_api" = no; then
1502 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1503 fi
1504 fi
1505
1506 if test "$ac_cv_lbl_snf_api" = yes; then
1507 AC_MSG_RESULT([yes ($snf_root)])
1508
1509 V_INCLS="$V_INCLS -I$snf_include_dir"
1510 LIBS="$LIBS -lsnf"
1511 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1512
1513 if test "$V_PCAP" != snf ; then
1514 MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
1515 fi
1516
1517 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1518 else
1519 AC_MSG_RESULT(no)
1520
1521 if test "$want_snf" = yes; then
1522 # User requested "snf" capture type but
1523 # we couldn't find the Sniffer API support.
1524 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])
1525 fi
1526
1527 if test "$want_snf" = yes; then
1528 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])
1529 fi
1530 fi
1531 fi
1532
1533 # Check for Riverbed TurboCap support.
1534 AC_ARG_WITH([turbocap],
1535 AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1536 [
1537 if test "$withval" = no
1538 then
1539 # User explicitly doesn't want TurboCap
1540 want_turbocap=no
1541 elif test "$withval" = yes
1542 then
1543 # User wants TurboCap support but hasn't specified a directory.
1544 want_turbocap=yes
1545 else
1546 # User wants TurboCap support with a specified directory.
1547 want_turbocap=yes
1548 turbocap_root=$withval
1549 fi
1550 ],[
1551 if test "xxx_only" = yes; then
1552 # User requested something-else-only pcap, so they don't
1553 # want TurboCap support.
1554 want_turbocap=no
1555 else
1556 #
1557 # Use TurboCap API if present, otherwise don't
1558 #
1559 want_turbocap=ifpresent
1560 fi
1561 ])
1562
1563 ac_cv_lbl_turbocap_api=no
1564 if test "$want_turbocap" != no; then
1565
1566 AC_MSG_CHECKING(whether TurboCap is supported)
1567
1568 save_CFLAGS="$CFLAGS"
1569 save_LIBS="$LIBS"
1570 if test ! -z "$turbocap_root"; then
1571 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1572 TURBOCAP_LIBS="-L$turbocap_root/lib"
1573 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1574 fi
1575
1576 AC_TRY_COMPILE(
1577 [
1578 #include <TcApi.h>
1579 ],
1580 [
1581 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1582 TC_INSTANCE i;
1583 (void)TcInstanceCreateByName("foo", &i);
1584 ],
1585 ac_cv_lbl_turbocap_api=yes)
1586
1587 CFLAGS="$save_CFLAGS"
1588 if test $ac_cv_lbl_turbocap_api = yes; then
1589 AC_MSG_RESULT(yes)
1590
1591 MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c"
1592 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1593 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1594
1595 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1596 else
1597 AC_MSG_RESULT(no)
1598
1599 if test "$want_turbocap" = yes; then
1600 # User wanted Turbo support but we couldn't find it.
1601 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])
1602 fi
1603 fi
1604 fi
1605
1606 dnl
1607 dnl Allow the user to enable remote capture.
1608 dnl It's off by default, as that increases the attack surface of
1609 dnl libpcap, exposing it to malicious servers.
1610 dnl
1611 AC_MSG_CHECKING([whether to enable remote packet capture])
1612 AC_ARG_ENABLE(remote,
1613 [ --enable-remote enable remote packet capture @<:@default=no@:>@
1614 --disable-remote disable remote packet capture],,
1615 enableval=no)
1616 case "$enableval" in
1617 yes) AC_MSG_RESULT(yes)
1618 AC_WARN([Remote packet capture may expose libpcap-based applications])
1619 AC_WARN([to attacks by malicious remote capture servers!])
1620 #
1621 # rpcapd requires pthreads on UN*X.
1622 #
1623 if test "$ac_lbl_have_pthreads" != "found"; then
1624 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1625 fi
1626 #
1627 # It also requires crypt().
1628 # Do we have it in the system libraries?
1629 #
1630 AC_CHECK_FUNC(crypt,,
1631 [
1632 #
1633 # No. Do we have it in -lcrypt?
1634 #
1635 AC_CHECK_LIB(crypt, crypt,
1636 [
1637 #
1638 # Yes; add -lcrypt to the libraries for rpcapd.
1639 #
1640 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1641 ],
1642 [
1643 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1644 ])
1645 ])
1646
1647 #
1648 # OK, we have crypt(). Do we have getspnam()?
1649 #
1650 AC_CHECK_FUNCS(getspnam)
1651
1652 #
1653 # Check for various members of struct msghdr.
1654 #
1655 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1656 [
1657 #include "ftmacros.h"
1658 #include <sys/socket.h>
1659 ])
1660 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1661 [
1662 #include "ftmacros.h"
1663 #include <sys/socket.h>
1664 ])
1665
1666 #
1667 # Optionally, we may want to support SSL.
1668 # Check for OpenSSL/libressl.
1669 #
1670 # First, try looking for it as a regular system library.
1671 # Make sure we can find SSL_library_init() using the
1672 # standard headers, just in case we're running a version
1673 # of macOS that ships with the OpenSSL library but not
1674 # the OpenSSL headers, and have also installed another
1675 # version of OpenSSL with headers.
1676 #
1677 save_LIBS="$LIBS"
1678 LIBS="-lssl -lcrypto"
1679 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1680 AC_TRY_LINK(
1681 [
1682 #include <openssl/ssl.h>
1683 ],
1684 [
1685 SSL_library_init();
1686 return 0;
1687 ],
1688 [
1689 AC_MSG_RESULT(yes)
1690 HAVE_OPENSSL=yes
1691 OPENSSL_LIBS="-lssl -lcrypto"
1692 ],
1693 AC_MSG_RESULT(no))
1694 LIBS="$save_LIBS"
1695
1696 #
1697 # If we didn't find it, check for it with pkg-config.
1698 #
1699 if test "x$HAVE_OPENSSL" != "xyes"; then
1700 if test "x$PKGCONFIG" != "xno"; then
1701 #
1702 # We have pkg-config; see if we have OpenSSL/
1703 # libressl installed as a package.
1704 #
1705 AC_MSG_CHECKING([for OpenSSL/libressl with pkg-config])
1706 if "$PKGCONFIG" openssl; then
1707 AC_MSG_RESULT([found])
1708 HAVE_OPENSSL=yes
1709 OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl`
1710 OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl`
1711 else
1712 AC_MSG_RESULT([not found])
1713 fi
1714 fi
1715 fi
1716
1717 #
1718 # OK, did we find it?
1719 #
1720 if test "x$HAVE_OPENSSL" = "xyes"; then
1721 AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
1722 CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
1723 LIBS="$LIBS $OPENSSL_LIBS"
1724 else
1725 AC_MSG_NOTICE(OpenSSL not found)
1726 fi
1727
1728 AC_DEFINE(ENABLE_REMOTE,,
1729 [Define to 1 if remote packet capture is to be supported])
1730 REMOTE_C_SRC="$REMOTE_C_SRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c"
1731 BUILD_RPCAPD=build-rpcapd
1732 INSTALL_RPCAPD=install-rpcapd
1733 ;;
1734 *) AC_MSG_RESULT(no)
1735 ;;
1736 esac
1737
1738 AC_MSG_CHECKING(whether to build optimizer debugging code)
1739 AC_ARG_ENABLE(optimizer-dbg,
1740 AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1741 if test "$enable_optimizer_dbg" = "yes"; then
1742 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1743 fi
1744 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1745
1746 AC_MSG_CHECKING(whether to build parser debugging code)
1747 AC_ARG_ENABLE(yydebug,
1748 AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1749 if test "$enable_yydebug" = "yes"; then
1750 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1751 fi
1752 AC_MSG_RESULT(${enable_yydebug-no})
1753
1754 #
1755 # Look for {f}lex.
1756 #
1757 AC_PROG_LEX
1758 if test "$LEX" = ":"; then
1759 AC_MSG_ERROR([Neither flex nor lex was found.])
1760 fi
1761
1762 #
1763 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1764 # and supports processing our scanner.l.
1765 #
1766 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1767 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1768 tcpdump_cv_capable_lex=yes
1769 else
1770 tcpdump_cv_capable_lex=insufficient
1771 fi)
1772 if test $tcpdump_cv_capable_lex = insufficient ; then
1773 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1774 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
1775 fi
1776
1777 #
1778 # Look for yacc/bison/byacc.
1779 #
1780 AC_PROG_YACC
1781
1782 #
1783 # Make sure it supports the -p flag and supports processing our
1784 # grammar.y.
1785 #
1786 AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
1787 if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
1788 tcpdump_cv_capable_yacc=yes
1789 else
1790 tcpdump_cv_capable_yacc=insufficient
1791 fi)
1792 if test $tcpdump_cv_capable_yacc = insufficient ; then
1793 AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
1794 libpcap requires Bison, a newer version of Berkeley YACC with support
1795 for reentrant parsers, or another YACC compatible with them.])
1796 fi
1797
1798 #
1799 # Do various checks for various OSes and versions of those OSes.
1800 #
1801 # Assume, by default, no support for shared libraries and V7/BSD
1802 # convention for man pages (devices in section 4, file formats in
1803 # section 5, miscellaneous info in section 7, administrative commands
1804 # and daemons in section 8). Individual cases can override this.
1805 #
1806 DYEXT="none"
1807 MAN_DEVICES=4
1808 MAN_FILE_FORMATS=5
1809 MAN_MISC_INFO=7
1810 MAN_ADMIN_COMMANDS=8
1811 case "$host_os" in
1812
1813 aix*)
1814 dnl Workaround to enable certain features
1815 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1816
1817 #
1818 # AIX makes it fun to build shared and static libraries,
1819 # because they're *both* ".a" archive libraries. We
1820 # build the static library for the benefit of the traditional
1821 # scheme of building libpcap and tcpdump in subdirectories of
1822 # the same directory, with tcpdump statically linked with the
1823 # libpcap in question, but we also build a shared library as
1824 # "libpcap.shareda" and install *it*, rather than the static
1825 # library, as "libpcap.a".
1826 #
1827 DYEXT="shareda"
1828
1829 case "$V_PCAP" in
1830
1831 dlpi)
1832 #
1833 # If we're using DLPI, applications will need to
1834 # use /lib/pse.exp if present, as we use the
1835 # STREAMS routines.
1836 #
1837 pseexe="/lib/pse.exp"
1838 AC_MSG_CHECKING(for $pseexe)
1839 if test -f $pseexe ; then
1840 AC_MSG_RESULT(yes)
1841 LIBS="-I:$pseexe"
1842 fi
1843 ;;
1844
1845 bpf)
1846 #
1847 # If we're using BPF, we need "-lodm" and "-lcfg", as
1848 # we use them to load the BPF module.
1849 #
1850 LIBS="-lodm -lcfg"
1851 ;;
1852 esac
1853 ;;
1854
1855 darwin*)
1856 DYEXT="dylib"
1857 V_CCOPT="$V_CCOPT -fno-common"
1858 AC_ARG_ENABLE(universal,
1859 AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1860 if test "$enable_universal" != "no"; then
1861 case "$host_os" in
1862
1863 darwin[[0-7]].*)
1864 #
1865 # Pre-Tiger. Build only for 32-bit PowerPC; no
1866 # need for any special compiler or linker flags.
1867 #
1868 ;;
1869
1870 darwin8.[[0123]]|darwin8.[[0123]].*)
1871 #
1872 # Tiger, prior to Intel support. Build
1873 # libraries and executables for 32-bit PowerPC
1874 # and 64-bit PowerPC, with 32-bit PowerPC first.
1875 # (I'm guessing that's what Apple does.)
1876 #
1877 # (The double brackets are needed because
1878 # autotools/m4 use brackets as a quoting
1879 # character; the double brackets turn into
1880 # single brackets in the generated configure
1881 # file.)
1882 #
1883 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
1884 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
1885 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
1886 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
1887 ;;
1888
1889 darwin8.[[456]]|darwin.[[456]].*)
1890 #
1891 # Tiger, subsequent to Intel support but prior
1892 # to x86-64 support. Build libraries and
1893 # executables for 32-bit PowerPC, 64-bit
1894 # PowerPC, and 32-bit x86, with 32-bit PowerPC
1895 # first. (I'm guessing that's what Apple does.)
1896 #
1897 # (The double brackets are needed because
1898 # autotools/m4 use brackets as a quoting
1899 # character; the double brackets turn into
1900 # single brackets in the generated configure
1901 # file.)
1902 #
1903 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1904 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1905 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1906 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1907 ;;
1908
1909 darwin8.*)
1910 #
1911 # All other Tiger, so subsequent to x86-64
1912 # support. Build libraries and executables for
1913 # 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
1914 # and x86-64, with 32-bit PowerPC first. (I'm
1915 # guessing that's what Apple does.)
1916 #
1917 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1918 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1919 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1920 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1921 ;;
1922
1923 darwin9.*)
1924 #
1925 # Leopard. Build libraries for 32-bit PowerPC,
1926 # 64-bit PowerPC, 32-bit x86, and x86-64, with
1927 # 32-bit PowerPC first, and build executables
1928 # for 32-bit x86 and 32-bit PowerPC, with 32-bit
1929 # x86 first. (That's what Apple does.)
1930 #
1931 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1932 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1933 V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
1934 V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
1935 ;;
1936
1937 darwin10.*)
1938 #
1939 # Snow Leopard. Build libraries for x86-64,
1940 # 32-bit x86, and 32-bit PowerPC, with x86-64
1941 # first, and build executables for x86-64 and
1942 # 32-bit x86, with x86-64 first. (That's what
1943 # Apple does, even though Snow Leopard doesn't
1944 # run on PPC, so PPC libpcap runs under Rosetta,
1945 # and Rosetta doesn't support BPF ioctls, so PPC
1946 # programs can't do live captures.)
1947 #
1948 V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
1949 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
1950 V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
1951 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
1952 ;;
1953
1954 darwin*)
1955 #
1956 # Post-Snow Leopard. Build libraries for x86-64
1957 # and 32-bit x86, with x86-64 first, and build
1958 # executables only for x86-64. (That's what
1959 # Apple does.) This requires no special flags
1960 # for programs.
1961 # XXX - update if and when Apple drops support
1962 # for 32-bit x86 code and if and when Apple adds
1963 # ARM-based Macs. (You're on your own for iOS
1964 # etc.)
1965 #
1966 # XXX - check whether we *can* build for
1967 # i386 and, if not, suggest that the user
1968 # install the /usr/include headers if they
1969 # want to build fat.
1970 #
1971 AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
1972 save_CFLAGS="$CFLAGS"
1973 CFLAGS="$CFLAGS -arch i386"
1974 AC_TRY_COMPILE(
1975 [],
1976 [return 0;],
1977 [
1978 AC_MSG_RESULT(yes)
1979 V_LIB_CCOPT_FAT="-arch x86_64"
1980 V_LIB_LDFLAGS_FAT="-arch x86_64"
1981
1982 #
1983 # OpenSSL installation on macOS seems
1984 # to install only the libs for 64-bit
1985 # x86 - at least that's what Brew does:
1986 # only configure 32-bit builds if we
1987 # don't have OpenSSL.
1988 #
1989 if test "$HAVE_OPENSSL" != yes; then
1990 V_LIB_CCOPT_FAT="$V_LIB_CCOPT_FAT -arch i386"
1991 V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386"
1992 fi
1993 ],
1994 [
1995 AC_MSG_RESULT(no)
1996 V_LIB_CCOPT_FAT="-arch x86_64"
1997 V_LIB_LDFLAGS_FAT="-arch x86_64"
1998 case "$host_os" in
1999
2000 darwin18.*)
2001 #
2002 # Mojave; you need to install the
2003 # /usr/include headers to get
2004 # 32-bit x86 builds to work.
2005 #
2006 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package])
2007 ;;
2008
2009 *)
2010 #
2011 # Pre-Mojave; the command-line
2012 # tools should be sufficient to
2013 # enable 32-bit x86 builds.
2014 #
2015 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
2016 ;;
2017 esac
2018 ])
2019 CFLAGS="$save_CFLAGS"
2020 if test "$HAVE_OPENSSL" = yes; then
2021 #
2022 # If all else fails, look for OpenSSL in
2023 # /usr/local/opt.
2024 #
2025 CFLAGS="$CFLAGS -I/usr/local/opt/openssl/include"
2026 LIBS="$LIBS -L/usr/local/opt/openssl/lib"
2027 fi
2028 ;;
2029 esac
2030 fi
2031 ;;
2032
2033 hpux9*)
2034 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
2035
2036 #
2037 # Use System V conventions for man pages.
2038 #
2039 MAN_ADMIN_COMMANDS=1m
2040 MAN_FILE_FORMATS=4
2041 MAN_MISC_INFO=5
2042 ;;
2043
2044 hpux10.0*)
2045
2046 #
2047 # Use System V conventions for man pages.
2048 #
2049 MAN_ADMIN_COMMANDS=1m
2050 MAN_FILE_FORMATS=4
2051 MAN_MISC_INFO=5
2052 ;;
2053
2054 hpux10.1*)
2055
2056 #
2057 # Use System V conventions for man pages.
2058 #
2059 MAN_ADMIN_COMMANDS=1m
2060 MAN_FILE_FORMATS=4
2061 MAN_MISC_INFO=5
2062 ;;
2063
2064 hpux*)
2065 dnl HPUX 10.20 and above is similar to HPUX 9, but
2066 dnl not the same....
2067 dnl
2068 dnl XXX - DYEXT should be set to "sl" if this is building
2069 dnl for 32-bit PA-RISC, but should be left as "so" for
2070 dnl 64-bit PA-RISC or, I suspect, IA-64.
2071 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
2072 if test "`uname -m`" = "ia64"; then
2073 DYEXT="so"
2074 else
2075 DYEXT="sl"
2076 fi
2077
2078 #
2079 # "-b" builds a shared library; "+h" sets the soname.
2080 #
2081 SHLIB_OPT="-b"
2082 SONAME_OPT="+h"
2083
2084 #
2085 # Use System V conventions for man pages.
2086 #
2087 MAN_FILE_FORMATS=4
2088 MAN_MISC_INFO=5
2089 ;;
2090
2091 irix*)
2092 #
2093 # Use IRIX conventions for man pages; they're the same as the
2094 # System V conventions, except that they use section 8 for
2095 # administrative commands and daemons.
2096 #
2097 MAN_FILE_FORMATS=4
2098 MAN_MISC_INFO=5
2099 ;;
2100
2101 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*)
2102 DYEXT="so"
2103
2104 #
2105 # Compiler assumed to be GCC; run-time linker may require a -R
2106 # flag.
2107 #
2108 if test "$libdir" != "/usr/lib"; then
2109 V_RFLAGS=-Wl,-R$libdir
2110 fi
2111 ;;
2112
2113 osf*)
2114 DYEXT="so"
2115
2116 #
2117 # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
2118 # Use Tru64 UNIX conventions for man pages; they're the same as
2119 # the System V conventions except that they use section 8 for
2120 # administrative commands and daemons.
2121 #
2122 MAN_FILE_FORMATS=4
2123 MAN_MISC_INFO=5
2124 MAN_DEVICES=7
2125 ;;
2126
2127 sinix*)
2128 AC_MSG_CHECKING(if SINIX compiler defines sinix)
2129 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
2130 AC_TRY_COMPILE(
2131 [],
2132 [int i = sinix;],
2133 ac_cv_cc_sinix_defined=yes,
2134 ac_cv_cc_sinix_defined=no))
2135 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
2136 if test $ac_cv_cc_sinix_defined = no ; then
2137 AC_DEFINE(sinix,1,[on sinix])
2138 fi
2139 ;;
2140
2141 solaris*)
2142 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
2143
2144 DYEXT="so"
2145
2146 #
2147 # Make sure errno is thread-safe, in case we're called in
2148 # a multithreaded program. We don't guarantee that two
2149 # threads can use the *same* pcap_t safely, but the
2150 # current version does guarantee that you can use different
2151 # pcap_t's in different threads, and even that pcap_compile()
2152 # is thread-safe (it wasn't thread-safe in some older versions).
2153 #
2154 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
2155
2156 case "`uname -r`" in
2157
2158 5.12)
2159 ;;
2160
2161 *)
2162 #
2163 # Use System V conventions for man pages.
2164 #
2165 MAN_ADMIN_COMMANDS=1m
2166 MAN_FILE_FORMATS=4
2167 MAN_MISC_INFO=5
2168 MAN_DEVICES=7D
2169 esac
2170 ;;
2171 esac
2172
2173 AC_ARG_ENABLE(shared,
2174 AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
2175 test "x$enable_shared" = "xno" && DYEXT="none"
2176
2177 AC_PROG_RANLIB
2178 AC_CHECK_TOOL([AR], [ar])
2179
2180 AC_PROG_LN_S
2181 AC_SUBST(LN_S)
2182
2183 AC_LBL_DEVEL(V_CCOPT)
2184
2185 #
2186 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
2187 #
2188 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2189 [
2190 #include <sys/types.h>
2191 #include <sys/socket.h>
2192 ])
2193
2194 #
2195 # Check to see if there's a sockaddr_storage structure.
2196 #
2197 AC_CHECK_TYPES(struct sockaddr_storage,,,
2198 [
2199 #include <sys/types.h>
2200 #include <sys/socket.h>
2201 ])
2202
2203 #
2204 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
2205 # dl_module_id_1 member.
2206 #
2207 # NOTE: any failure means we conclude that it doesn't have that member,
2208 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
2209 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
2210 # it doesn't have that member (which is OK, as either we won't be
2211 # using code that would use that member, or we wouldn't compile in
2212 # any case).
2213 #
2214 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
2215 [
2216 #include <sys/types.h>
2217 #include <sys/dlpi.h>
2218 #include <sys/dlpi_ext.h>
2219 ])
2220
2221 AC_SUBST(V_CCOPT)
2222 AC_SUBST(V_LIB_CCOPT_FAT)
2223 AC_SUBST(V_LIB_LDFLAGS_FAT)
2224 AC_SUBST(V_PROG_CCOPT_FAT)
2225 AC_SUBST(V_PROG_LDFLAGS_FAT)
2226 AC_SUBST(V_DEFS)
2227 AC_SUBST(V_INCLS)
2228 AC_SUBST(V_LEX)
2229 AC_SUBST(V_SHLIB_CCOPT)
2230 AC_SUBST(V_SHLIB_CMD)
2231 AC_SUBST(V_SHLIB_OPT)
2232 AC_SUBST(V_SONAME_OPT)
2233 AC_SUBST(V_RPATH_OPT)
2234 AC_SUBST(V_YACC)
2235 AC_SUBST(ADDLOBJS)
2236 AC_SUBST(ADDLARCHIVEOBJS)
2237 AC_SUBST(PLATFORM_C_SRC)
2238 AC_SUBST(PLATFORM_CXX_SRC)
2239 AC_SUBST(MODULE_C_SRC)
2240 AC_SUBST(REMOTE_C_SRC)
2241 AC_SUBST(DYEXT)
2242 AC_SUBST(MAN_DEVICES)
2243 AC_SUBST(MAN_FILE_FORMATS)
2244 AC_SUBST(MAN_MISC_INFO)
2245 AC_SUBST(MAN_ADMIN_COMMANDS)
2246 AC_SUBST(PTHREAD_LIBS)
2247 AC_SUBST(BUILD_RPCAPD)
2248 AC_SUBST(INSTALL_RPCAPD)
2249 AC_SUBST(RPCAPD_LIBS)
2250 AC_SUBST(EXTRA_NETWORK_LIBS)
2251
2252 AC_ARG_ENABLE([usb],
2253 [AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])],
2254 [],
2255 [enable_usb=yes])
2256
2257 if test "xxx_only" = yes; then
2258 # User requested something-else-only pcap, so they don't
2259 # want USB support.
2260 enable_usb=no
2261 fi
2262
2263 if test "x$enable_usb" != "xno" ; then
2264 dnl check for USB sniffing support
2265 AC_MSG_CHECKING(for USB sniffing support)
2266 case "$host_os" in
2267 linux*)
2268 AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
2269 MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c"
2270 AC_MSG_RESULT(yes)
2271 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
2272 if test $? -ne 0 ; then
2273 ac_usb_dev_name="usbmon"
2274 fi
2275 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
2276 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
2277 #
2278 # Do we have a version of <linux/compiler.h> available?
2279 # If so, we might need it for <linux/usbdevice_fs.h>.
2280 #
2281 AC_CHECK_HEADERS(linux/compiler.h)
2282 if test "$ac_cv_header_linux_compiler_h" = yes; then
2283 #
2284 # Yes - include it when testing for <linux/usbdevice_fs.h>.
2285 #
2286 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
2287 else
2288 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
2289 fi
2290 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
2291 #
2292 # OK, does it define bRequestType? Older versions of the kernel
2293 # define fields with names like "requesttype, "request", and
2294 # "value", rather than "bRequestType", "bRequest", and
2295 # "wValue".
2296 #
2297 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
2298 [
2299 AC_INCLUDES_DEFAULT
2300 #ifdef HAVE_LINUX_COMPILER_H
2301 #include <linux/compiler.h>
2302 #endif
2303 #include <linux/usbdevice_fs.h>
2304 ])
2305 fi
2306 ;;
2307 freebsd*)
2308 #
2309 # This just uses BPF in FreeBSD 8.4 and later; we don't need
2310 # to check for anything special for capturing.
2311 #
2312 AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
2313 ;;
2314
2315 *)
2316 AC_MSG_RESULT(no)
2317 ;;
2318 esac
2319 fi
2320 AC_SUBST(PCAP_SUPPORT_USB)
2321
2322 dnl check for netfilter sniffing support
2323 if test "xxx_only" != yes; then
2324 AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
2325 case "$host_os" in
2326 linux*)
2327 AC_MSG_RESULT(yes)
2328 #
2329 # Life's too short to deal with trying to get this to compile
2330 # if you don't get the right types defined with
2331 # __KERNEL_STRICT_NAMES getting defined by some other include.
2332 #
2333 # Check whether the includes Just Work. If not, don't turn on
2334 # netfilter support.
2335 #
2336 AC_MSG_CHECKING(whether we can compile the netfilter support)
2337 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2338 AC_TRY_COMPILE([
2339 AC_INCLUDES_DEFAULT
2340 #include <sys/socket.h>
2341 #include <netinet/in.h>
2342 #include <linux/types.h>
2343
2344 #include <linux/netlink.h>
2345 #include <linux/netfilter.h>
2346 #include <linux/netfilter/nfnetlink.h>
2347 #include <linux/netfilter/nfnetlink_log.h>
2348 #include <linux/netfilter/nfnetlink_queue.h>],
2349 [],
2350 ac_cv_netfilter_can_compile=yes,
2351 ac_cv_netfilter_can_compile=no))
2352 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2353 if test $ac_cv_netfilter_can_compile = yes ; then
2354 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2355 [target host supports netfilter sniffing])
2356 MODULE_C_SRC="$MODULE_C_SRC pcap-netfilter-linux.c"
2357 fi
2358 ;;
2359 *)
2360 AC_MSG_RESULT(no)
2361 ;;
2362 esac
2363 fi
2364 AC_SUBST(PCAP_SUPPORT_NETFILTER)
2365
2366 AC_ARG_ENABLE([netmap],
2367 [AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2368 [],
2369 [enable_netmap=yes])
2370
2371 if test "x$enable_netmap" != "xno" ; then
2372 #
2373 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2374 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2375 # is defined, for example, as it includes a non-existent malloc.h
2376 # header.
2377 #
2378 AC_MSG_CHECKING(whether we can compile the netmap support)
2379 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2380 AC_TRY_COMPILE([
2381 AC_INCLUDES_DEFAULT
2382 #define NETMAP_WITH_LIBS
2383 #include <net/netmap_user.h>],
2384 [],
2385 ac_cv_net_netmap_user_can_compile=yes,
2386 ac_cv_net_netmap_user_can_compile=no))
2387 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2388 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2389 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2390 [target host supports netmap])
2391 MODULE_C_SRC="$MODULE_C_SRC pcap-netmap.c"
2392 fi
2393 AC_SUBST(PCAP_SUPPORT_NETMAP)
2394 fi
2395
2396 # Check for DPDK support.
2397 AC_ARG_WITH([dpdk],
2398 AC_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
2399 [
2400 if test "$withval" = no
2401 then
2402 # User doesn't want DPDK support.
2403 want_dpdk=no
2404 elif test "$withval" = yes
2405 then
2406 # User wants DPDK support but hasn't specified a directory.
2407 want_dpdk=yes
2408 else
2409 # User wants DPDK support and has specified a directory,
2410 # so use the provided value.
2411 want_dpdk=yes
2412 dpdk_dir=$withval
2413 fi
2414 ],[
2415 if test "$V_PCAP" = dpdk; then
2416 # User requested DPDK-only libpcap, so we'd better have
2417 # the DPDK API.
2418 want_dpdk=yes
2419 elif test "xxx_only" = yes; then
2420 # User requested something-else-only pcap, so they don't
2421 # want DPDK support.
2422 want_dpdk=no
2423 else
2424 #
2425 # Use DPDK API if present, otherwise don't
2426 #
2427 want_dpdk=ifpresent
2428 fi
2429 ])
2430
2431 if test "$want_dpdk" != no; then
2432 if test -z "$dpdk_dir"; then
2433 #
2434 # The user didn't specify a directory containing
2435 # the DPDK headers and libraries. If we find
2436 # a /usr/local/include/dpdk directory, assume
2437 # it's /usr/local, otherwise assume it's /usr.
2438 #
2439 if test -d "/usr/local/include/dpdk"; then
2440 dpdk_dir="/usr/local"
2441 else
2442 dpdk_dir="/usr"
2443 fi
2444 fi
2445 #
2446 # The convention appears to be that 1) there's a "dpdk"
2447 # subdirectory of the include directory, containing DPDK
2448 # headers (at least in the installation on Ubuntu with
2449 # the system DPDK packages) and 2) includes of DPDK
2450 # headers don't use "dpdk/{header}" (at least from the
2451 # way the DPDK documentation is written).
2452 #
2453 # So we add "/dpdk" to the include directory, and always
2454 # add that to the list of include directories to search.
2455 #
2456 dpdk_inc_dir="$dpdk_dir/include/dpdk"
2457 dpdk_lib_dir="$dpdk_dir/lib"
2458 DPDK_MACHINE_CFLAGS="-march=native"
2459 DPDK_CFLAGS="$DPDK_MACHINE_CFLAGS -I$dpdk_inc_dir"
2460 DPDK_LDFLAGS="-L$dpdk_lib_dir -ldpdk -lrt -lm -lnuma -ldl -pthread"
2461
2462 save_CFLAGS="$CFLAGS"
2463 save_LIBS="$LIBS"
2464 save_LDFLAGS="$LDFLAGS"
2465 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2466 LIBS="$LIBS $DPDK_LDFLAGS"
2467 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2468
2469 AC_MSG_CHECKING(whether we can compile the DPDK support)
2470 AC_CACHE_VAL(ac_cv_dpdk_can_compile,
2471 AC_TRY_COMPILE([
2472 AC_INCLUDES_DEFAULT
2473 #include <rte_common.h>],
2474 [],
2475 ac_cv_dpdk_can_compile=yes,
2476 ac_cv_dpdk_can_compile=no))
2477 AC_MSG_RESULT($ac_cv_dpdk_can_compile)
2478
2479 #
2480 # We include rte_bus.h, and older versions of DPDK
2481 # didn't have it, so check for it.
2482 #
2483 if test "$ac_cv_dpdk_can_compile" = yes; then
2484 AC_CHECK_HEADERS(rte_bus.h)
2485 fi
2486
2487 CFLAGS="$save_CFLAGS"
2488 LIBS="$save_LIBS"
2489 LDFLAGS="$save_LDFLAGS"
2490
2491 if test "$ac_cv_header_rte_bus_h" = yes; then
2492 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2493 LIBS="$LIBS $DPDK_LDFLAGS"
2494 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2495 V_INCLS="$V_INCLS $DPDK_CFLAGS"
2496 AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
2497 if test $V_PCAP != dpdk ; then
2498 MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
2499 fi
2500 else
2501 if test "$V_PCAP" = dpdk; then
2502 # User requested "dpdk" capture type but we couldn't
2503 # find the DPDK API support.
2504 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2505 fi
2506
2507 if test "$want_dpdk" = yes; then
2508 # User wanted DPDK support but we couldn't find it.
2509 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2510 fi
2511 fi
2512 fi
2513 AC_SUBST(PCAP_SUPPORT_DPDK)
2514
2515 AC_ARG_ENABLE([bluetooth],
2516 [AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2517 [],
2518 [enable_bluetooth=ifsupportavailable])
2519
2520 if test "xxx_only" = yes; then
2521 # User requested something-else-only pcap, so they don't
2522 # want Bluetooth support.
2523 enable_bluetooth=no
2524 fi
2525
2526 if test "x$enable_bluetooth" != "xno" ; then
2527 dnl check for Bluetooth sniffing support
2528 case "$host_os" in
2529 linux*)
2530 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2531 [
2532 #
2533 # We have bluetooth.h, so we support Bluetooth
2534 # sniffing.
2535 #
2536 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2537 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-linux.c"
2538 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2539 ac_lbl_bluetooth_available=yes
2540
2541 #
2542 # OK, does struct sockaddr_hci have an hci_channel
2543 # member?
2544 #
2545 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2546 [
2547 #
2548 # Yes; is HCI_CHANNEL_MONITOR defined?
2549 #
2550 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2551 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2552 AC_TRY_COMPILE(
2553 [
2554 #include <bluetooth/bluetooth.h>
2555 #include <bluetooth/hci.h>
2556 ],
2557 [
2558 u_int i = HCI_CHANNEL_MONITOR;
2559 ],
2560 [
2561 AC_MSG_RESULT(yes)
2562 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2563 [target host supports Bluetooth Monitor])
2564 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-monitor-linux.c"
2565 ],
2566 [
2567 AC_MSG_RESULT(no)
2568 ]))
2569 ],,
2570 [
2571 #include <bluetooth/bluetooth.h>
2572 #include <bluetooth/hci.h>
2573 ])
2574 ],
2575 [
2576 #
2577 # We don't have bluetooth.h, so we don't support
2578 # Bluetooth sniffing.
2579 #
2580 if test "x$enable_bluetooth" = "xyes" ; then
2581 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2582 else
2583 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2584 fi
2585 ])
2586 ;;
2587 *)
2588 if test "x$enable_bluetooth" = "xyes" ; then
2589 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2590 else
2591 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2592 fi
2593 ;;
2594 esac
2595 AC_SUBST(PCAP_SUPPORT_BT)
2596 fi
2597
2598 AC_ARG_ENABLE([dbus],
2599 [AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2600 [],
2601 [enable_dbus=ifavailable])
2602
2603 if test "xxx_only" = yes; then
2604 # User requested something-else-only pcap, so they don't
2605 # want D-Bus support.
2606 enable_dbus=no
2607 fi
2608
2609 if test "x$enable_dbus" != "xno"; then
2610 if test "x$enable_dbus" = "xyes"; then
2611 case "$host_os" in
2612
2613 darwin*)
2614 #
2615 # We don't support D-Bus sniffing on macOS; see
2616 #
2617 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2618 #
2619 # The user requested it, so fail.
2620 #
2621 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2622 esac
2623 else
2624 case "$host_os" in
2625
2626 darwin*)
2627 #
2628 # We don't support D-Bus sniffing on macOS; see
2629 #
2630 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2631 #
2632 # The user dind't explicitly request it, so just
2633 # silently refuse to enable it.
2634 #
2635 enable_dbus="no"
2636 ;;
2637 esac
2638 fi
2639 fi
2640
2641 if test "x$enable_dbus" != "xno"; then
2642 if test "x$PKGCONFIG" != "xno"; then
2643 AC_MSG_CHECKING([for D-Bus])
2644 if "$PKGCONFIG" dbus-1; then
2645 AC_MSG_RESULT([yes])
2646 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2647 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2648 save_CFLAGS="$CFLAGS"
2649 save_LIBS="$LIBS"
2650 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2651 LIBS="$LIBS $DBUS_LIBS"
2652 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2653 AC_TRY_LINK(
2654 [#include <string.h>
2655
2656 #include <time.h>
2657 #include <sys/time.h>
2658
2659 #include <dbus/dbus.h>],
2660 [return dbus_connection_read_write(NULL, 0);],
2661 [
2662 AC_MSG_RESULT([yes])
2663 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2664 MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
2665 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2666 ],
2667 [
2668 AC_MSG_RESULT([no])
2669 if test "x$enable_dbus" = "xyes"; then
2670 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2671 fi
2672 LIBS="$save_LIBS"
2673 ])
2674 CFLAGS="$save_CFLAGS"
2675 else
2676 AC_MSG_RESULT([no])
2677 if test "x$enable_dbus" = "xyes"; then
2678 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2679 fi
2680 fi
2681 fi
2682 AC_SUBST(PCAP_SUPPORT_DBUS)
2683 fi
2684
2685 AC_ARG_ENABLE([rdma],
2686 [AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2687 [],
2688 [enable_rdma=ifavailable])
2689
2690 if test "xxx_only" = yes; then
2691 # User requested something-else-only pcap, so they don't
2692 # want RDMA support.
2693 enable_rdma=no
2694 fi
2695
2696 if test "x$enable_rdma" != "xno"; then
2697 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2698 AC_CHECK_HEADER(infiniband/verbs.h, [
2699 #
2700 # ibv_create_flow may be defined as a static inline
2701 # function in infiniband/verbs.h, so we can't
2702 # use AC_CHECK_LIB.
2703 #
2704 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2705 # macro that works like CMake's check_symbol_exists()
2706 # function, to check do a compile check like
2707 # this (they do a clever trick to avoid having
2708 # to know the function's signature).
2709 #
2710 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2711 AC_TRY_LINK(
2712 [
2713 #include <infiniband/verbs.h>
2714 ],
2715 [
2716 (void) ibv_create_flow((struct ibv_qp *) NULL,
2717 (struct ibv_flow_attr *) NULL);
2718 ],
2719 [
2720 AC_MSG_RESULT([yes])
2721 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2722 MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
2723 LIBS="-libverbs $LIBS"
2724 ],
2725 [
2726 AC_MSG_RESULT([no])
2727 ]
2728 )
2729 ])
2730 ])
2731 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2732 fi
2733
2734 AC_PROG_INSTALL
2735
2736 AC_CONFIG_HEADER(config.h)
2737
2738 AC_OUTPUT_COMMANDS([if test -f .devel; then
2739 echo timestamp > stamp-h
2740 cat $srcdir/Makefile-devel-adds >> Makefile
2741 make depend
2742 fi])
2743 AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
2744 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2745 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2746 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2747 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2748 pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
2749 pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
2750 rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile
2751 testprogs/Makefile)
2752 exit 0