]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/tcpdump/configure.in
This commit was generated by cvs2svn to compensate for changes in r92688,
[FreeBSD/FreeBSD.git] / contrib / tcpdump / configure.in
1 dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.132.4.1 2001/01/17 18:29:58 guy Exp $ (LBL)
2 dnl
3 dnl Copyright (c) 1994, 1995, 1996, 1997
4 dnl     The Regents of the University of California.  All rights reserved.
5 dnl
6 dnl Process this file with autoconf to produce a configure script.
7 dnl
8
9 AC_REVISION($Revision: 1.132.4.1 $)
10 AC_PREREQ(2.13)
11 AC_INIT(tcpdump.c)
12
13 AC_CANONICAL_SYSTEM
14
15 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
16 AC_C_INLINE
17 AC_C___ATTRIBUTE__
18
19 AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h)
20 AC_HEADER_TIME
21
22 case "$target_os" in
23
24 linux*)
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         ;;
45 esac
46
47
48 AC_CHECK_HEADERS(smi.h)
49 AC_CHECK_LIB(smi, smiInit)
50 AC_MSG_CHECKING([whether to enable libsmi])
51         AC_TRY_RUN([ /* libsmi available check */
52 #include <smi.h>
53 main()
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
79 CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
80 AC_MSG_CHECKING([whether to enable ipv6])
81 AC_ARG_ENABLE(ipv6,
82 [  --enable-ipv6           enable ipv6 (with ipv4) support
83   --disable-ipv6          disable ipv6 support],
84 [ case "$enableval" in
85 yes)   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>
99 main()
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
117 ipv6type=unknown
118 ipv6lib=none
119 ipv6trylibc=no
120
121 if 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
130 yes
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__
140 yes
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
153 yes
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
172 yes
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__
183 yes
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
194 yes
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)
207 fi
208
209 if 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
223 fi
224
225
226 if 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
236 main()
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)
342 fi
343 dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
344 AC_MSG_CHECKING(for inet_ntop)
345 AC_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];
349 inet_ntop(AF_INET, src, dst, sizeof(dst));],
350         [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
351         AC_REPLACE_FUNCS(inet_ntop)])
352 AC_MSG_CHECKING(for inet_pton)
353 AC_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];
357 inet_pton(AF_INET, src, dst);],
358         [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
359         AC_REPLACE_FUNCS(inet_pton)])
360 AC_MSG_CHECKING(for inet_aton)
361 AC_TRY_COMPILE([#include <sys/types.h>
362 #include <netinet/in.h>
363 #include <arpa/inet.h>], [char src[128];
364 struct in_addr dst;
365 inet_aton(src, &dst);],
366         [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
367         AC_REPLACE_FUNCS(inet_aton)])
368
369 dnl portability macros for getaddrinfo/getnameinfo
370 dnl
371 dnl Check for sa_len
372 AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
373 if test "$ac_cv_sockaddr_has_sa_len" = no; then
374         missing_includes=yes
375 fi
376
377 dnl
378 dnl check sizeof basic types.
379 dnl They're very likely to be wrong for cross-compiling.
380 AC_CHECK_SIZEOF(char, 1)
381 AC_CHECK_SIZEOF(short, 2)
382 AC_CHECK_SIZEOF(int, 4)
383 AC_CHECK_SIZEOF(long, 4)
384
385 dnl
386 dnl Checks for u_intXX_t
387 dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
388 dnl if test "$ac_cv_bittypes" = no; then
389 dnl     missing_includes=yes
390 dnl fi
391
392 dnl
393 dnl Checks for addrinfo structure
394 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
395 if test "$ac_cv_addrinfo" = no; then
396         missing_includes=yes
397 fi
398
399 dnl
400 dnl Checks for NI_MAXSERV
401 AC_NI_MAXSERV(ac_cv_maxserv)
402 if test "$ac_cv_maxserv" = no; then
403         missing_includes=yes
404 fi
405
406 dnl
407 dnl Checks for NI_NAMEREQD
408 AC_NI_NAMEREQD(ac_cv_namereqd)
409 if test "$ac_cv_namereqd" = no; then
410         missing_includes=yes
411 fi
412
413 dnl
414 dnl Checks for sockaddr_storage structure
415 AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
416 if test "$ac_cv_sa_storage" = no; then
417         missing_includes=yes
418 fi
419
420 dnl
421 dnl Checks for IN[6]ADDRSZ
422 AC_CHECK_ADDRSZ(ac_cv_addrsz)
423 if test "$ac_cv_addrsz" = no; then
424         missing_includes=yes
425 fi
426
427 dnl
428 dnl Checks for RES_USE_INET6
429 AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
430 if test "$ac_cv_res_inet6" = no; then
431         missing_includes=yes
432 fi
433
434 dnl
435 dnl Checks for res_state_ext structure
436 AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
437 if test "$ac_cv_res_state_ext" = no; then
438         missing_includes=yes
439 fi
440
441 dnl
442 dnl Checks if res_state structure has nsort member.
443 AC_STRUCT_RES_STATE(ac_cv_res_state)
444
445 dnl
446 dnl set additional include path if necessary
447 if test "$missing_includes" = "yes"; then
448         CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
449         V_INCLS="$V_INCLS -I\$(srcdir)/missing"
450 fi
451
452
453 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy)
454 AC_CHECK_FUNCS(ether_ntohost setlinebuf)
455
456 usegetipnodeby=yes
457 AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freeaddrinfo,
458         [], [usegetipnodeby=no])
459 if test $usegetipnodeby = yes; then
460         AC_DEFINE(USE_GETIPNODEBY)
461 fi
462
463 needsnprintf=no
464 AC_CHECK_FUNCS(vsnprintf snprintf,,
465         [needsnprintf=yes])
466 if test $needsnprintf = yes; then
467         LIBOBJS="$LIBOBJS snprintf.o"
468 fi
469
470 dnl The following generates a warning from autoconf...
471 errprint(__file__:__line__: please ignore the next warning:
472 )dnl
473 AC_C_BIGENDIAN
474
475 AC_CHECK_LIB(dnet, main)
476 AC_CHECK_LIB(rpc, main)
477 AC_CHECK_LIB(nsl, getrpcbynumber)
478 dnl AC_CHECK_LIB(z, uncompress)
479 dnl AC_CHECK_HEADERS(zlib.h)
480
481 AC_LBL_TYPE_SIGNAL
482
483 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
484
485 AC_REPLACE_FUNCS(bpf_dump)      dnl moved to libpcap in 0.6
486
487 V_GROUP=0
488 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
489         V_GROUP=wheel
490 fi
491 case "$target_os" in
492
493 aix*)
494         dnl Workaround to enable certain features
495         AC_DEFINE(_SUN)
496         ;;
497
498 irix*)
499         V_GROUP=sys
500         ;;
501
502 osf*)
503         V_GROUP=system
504         ;;
505
506 solaris*)
507         V_GROUP=sys
508         ;;
509 esac
510
511 if test -f /dev/bpf0 ; then
512         V_GROUP=bpf
513 fi
514
515 AC_LBL_CHECK_TYPE(u_int8_t, u_char)
516 AC_LBL_CHECK_TYPE(int16_t, short)
517 AC_LBL_CHECK_TYPE(u_int16_t, u_short)
518 AC_LBL_CHECK_TYPE(int32_t, int)
519 AC_LBL_CHECK_TYPE(u_int32_t, u_int)
520
521 AC_LBL_DEVEL(V_CCOPT)
522
523 AC_LBL_SOCKADDR_SA_LEN
524
525 AC_LBL_UNALIGNED_ACCESS
526
527 AC_VAR_H_ERRNO
528
529 AC_ARG_WITH(crypto, [  --without-crypto        disable crypto support],
530         [], [
531 AC_MSG_CHECKING(for SSLeay)
532 ac_cv_ssleay_path=no
533 incdir=no
534 for 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
551 done
552 AC_MSG_RESULT($ac_cv_ssleay_path)
553 if 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>
573 main()
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
599 fi
600 ])
601 AC_CHECK_HEADERS(rc5.h)
602
603 AC_SUBST(V_CCOPT)
604 AC_SUBST(V_GROUP)
605 AC_SUBST(V_INCLS)
606 AC_SUBST(V_PCAPDEP)
607 AC_SUBST(LOCALSRC)
608
609 AC_PROG_INSTALL
610
611 AC_CONFIG_HEADER(config.h)
612
613 AC_OUTPUT_COMMANDS([if test -f .devel; then
614         echo timestamp > stamp-h
615         cat Makefile-devel-adds >> Makefile
616         make depend
617 fi])
618 AC_OUTPUT(Makefile)
619 exit 0