]> The Tcpdump Group git mirrors - tcpdump/blob - configure.ac
e6bf70643369675df42d886ec72c7f8f49e6c244
[tcpdump] / configure.ac
1 dnl Copyright (c) 1994, 1995, 1996, 1997
2 dnl The Regents of the University of California. All rights reserved.
3 dnl
4 dnl Process this file with autoconf to produce a configure script.
5 dnl
6
7 #
8 # See
9 #
10 # https://ftp.gnu.org/gnu/config/README
11 #
12 # for the URLs to use to fetch new versions of config.guess and
13 # config.sub.
14 #
15
16 AC_PREREQ([2.69])
17 AC_INIT([tcpdump],[m4_esyscmd_s(cat VERSION)])
18 AC_CONFIG_SRCDIR(tcpdump.c)
19
20 AC_CANONICAL_HOST
21
22 case "$host_os" in
23
24 haiku*)
25 #
26 # On Haiku, all executables are built as shared objects,
27 # and must have their code build as PIC. This also
28 # applies to code in static libraries, as well as
29 # shared libraries, as executables may be linked
30 # with that code.
31 #
32 # At least some versions of Haiku's GCC default to PIC,
33 # with a -fno-pic option for cases where that's not desired.
34 #
35 # Clang hasn't been modified in that fashion, so Clang
36 # builds of tcpdump fail. This is Haiku bug 18258.
37 #
38 # Force the use of -fPIC (even for GCC; adding -fPIC for GCC
39 # won't break anything).
40 #
41 CFLAGS="$CFLAGS -fPIC"
42 ;;
43 esac
44
45 AC_LBL_C_INIT_BEFORE_CC(V_INCLS)
46 #
47 # Try to enable as many C99 features as we can.
48 # At minimum, we want C++/C99-style // comments.
49 #
50 AC_PROG_CC_C99
51 if test "$ac_cv_prog_cc_c99" = "no"; then
52 AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
53 fi
54 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
55 AC_C_INLINE
56
57 AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h net/if.h)
58
59 case "$host_os" in
60
61 darwin*)
62 AC_ARG_ENABLE(universal,
63 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
64 if test "$enable_universal" != "no"; then
65 case "$host_os" in
66
67 darwin9.*)
68 #
69 # Leopard. Build for x86 and 32-bit PowerPC, with
70 # x86 first. (That's what Apple does.)
71 #
72 V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
73 LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
74 ;;
75
76 darwin10.*)
77 #
78 # Snow Leopard. Build for x86-64 and x86, with
79 # x86-64 first. (That's what Apple does.)
80 #
81 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
82 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
83 ;;
84 esac
85 fi
86 ;;
87 esac
88
89 AC_ARG_WITH([smi],
90 [AS_HELP_STRING([--with-smi],
91 [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
92 [],
93 [with_smi=yes])
94
95 if test "x$with_smi" != "xno" ; then
96 AC_CHECK_HEADER(smi.h,
97 [
98 #
99 # OK, we found smi.h. Do we have libsmi with smiInit?
100 #
101 AC_CHECK_LIB(smi, smiInit,
102 [
103 #
104 # OK, we have libsmi with smiInit. Can we use it?
105 #
106 AC_MSG_CHECKING([whether to enable libsmi])
107 savedlibs="$LIBS"
108 LIBS="-lsmi $LIBS"
109 AC_RUN_IFELSE([AC_LANG_SOURCE([[
110 /* libsmi available check */
111 #include <stdio.h>
112 #include <stdlib.h>
113 #include <string.h>
114 #include <smi.h>
115 int main()
116 {
117 int current, revision, age, n;
118 const int required = 2;
119 if (smiInit(""))
120 exit(1);
121 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
122 exit(2);
123 n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
124 if (n != 3)
125 exit(3);
126 if (required < current - age || required > current)
127 exit(4);
128 exit(0);
129 }
130 ]])
131 ],
132 [
133 AC_MSG_RESULT(yes)
134 AC_DEFINE(USE_LIBSMI, 1,
135 [Define if you enable support for libsmi])
136 ],
137 [
138 dnl autoconf documentation says that
139 dnl $? contains the exit value.
140 dnl reality is that it does not.
141 dnl We leave this in just in case
142 dnl autoconf ever comes back to
143 dnl match the documentation.
144 case $? in
145 1) AC_MSG_RESULT(no - smiInit failed) ;;
146 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
147 3) AC_MSG_RESULT(no - can't determine library version) ;;
148 4) AC_MSG_RESULT(no - too old) ;;
149 *) AC_MSG_RESULT(no) ;;
150 esac
151 LIBS="$savedlibs"
152 ],
153 [
154 AC_MSG_RESULT(not when cross-compiling)
155 LIBS="$savedlibs"
156 ]
157 )
158 ])
159 ])
160 fi
161
162 AC_MSG_CHECKING([whether to enable the instrument functions code])
163 AC_ARG_ENABLE([instrument-functions],
164 [AS_HELP_STRING([--enable-instrument-functions],
165 [enable instrument functions code [default=no]])],
166 [],
167 [enableval=no])
168 case "$enableval" in
169 yes) AC_MSG_RESULT(yes)
170 AC_CHECK_LIB([bfd], [bfd_init],
171 [true],
172 [AC_MSG_ERROR(
173 [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
174 [])
175 AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
176 [define if you want to build the instrument functions code])
177 LOCALSRC="$LOCALSRC instrument-functions.c"
178 # Add '-finstrument-functions' instrumentation option to generate
179 # instrumentation calls for entry and exit to functions.
180 # Try to avoid Address Space Layout Randomization (ALSR).
181 CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
182 LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
183 LIBS="$LIBS -lbfd"
184 ;;
185 *) AC_MSG_RESULT(no)
186 ;;
187 esac
188
189 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
190 AC_ARG_ENABLE([smb],
191 [AS_HELP_STRING([--enable-smb],
192 [enable possibly-buggy SMB printer [default=no]])],
193 [],
194 [enableval=no])
195 case "$enableval" in
196 yes) AC_MSG_RESULT(yes)
197 AC_DEFINE(ENABLE_SMB, 1,
198 [define if you want to build the possibly-buggy SMB printer])
199 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
200 ;;
201 *) AC_MSG_RESULT(no)
202 ;;
203 esac
204
205 AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
206 AC_MSG_CHECKING([whether to drop root privileges by default])
207 if test ! -z "$withval" && test "$withval" != "no" ; then
208 if test "$withval" = "yes" ; then
209 AC_MSG_ERROR([--with-user requires a username])
210 fi
211 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
212 [define if should drop privileges by default])
213 AC_MSG_RESULT([yes, to user "$withval"])
214 else
215 AC_MSG_RESULT(no)
216 fi
217
218 AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
219 AC_MSG_CHECKING([whether to chroot])
220 if test ! -z "$withval" && test "$withval" != "no" ; then
221 if test "$withval" = "yes" ; then
222 AC_MSG_ERROR([--with-chroot requires a directory])
223 fi
224 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
225 [define if should chroot when dropping privileges])
226 AC_MSG_RESULT([yes, to directory "$withval"])
227 else
228 AC_MSG_RESULT(no)
229 fi
230
231 AC_ARG_WITH(sandbox-capsicum,
232 AS_HELP_STRING([--with-sandbox-capsicum],
233 [use Capsicum security functions @<:@default=yes, if available@:>@]))
234 #
235 # Check whether various functions are available. If any are, set
236 # ac_lbl_capsicum_function_seen to yes; if any are not, set
237 # ac_lbl_capsicum_function_not_seen to yes.
238 #
239 # We don't check cap_rights_init(), as it's a macro, wrapping another
240 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
241 # doesn't handle that.
242 #
243 # All of the ones we check for must be available in order to enable
244 # capsicum sandboxing.
245 #
246 # XXX - do we need to check for all of them, or are there some that, if
247 # present, imply others are present?
248 #
249 if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
250 #
251 # First, make sure we have the required header.
252 #
253 AC_CHECK_HEADER(sys/capsicum.h,
254 [
255 #
256 # We do; now make sure we have the required functions.
257 #
258 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
259 ac_lbl_capsicum_function_seen=yes,
260 ac_lbl_capsicum_function_not_seen=yes)
261 ])
262 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
263 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
264 fi
265 AC_MSG_CHECKING([whether to sandbox using capsicum])
266 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
267 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
268 AC_MSG_RESULT(yes)
269 else
270 AC_MSG_RESULT(no)
271 fi
272 AC_MSG_CHECKING([whether to sandbox using Casper library])
273 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
274 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
275 AC_MSG_RESULT(yes)
276 else
277 AC_MSG_RESULT(no)
278 fi
279
280 #
281 # We must check this before checking whether to check the OS's IPv6,
282 # support because, on some platforms (such as SunOS 5.x), the test
283 # program requires the extra networking libraries.
284 #
285 AC_LBL_LIBRARY_NET
286
287 #
288 # Check whether AF_INET6 and struct in6_addr are defined.
289 # If they aren't both defined, we don't have sufficient OS
290 # support for IPv6, so we don't look for IPv6 support libraries,
291 # and we define AF_INET6 and struct in6_addr ourselves.
292 #
293 AC_MSG_CHECKING([whether the operating system supports IPv6])
294 AC_COMPILE_IFELSE(
295 [
296 AC_LANG_SOURCE(
297 [[
298 #include <string.h>
299 /* AF_INET6 available check */
300 #include <sys/types.h>
301 #ifdef _WIN32
302 #include <ws2tcpip.h>
303 #else
304 #include <sys/socket.h>
305 #include <netinet/in.h>
306 #endif
307 #ifdef AF_INET6
308 void
309 foo(struct in6_addr *addr)
310 {
311 memset(addr, 0, sizeof (struct in6_addr));
312 }
313 #else
314 #error "AF_INET6 not defined"
315 #endif
316 ]])
317 ],
318 [
319 AC_MSG_RESULT(yes)
320 AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
321 [define if the OS provides AF_INET6 and struct in6_addr])
322 ipv6=yes
323 ],
324 [
325 AC_MSG_RESULT(no)
326 ipv6=no
327 ]
328 )
329
330 ipv6type=unknown
331 ipv6lib=none
332 ipv6trylibc=no
333
334 if test "$ipv6" = "yes"; then
335 # Apparently, only on Linux by this point the configure script knows
336 # what the C preprocessor and the extended regexp grep commands are.
337 # On other OSes the first call to AC_EGREP_CPP() induces a search for
338 # these tools, which prints three lines in the middle of the IPv6
339 # detection message and distorts it. Resolve these dependencies
340 # beforehand to prevent that.
341 AC_PROG_CPP
342 AC_PROG_EGREP
343
344 AC_MSG_CHECKING([ipv6 stack type])
345 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
346 case $i in
347 inria)
348 dnl http://www.kame.net/
349 AC_EGREP_CPP(yes,
350 [#include <netinet/in.h>
351 #ifdef IPV6_INRIA_VERSION
352 yes
353 #endif],
354 [ipv6type=$i])
355 ;;
356 kame)
357 dnl http://www.kame.net/
358 AC_EGREP_CPP(yes,
359 [#include <netinet/in.h>
360 #ifdef __KAME__
361 yes
362 #endif],
363 [ipv6type=$i;
364 ipv6lib=inet6;
365 ipv6libdir=/usr/local/v6/lib;
366 ipv6trylibc=yes])
367 ;;
368 linux-glibc)
369 dnl http://www.v6.linux.or.jp/
370 AC_EGREP_CPP(yes,
371 [#include <features.h>
372 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
373 yes
374 #endif],
375 [ipv6type=$i])
376 ;;
377 linux-libinet6)
378 dnl http://www.v6.linux.or.jp/
379 dnl
380 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
381 dnl and possibly other versions of those OSes
382 dnl
383 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
384 ipv6type=$i
385 ipv6lib=inet6
386 ipv6libdir=/usr/inet6/lib
387 ipv6trylibc=yes;
388 CFLAGS="-I/usr/inet6/include $CFLAGS"
389 fi
390 ;;
391 toshiba)
392 AC_EGREP_CPP(yes,
393 [#include <sys/param.h>
394 #ifdef _TOSHIBA_INET6
395 yes
396 #endif],
397 [ipv6type=$i;
398 ipv6lib=inet6;
399 ipv6libdir=/usr/local/v6/lib])
400 ;;
401 v6d)
402 AC_EGREP_CPP(yes,
403 [#include </usr/local/v6/include/sys/v6config.h>
404 #ifdef __V6D__
405 yes
406 #endif],
407 [ipv6type=$i;
408 ipv6lib=v6;
409 ipv6libdir=/usr/local/v6/lib;
410 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
411 ;;
412 zeta)
413 AC_EGREP_CPP(yes,
414 [#include <sys/param.h>
415 #ifdef _ZETA_MINAMI_INET6
416 yes
417 #endif],
418 [ipv6type=$i;
419 ipv6lib=inet6;
420 ipv6libdir=/usr/local/v6/lib])
421 ;;
422 esac
423 if test "$ipv6type" != "unknown"; then
424 break
425 fi
426 done
427 AC_MSG_RESULT($ipv6type)
428 fi
429
430 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
431 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
432 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
433 echo "You have $ipv6lib library, using it"
434 else
435 if test "$ipv6trylibc" = "yes"; then
436 echo "You do not have $ipv6lib library, using libc"
437 else
438 echo 'Fatal: no $ipv6lib library found. cannot continue.'
439 echo "You need to fetch lib$ipv6lib.a from appropriate"
440 echo 'ipv6 kit and compile beforehand.'
441 exit 1
442 fi
443 fi
444 fi
445
446 AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
447 AC_CHECK_FUNCS(fork vfork)
448 AC_CHECK_FUNCS(setlinebuf)
449
450 #
451 # Make sure we have vsnprintf() and snprintf(); we require them.
452 #
453 AC_CHECK_FUNC(vsnprintf,,
454 AC_MSG_ERROR([vsnprintf() is required but wasn't found]))
455 AC_CHECK_FUNC(snprintf,,
456 AC_MSG_ERROR([snprintf() is required but wasn't found]))
457
458 #
459 # Define HAVE_NO_PRINTF_Z to make it possible to disable test cases that
460 # depend on %zu.
461 #
462 AC_MSG_CHECKING([whether printf(3) supports the z length modifier])
463 AC_RUN_IFELSE(
464 [
465 AC_LANG_SOURCE([[
466 #include <stdio.h>
467 #include <string.h>
468
469 int main()
470 {
471 char buf[100];
472 snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
473 return strncmp(buf, "100", sizeof(buf)) ? 1 : 0;
474 }
475 ]])
476 ],
477 [
478 AC_MSG_RESULT(yes)
479 ],
480 [
481 AC_MSG_RESULT(no)
482 AC_DEFINE(HAVE_NO_PRINTF_Z, 1,
483 [Define to 1 if printf(3) does not support the z length modifier.])
484 ],
485 [
486 AC_MSG_RESULT(not while cross-compiling)
487 ]
488 )
489
490 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
491
492 dnl Some platforms may need -lnsl for getrpcbynumber.
493 AC_SEARCH_LIBS(getrpcbynumber, nsl,
494 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
495
496 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
497
498 #
499 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
500 # libraries (e.g., "-lsocket -lnsl" on Solaris).
501 #
502 # You are in a twisty little maze of UN*Xes, all different.
503 # Some might not have ether_ntohost().
504 # Some might have it and declare it in <net/ethernet.h>.
505 # Some might have it and declare it in <netinet/ether.h>
506 # Some might have it and declare it in <sys/ethernet.h>.
507 # Some might have it and declare it in <arpa/inet.h>.
508 # Some might have it and declare it in <netinet/if_ether.h>.
509 # Some might have it and not declare it in any header file.
510 #
511 # Before you is a C compiler.
512 #
513 AC_CHECK_FUNCS(ether_ntohost, [
514 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
515 AC_RUN_IFELSE([AC_LANG_SOURCE([[
516 #include <netdb.h>
517 #include <netinet/ether.h>
518 #include <stdlib.h>
519 #include <sys/types.h>
520 #include <sys/param.h>
521 #include <sys/socket.h>
522
523 int
524 main(int argc, char **argv)
525 {
526 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
527 char name[MAXHOSTNAMELEN];
528
529 ether_ntohost(name, (struct ether_addr *)ea);
530 exit(0);
531 }
532 ]])
533 ], [ac_cv_buggy_ether_ntohost=no],
534 [ac_cv_buggy_ether_ntohost=yes],
535 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
536 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
537 AC_DEFINE(USE_ETHER_NTOHOST, 1,
538 [define if you have ether_ntohost() and it works])
539 fi
540 ])
541 if test "$ac_cv_func_ether_ntohost" = yes -a \
542 "$ac_cv_buggy_ether_ntohost" = "no"; then
543 #
544 # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
545 #
546 # This test fails if we don't have <net/ethernet.h> or if we do
547 # but it doesn't declare ether_ntohost().
548 #
549 AC_CHECK_DECL(ether_ntohost,
550 [
551 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
552 [Define to 1 if net/ethernet.h declares `ether_ntohost'])
553 ],,
554 [
555 #include <net/ethernet.h>
556 ])
557 #
558 # Did that succeed?
559 #
560 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
561 #
562 # No, how about <netinet/ether.h>, as on Linux?
563 #
564 # This test fails if we don't have <netinet/ether.h>
565 # or if we do but it doesn't declare ether_ntohost().
566 #
567 # Unset ac_cv_have_decl_ether_ntohost so we don't
568 # treat the previous failure as a cached value and
569 # suppress the next test.
570 #
571 unset ac_cv_have_decl_ether_ntohost
572 AC_CHECK_DECL(ether_ntohost,
573 [
574 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
575 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
576 ],,
577 [
578 #include <netinet/ether.h>
579 ])
580 fi
581 #
582 # Did that succeed?
583 #
584 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
585 #
586 # No, how about <sys/ethernet.h>, as on Solaris 10
587 # and later?
588 #
589 # This test fails if we don't have <sys/ethernet.h>
590 # or if we do but it doesn't declare ether_ntohost().
591 #
592 # Unset ac_cv_have_decl_ether_ntohost so we don't
593 # treat the previous failure as a cached value and
594 # suppress the next test.
595 #
596 unset ac_cv_have_decl_ether_ntohost
597 AC_CHECK_DECL(ether_ntohost,
598 [
599 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
600 [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
601 ],,
602 [
603 #include <sys/ethernet.h>
604 ])
605 fi
606 #
607 # Did that succeed?
608 #
609 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
610 #
611 # No, how about <arpa/inet.h>, as in AIX?
612 #
613 # This test fails if we don't have <arpa/inet.h>
614 # (if we have ether_ntohost(), we should have
615 # networking, and if we have networking, we should
616 # have <arpa/inet.h>) or if we do but it doesn't
617 # declare ether_ntohost().
618 #
619 # Unset ac_cv_have_decl_ether_ntohost so we don't
620 # treat the previous failure as a cached value and
621 # suppress the next test.
622 #
623 unset ac_cv_have_decl_ether_ntohost
624 AC_CHECK_DECL(ether_ntohost,
625 [
626 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
627 [Define to 1 if arpa/inet.h declares `ether_ntohost'])
628 ],,
629 [
630 #include <arpa/inet.h>
631 ])
632 fi
633 #
634 # Did that succeed?
635 #
636 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
637 #
638 # No, how about <netinet/if_ether.h>?
639 # On some platforms, it requires <net/if.h> and
640 # <netinet/in.h>, and we always include it with
641 # both of them, so test it with both of them.
642 #
643 # This test fails if we don't have <netinet/if_ether.h>
644 # and the headers we include before it, or if we do but
645 # <netinet/if_ether.h> doesn't declare ether_hostton().
646 #
647 # Unset ac_cv_have_decl_ether_ntohost so we don't
648 # treat the previous failure as a cached value and
649 # suppress the next test.
650 #
651 unset ac_cv_have_decl_ether_ntohost
652 AC_CHECK_DECL(ether_ntohost,
653 [
654 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
655 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
656 ],,
657 [
658 #include <sys/types.h>
659 #include <sys/socket.h>
660 #include <net/if.h>
661 #include <netinet/in.h>
662 #include <netinet/if_ether.h>
663 ])
664 fi
665 #
666 # After all that, is ether_ntohost() declared?
667 #
668 if test "$ac_cv_have_decl_ether_ntohost" = yes; then
669 #
670 # Yes.
671 #
672 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
673 [Define to 1 if you have the declaration of `ether_ntohost'])
674 else
675 #
676 # No, we'll have to declare it ourselves.
677 # Do we have "struct ether_addr" if we include
678 # <netinet/if_ether.h>?
679 #
680 AC_CHECK_TYPES(struct ether_addr,,,
681 [
682 #include <sys/types.h>
683 #include <sys/socket.h>
684 #include <net/if.h>
685 #include <netinet/in.h>
686 #include <netinet/if_ether.h>
687 ])
688 fi
689 fi
690
691 dnl
692 dnl Check for "pcap_list_datalinks()" and use a substitute version if
693 dnl it's not present. If it is present, check for "pcap_free_datalinks()";
694 dnl if it's not present, we don't replace it for now. (We could do so
695 dnl on UN*X, but not on Windows, where hilarity ensues if a program
696 dnl built with one version of the MSVC support library tries to free
697 dnl something allocated by a library built with another version of
698 dnl the MSVC support library.)
699 dnl
700 AC_CHECK_FUNC(pcap_list_datalinks,
701 [
702 AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
703 [define if libpcap has pcap_list_datalinks()])
704 AC_CHECK_FUNCS(pcap_free_datalinks)
705 ],
706 [
707 AC_LIBOBJ(datalinks)
708 ])
709
710 dnl
711 dnl Check for "pcap_datalink_name_to_val()", and use a substitute
712 dnl version if it's not present. If it is present, check for
713 dnl "pcap_datalink_val_to_description()", and if we don't have it,
714 dnl use a substitute version.
715 dnl
716 AC_CHECK_FUNC(pcap_datalink_name_to_val,
717 [
718 AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
719 [define if libpcap has pcap_datalink_name_to_val()])
720 AC_CHECK_FUNC(pcap_datalink_val_to_description,
721 AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
722 [define if libpcap has pcap_datalink_val_to_description()]),
723 [
724 AC_LIBOBJ(dlnames)
725 ])
726 ],
727 [
728 AC_LIBOBJ(dlnames)
729 ])
730
731 dnl
732 dnl Check for "pcap_set_datalink()"; you can't substitute for it if
733 dnl it's absent (it has hooks into libpcap), so just define the
734 dnl HAVE_ value if it's there.
735 dnl
736 AC_CHECK_FUNCS(pcap_set_datalink)
737
738 dnl
739 dnl Check for "pcap_breakloop()"; you can't substitute for it if
740 dnl it's absent (it has hooks into the live capture routines),
741 dnl so just define the HAVE_ value if it's there.
742 dnl
743 AC_CHECK_FUNCS(pcap_breakloop)
744
745 #
746 # Do we have the new open API? Check for pcap_create, and assume that,
747 # if we do, we also have pcap_activate() and the other new routines
748 # introduced in libpcap 1.0.0.
749 #
750 AC_CHECK_FUNCS(pcap_create)
751 if test $ac_cv_func_pcap_create = "yes" ; then
752 #
753 # OK, do we have pcap_set_tstamp_type? If so, assume we have
754 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
755 #
756 AC_CHECK_FUNCS(pcap_set_tstamp_type)
757 #
758 # And do we have pcap_set_tstamp_precision? If so, we assume
759 # we also have pcap_open_offline_with_tstamp_precision.
760 #
761 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
762 fi
763
764 #
765 # Check for a miscellaneous collection of functions which we use
766 # if we have them.
767 #
768 AC_CHECK_FUNCS(pcap_findalldevs)
769 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
770 dnl Check for libpcap having pcap_findalldevs() but the pcap.h header
771 dnl not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
772 dnl from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
773 dnl pcap.h didn't have pcap_if_t.
774 savedcppflags="$CPPFLAGS"
775 CPPFLAGS="$CPPFLAGS $V_INCLS"
776 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
777 CPPFLAGS="$savedcppflags"
778 fi
779 AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
780 if test $ac_cv_func_pcap_lib_version = "no" ; then
781 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
782 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
783 extern char pcap_version[];
784
785 return (int)pcap_version;
786 ]])
787 ],
788 [ac_lbl_cv_pcap_version_defined=yes],
789 [ac_lbl_cv_pcap_version_defined=no])
790 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
791 AC_MSG_RESULT(yes)
792 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
793 else
794 AC_MSG_RESULT(no)
795 fi
796 fi
797 AC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
798 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
799 AC_REPLACE_FUNCS(pcap_dump_ftell)
800
801 #
802 # Check for special debugging functions
803 #
804 AC_CHECK_FUNCS(pcap_set_parser_debug)
805 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
806 #
807 # OK, we don't have pcap_set_parser_debug() to set the libpcap
808 # filter expression parser debug flag; can we directly set the
809 # flag?
810 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
811 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
812 extern int pcap_debug;
813
814 return pcap_debug;
815 ]])
816 ],
817 [ac_lbl_cv_pcap_debug_defined=yes],
818 [ac_lbl_cv_pcap_debug_defined=no])
819 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
820 AC_MSG_RESULT(yes)
821 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
822 else
823 AC_MSG_RESULT(no)
824 #
825 # OK, what about "yydebug"?
826 #
827 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
828 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
829 extern int yydebug;
830
831 return yydebug;
832 ]])
833 ],
834 [ac_lbl_cv_yydebug_defined=yes],
835 [ac_lbl_cv_yydebug_defined=no])
836 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
837 AC_MSG_RESULT(yes)
838 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
839 else
840 AC_MSG_RESULT(no)
841 fi
842 fi
843 fi
844 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
845 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
846
847 V_GROUP=0
848 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
849 V_GROUP=wheel
850 fi
851 #
852 # Assume V7/BSD convention for man pages (file formats in section 5,
853 # miscellaneous info in section 7).
854 #
855 MAN_FILE_FORMATS=5
856 MAN_MISC_INFO=7
857 case "$host_os" in
858
859 aix*)
860 dnl Workaround to enable certain features
861 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
862 ;;
863
864 hpux*)
865 #
866 # Use System V conventions for man pages.
867 #
868 MAN_FILE_FORMATS=4
869 MAN_MISC_INFO=5
870 ;;
871
872 irix*)
873 V_GROUP=sys
874
875 #
876 # Use System V conventions for man pages.
877 #
878 MAN_FILE_FORMATS=4
879 MAN_MISC_INFO=5
880 ;;
881
882 osf*)
883 V_GROUP=system
884
885 #
886 # Use System V conventions for man pages.
887 #
888 MAN_FILE_FORMATS=4
889 MAN_MISC_INFO=5
890 ;;
891
892 solaris*)
893 V_GROUP=sys
894
895 #
896 # Use System V conventions for man pages.
897 #
898 MAN_FILE_FORMATS=4
899 MAN_MISC_INFO=5
900 ;;
901 esac
902
903 if test -f /dev/bpf0 ; then
904 V_GROUP=bpf
905 fi
906
907 #
908 # Make sure we have a definition for C99's uintptr_t (regardless of
909 # whether the environment is a C99 environment or not).
910 #
911 AC_TYPE_UINTPTR_T
912
913 #
914 # Check whether we have pcap/pcap-inttypes.h.
915 # If we do, we use that to get the C99 types defined.
916 #
917 savedcppflags="$CPPFLAGS"
918 CPPFLAGS="$CPPFLAGS $V_INCLS"
919 AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
920 CPPFLAGS="$savedcppflags"
921
922 #
923 # Define the old BSD specified-width types in terms of the C99 types;
924 # we may need them with libpcap include files.
925 #
926 AC_CHECK_TYPE([u_int8_t], ,
927 [AC_DEFINE([u_int8_t], [uint8_t],
928 [Define to `uint8_t' if u_int8_t not defined.])],
929 [AC_INCLUDES_DEFAULT
930 #include <sys/types.h>
931 ])
932 AC_CHECK_TYPE([u_int16_t], ,
933 [AC_DEFINE([u_int16_t], [uint16_t],
934 [Define to `uint16_t' if u_int16_t not defined.])],
935 [AC_INCLUDES_DEFAULT
936 #include <sys/types.h>
937 ])
938 AC_CHECK_TYPE([u_int32_t], ,
939 [AC_DEFINE([u_int32_t], [uint32_t],
940 [Define to `uint32_t' if u_int32_t not defined.])],
941 [AC_INCLUDES_DEFAULT
942 #include <sys/types.h>
943 ])
944 AC_CHECK_TYPE([u_int64_t], ,
945 [AC_DEFINE([u_int64_t], [uint64_t],
946 [Define to `uint64_t' if u_int64_t not defined.])],
947 [AC_INCLUDES_DEFAULT
948 #include <sys/types.h>
949 ])
950
951 AC_PROG_RANLIB
952 AC_CHECK_TOOL([AR], [ar])
953
954 AC_LBL_DEVEL(V_CCOPT)
955
956 # Check for OpenSSL/libressl libcrypto
957 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
958 # Specify location for both includes and libraries.
959 want_libcrypto=ifavailable
960 AC_ARG_WITH(crypto,
961 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
962 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
963 [
964 if test $withval = no
965 then
966 # User doesn't want to link with libcrypto.
967 want_libcrypto=no
968 AC_MSG_RESULT(no)
969 elif test $withval = yes
970 then
971 # User wants to link with libcrypto but hasn't specified
972 # a directory.
973 want_libcrypto=yes
974 AC_MSG_RESULT(yes)
975 else
976 # User wants to link with libcrypto and has specified
977 # a directory, so use the provided value.
978 want_libcrypto=yes
979 libcrypto_root=$withval
980 AC_MSG_RESULT([yes, using the version installed in $withval])
981
982 #
983 # Put the subdirectories of the libcrypto root directory
984 # at the front of the header and library search path.
985 #
986 CFLAGS="-I$withval/include $CFLAGS"
987 LIBS="-L$withval/lib $LIBS"
988 fi
989 ],[
990 #
991 # Use libcrypto if it's present, otherwise don't; no directory
992 # was specified.
993 #
994 want_libcrypto=ifavailable
995 AC_MSG_RESULT([yes, if available])
996 ])
997 if test "$want_libcrypto" != "no"; then
998 #
999 # Don't check for libcrypto unless we have its headers;
1000 # Apple, bless their pointy little heads, apparently ship
1001 # libcrypto as a library, but not the header files, in
1002 # El Capitan, probably because they don't want you writing
1003 # nasty portable code that could run on other UN*Xes, they
1004 # want you writing code that uses their Shiny New Crypto
1005 # Library and that only runs on macOS.
1006 #
1007 AC_CHECK_HEADER(openssl/crypto.h,
1008 [
1009 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
1010 if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
1011 AC_CHECK_HEADERS(openssl/evp.h)
1012 #
1013 # OK, then:
1014 #
1015 # 1) do we have EVP_CIPHER_CTX_new?
1016 # If so, we use it to allocate an
1017 # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
1018 # opaque; otherwise, we allocate it ourselves.
1019 #
1020 # 2) do we have EVP_DecryptInit_ex()?
1021 # If so, we use it, because we need to be
1022 # able to make two "initialize the cipher"
1023 # calls, one with the cipher and key, and
1024 # one with the IV, and, as of OpenSSL 1.1,
1025 # You Can't Do That with EVP_DecryptInit(),
1026 # because a call to EVP_DecryptInit() will
1027 # unconditionally clear the context, and
1028 # if you don't supply a cipher, it'll
1029 # clear the cipher, rendering the context
1030 # unusable and causing a crash.
1031 #
1032 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
1033 fi
1034 ])
1035 fi
1036
1037 # Check for libcap-ng
1038 AC_MSG_CHECKING(whether to use libcap-ng)
1039 # Specify location for both includes and libraries.
1040 want_libcap_ng=ifavailable
1041 AC_ARG_WITH(cap_ng,
1042 AS_HELP_STRING([--with-cap-ng],
1043 [use libcap-ng @<:@default=yes, if available@:>@]),
1044 [
1045 if test $withval = no
1046 then
1047 want_libcap_ng=no
1048 AC_MSG_RESULT(no)
1049 elif test $withval = yes
1050 then
1051 want_libcap_ng=yes
1052 AC_MSG_RESULT(yes)
1053 fi
1054 ],[
1055 #
1056 # Use libcap-ng if it's present, otherwise don't.
1057 #
1058 want_libcap_ng=ifavailable
1059 AC_MSG_RESULT([yes, if available])
1060 ])
1061 if test "$want_libcap_ng" != "no"; then
1062 AC_CHECK_LIB(cap-ng, capng_change_id)
1063 AC_CHECK_HEADERS(cap-ng.h)
1064 fi
1065
1066 dnl
1067 dnl set additional include path if necessary
1068 if test "$missing_includes" = "yes"; then
1069 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1070 V_INCLS="$V_INCLS -I$srcdir/missing"
1071 fi
1072
1073 AC_SUBST(V_CCOPT)
1074 AC_SUBST(V_DEFS)
1075 AC_SUBST(V_GROUP)
1076 AC_SUBST(V_INCLS)
1077 AC_SUBST(V_PCAPDEP)
1078 AC_SUBST(LOCALSRC)
1079 AC_SUBST(MAN_FILE_FORMATS)
1080 AC_SUBST(MAN_MISC_INFO)
1081
1082 AC_PROG_INSTALL
1083
1084 AC_CONFIG_HEADERS([config.h])
1085
1086 AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
1087 echo timestamp > stamp-h
1088 cat $srcdir/Makefile-devel-adds >> Makefile
1089 make depend || exit 1
1090 fi]])
1091 AC_CONFIG_FILES([Makefile tcpdump.1])
1092 AC_OUTPUT
1093 exit 0