1 dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.179 2004-04-17 04:33:17 guy 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.179 $)
15 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
19 AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h netinet/ether.h)
20 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
21 #include <sys/socket.h>])
27 AC_MSG_CHECKING(Linux kernel version)
28 if test "$cross_compiling" = yes; then
29 AC_CACHE_VAL(ac_cv_linux_vers,
30 ac_cv_linux_vers=unknown)
32 AC_CACHE_VAL(ac_cv_linux_vers,
33 ac_cv_linux_vers=`uname -r 2>&1 | \
34 sed -n -e '$s/.* //' -e '$s/\..*//p'`)
36 AC_MSG_RESULT($ac_cv_linux_vers)
37 if test $ac_cv_linux_vers = unknown ; then
38 AC_MSG_ERROR(cannot determine linux version when cross-compiling)
40 if test $ac_cv_linux_vers -lt 2 ; then
41 AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
50 AC_CHECK_HEADERS(smi.h)
51 AC_CHECK_LIB(smi, smiInit)
52 if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
54 AC_MSG_CHECKING([whether to enable libsmi])
55 AC_TRY_RUN([ /* libsmi available check */
59 int current, revision, age, n;
60 const int required = 2;
63 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
65 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
68 if (required < current - age || required > current)
76 dnl autoconf documentation says that $? contains the exit value.
77 dnl reality is that it does not. We leave this in just in case
78 dnl autoconf ever comes back to match the documentation.
80 1) AC_MSG_RESULT(no - smiInit failed) ;;
81 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
82 3) AC_MSG_RESULT(no - can't determine library version) ;;
83 4) AC_MSG_RESULT(no - too old) ;;
84 *) AC_MSG_RESULT(no) ;;
87 [ AC_MSG_RESULT(not when cross-compiling)
92 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
94 [ --enable-smb enable possibly-buggy SMB printer [default=yes]
95 --disable-smb disable possibly-buggy SMB printer],,
98 yes) AC_MSG_RESULT(yes)
99 AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
100 AC_DEFINE(TCPDUMP_DO_SMB)
101 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
107 AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
108 AC_MSG_CHECKING([whether to drop root privileges by default])
109 if test ! -z "$with_user" ; then
110 AC_DEFINE_UNQUOTED(WITH_USER, "$withval")
111 AC_MSG_RESULT(to \"$withval\")
116 AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
117 AC_MSG_CHECKING([whether to chroot])
118 if test ! -z "$with_chroot" ; then
119 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval")
120 AC_MSG_RESULT(to \"$withval\")
125 AC_MSG_CHECKING([whether to enable ipv6])
127 [ --enable-ipv6 enable ipv6 (with ipv4) support
128 --disable-ipv6 disable ipv6 support],
129 [ case "$enableval" in
130 yes) AC_MSG_RESULT(yes)
131 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"
141 AC_TRY_RUN([ /* AF_INET6 available check */
142 #include <sys/types.h>
143 #include <sys/socket.h>
146 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
153 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"
166 if test "$ipv6" = "yes"; then
167 AC_MSG_CHECKING([ipv6 stack type])
168 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
171 dnl http://www.kame.net/
173 [#include <netinet/in.h>
174 #ifdef IPV6_INRIA_VERSION
178 CFLAGS="-DINET6 $CFLAGS"])
181 dnl http://www.kame.net/
183 [#include <netinet/in.h>
189 ipv6libdir=/usr/local/v6/lib;
191 CFLAGS="-DINET6 $CFLAGS"])
194 dnl http://www.v6.linux.or.jp/
196 [#include <features.h>
197 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
201 CFLAGS="-DINET6 $CFLAGS"])
204 dnl http://www.v6.linux.or.jp/
206 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
207 dnl and possibly other versions of those OSes
209 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
212 ipv6libdir=/usr/inet6/lib
214 CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
219 [#include <sys/param.h>
220 #ifdef _TOSHIBA_INET6
225 ipv6libdir=/usr/local/v6/lib;
226 CFLAGS="-DINET6 $CFLAGS"])
230 [#include </usr/local/v6/include/sys/v6config.h>
236 ipv6libdir=/usr/local/v6/lib;
237 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
241 [#include <sys/param.h>
242 #ifdef _ZETA_MINAMI_INET6
247 ipv6libdir=/usr/local/v6/lib;
248 CFLAGS="-DINET6 $CFLAGS"])
251 if test "$ipv6type" != "unknown"; then
255 AC_MSG_RESULT($ipv6type)
258 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
259 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
260 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
261 echo "You have $ipv6lib library, using it"
263 if test "$ipv6trylibc" = "yes"; then
264 echo "You do not have $ipv6lib library, using libc"
266 echo 'Fatal: no $ipv6lib library found. cannot continue.'
267 echo "You need to fetch lib$ipv6lib.a from appropriate"
268 echo 'ipv6 kit and compile beforehand.'
275 if test "$ipv6" = "yes"; then
277 # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
278 # function in libc; there are "ngetaddrinfo()" and
279 # "ogetaddrinfo()" functions, and <netdb.h> #defines
280 # "getaddrinfo" to be either "ngetaddrinfo" or
281 # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
282 # or _XOPEN_SOURCE_EXTENDED are defined or not.
284 # So this test doesn't work on Tru64 5.1, and possibly
285 # on other 5.x releases. This causes the configure
286 # script to become confused, and results in libpcap
289 AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
290 AC_MSG_CHECKING(getaddrinfo bug)
291 AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
292 #include <sys/types.h>
295 #include <sys/socket.h>
296 #include <netinet/in.h>
300 int passive, gaierr, inet4 = 0, inet6 = 0;
301 struct addrinfo hints, *ai, *aitop;
302 char straddr[INET6_ADDRSTRLEN], strport[16];
304 for (passive = 0; passive <= 1; passive++) {
305 memset(&hints, 0, sizeof(hints));
306 hints.ai_family = AF_UNSPEC;
307 hints.ai_flags = passive ? AI_PASSIVE : 0;
308 hints.ai_socktype = SOCK_STREAM;
309 hints.ai_protocol = IPPROTO_TCP;
310 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
311 (void)gai_strerror(gaierr);
314 for (ai = aitop; ai; ai = ai->ai_next) {
315 if (ai->ai_addr == NULL ||
316 ai->ai_addrlen == 0 ||
317 getnameinfo(ai->ai_addr, ai->ai_addrlen,
318 straddr, sizeof(straddr), strport, sizeof(strport),
319 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
322 switch (ai->ai_family) {
324 if (strcmp(strport, "54321") != 0) {
328 if (strcmp(straddr, "0.0.0.0") != 0) {
332 if (strcmp(straddr, "127.0.0.1") != 0) {
339 if (strcmp(strport, "54321") != 0) {
343 if (strcmp(straddr, "::") != 0) {
347 if (strcmp(straddr, "::1") != 0) {
364 /* another family support? */
370 /* supported family should be 2, unsupported family should be 0 */
371 if (!(inet4 == 0 || inet4 == 2))
373 if (!(inet6 == 0 || inet6 == 2))
386 td_cv_buggygetaddrinfo=no,
387 td_cv_buggygetaddrinfo=yes,
388 td_cv_buggygetaddrinfo=yes)])
389 if test "$td_cv_buggygetaddrinfo" = no; then
395 if test "$td_cv_buggygetaddrinfo" = "yes"; then
397 # XXX - it doesn't appear that "ipv6type" can ever be
398 # set to "linux". Should this be testing for
399 # "linux-glibc", or for that *or* "linux-libinet6"?
400 # If the latter, note that "linux-libinet6" is also
401 # the type given to some non-Linux OSes.
403 if test "$ipv6type" != "linux"; then
404 echo 'Fatal: You must get working getaddrinfo() function.'
405 echo ' or you can specify "--disable-ipv6"'.
408 echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
409 echo ' Better upgrade your system library to newest version'
410 echo ' of GNU C library (aka glibc).'
414 AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
417 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
418 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
419 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
420 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
421 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
422 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
423 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
427 dnl check sizeof basic types.
428 dnl They're very likely to be wrong for cross-compiling.
429 AC_CHECK_SIZEOF(char, 1)
430 AC_CHECK_SIZEOF(short, 2)
431 AC_CHECK_SIZEOF(int, 4)
432 AC_CHECK_SIZEOF(long, 4)
433 AC_CHECK_SIZEOF(long long, 8)
436 dnl Checks for u_intXX_t
437 dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
438 dnl if test "$ac_cv_bittypes" = no; then
439 dnl missing_includes=yes
443 dnl Checks for addrinfo structure
444 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
445 if test "$ac_cv_addrinfo" = no; then
450 dnl Checks for NI_MAXSERV
451 AC_NI_MAXSERV(ac_cv_maxserv)
452 if test "$ac_cv_maxserv" = no; then
457 dnl Checks for NI_NAMEREQD
458 AC_NI_NAMEREQD(ac_cv_namereqd)
459 if test "$ac_cv_namereqd" = no; then
464 dnl Checks for sockaddr_storage structure
465 AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
466 if test "$ac_cv_sa_storage" = no; then
471 dnl Checks for IN[6]ADDRSZ
472 AC_CHECK_ADDRSZ(ac_cv_addrsz)
473 if test "$ac_cv_addrsz" = no; then
478 dnl Checks for RES_USE_INET6
479 AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
480 if test "$ac_cv_res_inet6" = no; then
485 dnl Checks for res_state_ext structure
486 AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
487 if test "$ac_cv_res_state_ext" = no; then
492 dnl Checks if res_state structure has nsort member.
493 AC_STRUCT_RES_STATE(ac_cv_res_state)
496 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
497 AC_CHECK_FUNCS(strftime)
498 AC_CHECK_FUNCS(ether_ntohost, [
499 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
502 #include <sys/types.h>
503 #include <sys/param.h>
504 #include <sys/socket.h>
507 main(int argc, char **argv)
509 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
510 char name[MAXHOSTNAMELEN];
512 ether_ntohost(name, (struct ether_addr *)ea);
515 ], [ac_cv_buggy_ether_ntohost=no],
516 [ac_cv_buggy_ether_ntohost=yes],
517 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
518 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
519 AC_DEFINE(USE_ETHER_NTOHOST)
522 AC_CHECK_FUNCS(setlinebuf alarm)
525 AC_CHECK_FUNCS(vsnprintf snprintf,,
527 if test $needsnprintf = yes; then
533 AC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA))
535 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
537 dnl HP/UX may need -lnsl for getrpcbynumber.
538 AC_SEARCH_LIBS(getrpcbynumber, nsl)
540 dnl AC_CHECK_LIB(z, uncompress)
541 dnl AC_CHECK_HEADERS(zlib.h)
543 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
546 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
547 # libraries (e.g., "-lsocket -lnsl" on Solaris).
549 # We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
550 # use AC_CHECK_FUNC which doesn't let us specify the right #includes
551 # to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
552 # resolver, and the way it defines inet_{ntop,pton} is rather strange;
553 # it does not ship with a libc symbol "inet_ntop()", it ships with
554 # "_inet_ntop()", and has a #define macro in one of the system headers
557 dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
558 AC_MSG_CHECKING(for inet_ntop)
559 AC_TRY_LINK([#include <sys/types.h>
560 #include <sys/socket.h>
561 #include <netinet/in.h>
562 #include <arpa/inet.h>], [char src[4], dst[128];
563 inet_ntop(AF_INET, src, dst, sizeof(dst));],
564 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
565 AC_LIBOBJ(inet_ntop)])
566 AC_MSG_CHECKING(for inet_pton)
567 AC_TRY_LINK([#include <sys/types.h>
568 #include <sys/socket.h>
569 #include <netinet/in.h>
570 #include <arpa/inet.h>], [char src[128], dst[4];
571 inet_pton(AF_INET, src, dst);],
572 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
573 AC_LIBOBJ(inet_pton)])
574 AC_MSG_CHECKING(for inet_aton)
575 AC_TRY_LINK([#include <sys/types.h>
576 #include <netinet/in.h>
577 #include <arpa/inet.h>], [char src[128];
579 inet_aton(src, &dst);],
580 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
581 AC_LIBOBJ(inet_aton)])
583 dnl portability macros for getaddrinfo/getnameinfo
586 AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
587 if test "$ac_cv_sockaddr_has_sa_len" = no; then
591 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
592 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
593 dnl Check for MacOS X, which may ship pcap.h from 0.6 but libpcap may
594 dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
596 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
598 if test $ac_cv_func_pcap_lib_version = "no" ; then
599 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
603 return_pcap_version(void)
605 extern char pcap_version[];
610 ac_lbl_cv_pcap_version_defined=yes,
611 ac_lbl_cv_pcap_version_defined=no)
612 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
614 AC_DEFINE(HAVE_PCAP_VERSION)
619 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
623 return_pcap_debug(void)
625 extern int pcap_debug;
630 ac_lbl_cv_pcap_debug_defined=yes,
631 ac_lbl_cv_pcap_debug_defined=no)
632 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
634 AC_DEFINE(HAVE_PCAP_DEBUG)
638 # OK, what about "yydebug"?
640 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
651 ac_lbl_cv_yydebug_defined=yes,
652 ac_lbl_cv_yydebug_defined=no)
653 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
655 AC_DEFINE(HAVE_YYDEBUG)
660 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
663 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
669 dnl Workaround to enable certain features
686 if test -f /dev/bpf0 ; then
690 AC_LBL_CHECK_TYPE(int8_t, signed char)
691 AC_LBL_CHECK_TYPE(u_int8_t, u_char)
692 AC_LBL_CHECK_TYPE(int16_t, short)
693 AC_LBL_CHECK_TYPE(u_int16_t, u_short)
694 AC_LBL_CHECK_TYPE(int32_t, int)
695 AC_LBL_CHECK_TYPE(u_int32_t, u_int)
696 AC_LBL_CHECK_TYPE(int64_t, long long)
697 AC_LBL_CHECK_TYPE(u_int64_t, unsigned long long)
699 AC_LBL_DEVEL(V_CCOPT)
701 AC_LBL_SOCKADDR_SA_LEN
703 AC_LBL_UNALIGNED_ACCESS
707 AC_ARG_WITH(crypto, [ --without-crypto disable crypto support],
709 AC_MSG_CHECKING(for SSLeay)
713 Xprefix=`eval echo $prefix`
715 for dir in $Xprefix /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do
717 # XXX - is there a better way to check if a given library is
718 # in a given directory than checking each of the possible
719 # shared library suffixes?
721 # Are there any other suffixes we need to look for? Do we have to
722 # worry about ".so.{version}"?
724 # Or should we just look for "libcrypto.*"?
726 if test -d $dir/lib -a \( -f $dir/lib/libcrypto.a -o \
727 -f $dir/lib/libcrypto.so -o \
728 -f $dir/lib/libcrypto.sl -o \
729 -f $dir/lib/libcrypto.dylib \); then
730 ac_cv_ssleay_path=$dir
732 if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
733 incdir="-I$dir/include"
735 if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
742 AC_MSG_RESULT($ac_cv_ssleay_path)
743 if test "$ac_cv_ssleay_path" != no; then
744 V_INCLS="$V_INCLS $incdir"
745 LDFLAGS="-L$dir/lib $LDFLAGS"
746 if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
747 LIBS="$LIBS -lRSAglue"
749 if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
750 LIBS="$LIBS -lrsaref"
752 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
754 CPPFLAGS="$CPPFLAGS $V_INCLS"
755 AC_CHECK_HEADERS(openssl/evp.h)
760 dnl set additional include path if necessary
761 if test "$missing_includes" = "yes"; then
762 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
763 V_INCLS="$V_INCLS -I\$(srcdir)/missing"
775 AC_CONFIG_HEADER(config.h)
777 AC_OUTPUT_COMMANDS([if test -f .devel; then
778 echo timestamp > stamp-h
779 cat Makefile-devel-adds >> Makefile