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