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