1 dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.176 2004-02-25 14:23:32 hannes 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.176 $)
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_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
106 AC_MSG_CHECKING([whether to drop root privileges by default])
107 if test ! -z "$with_user" ; then
108 AC_DEFINE_UNQUOTED(WITH_USER, "$withval")
109 AC_MSG_RESULT(to \"$withval\")
114 AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
115 AC_MSG_CHECKING([whether to chroot])
116 if test ! -z "$with_chroot" ; then
117 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval")
118 AC_MSG_RESULT(to \"$withval\")
123 AC_MSG_CHECKING([whether to enable ipv6])
125 [ --enable-ipv6 enable ipv6 (with ipv4) support
126 --disable-ipv6 disable ipv6 support],
127 [ case "$enableval" in
128 yes) AC_MSG_RESULT(yes)
129 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"
139 AC_TRY_RUN([ /* AF_INET6 available check */
140 #include <sys/types.h>
141 #include <sys/socket.h>
144 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
151 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"
164 if test "$ipv6" = "yes"; then
165 AC_MSG_CHECKING([ipv6 stack type])
166 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
169 dnl http://www.kame.net/
171 [#include <netinet/in.h>
172 #ifdef IPV6_INRIA_VERSION
176 CFLAGS="-DINET6 $CFLAGS"])
179 dnl http://www.kame.net/
181 [#include <netinet/in.h>
187 ipv6libdir=/usr/local/v6/lib;
189 CFLAGS="-DINET6 $CFLAGS"])
192 dnl http://www.v6.linux.or.jp/
194 [#include <features.h>
195 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
199 CFLAGS="-DINET6 $CFLAGS"])
202 dnl http://www.v6.linux.or.jp/
204 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
205 dnl and possibly other versions of those OSes
207 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
210 ipv6libdir=/usr/inet6/lib
212 CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
217 [#include <sys/param.h>
218 #ifdef _TOSHIBA_INET6
223 ipv6libdir=/usr/local/v6/lib;
224 CFLAGS="-DINET6 $CFLAGS"])
228 [#include </usr/local/v6/include/sys/v6config.h>
234 ipv6libdir=/usr/local/v6/lib;
235 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
239 [#include <sys/param.h>
240 #ifdef _ZETA_MINAMI_INET6
245 ipv6libdir=/usr/local/v6/lib;
246 CFLAGS="-DINET6 $CFLAGS"])
249 if test "$ipv6type" != "unknown"; then
253 AC_MSG_RESULT($ipv6type)
256 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
257 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
258 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
259 echo "You have $ipv6lib library, using it"
261 if test "$ipv6trylibc" = "yes"; then
262 echo "You do not have $ipv6lib library, using libc"
264 echo 'Fatal: no $ipv6lib library found. cannot continue.'
265 echo "You need to fetch lib$ipv6lib.a from appropriate"
266 echo 'ipv6 kit and compile beforehand.'
273 if test "$ipv6" = "yes"; then
275 # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
276 # function in libc; there are "ngetaddrinfo()" and
277 # "ogetaddrinfo()" functions, and <netdb.h> #defines
278 # "getaddrinfo" to be either "ngetaddrinfo" or
279 # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
280 # or _XOPEN_SOURCE_EXTENDED are defined or not.
282 # So this test doesn't work on Tru64 5.1, and possibly
283 # on other 5.x releases. This causes the configure
284 # script to become confused, and results in libpcap
287 AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
288 AC_MSG_CHECKING(getaddrinfo bug)
289 AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
290 #include <sys/types.h>
293 #include <sys/socket.h>
294 #include <netinet/in.h>
298 int passive, gaierr, inet4 = 0, inet6 = 0;
299 struct addrinfo hints, *ai, *aitop;
300 char straddr[INET6_ADDRSTRLEN], strport[16];
302 for (passive = 0; passive <= 1; passive++) {
303 memset(&hints, 0, sizeof(hints));
304 hints.ai_family = AF_UNSPEC;
305 hints.ai_flags = passive ? AI_PASSIVE : 0;
306 hints.ai_socktype = SOCK_STREAM;
307 hints.ai_protocol = IPPROTO_TCP;
308 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
309 (void)gai_strerror(gaierr);
312 for (ai = aitop; ai; ai = ai->ai_next) {
313 if (ai->ai_addr == NULL ||
314 ai->ai_addrlen == 0 ||
315 getnameinfo(ai->ai_addr, ai->ai_addrlen,
316 straddr, sizeof(straddr), strport, sizeof(strport),
317 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
320 switch (ai->ai_family) {
322 if (strcmp(strport, "54321") != 0) {
326 if (strcmp(straddr, "0.0.0.0") != 0) {
330 if (strcmp(straddr, "127.0.0.1") != 0) {
337 if (strcmp(strport, "54321") != 0) {
341 if (strcmp(straddr, "::") != 0) {
345 if (strcmp(straddr, "::1") != 0) {
362 /* another family support? */
368 /* supported family should be 2, unsupported family should be 0 */
369 if (!(inet4 == 0 || inet4 == 2))
371 if (!(inet6 == 0 || inet6 == 2))
384 td_cv_buggygetaddrinfo=no,
385 td_cv_buggygetaddrinfo=yes,
386 td_cv_buggygetaddrinfo=yes)])
387 if test "$td_cv_buggygetaddrinfo" = no; then
393 if test "$td_cv_buggygetaddrinfo" = "yes"; then
395 # XXX - it doesn't appear that "ipv6type" can ever be
396 # set to "linux". Should this be testing for
397 # "linux-glibc", or for that *or* "linux-libinet6"?
398 # If the latter, note that "linux-libinet6" is also
399 # the type given to some non-Linux OSes.
401 if test "$ipv6type" != "linux"; then
402 echo 'Fatal: You must get working getaddrinfo() function.'
403 echo ' or you can specify "--disable-ipv6"'.
406 echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
407 echo ' Better upgrade your system library to newest version'
408 echo ' of GNU C library (aka glibc).'
412 AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
415 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
416 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
417 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
418 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
419 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
420 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
421 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
425 dnl check sizeof basic types.
426 dnl They're very likely to be wrong for cross-compiling.
427 AC_CHECK_SIZEOF(char, 1)
428 AC_CHECK_SIZEOF(short, 2)
429 AC_CHECK_SIZEOF(int, 4)
430 AC_CHECK_SIZEOF(long, 4)
433 dnl Checks for u_intXX_t
434 dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
435 dnl if test "$ac_cv_bittypes" = no; then
436 dnl missing_includes=yes
440 dnl Checks for addrinfo structure
441 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
442 if test "$ac_cv_addrinfo" = no; then
447 dnl Checks for NI_MAXSERV
448 AC_NI_MAXSERV(ac_cv_maxserv)
449 if test "$ac_cv_maxserv" = no; then
454 dnl Checks for NI_NAMEREQD
455 AC_NI_NAMEREQD(ac_cv_namereqd)
456 if test "$ac_cv_namereqd" = no; then
461 dnl Checks for sockaddr_storage structure
462 AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
463 if test "$ac_cv_sa_storage" = no; then
468 dnl Checks for IN[6]ADDRSZ
469 AC_CHECK_ADDRSZ(ac_cv_addrsz)
470 if test "$ac_cv_addrsz" = no; then
475 dnl Checks for RES_USE_INET6
476 AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
477 if test "$ac_cv_res_inet6" = no; then
482 dnl Checks for res_state_ext structure
483 AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
484 if test "$ac_cv_res_state_ext" = no; then
489 dnl Checks if res_state structure has nsort member.
490 AC_STRUCT_RES_STATE(ac_cv_res_state)
493 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
494 AC_CHECK_FUNCS(strftime)
495 AC_CHECK_FUNCS(ether_ntohost, [
496 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
499 #include <sys/types.h>
500 #include <sys/param.h>
501 #include <sys/socket.h>
504 main(int argc, char **argv)
506 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
507 char name[MAXHOSTNAMELEN];
509 ether_ntohost(name, (struct ether_addr *)ea);
512 ], [ac_cv_buggy_ether_ntohost=no],
513 [ac_cv_buggy_ether_ntohost=yes],
514 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
515 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
516 AC_DEFINE(USE_ETHER_NTOHOST)
519 AC_CHECK_FUNCS(setlinebuf alarm)
522 AC_CHECK_FUNCS(vsnprintf snprintf,,
524 if test $needsnprintf = yes; then
530 AC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA))
532 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
534 dnl HP/UX may need -lnsl for getrpcbynumber.
535 AC_SEARCH_LIBS(getrpcbynumber, nsl)
537 dnl AC_CHECK_LIB(z, uncompress)
538 dnl AC_CHECK_HEADERS(zlib.h)
540 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
543 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
544 # libraries (e.g., "-lsocket -lnsl" on Solaris).
546 # We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
547 # use AC_CHECK_FUNC which doesn't let us specify the right #includes
548 # to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
549 # resolver, and the way it defines inet_{ntop,pton} is rather strange;
550 # it does not ship with a libc symbol "inet_ntop()", it ships with
551 # "_inet_ntop()", and has a #define macro in one of the system headers
554 dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
555 AC_MSG_CHECKING(for inet_ntop)
556 AC_TRY_LINK([#include <sys/types.h>
557 #include <sys/socket.h>
558 #include <netinet/in.h>
559 #include <arpa/inet.h>], [char src[4], dst[128];
560 inet_ntop(AF_INET, src, dst, sizeof(dst));],
561 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
562 AC_LIBOBJ(inet_ntop)])
563 AC_MSG_CHECKING(for inet_pton)
564 AC_TRY_LINK([#include <sys/types.h>
565 #include <sys/socket.h>
566 #include <netinet/in.h>
567 #include <arpa/inet.h>], [char src[128], dst[4];
568 inet_pton(AF_INET, src, dst);],
569 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
570 AC_LIBOBJ(inet_pton)])
571 AC_MSG_CHECKING(for inet_aton)
572 AC_TRY_LINK([#include <sys/types.h>
573 #include <netinet/in.h>
574 #include <arpa/inet.h>], [char src[128];
576 inet_aton(src, &dst);],
577 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
578 AC_LIBOBJ(inet_aton)])
580 dnl portability macros for getaddrinfo/getnameinfo
583 AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
584 if test "$ac_cv_sockaddr_has_sa_len" = no; then
588 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
589 if test $ac_cv_func_pcap_lib_version = "no" ; then
590 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
594 return_pcap_version(void)
596 extern char pcap_version[];
601 ac_lbl_cv_pcap_version_defined=yes,
602 ac_lbl_cv_pcap_version_defined=no)
603 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
605 AC_DEFINE(HAVE_PCAP_VERSION)
610 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
614 return_pcap_debug(void)
616 extern int pcap_debug;
621 ac_lbl_cv_pcap_debug_defined=yes,
622 ac_lbl_cv_pcap_debug_defined=no)
623 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
625 AC_DEFINE(HAVE_PCAP_DEBUG)
629 # OK, what about "yydebug"?
631 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
642 ac_lbl_cv_yydebug_defined=yes,
643 ac_lbl_cv_yydebug_defined=no)
644 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
646 AC_DEFINE(HAVE_YYDEBUG)
651 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
654 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
660 dnl Workaround to enable certain features
677 if test -f /dev/bpf0 ; then
681 AC_LBL_CHECK_TYPE(int8_t, signed char)
682 AC_LBL_CHECK_TYPE(u_int8_t, u_char)
683 AC_LBL_CHECK_TYPE(int16_t, short)
684 AC_LBL_CHECK_TYPE(u_int16_t, u_short)
685 AC_LBL_CHECK_TYPE(int32_t, int)
686 AC_LBL_CHECK_TYPE(u_int32_t, u_int)
688 AC_LBL_DEVEL(V_CCOPT)
690 AC_LBL_SOCKADDR_SA_LEN
692 AC_LBL_UNALIGNED_ACCESS
696 AC_ARG_WITH(crypto, [ --without-crypto disable crypto support],
698 AC_MSG_CHECKING(for SSLeay)
701 for dir in /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do
703 # XXX - is there a better way to check if a given library is
704 # in a given directory than checking each of the possible
705 # shared library suffixes?
707 # Are there any other suffixes we need to look for? Do we have to
708 # worry about ".so.{version}"?
710 # Or should we just look for "libcrypto.*"?
712 if test -d $dir/lib -a \( -f $dir/lib/libcrypto.a -o \
713 -f $dir/lib/libcrypto.so -o \
714 -f $dir/lib/libcrypto.sl -o \
715 -f $dir/lib/libcrypto.dylib \); then
716 ac_cv_ssleay_path=$dir
718 if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
719 incdir="-I$dir/include"
721 if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
728 AC_MSG_RESULT($ac_cv_ssleay_path)
729 if test "$ac_cv_ssleay_path" != no; then
730 V_INCLS="$V_INCLS $incdir"
731 LDFLAGS="-L$dir/lib $LDFLAGS"
732 if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
733 LIBS="$LIBS -lRSAglue"
735 if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
736 LIBS="$LIBS -lrsaref"
738 AC_CHECK_LIB(crypto, des_cbc_encrypt)
740 CPPFLAGS="$CPPFLAGS $V_INCLS"
741 AC_CHECK_HEADERS(openssl/evp.h)
746 dnl set additional include path if necessary
747 if test "$missing_includes" = "yes"; then
748 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
749 V_INCLS="$V_INCLS -I\$(srcdir)/missing"
761 AC_CONFIG_HEADER(config.h)
763 AC_OUTPUT_COMMANDS([if test -f .devel; then
764 echo timestamp > stamp-h
765 cat Makefile-devel-adds >> Makefile