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