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