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