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