xref: /freebsd/contrib/tcpdump/configure.in (revision adeb92a24c57f97d5cd3c3c45be239cbb23aed68)
1dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.132.4.1 2001/01/17 18:29:58 guy Exp $ (LBL)
2dnl
3dnl Copyright (c) 1994, 1995, 1996, 1997
4dnl	The Regents of the University of California.  All rights reserved.
5dnl
6dnl Process this file with autoconf to produce a configure script.
7dnl
8
9AC_REVISION($Revision: 1.132.4.1 $)
10AC_PREREQ(2.13)
11AC_INIT(tcpdump.c)
12
13AC_CANONICAL_SYSTEM
14
15AC_LBL_C_INIT(V_CCOPT, V_INCLS)
16AC_C_INLINE
17AC_C___ATTRIBUTE__
18
19AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h)
20AC_HEADER_TIME
21
22case "$target_os" in
23
24linux*)
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)
29 	else
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'`)
33 	fi
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)
37 	fi
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)
40	fi
41	;;
42
43*)
44	;;
45esac
46
47
48AC_CHECK_HEADERS(smi.h)
49AC_CHECK_LIB(smi, smiInit)
50AC_MSG_CHECKING([whether to enable libsmi])
51        AC_TRY_RUN([ /* libsmi available check */
52#include <smi.h>
53main()
54{
55  int current, revision, age, n;
56  const int required = 2;
57  if (smiInit(""))
58    exit(1);
59  if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
60    exit(2);
61  n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
62  if (n != 3)
63    exit(3);
64  if (required < current - age || required > current)
65    exit(4);
66  exit(0);
67}
68],
69[ AC_MSG_RESULT(yes)
70  AC_DEFINE(LIBSMI)
71  libsmi=yes],
72[ AC_MSG_RESULT(no)
73  libsmi=no],
74[ AC_MSG_RESULT(not when cross-compiling)
75  libsmi=no]
76)
77
78
79CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
80AC_MSG_CHECKING([whether to enable ipv6])
81AC_ARG_ENABLE(ipv6,
82[  --enable-ipv6           enable ipv6 (with ipv4) support
83  --disable-ipv6          disable ipv6 support],
84[ case "$enableval" in
85yes)   AC_MSG_RESULT(yes)
86       LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
87       AC_DEFINE(INET6)
88       ipv6=yes
89       ;;
90*)
91       AC_MSG_RESULT(no)
92       ipv6=no
93       ;;
94  esac ],
95
96  AC_TRY_RUN([ /* AF_INET6 available check */
97#include <sys/types.h>
98#include <sys/socket.h>
99main()
100{
101 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
102   exit(1);
103 else
104   exit(0);
105}
106],
107[ AC_MSG_RESULT(yes)
108  LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
109  AC_DEFINE(INET6)
110  ipv6=yes],
111[ AC_MSG_RESULT(no)
112  ipv6=no],
113[ AC_MSG_RESULT(no)
114  ipv6=no]
115))
116
117ipv6type=unknown
118ipv6lib=none
119ipv6trylibc=no
120
121if test "$ipv6" = "yes"; then
122	AC_MSG_CHECKING([ipv6 stack type])
123	for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
124		case $i in
125		inria)
126			dnl http://www.kame.net/
127			AC_EGREP_CPP(yes, [dnl
128#include <netinet/in.h>
129#ifdef IPV6_INRIA_VERSION
130yes
131#endif],
132				[ipv6type=$i;
133				CFLAGS="-DINET6 $CFLAGS"])
134			;;
135		kame)
136			dnl http://www.kame.net/
137			AC_EGREP_CPP(yes, [dnl
138#include <netinet/in.h>
139#ifdef __KAME__
140yes
141#endif],
142				[ipv6type=$i;
143				ipv6lib=inet6;
144				ipv6libdir=/usr/local/v6/lib;
145				ipv6trylibc=yes;
146				CFLAGS="-DINET6 $CFLAGS"])
147			;;
148		linux-glibc)
149			dnl http://www.v6.linux.or.jp/
150			AC_EGREP_CPP(yes, [dnl
151#include <features.h>
152#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
153yes
154#endif],
155				[ipv6type=$i;
156				CFLAGS="-DINET6 $CFLAGS"])
157			;;
158		linux-libinet6)
159			dnl http://www.v6.linux.or.jp/
160			if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
161				ipv6type=$i
162				ipv6lib=inet6
163				ipv6libdir=/usr/inet6/lib
164				ipv6trylibc=yes;
165				CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
166			fi
167			;;
168		toshiba)
169			AC_EGREP_CPP(yes, [dnl
170#include <sys/param.h>
171#ifdef _TOSHIBA_INET6
172yes
173#endif],
174				[ipv6type=$i;
175				ipv6lib=inet6;
176				ipv6libdir=/usr/local/v6/lib;
177				CFLAGS="-DINET6 $CFLAGS"])
178			;;
179		v6d)
180			AC_EGREP_CPP(yes, [dnl
181#include </usr/local/v6/include/sys/v6config.h>
182#ifdef __V6D__
183yes
184#endif],
185				[ipv6type=$i;
186				ipv6lib=v6;
187				ipv6libdir=/usr/local/v6/lib;
188				CFLAGS="-I/usr/local/v6/include $CFLAGS"])
189			;;
190		zeta)
191			AC_EGREP_CPP(yes, [dnl
192#include <sys/param.h>
193#ifdef _ZETA_MINAMI_INET6
194yes
195#endif],
196				[ipv6type=$i;
197				ipv6lib=inet6;
198				ipv6libdir=/usr/local/v6/lib;
199				CFLAGS="-DINET6 $CFLAGS"])
200			;;
201		esac
202		if test "$ipv6type" != "unknown"; then
203			break
204		fi
205	done
206	AC_MSG_RESULT($ipv6type)
207fi
208
209if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
210	if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
211		LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
212		echo "You have $ipv6lib library, using it"
213	else
214		if test "$ipv6trylibc" = "yes"; then
215			echo "You do not have $ipv6lib library, using libc"
216		else
217			echo 'Fatal: no $ipv6lib library found.  cannot continue.'
218			echo "You need to fetch lib$ipv6lib.a from appropriate"
219			echo 'ipv6 kit and compile beforehand.'
220			exit 1
221		fi
222	fi
223fi
224
225
226if test "$ipv6" = "yes"; then
227	AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
228	AC_MSG_CHECKING(getaddrinfo bug)
229	AC_TRY_RUN([
230#include <sys/types.h>
231#include <netdb.h>
232#include <string.h>
233#include <sys/socket.h>
234#include <netinet/in.h>
235
236main()
237{
238  int passive, gaierr, inet4 = 0, inet6 = 0;
239  struct addrinfo hints, *ai, *aitop;
240  char straddr[INET6_ADDRSTRLEN], strport[16];
241
242  for (passive = 0; passive <= 1; passive++) {
243    memset(&hints, 0, sizeof(hints));
244    hints.ai_family = AF_UNSPEC;
245    hints.ai_flags = passive ? AI_PASSIVE : 0;
246    hints.ai_socktype = SOCK_STREAM;
247    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
248      (void)gai_strerror(gaierr);
249      goto bad;
250    }
251    for (ai = aitop; ai; ai = ai->ai_next) {
252      if (ai->ai_addr == NULL ||
253          ai->ai_addrlen == 0 ||
254          getnameinfo(ai->ai_addr, ai->ai_addrlen,
255                      straddr, sizeof(straddr), strport, sizeof(strport),
256                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
257        goto bad;
258      }
259      switch (ai->ai_family) {
260      case AF_INET:
261        if (strcmp(strport, "54321") != 0) {
262          goto bad;
263        }
264        if (passive) {
265          if (strcmp(straddr, "0.0.0.0") != 0) {
266            goto bad;
267          }
268        } else {
269          if (strcmp(straddr, "127.0.0.1") != 0) {
270            goto bad;
271          }
272        }
273        inet4++;
274        break;
275      case AF_INET6:
276        if (strcmp(strport, "54321") != 0) {
277          goto bad;
278        }
279        if (passive) {
280          if (strcmp(straddr, "::") != 0) {
281            goto bad;
282          }
283        } else {
284          if (strcmp(straddr, "::1") != 0) {
285            goto bad;
286          }
287        }
288        inet6++;
289        break;
290      case AF_UNSPEC:
291        goto bad;
292        break;
293#ifdef AF_UNIX
294      case AF_UNIX:
295#else
296#ifdef AF_LOCAL
297      case AF_LOCAL:
298#endif
299#endif
300      default:
301        /* another family support? */
302        break;
303      }
304    }
305  }
306
307  /* supported family should be 2, unsupported family should be 0 */
308  if (!(inet4 == 0 || inet4 == 2))
309    goto bad;
310  if (!(inet6 == 0 || inet6 == 2))
311    goto bad;
312
313  if (aitop)
314    freeaddrinfo(aitop);
315  exit(0);
316
317 bad:
318  if (aitop)
319    freeaddrinfo(aitop);
320  exit(1);
321}
322],
323	AC_MSG_RESULT(good)
324	buggygetaddrinfo=no,
325	AC_MSG_RESULT(buggy)
326	buggygetaddrinfo=yes,
327	AC_MSG_RESULT(buggy)
328	buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
329
330	if test "$buggygetaddrinfo" = "yes"; then
331		if test "$ipv6type" != "linux"; then
332			echo 'Fatal: You must get working getaddrinfo() function.'
333			echo '       or you can specify "--disable-ipv6"'.
334			exit 1
335		else
336			echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
337			echo '         Better upgreade your system library to newest version'
338			echo '         of GNU C library (aka glibc).'
339		fi
340	fi
341	AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
342fi
343dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
344AC_MSG_CHECKING(for inet_ntop)
345AC_TRY_COMPILE([#include <sys/types.h>
346#include <sys/socket.h>
347#include <netinet/in.h>
348#include <arpa/inet.h>], [char src[4], dst[128];
349inet_ntop(AF_INET, src, dst, sizeof(dst));],
350	[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
351	AC_REPLACE_FUNCS(inet_ntop)])
352AC_MSG_CHECKING(for inet_pton)
353AC_TRY_COMPILE([#include <sys/types.h>
354#include <sys/socket.h>
355#include <netinet/in.h>
356#include <arpa/inet.h>], [char src[128], dst[4];
357inet_pton(AF_INET, src, dst);],
358	[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
359	AC_REPLACE_FUNCS(inet_pton)])
360AC_MSG_CHECKING(for inet_aton)
361AC_TRY_COMPILE([#include <sys/types.h>
362#include <netinet/in.h>
363#include <arpa/inet.h>], [char src[128];
364struct in_addr dst;
365inet_aton(src, &dst);],
366	[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
367	AC_REPLACE_FUNCS(inet_aton)])
368
369dnl portability macros for getaddrinfo/getnameinfo
370dnl
371dnl Check for sa_len
372AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
373if test "$ac_cv_sockaddr_has_sa_len" = no; then
374	missing_includes=yes
375fi
376
377dnl
378dnl check sizeof basic types.
379dnl They're very likely to be wrong for cross-compiling.
380AC_CHECK_SIZEOF(char, 1)
381AC_CHECK_SIZEOF(short, 2)
382AC_CHECK_SIZEOF(int, 4)
383AC_CHECK_SIZEOF(long, 4)
384
385dnl
386dnl Checks for u_intXX_t
387dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
388dnl if test "$ac_cv_bittypes" = no; then
389dnl 	missing_includes=yes
390dnl fi
391
392dnl
393dnl Checks for addrinfo structure
394AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
395if test "$ac_cv_addrinfo" = no; then
396	missing_includes=yes
397fi
398
399dnl
400dnl Checks for NI_MAXSERV
401AC_NI_MAXSERV(ac_cv_maxserv)
402if test "$ac_cv_maxserv" = no; then
403	missing_includes=yes
404fi
405
406dnl
407dnl Checks for NI_NAMEREQD
408AC_NI_NAMEREQD(ac_cv_namereqd)
409if test "$ac_cv_namereqd" = no; then
410	missing_includes=yes
411fi
412
413dnl
414dnl Checks for sockaddr_storage structure
415AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
416if test "$ac_cv_sa_storage" = no; then
417	missing_includes=yes
418fi
419
420dnl
421dnl Checks for IN[6]ADDRSZ
422AC_CHECK_ADDRSZ(ac_cv_addrsz)
423if test "$ac_cv_addrsz" = no; then
424	missing_includes=yes
425fi
426
427dnl
428dnl Checks for RES_USE_INET6
429AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
430if test "$ac_cv_res_inet6" = no; then
431	missing_includes=yes
432fi
433
434dnl
435dnl Checks for res_state_ext structure
436AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
437if test "$ac_cv_res_state_ext" = no; then
438	missing_includes=yes
439fi
440
441dnl
442dnl Checks if res_state structure has nsort member.
443AC_STRUCT_RES_STATE(ac_cv_res_state)
444
445dnl
446dnl set additional include path if necessary
447if test "$missing_includes" = "yes"; then
448	CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
449	V_INCLS="$V_INCLS -I\$(srcdir)/missing"
450fi
451
452
453AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy)
454AC_CHECK_FUNCS(ether_ntohost setlinebuf)
455
456usegetipnodeby=yes
457AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freeaddrinfo,
458	[], [usegetipnodeby=no])
459if test $usegetipnodeby = yes; then
460	AC_DEFINE(USE_GETIPNODEBY)
461fi
462
463needsnprintf=no
464AC_CHECK_FUNCS(vsnprintf snprintf,,
465	[needsnprintf=yes])
466if test $needsnprintf = yes; then
467	LIBOBJS="$LIBOBJS snprintf.o"
468fi
469
470dnl The following generates a warning from autoconf...
471errprint(__file__:__line__: please ignore the next warning:
472)dnl
473AC_C_BIGENDIAN
474
475AC_CHECK_LIB(dnet, main)
476AC_CHECK_LIB(rpc, main)
477AC_CHECK_LIB(nsl, getrpcbynumber)
478dnl AC_CHECK_LIB(z, uncompress)
479dnl AC_CHECK_HEADERS(zlib.h)
480
481AC_LBL_TYPE_SIGNAL
482
483AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
484
485AC_REPLACE_FUNCS(bpf_dump)	dnl moved to libpcap in 0.6
486
487V_GROUP=0
488if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
489	V_GROUP=wheel
490fi
491case "$target_os" in
492
493aix*)
494	dnl Workaround to enable certain features
495	AC_DEFINE(_SUN)
496	;;
497
498irix*)
499	V_GROUP=sys
500	;;
501
502osf*)
503	V_GROUP=system
504	;;
505
506solaris*)
507	V_GROUP=sys
508	;;
509esac
510
511if test -f /dev/bpf0 ; then
512	V_GROUP=bpf
513fi
514
515AC_LBL_CHECK_TYPE(u_int8_t, u_char)
516AC_LBL_CHECK_TYPE(int16_t, short)
517AC_LBL_CHECK_TYPE(u_int16_t, u_short)
518AC_LBL_CHECK_TYPE(int32_t, int)
519AC_LBL_CHECK_TYPE(u_int32_t, u_int)
520
521AC_LBL_DEVEL(V_CCOPT)
522
523AC_LBL_SOCKADDR_SA_LEN
524
525AC_LBL_UNALIGNED_ACCESS
526
527AC_VAR_H_ERRNO
528
529AC_ARG_WITH(crypto, [  --without-crypto        disable crypto support],
530	[], [
531AC_MSG_CHECKING(for SSLeay)
532ac_cv_ssleay_path=no
533incdir=no
534for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do
535	if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then
536		ac_cv_ssleay_path=$dir
537	fi
538	if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
539	  incdir="-I$dir/include/ssleay"
540	elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
541   	  incdir="-I$dir/include -I$dir/include/openssl"
542	elif test -d $dir/include -a -f $dir/include/des.h; then
543		incdir="-I$dir/include"
544	fi
545	if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
546		break;
547	else
548		ac_cv_ssleay_path=no
549		incdir=no
550	fi
551done
552AC_MSG_RESULT($ac_cv_ssleay_path)
553if test "$ac_cv_ssleay_path" != no; then
554	V_INCLS="$V_INCLS $incdir"
555	LDFLAGS="-L$dir/lib $LDFLAGS"
556	if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
557		LIBS="$LIBS -lRSAglue"
558	fi
559	if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
560		LIBS="$LIBS -lrsaref"
561	fi
562	AC_CHECK_LIB(crypto, des_cbc_encrypt)
563
564	bak_CPPFLAGS=$CPPFLAGS
565	CPPFLAGS="$CPPFLAGS $V_INCLS"
566	AC_CHECK_HEADERS(cast.h)
567
568	if test "$ac_cv_header_cast_h" = "yes"; then
569		AC_MSG_CHECKING(for buggy CAST128)
570		AC_TRY_RUN(dnl
571[
572#include <cast.h>
573main()
574{
575	unsigned char key[] = {0x01,0x23,0x45,0x67,0x12};
576	unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
577	unsigned char out[sizeof(in)];
578	unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E};
579	CAST_KEY ks;
580	CAST_set_key(&ks, sizeof(key), key);
581	CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT);
582	if (memcmp(out, ok, sizeof(ok)) != 0)
583		return 0;
584	else
585		return 1;
586}],
587			[buggy_cast128=yes],
588			[buggy_cast128=no],
589			[buggy_cast128="cross-compiling, assume yes"])
590		AC_MSG_RESULT($buggy_cast128)
591		if test "$buggy_cast128" != no; then
592			echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine."
593			echo "disabling CAST128 support."
594			AC_DEFINE(HAVE_BUGGY_CAST128)
595		fi
596	fi
597
598	CPPFLAGS=$bak_CPPFLAGS
599fi
600])
601AC_CHECK_HEADERS(rc5.h)
602
603AC_SUBST(V_CCOPT)
604AC_SUBST(V_GROUP)
605AC_SUBST(V_INCLS)
606AC_SUBST(V_PCAPDEP)
607AC_SUBST(LOCALSRC)
608
609AC_PROG_INSTALL
610
611AC_CONFIG_HEADER(config.h)
612
613AC_OUTPUT_COMMANDS([if test -f .devel; then
614	echo timestamp > stamp-h
615	cat Makefile-devel-adds >> Makefile
616	make depend
617fi])
618AC_OUTPUT(Makefile)
619exit 0
620