1 dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.169 2003-08-01 01:18:24 fenner Exp $ (LBL)
3 dnl Copyright (c) 1994, 1995, 1996, 1997
4 dnl The Regents of the University of California. All rights reserved.
6 dnl Process this file with autoconf to produce a configure script.
9 AC_REVISION($Revision: 1.169 $)
15 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
19 AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h netdnet/dnetdb.h netinet/ether.h)
25 AC_MSG_CHECKING(Linux kernel version)
26 if test "$cross_compiling" = yes; then
27 AC_CACHE_VAL(ac_cv_linux_vers,
28 ac_cv_linux_vers=unknown)
30 AC_CACHE_VAL(ac_cv_linux_vers,
31 ac_cv_linux_vers=`uname -r 2>&1 | \
32 sed -n -e '$s/.* //' -e '$s/\..*//p'`)
34 AC_MSG_RESULT($ac_cv_linux_vers)
35 if test $ac_cv_linux_vers = unknown ; then
36 AC_MSG_ERROR(cannot determine linux version when cross-compiling)
38 if test $ac_cv_linux_vers -lt 2 ; then
39 AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
48 AC_CHECK_HEADERS(smi.h)
49 AC_CHECK_LIB(smi, smiInit)
50 if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
52 AC_MSG_CHECKING([whether to enable libsmi])
53 AC_TRY_RUN([ /* libsmi available check */
57 int current, revision, age, n;
58 const int required = 2;
61 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
63 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
66 if (required < current - age || required > current)
74 dnl autoconf documentation says that $? contains the exit value.
75 dnl reality is that it does not. We leave this in just in case
76 dnl autoconf ever comes back to match the documentation.
78 1) AC_MSG_RESULT(no - smiInit failed) ;;
79 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
80 3) AC_MSG_RESULT(no - can't determine library version) ;;
81 4) AC_MSG_RESULT(no - too old) ;;
82 *) AC_MSG_RESULT(no) ;;
85 [ AC_MSG_RESULT(not when cross-compiling)
90 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
92 [ --enable-smb enable possibly-buggy SMB printer [default=yes]
93 --disable-smb disable possibly-buggy SMB printer],,
96 yes) AC_MSG_RESULT(yes)
97 AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
98 AC_DEFINE(TCPDUMP_DO_SMB)
99 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
105 AC_MSG_CHECKING([whether to enable ipv6])
107 [ --enable-ipv6 enable ipv6 (with ipv4) support
108 --disable-ipv6 disable ipv6 support],
109 [ case "$enableval" in
110 yes) AC_MSG_RESULT(yes)
111 LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
121 AC_TRY_RUN([ /* AF_INET6 available check */
122 #include <sys/types.h>
123 #include <sys/socket.h>
126 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
133 LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
146 if test "$ipv6" = "yes"; then
147 AC_MSG_CHECKING([ipv6 stack type])
148 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
151 dnl http://www.kame.net/
152 AC_EGREP_CPP(yes, [dnl
153 #include <netinet/in.h>
154 #ifdef IPV6_INRIA_VERSION
158 CFLAGS="-DINET6 $CFLAGS"])
161 dnl http://www.kame.net/
162 AC_EGREP_CPP(yes, [dnl
163 #include <netinet/in.h>
169 ipv6libdir=/usr/local/v6/lib;
171 CFLAGS="-DINET6 $CFLAGS"])
174 dnl http://www.v6.linux.or.jp/
175 AC_EGREP_CPP(yes, [dnl
176 #include <features.h>
177 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
181 CFLAGS="-DINET6 $CFLAGS"])
184 dnl http://www.v6.linux.or.jp/
186 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
187 dnl and possibly other versions of those OSes
189 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
192 ipv6libdir=/usr/inet6/lib
194 CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
198 AC_EGREP_CPP(yes, [dnl
199 #include <sys/param.h>
200 #ifdef _TOSHIBA_INET6
205 ipv6libdir=/usr/local/v6/lib;
206 CFLAGS="-DINET6 $CFLAGS"])
209 AC_EGREP_CPP(yes, [dnl
210 #include </usr/local/v6/include/sys/v6config.h>
216 ipv6libdir=/usr/local/v6/lib;
217 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
220 AC_EGREP_CPP(yes, [dnl
221 #include <sys/param.h>
222 #ifdef _ZETA_MINAMI_INET6
227 ipv6libdir=/usr/local/v6/lib;
228 CFLAGS="-DINET6 $CFLAGS"])
231 if test "$ipv6type" != "unknown"; then
235 AC_MSG_RESULT($ipv6type)
238 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
239 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
240 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
241 echo "You have $ipv6lib library, using it"
243 if test "$ipv6trylibc" = "yes"; then
244 echo "You do not have $ipv6lib library, using libc"
246 echo 'Fatal: no $ipv6lib library found. cannot continue.'
247 echo "You need to fetch lib$ipv6lib.a from appropriate"
248 echo 'ipv6 kit and compile beforehand.'
255 if test "$ipv6" = "yes"; then
257 # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
258 # function in libc; there are "ngetaddrinfo()" and
259 # "ogetaddrinfo()" functions, and <netdb.h> #defines
260 # "getaddrinfo" to be either "ngetaddrinfo" or
261 # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
262 # or _XOPEN_SOURCE_EXTENDED are defined or not.
264 # So this test doesn't work on Tru64 5.1, and possibly
265 # on other 5.x releases. This causes the configure
266 # script to become confused, and results in libpcap
269 AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
270 AC_MSG_CHECKING(getaddrinfo bug)
271 AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
272 #include <sys/types.h>
275 #include <sys/socket.h>
276 #include <netinet/in.h>
280 int passive, gaierr, inet4 = 0, inet6 = 0;
281 struct addrinfo hints, *ai, *aitop;
282 char straddr[INET6_ADDRSTRLEN], strport[16];
284 for (passive = 0; passive <= 1; passive++) {
285 memset(&hints, 0, sizeof(hints));
286 hints.ai_family = AF_UNSPEC;
287 hints.ai_flags = passive ? AI_PASSIVE : 0;
288 hints.ai_socktype = SOCK_STREAM;
289 hints.ai_protocol = IPPROTO_TCP;
290 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
291 (void)gai_strerror(gaierr);
294 for (ai = aitop; ai; ai = ai->ai_next) {
295 if (ai->ai_addr == NULL ||
296 ai->ai_addrlen == 0 ||
297 getnameinfo(ai->ai_addr, ai->ai_addrlen,
298 straddr, sizeof(straddr), strport, sizeof(strport),
299 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
302 switch (ai->ai_family) {
304 if (strcmp(strport, "54321") != 0) {
308 if (strcmp(straddr, "0.0.0.0") != 0) {
312 if (strcmp(straddr, "127.0.0.1") != 0) {
319 if (strcmp(strport, "54321") != 0) {
323 if (strcmp(straddr, "::") != 0) {
327 if (strcmp(straddr, "::1") != 0) {
344 /* another family support? */
350 /* supported family should be 2, unsupported family should be 0 */
351 if (!(inet4 == 0 || inet4 == 2))
353 if (!(inet6 == 0 || inet6 == 2))
366 td_cv_buggygetaddrinfo=no,
367 td_cv_buggygetaddrinfo=yes,
368 td_cv_buggygetaddrinfo=yes)])
369 if test "$td_cv_buggygetaddrinfo" = no; then
375 if test "$td_cv_buggygetaddrinfo" = "yes"; then
377 # XXX - it doesn't appear that "ipv6type" can ever be
378 # set to "linux". Should this be testing for
379 # "linux-glibc", or for that *or* "linux-libinet6"?
380 # If the latter, note that "linux-libinet6" is also
381 # the type given to some non-Linux OSes.
383 if test "$ipv6type" != "linux"; then
384 echo 'Fatal: You must get working getaddrinfo() function.'
385 echo ' or you can specify "--disable-ipv6"'.
388 echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
389 echo ' Better upgrade your system library to newest version'
390 echo ' of GNU C library (aka glibc).'
394 AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
397 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
398 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
399 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
400 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
401 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
402 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
403 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
407 dnl check sizeof basic types.
408 dnl They're very likely to be wrong for cross-compiling.
409 AC_CHECK_SIZEOF(char, 1)
410 AC_CHECK_SIZEOF(short, 2)
411 AC_CHECK_SIZEOF(int, 4)
412 AC_CHECK_SIZEOF(long, 4)
415 dnl Checks for u_intXX_t
416 dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
417 dnl if test "$ac_cv_bittypes" = no; then
418 dnl missing_includes=yes
422 dnl Checks for addrinfo structure
423 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
424 if test "$ac_cv_addrinfo" = no; then
429 dnl Checks for NI_MAXSERV
430 AC_NI_MAXSERV(ac_cv_maxserv)
431 if test "$ac_cv_maxserv" = no; then
436 dnl Checks for NI_NAMEREQD
437 AC_NI_NAMEREQD(ac_cv_namereqd)
438 if test "$ac_cv_namereqd" = no; then
443 dnl Checks for sockaddr_storage structure
444 AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
445 if test "$ac_cv_sa_storage" = no; then
450 dnl Checks for IN[6]ADDRSZ
451 AC_CHECK_ADDRSZ(ac_cv_addrsz)
452 if test "$ac_cv_addrsz" = no; then
457 dnl Checks for RES_USE_INET6
458 AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
459 if test "$ac_cv_res_inet6" = no; then
464 dnl Checks for res_state_ext structure
465 AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
466 if test "$ac_cv_res_state_ext" = no; then
471 dnl Checks if res_state structure has nsort member.
472 AC_STRUCT_RES_STATE(ac_cv_res_state)
475 dnl set additional include path if necessary
476 if test "$missing_includes" = "yes"; then
477 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
478 V_INCLS="$V_INCLS -I\$(srcdir)/missing"
482 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
483 AC_CHECK_FUNCS(strftime)
484 AC_CHECK_FUNCS(ether_ntohost, [
485 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
488 #include <sys/types.h>
489 #include <sys/param.h>
490 #include <sys/socket.h>
493 main(int argc, char **argv)
495 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
496 char name[MAXHOSTNAMELEN];
498 ether_ntohost(name, (struct ether_addr *)ea);
501 ], [ac_cv_buggy_ether_ntohost=no],
502 [ac_cv_buggy_ether_ntohost=yes],
503 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
504 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
505 AC_DEFINE(USE_ETHER_NTOHOST)
508 AC_CHECK_FUNCS(setlinebuf)
511 AC_CHECK_FUNCS(vsnprintf snprintf,,
513 if test $needsnprintf = yes; then
514 LIBOBJS="$LIBOBJS snprintf.o"
519 AC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA))
521 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
523 dnl HP/UX may need -lnsl for getrpcbynumber.
524 AC_SEARCH_LIBS(getrpcbynumber, nsl)
526 dnl AC_CHECK_LIB(z, uncompress)
527 dnl AC_CHECK_HEADERS(zlib.h)
529 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
532 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
533 # libraries (e.g., "-lsocket -lnsl" on Solaris).
535 # We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
536 # use AC_CHECK_FUNC which doesn't let us specify the right #includes
537 # to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
538 # resolver, and the way it defines inet_{ntop,pton} is rather strange;
539 # it does not ship with a libc symbol "inet_ntop()", it ships with
540 # "_inet_ntop()", and has a #define macro in one of the system headers
543 dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
544 AC_MSG_CHECKING(for inet_ntop)
545 AC_TRY_LINK([#include <sys/types.h>
546 #include <sys/socket.h>
547 #include <netinet/in.h>
548 #include <arpa/inet.h>], [char src[4], dst[128];
549 inet_ntop(AF_INET, src, dst, sizeof(dst));],
550 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
551 LIBOBJS="$LIBOBJS inet_ntop.o"])
552 AC_MSG_CHECKING(for inet_pton)
553 AC_TRY_LINK([#include <sys/types.h>
554 #include <sys/socket.h>
555 #include <netinet/in.h>
556 #include <arpa/inet.h>], [char src[128], dst[4];
557 inet_pton(AF_INET, src, dst);],
558 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
559 LIBOBJS="$LIBOBJS inet_pton.o"])
560 AC_MSG_CHECKING(for inet_aton)
561 AC_TRY_LINK([#include <sys/types.h>
562 #include <netinet/in.h>
563 #include <arpa/inet.h>], [char src[128];
565 inet_aton(src, &dst);],
566 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
567 LIBOBJS="$LIBOBJS inet_aton.o"])
569 dnl portability macros for getaddrinfo/getnameinfo
572 AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
573 if test "$ac_cv_sockaddr_has_sa_len" = no; then
577 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
578 if test $ac_cv_func_pcap_lib_version = "no" ; then
579 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
583 return_pcap_version(void)
585 extern char pcap_version[];
590 ac_lbl_cv_pcap_version_defined=yes,
591 ac_lbl_cv_pcap_version_defined=no)
592 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
594 AC_DEFINE(HAVE_PCAP_VERSION)
599 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
603 return_pcap_debug(void)
605 extern int pcap_debug;
610 ac_lbl_cv_pcap_debug_defined=yes,
611 ac_lbl_cv_pcap_debug_defined=no)
612 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
614 AC_DEFINE(HAVE_PCAP_DEBUG)
618 # OK, what about "yydebug"?
620 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
631 ac_lbl_cv_yydebug_defined=yes,
632 ac_lbl_cv_yydebug_defined=no)
633 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
635 AC_DEFINE(HAVE_YYDEBUG)
640 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
643 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
649 dnl Workaround to enable certain features
666 if test -f /dev/bpf0 ; then
670 AC_LBL_CHECK_TYPE(int8_t, signed char)
671 AC_LBL_CHECK_TYPE(u_int8_t, u_char)
672 AC_LBL_CHECK_TYPE(int16_t, short)
673 AC_LBL_CHECK_TYPE(u_int16_t, u_short)
674 AC_LBL_CHECK_TYPE(int32_t, int)
675 AC_LBL_CHECK_TYPE(u_int32_t, u_int)
677 AC_LBL_DEVEL(V_CCOPT)
679 AC_LBL_SOCKADDR_SA_LEN
681 AC_LBL_UNALIGNED_ACCESS
685 AC_ARG_WITH(crypto, [ --without-crypto disable crypto support],
687 AC_MSG_CHECKING(for SSLeay)
690 for dir in /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do
692 # XXX - is there a better way to check if a given library is
693 # in a given directory than checking each of the possible
694 # shared library suffixes?
696 # Are there any other suffixes we need to look for? Do we have to
697 # worry about ".so.{version}"?
699 # Or should we just look for "libcrypto.*"?
701 if test -d $dir/lib -a \( -f $dir/lib/libcrypto.a -o \
702 -f $dir/lib/libcrypto.so -o \
703 -f $dir/lib/libcrypto.sl -o \
704 -f $dir/lib/libcrypto.dylib \); then
705 ac_cv_ssleay_path=$dir
707 if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
708 incdir="-I$dir/include"
710 if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
717 AC_MSG_RESULT($ac_cv_ssleay_path)
718 if test "$ac_cv_ssleay_path" != no; then
719 V_INCLS="$V_INCLS $incdir"
720 LDFLAGS="-L$dir/lib $LDFLAGS"
721 if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
722 LIBS="$LIBS -lRSAglue"
724 if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
725 LIBS="$LIBS -lrsaref"
727 AC_CHECK_LIB(crypto, des_cbc_encrypt)
729 CPPFLAGS="$CPPFLAGS $V_INCLS"
730 AC_CHECK_HEADERS(openssl/evp.h)
742 AC_CONFIG_HEADER(config.h)
744 AC_OUTPUT_COMMANDS([if test -f .devel; then
745 echo timestamp > stamp-h
746 cat Makefile-devel-adds >> Makefile