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