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