]> The Tcpdump Group git mirrors - tcpdump/blob - configure.in
ae9fb061d1a00b49ed0979cf6f7126d820fc4081
[tcpdump] / configure.in
1 dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.128 2000-10-21 04:54:26 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.128 $)
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)
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 __P macro
379 AC_CHECK_PORTABLE_PROTO(ac_cv_portable_proto)
380 if test "$ac_cv_portable_proto" = no; then
381 missing_includes=yes
382 fi
383
384 dnl
385 dnl check sizeof basic types.
386 dnl They're very likely to be wrong for cross-compiling.
387 AC_CHECK_SIZEOF(char, 1)
388 AC_CHECK_SIZEOF(short, 2)
389 AC_CHECK_SIZEOF(int, 4)
390 AC_CHECK_SIZEOF(long, 4)
391
392 dnl
393 dnl Checks for u_intXX_t
394 dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
395 dnl if test "$ac_cv_bittypes" = no; then
396 dnl missing_includes=yes
397 dnl fi
398
399 dnl
400 dnl Checks for addrinfo structure
401 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
402 if test "$ac_cv_addrinfo" = no; then
403 missing_includes=yes
404 fi
405
406 dnl
407 dnl Checks for NI_MAXSERV
408 AC_NI_MAXSERV(ac_cv_maxserv)
409 if test "$ac_cv_maxserv" = no; then
410 missing_includes=yes
411 fi
412
413 dnl
414 dnl Checks for NI_NAMEREQD
415 AC_NI_NAMEREQD(ac_cv_namereqd)
416 if test "$ac_cv_namereqd" = no; then
417 missing_includes=yes
418 fi
419
420 dnl
421 dnl Checks for sockaddr_storage structure
422 AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
423 if test "$ac_cv_sa_storage" = no; then
424 missing_includes=yes
425 fi
426
427 dnl
428 dnl Checks for IN[6]ADDRSZ
429 AC_CHECK_ADDRSZ(ac_cv_addrsz)
430 if test "$ac_cv_addrsz" = no; then
431 missing_includes=yes
432 fi
433
434 dnl
435 dnl Checks for RES_USE_INET6
436 AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
437 if test "$ac_cv_res_inet6" = no; then
438 missing_includes=yes
439 fi
440
441 dnl
442 dnl Checks for res_state_ext structure
443 AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
444 if test "$ac_cv_res_state_ext" = no; then
445 missing_includes=yes
446 fi
447
448 dnl
449 dnl Checks if res_state structure has nsort member.
450 AC_STRUCT_RES_STATE(ac_cv_res_state)
451
452 dnl
453 dnl set additional include path if necessary
454 if test "$missing_includes" = "yes"; then
455 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
456 V_INCLS="$V_INCLS -I\$(srcdir)/missing"
457 fi
458
459
460 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy)
461 AC_CHECK_FUNCS(ether_ntohost setlinebuf)
462
463 usegetipnodeby=yes
464 AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freeaddrinfo,
465 [], [usegetipnodeby=no])
466 if test $usegetipnodeby = yes; then
467 AC_DEFINE(USE_GETIPNODEBY)
468 fi
469
470 needsnprintf=no
471 AC_CHECK_FUNCS(vsnprintf snprintf asprintf asnprintf vasprintf vasnprintf,,
472 [needsnprintf=yes])
473 if test $needsnprintf = yes; then
474 LIBOBJS="$LIBOBJS snprintf.o"
475 fi
476
477 dnl The following generates a warning from autoconf...
478 errprint(__file__:__line__: please ignore the next warning:
479 )dnl
480 AC_C_BIGENDIAN
481
482 AC_CHECK_LIB(dnet, main)
483 AC_CHECK_LIB(rpc, main)
484 AC_CHECK_LIB(nsl, getrpcbynumber)
485 dnl AC_CHECK_LIB(z, uncompress)
486 dnl AC_CHECK_HEADERS(zlib.h)
487
488 AC_LBL_TYPE_SIGNAL
489
490 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
491
492 V_GROUP=0
493 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
494 V_GROUP=wheel
495 fi
496 case "$target_os" in
497
498 aix*)
499 dnl Workaround to enable certain features
500 AC_DEFINE(_SUN)
501 ;;
502
503 irix*)
504 V_GROUP=sys
505 ;;
506
507 osf*)
508 V_GROUP=system
509 ;;
510
511 solaris*)
512 V_GROUP=sys
513 ;;
514 esac
515
516 if test -f /dev/bpf0 ; then
517 V_GROUP=bpf
518 fi
519
520 AC_LBL_CHECK_TYPE(u_int8_t, u_char)
521 AC_LBL_CHECK_TYPE(int16_t, short)
522 AC_LBL_CHECK_TYPE(u_int16_t, u_short)
523 AC_LBL_CHECK_TYPE(int32_t, int)
524 AC_LBL_CHECK_TYPE(u_int32_t, u_int)
525
526 AC_LBL_DEVEL(V_CCOPT)
527
528 AC_LBL_SOCKADDR_SA_LEN
529
530 AC_LBL_UNALIGNED_ACCESS
531
532 AC_VAR_H_ERRNO
533
534 AC_ARG_WITH(crypto, [ --without-crypto disable crypto support],
535 [], [
536 AC_MSG_CHECKING(for SSLeay)
537 ac_cv_ssleay_path=no
538 incdir=no
539 for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do
540 if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then
541 ac_cv_ssleay_path=$dir
542 fi
543 if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
544 incdir="-I$dir/include/ssleay"
545 elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
546 incdir="-I$dir/include -I$dir/include/openssl"
547 elif test -d $dir/include -a -f $dir/include/des.h; then
548 incdir="-I$dir/include"
549 fi
550 if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
551 break;
552 else
553 ac_cv_ssleay_path=no
554 incdir=no
555 fi
556 done
557 AC_MSG_RESULT($ac_cv_ssleay_path)
558 if test "$ac_cv_ssleay_path" != no; then
559 V_INCLS="$V_INCLS $incdir"
560 LIBS="$LIBS -L$dir/lib"
561 if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
562 LIBS="$LIBS -lRSAglue"
563 fi
564 if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
565 LIBS="$LIBS -lrsaref"
566 fi
567 AC_CHECK_LIB(crypto, des_cbc_encrypt)
568
569 bak_CPPFLAGS=$CPPFLAGS
570 CPPFLAGS="$CPPFLAGS $V_INCLS"
571 AC_CHECK_HEADERS(cast.h)
572
573 if test "$ac_cv_header_cast_h" = "yes"; then
574 AC_MSG_CHECKING(for buggy CAST128)
575 AC_TRY_RUN(dnl
576 [
577 #include <cast.h>
578 main()
579 {
580 unsigned char key[] = {0x01,0x23,0x45,0x67,0x12};
581 unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
582 unsigned char out[sizeof(in)];
583 unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E};
584 CAST_KEY ks;
585 CAST_set_key(&ks, sizeof(key), key);
586 CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT);
587 if (memcmp(out, ok, sizeof(ok)) != 0)
588 return 0;
589 else
590 return 1;
591 }],
592 [buggy_cast128=yes],
593 [buggy_cast128=no],
594 [buggy_cast128="cross-compiling, assume yes"])
595 AC_MSG_RESULT($buggy_cast128)
596 if test "$buggy_cast128" != no; then
597 echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine."
598 echo "disabling CAST128 support."
599 AC_DEFINE(HAVE_BUGGY_CAST128)
600 fi
601 fi
602
603 CPPFLAGS=$bak_CPPFLAGS
604 fi
605 ])
606 AC_CHECK_HEADERS(rc5.h)
607
608 AC_SUBST(V_CCOPT)
609 AC_SUBST(V_GROUP)
610 AC_SUBST(V_INCLS)
611 AC_SUBST(V_PCAPDEP)
612 AC_SUBST(LOCALSRC)
613
614 AC_PROG_INSTALL
615
616 AC_CONFIG_HEADER(config.h)
617
618 AC_OUTPUT_COMMANDS([if test -f .devel; then
619 echo timestamp > stamp-h
620 cat Makefile-devel-adds >> Makefile
621 make depend
622 fi])
623 AC_OUTPUT(Makefile)
624 exit 0