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