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