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