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