]> The Tcpdump Group git mirrors - tcpdump/blob - configure.in
Check that bytes exist in the captured data before fetching them.
[tcpdump] / configure.in
1 dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 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 #
10 # See
11 #
12 # http://ftp.gnu.org/gnu/config/README
13 #
14 # for the URLs to use to fetch new versions of config.guess and
15 # config.sub.
16 #
17
18 AC_REVISION($Revision: 1.204 $)
19 AC_PREREQ(2.50)
20 AC_INIT(tcpdump.c)
21
22 AC_CANONICAL_HOST
23
24 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
25 AC_LBL_C_INLINE
26 AC_C___ATTRIBUTE__
27 if test "$ac_cv___attribute__" = "yes"; then
28 AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
29 fi
30 AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h)
31 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
32 #include <sys/socket.h>
33 #include <net/if.h>])
34 if test "$ac_cv_header_net_pfvar_h" = yes; then
35 LOCALSRC="print-pflog.c $LOCALSRC"
36 fi
37 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
38 #include <sys/socket.h>])
39 if test "$ac_cv_header_netinet_if_ether_h" != yes; then
40 #
41 # The simple test didn't work.
42 # Do we need to include <net/if.h> first?
43 # Unset ac_cv_header_netinet_if_ether_h so we don't
44 # treat the previous failure as a cached value and
45 # suppress the next test.
46 #
47 AC_MSG_NOTICE([Rechecking with some additional includes])
48 unset ac_cv_header_netinet_if_ether_h
49 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
50 #include <sys/socket.h>
51 #include <netinet/in.h>
52 struct mbuf;
53 struct rtentry;
54 #include <net/if.h>])
55 fi
56
57 AC_HEADER_TIME
58
59 case "$host_os" in
60
61 linux*)
62 AC_MSG_CHECKING(Linux kernel version)
63 if test "$cross_compiling" = yes; then
64 AC_CACHE_VAL(ac_cv_linux_vers,
65 ac_cv_linux_vers=unknown)
66 else
67 AC_CACHE_VAL(ac_cv_linux_vers,
68 ac_cv_linux_vers=`uname -r 2>&1 | \
69 sed -n -e '$s/.* //' -e '$s/\..*//p'`)
70 fi
71 AC_MSG_RESULT($ac_cv_linux_vers)
72 if test $ac_cv_linux_vers = unknown ; then
73 AC_MSG_ERROR(cannot determine linux version when cross-compiling)
74 fi
75 if test $ac_cv_linux_vers -lt 2 ; then
76 AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
77 fi
78 ;;
79
80 *)
81 ;;
82 esac
83
84
85 AC_ARG_WITH(smi,
86 [ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
87 --without-smi don't link with libsmi],,
88 with_smi=yes)
89
90 if test "x$with_smi" != "xno" ; then
91 AC_CHECK_HEADERS(smi.h)
92 AC_CHECK_LIB(smi, smiInit)
93 if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
94 then
95 AC_MSG_CHECKING([whether to enable libsmi])
96 AC_TRY_RUN([ /* libsmi available check */
97 #include <smi.h>
98 main()
99 {
100 int current, revision, age, n;
101 const int required = 2;
102 if (smiInit(""))
103 exit(1);
104 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
105 exit(2);
106 n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
107 if (n != 3)
108 exit(3);
109 if (required < current - age || required > current)
110 exit(4);
111 exit(0);
112 }
113 ],
114 [ AC_MSG_RESULT(yes)
115 AC_DEFINE(LIBSMI)
116 libsmi=yes],
117 dnl autoconf documentation says that $? contains the exit value.
118 dnl reality is that it does not. We leave this in just in case
119 dnl autoconf ever comes back to match the documentation.
120 [ case $? in
121 1) AC_MSG_RESULT(no - smiInit failed) ;;
122 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
123 3) AC_MSG_RESULT(no - can't determine library version) ;;
124 4) AC_MSG_RESULT(no - too old) ;;
125 *) AC_MSG_RESULT(no) ;;
126 esac
127 libsmi=no],
128 [ AC_MSG_RESULT(not when cross-compiling)
129 libsmi=no]
130 )
131 fi
132 fi
133
134 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
135 AC_ARG_ENABLE(smb,
136 [ --enable-smb enable possibly-buggy SMB printer [default=yes]
137 --disable-smb disable possibly-buggy SMB printer],,
138 enableval=yes)
139 case "$enableval" in
140 yes) AC_MSG_RESULT(yes)
141 AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
142 AC_DEFINE(TCPDUMP_DO_SMB)
143 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
144 ;;
145 *) AC_MSG_RESULT(no)
146 ;;
147 esac
148
149 AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
150 AC_MSG_CHECKING([whether to drop root privileges by default])
151 if test ! -z "$with_user" ; then
152 AC_DEFINE_UNQUOTED(WITH_USER, "$withval")
153 AC_MSG_RESULT(to \"$withval\")
154 else
155 AC_MSG_RESULT(no)
156 fi
157
158 AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
159 AC_MSG_CHECKING([whether to chroot])
160 if test ! -z "$with_chroot" ; then
161 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval")
162 AC_MSG_RESULT(to \"$withval\")
163 else
164 AC_MSG_RESULT(no)
165 fi
166
167 AC_MSG_CHECKING([whether to enable ipv6])
168 AC_ARG_ENABLE(ipv6,
169 [ --enable-ipv6 enable ipv6 (with ipv4) support
170 --disable-ipv6 disable ipv6 support],
171 [ case "$enableval" in
172 yes) AC_MSG_RESULT(yes)
173 LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
174 AC_DEFINE(INET6)
175 ipv6=yes
176 ;;
177 *)
178 AC_MSG_RESULT(no)
179 ipv6=no
180 ;;
181 esac ],
182
183 AC_TRY_RUN([ /* AF_INET6 available check */
184 #include <sys/types.h>
185 #include <sys/socket.h>
186 main()
187 {
188 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
189 exit(1);
190 else
191 exit(0);
192 }
193 ],
194 [ AC_MSG_RESULT(yes)
195 LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
196 AC_DEFINE(INET6)
197 ipv6=yes],
198 [ AC_MSG_RESULT(no)
199 ipv6=no],
200 [ AC_MSG_RESULT(no)
201 ipv6=no]
202 ))
203
204 ipv6type=unknown
205 ipv6lib=none
206 ipv6trylibc=no
207
208 if test "$ipv6" = "yes"; then
209 AC_MSG_CHECKING([ipv6 stack type])
210 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
211 case $i in
212 inria)
213 dnl http://www.kame.net/
214 AC_EGREP_CPP(yes,
215 [#include <netinet/in.h>
216 #ifdef IPV6_INRIA_VERSION
217 yes
218 #endif],
219 [ipv6type=$i;
220 CFLAGS="-DINET6 $CFLAGS"])
221 ;;
222 kame)
223 dnl http://www.kame.net/
224 AC_EGREP_CPP(yes,
225 [#include <netinet/in.h>
226 #ifdef __KAME__
227 yes
228 #endif],
229 [ipv6type=$i;
230 ipv6lib=inet6;
231 ipv6libdir=/usr/local/v6/lib;
232 ipv6trylibc=yes;
233 CFLAGS="-DINET6 $CFLAGS"])
234 ;;
235 linux-glibc)
236 dnl http://www.v6.linux.or.jp/
237 AC_EGREP_CPP(yes,
238 [#include <features.h>
239 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
240 yes
241 #endif],
242 [ipv6type=$i;
243 CFLAGS="-DINET6 $CFLAGS"])
244 ;;
245 linux-libinet6)
246 dnl http://www.v6.linux.or.jp/
247 dnl
248 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
249 dnl and possibly other versions of those OSes
250 dnl
251 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
252 ipv6type=$i
253 ipv6lib=inet6
254 ipv6libdir=/usr/inet6/lib
255 ipv6trylibc=yes;
256 CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
257 fi
258 ;;
259 toshiba)
260 AC_EGREP_CPP(yes,
261 [#include <sys/param.h>
262 #ifdef _TOSHIBA_INET6
263 yes
264 #endif],
265 [ipv6type=$i;
266 ipv6lib=inet6;
267 ipv6libdir=/usr/local/v6/lib;
268 CFLAGS="-DINET6 $CFLAGS"])
269 ;;
270 v6d)
271 AC_EGREP_CPP(yes,
272 [#include </usr/local/v6/include/sys/v6config.h>
273 #ifdef __V6D__
274 yes
275 #endif],
276 [ipv6type=$i;
277 ipv6lib=v6;
278 ipv6libdir=/usr/local/v6/lib;
279 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
280 ;;
281 zeta)
282 AC_EGREP_CPP(yes,
283 [#include <sys/param.h>
284 #ifdef _ZETA_MINAMI_INET6
285 yes
286 #endif],
287 [ipv6type=$i;
288 ipv6lib=inet6;
289 ipv6libdir=/usr/local/v6/lib;
290 CFLAGS="-DINET6 $CFLAGS"])
291 ;;
292 esac
293 if test "$ipv6type" != "unknown"; then
294 break
295 fi
296 done
297 AC_MSG_RESULT($ipv6type)
298 fi
299
300 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
301 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
302 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
303 echo "You have $ipv6lib library, using it"
304 else
305 if test "$ipv6trylibc" = "yes"; then
306 echo "You do not have $ipv6lib library, using libc"
307 else
308 echo 'Fatal: no $ipv6lib library found. cannot continue.'
309 echo "You need to fetch lib$ipv6lib.a from appropriate"
310 echo 'ipv6 kit and compile beforehand.'
311 exit 1
312 fi
313 fi
314 fi
315
316
317 if test "$ipv6" = "yes"; then
318 #
319 # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
320 # function in libc; there are "ngetaddrinfo()" and
321 # "ogetaddrinfo()" functions, and <netdb.h> #defines
322 # "getaddrinfo" to be either "ngetaddrinfo" or
323 # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
324 # or _XOPEN_SOURCE_EXTENDED are defined or not.
325 #
326 # So this test doesn't work on Tru64 5.1, and possibly
327 # on other 5.x releases. This causes the configure
328 # script to become confused, and results in libpcap
329 # being unbuildable.
330 #
331 AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
332 AC_MSG_CHECKING(getaddrinfo bug)
333 AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
334 #include <sys/types.h>
335 #include <netdb.h>
336 #include <string.h>
337 #include <sys/socket.h>
338 #include <netinet/in.h>
339
340 main()
341 {
342 int passive, gaierr, inet4 = 0, inet6 = 0;
343 struct addrinfo hints, *ai, *aitop;
344 char straddr[INET6_ADDRSTRLEN], strport[16];
345
346 for (passive = 0; passive <= 1; passive++) {
347 memset(&hints, 0, sizeof(hints));
348 hints.ai_family = AF_UNSPEC;
349 hints.ai_flags = passive ? AI_PASSIVE : 0;
350 hints.ai_socktype = SOCK_STREAM;
351 hints.ai_protocol = IPPROTO_TCP;
352 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
353 (void)gai_strerror(gaierr);
354 goto bad;
355 }
356 for (ai = aitop; ai; ai = ai->ai_next) {
357 if (ai->ai_addr == NULL ||
358 ai->ai_addrlen == 0 ||
359 getnameinfo(ai->ai_addr, ai->ai_addrlen,
360 straddr, sizeof(straddr), strport, sizeof(strport),
361 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
362 goto bad;
363 }
364 switch (ai->ai_family) {
365 case AF_INET:
366 if (strcmp(strport, "54321") != 0) {
367 goto bad;
368 }
369 if (passive) {
370 if (strcmp(straddr, "0.0.0.0") != 0) {
371 goto bad;
372 }
373 } else {
374 if (strcmp(straddr, "127.0.0.1") != 0) {
375 goto bad;
376 }
377 }
378 inet4++;
379 break;
380 case AF_INET6:
381 if (strcmp(strport, "54321") != 0) {
382 goto bad;
383 }
384 if (passive) {
385 if (strcmp(straddr, "::") != 0) {
386 goto bad;
387 }
388 } else {
389 if (strcmp(straddr, "::1") != 0) {
390 goto bad;
391 }
392 }
393 inet6++;
394 break;
395 case AF_UNSPEC:
396 goto bad;
397 break;
398 #ifdef AF_UNIX
399 case AF_UNIX:
400 #else
401 #ifdef AF_LOCAL
402 case AF_LOCAL:
403 #endif
404 #endif
405 default:
406 /* another family support? */
407 break;
408 }
409 }
410 }
411
412 /* supported family should be 2, unsupported family should be 0 */
413 if (!(inet4 == 0 || inet4 == 2))
414 goto bad;
415 if (!(inet6 == 0 || inet6 == 2))
416 goto bad;
417
418 if (aitop)
419 freeaddrinfo(aitop);
420 exit(0);
421
422 bad:
423 if (aitop)
424 freeaddrinfo(aitop);
425 exit(1);
426 }
427 ],
428 td_cv_buggygetaddrinfo=no,
429 td_cv_buggygetaddrinfo=yes,
430 td_cv_buggygetaddrinfo=yes)])
431 if test "$td_cv_buggygetaddrinfo" = no; then
432 AC_MSG_RESULT(good)
433 else
434 AC_MSG_RESULT(buggy)
435 fi
436
437 if test "$td_cv_buggygetaddrinfo" = "yes"; then
438 #
439 # XXX - it doesn't appear that "ipv6type" can ever be
440 # set to "linux". Should this be testing for
441 # "linux-glibc", or for that *or* "linux-libinet6"?
442 # If the latter, note that "linux-libinet6" is also
443 # the type given to some non-Linux OSes.
444 #
445 if test "$ipv6type" != "linux"; then
446 echo 'Fatal: You must get working getaddrinfo() function.'
447 echo ' or you can specify "--disable-ipv6"'.
448 exit 1
449 else
450 echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
451 echo ' Better upgrade your system library to newest version'
452 echo ' of GNU C library (aka glibc).'
453 fi
454 fi
455 ])
456 AC_REPLACE_FUNCS(getnameinfo)
457 fi
458
459 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
460 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
461 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
462 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
463 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
464 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
465 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
466 fi
467
468 dnl
469 dnl check sizeof basic types.
470 dnl They're very likely to be wrong for cross-compiling.
471 AC_CHECK_SIZEOF(char, 1)
472 AC_CHECK_SIZEOF(short, 2)
473 AC_CHECK_SIZEOF(int, 4)
474 AC_CHECK_SIZEOF(long, 4)
475 AC_CHECK_SIZEOF(long long, 8)
476
477 dnl
478 dnl Checks for addrinfo structure
479 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
480 if test "$ac_cv_addrinfo" = no; then
481 missing_includes=yes
482 fi
483
484 dnl
485 dnl Checks for NI_MAXSERV
486 AC_NI_MAXSERV(ac_cv_maxserv)
487 if test "$ac_cv_maxserv" = no; then
488 missing_includes=yes
489 fi
490
491 dnl
492 dnl Checks for NI_NAMEREQD
493 AC_NI_NAMEREQD(ac_cv_namereqd)
494 if test "$ac_cv_namereqd" = no; then
495 missing_includes=yes
496 fi
497
498 dnl
499 dnl Checks for sockaddr_storage structure
500 AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
501 if test "$ac_cv_sa_storage" = no; then
502 missing_includes=yes
503 fi
504
505 dnl
506 dnl Checks for IN[6]ADDRSZ
507 AC_CHECK_ADDRSZ(ac_cv_addrsz)
508 if test "$ac_cv_addrsz" = no; then
509 missing_includes=yes
510 fi
511
512 dnl
513 dnl Checks for RES_USE_INET6
514 AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
515 if test "$ac_cv_res_inet6" = no; then
516 missing_includes=yes
517 fi
518
519 dnl
520 dnl Checks for res_state_ext structure
521 AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
522 if test "$ac_cv_res_state_ext" = no; then
523 missing_includes=yes
524 fi
525
526 dnl
527 dnl Checks if res_state structure has nsort member.
528 AC_STRUCT_RES_STATE(ac_cv_res_state)
529
530
531 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
532 AC_CHECK_FUNCS(strftime)
533 AC_CHECK_FUNCS(setlinebuf alarm)
534
535 needsnprintf=no
536 AC_CHECK_FUNCS(vsnprintf snprintf,,
537 [needsnprintf=yes])
538 if test $needsnprintf = yes; then
539 AC_LIBOBJ(snprintf)
540 fi
541
542 AC_LBL_TYPE_SIGNAL
543
544 AC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA))
545
546 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
547
548 dnl Some platforms may need -lnsl for getrpcbynumber.
549 AC_SEARCH_LIBS(getrpcbynumber, nsl, AC_DEFINE(HAVE_GETRPCBYNUMBER))
550
551 dnl AC_CHECK_LIB(z, uncompress)
552 dnl AC_CHECK_HEADERS(zlib.h)
553
554 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
555
556 #
557 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
558 # libraries (e.g., "-lsocket -lnsl" on Solaris).
559 #
560 # We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
561 # use AC_CHECK_FUNC which doesn't let us specify the right #includes
562 # to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
563 # resolver, and the way it defines inet_{ntop,pton} is rather strange;
564 # it does not ship with a libc symbol "inet_ntop()", it ships with
565 # "_inet_ntop()", and has a #define macro in one of the system headers
566 # to rename it.
567 #
568 dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
569 AC_MSG_CHECKING(for inet_ntop)
570 AC_TRY_LINK([#include <sys/types.h>
571 #include <sys/socket.h>
572 #include <netinet/in.h>
573 #include <arpa/inet.h>], [char src[4], dst[128];
574 inet_ntop(AF_INET, src, dst, sizeof(dst));],
575 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
576 AC_LIBOBJ(inet_ntop)])
577 AC_MSG_CHECKING(for inet_pton)
578 AC_TRY_LINK([#include <sys/types.h>
579 #include <sys/socket.h>
580 #include <netinet/in.h>
581 #include <arpa/inet.h>], [char src[128], dst[4];
582 inet_pton(AF_INET, src, dst);],
583 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
584 AC_LIBOBJ(inet_pton)])
585 AC_MSG_CHECKING(for inet_aton)
586 AC_TRY_LINK([#include <sys/types.h>
587 #include <netinet/in.h>
588 #include <arpa/inet.h>], [char src[128];
589 struct in_addr dst;
590 inet_aton(src, &dst);],
591 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
592 AC_LIBOBJ(inet_aton)])
593
594 #
595 # Check for these after AC_LBL_LIBPCAP, for the same reason.
596 #
597 # You are in a twisty little maze of UN*Xes, all different.
598 # Some might not have ether_ntohost().
599 # Some might have it, but not declare it in any header file.
600 # Some might have it, but declare it in <netinet/if_ether.h>.
601 # Some might have it, but declare it in <netinet/ether.h>
602 # (And some might have it but document it as something declared in
603 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
604 #
605 # Before you is a C compiler.
606 #
607 AC_CHECK_FUNCS(ether_ntohost, [
608 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
609 AC_TRY_RUN([
610 #include <netdb.h>
611 #include <sys/types.h>
612 #include <sys/param.h>
613 #include <sys/socket.h>
614
615 int
616 main(int argc, char **argv)
617 {
618 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
619 char name[MAXHOSTNAMELEN];
620
621 ether_ntohost(name, (struct ether_addr *)ea);
622 exit(0);
623 }
624 ], [ac_cv_buggy_ether_ntohost=no],
625 [ac_cv_buggy_ether_ntohost=yes],
626 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
627 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
628 AC_DEFINE(USE_ETHER_NTOHOST)
629 fi
630 ])
631 if test "$ac_cv_func_ether_ntohost" = yes -a \
632 "$ac_cv_buggy_ether_ntohost" = "no"; then
633 #
634 # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>?
635 #
636 if test "$ac_cv_header_netinet_if_ether_h" = yes; then
637 #
638 # Yes. Does it declare ether_ntohost()?
639 #
640 AC_CHECK_DECL(ether_ntohost,
641 [
642 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
643 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
644 ],,
645 [
646 #include <sys/types.h>
647 #include <sys/socket.h>
648 #include <netinet/in.h>
649 #include <arpa/inet.h>
650 struct mbuf;
651 struct rtentry;
652 #include <net/if.h>
653 #include <netinet/if_ether.h>
654 ])
655 fi
656 #
657 # Did that succeed?
658 #
659 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
660 #
661 # No, how about <netinet/ether.h>, as on Linux?
662 #
663 AC_CHECK_HEADERS(netinet/ether.h)
664 if test "$ac_cv_header_netinet_ether_h" = yes; then
665 #
666 # We have it - does it declare ether_ntohost()?
667 # Unset ac_cv_have_decl_ether_ntohost so we don't
668 # treat the previous failure as a cached value and
669 # suppress the next test.
670 #
671 unset ac_cv_have_decl_ether_ntohost
672 AC_CHECK_DECL(ether_ntohost,
673 [
674 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
675 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
676 ],,
677 [
678 #include <netinet/ether.h>
679 ])
680 fi
681 fi
682 #
683 # Is ether_ntohost() declared?
684 #
685 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
686 #
687 # No, we'll have to declare it ourselves.
688 # Do we have "struct ether_addr"?
689 #
690 AC_CHECK_TYPES(struct ether_addr,,,
691 [
692 #include <sys/types.h>
693 #include <sys/socket.h>
694 #include <netinet/in.h>
695 #include <arpa/inet.h>
696 struct mbuf;
697 struct rtentry;
698 #include <net/if.h>
699 #include <netinet/if_ether.h>
700 ])
701 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
702 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
703 don't.])
704 else
705 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
706 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
707 don't.])
708 fi
709 fi
710
711 # libdlpi is needed for Solaris 11 and later.
712 AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
713
714 dnl portability macros for getaddrinfo/getnameinfo
715 dnl
716 dnl Check for sa_len
717 AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
718 if test "$ac_cv_sockaddr_has_sa_len" = no; then
719 missing_includes=yes
720 fi
721
722 #
723 # Do we have the new open API? Check for pcap_create, and assume that,
724 # if we do, we also have pcap_activate() and the other new routines.
725 AC_CHECK_FUNCS(pcap_create)
726
727 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
728 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
729 dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
730 dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
731 dnl have pcap_if_t.
732 savedppflags="$CPPLAGS"
733 CPPFLAGS="$CPPFLAGS $V_INCLS"
734 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
735 CPPFLAGS="$savedcppflags"
736 fi
737
738 if test $ac_cv_func_pcap_lib_version = "no" ; then
739 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
740 AC_TRY_LINK([],
741 [
742 extern char pcap_version[];
743
744 return (int)pcap_version;
745 ],
746 ac_lbl_cv_pcap_version_defined=yes,
747 ac_lbl_cv_pcap_version_defined=no)
748 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
749 AC_MSG_RESULT(yes)
750 AC_DEFINE(HAVE_PCAP_VERSION)
751 else
752 AC_MSG_RESULT(no)
753 fi
754 fi
755 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
756 AC_TRY_LINK([],
757 [
758 extern int pcap_debug;
759
760 return pcap_debug;
761 ],
762 ac_lbl_cv_pcap_debug_defined=yes,
763 ac_lbl_cv_pcap_debug_defined=no)
764 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
765 AC_MSG_RESULT(yes)
766 AC_DEFINE(HAVE_PCAP_DEBUG)
767 else
768 AC_MSG_RESULT(no)
769 #
770 # OK, what about "yydebug"?
771 #
772 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
773 AC_TRY_LINK([],
774 [
775 extern int yydebug;
776
777 return yydebug;
778 ],
779 ac_lbl_cv_yydebug_defined=yes,
780 ac_lbl_cv_yydebug_defined=no)
781 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
782 AC_MSG_RESULT(yes)
783 AC_DEFINE(HAVE_YYDEBUG)
784 else
785 AC_MSG_RESULT(no)
786 fi
787 fi
788 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
789
790 V_GROUP=0
791 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
792 V_GROUP=wheel
793 fi
794 #
795 # Assume V7/BSD convention for man pages (file formats in section 5,
796 # miscellaneous info in section 7).
797 #
798 MAN_FILE_FORMATS=5
799 MAN_MISC_INFO=7
800 case "$host_os" in
801
802 aix*)
803 dnl Workaround to enable certain features
804 AC_DEFINE(_SUN)
805 ;;
806
807 hpux*)
808 #
809 # Use System V conventions for man pages.
810 #
811 MAN_FILE_FORMATS=4
812 MAN_MISC_INFO=5
813 ;;
814
815 irix*)
816 V_GROUP=sys
817
818 #
819 # Use System V conventions for man pages.
820 #
821 MAN_FILE_FORMATS=4
822 MAN_MISC_INFO=5
823 ;;
824
825 osf*)
826 V_GROUP=system
827
828 #
829 # Use System V conventions for man pages.
830 #
831 MAN_FILE_FORMATS=4
832 MAN_MISC_INFO=5
833 ;;
834
835 solaris*)
836 V_GROUP=sys
837
838 #
839 # Use System V conventions for man pages.
840 #
841 MAN_FILE_FORMATS=4
842 MAN_MISC_INFO=5
843 ;;
844 esac
845
846 if test -f /dev/bpf0 ; then
847 V_GROUP=bpf
848 fi
849
850 #
851 # Check for some headers introduced in later versions of libpcap
852 # and used by some printers.
853 #
854 savedcppflags="$CPPFLAGS"
855 CPPFLAGS="$CPPFLAGS $V_INCLS"
856 AC_CHECK_HEADERS(pcap/bluetooth.h)
857 AC_CHECK_HEADERS(pcap/usb.h)
858 CPPFLAGS="$savedcppflags"
859
860 AC_CHECK_HEADERS(sys/bitypes.h)
861
862 AC_CHECK_TYPE([int8_t], ,
863 [AC_DEFINE([int8_t], [signed char],
864 [Define to `signed char' if int8_t not defined.])],
865 [AC_INCLUDES_DEFAULT
866 #ifdef HAVE_SYS_BITYPES_H
867 #include <sys/bitypes.h>
868 #endif])
869 AC_CHECK_TYPE([u_int8_t], ,
870 [AC_DEFINE([u_int8_t], [unsigned char],
871 [Define to `unsigned char' if u_int8_t not defined.])],
872 [AC_INCLUDES_DEFAULT
873 #ifdef HAVE_SYS_BITYPES_H
874 #include <sys/bitypes.h>
875 #endif])
876 AC_CHECK_TYPE([int16_t], ,
877 [AC_DEFINE([int16_t], [short],
878 [Define to `short' if int16_t not defined.])]
879 [AC_INCLUDES_DEFAULT
880 #ifdef HAVE_SYS_BITYPES_H
881 #include <sys/bitypes.h>
882 #endif])
883 AC_CHECK_TYPE([u_int16_t], ,
884 [AC_DEFINE([u_int16_t], [unsigned short],
885 [Define to `unsigned short' if u_int16_t not defined.])],
886 [AC_INCLUDES_DEFAULT
887 #ifdef HAVE_SYS_BITYPES_H
888 #include <sys/bitypes.h>
889 #endif])
890 AC_CHECK_TYPE([int32_t], ,
891 [AC_DEFINE([int32_t], [int],
892 [Define to `int' if int32_t not defined.])],
893 [AC_INCLUDES_DEFAULT
894 #ifdef HAVE_SYS_BITYPES_H
895 #include <sys/bitypes.h>
896 #endif])
897 AC_CHECK_TYPE([u_int32_t], ,
898 [AC_DEFINE([u_int32_t], [unsigned int],
899 [Define to `unsigned int' if u_int32_t not defined.])],
900 [AC_INCLUDES_DEFAULT
901 #ifdef HAVE_SYS_BITYPES_H
902 #include <sys/bitypes.h>
903 #endif])
904 AC_CHECK_TYPE([int64_t], ,
905 [AC_DEFINE([int64_t], [long long],
906 [Define to `long long' if int64_t not defined.])],
907 [AC_INCLUDES_DEFAULT
908 #ifdef HAVE_SYS_BITYPES_H
909 #include <sys/bitypes.h>
910 #endif])
911 AC_CHECK_TYPE([u_int64_t], ,
912 [AC_DEFINE([u_int64_t], [unsigned long long],
913 [Define to `unsigned long long' if u_int64_t not defined.])],
914 [AC_INCLUDES_DEFAULT
915 #ifdef HAVE_SYS_BITYPES_H
916 #include <sys/bitypes.h>
917 #endif])
918
919 #
920 # We can't just check for <inttypes.h> - some systems have one that
921 # doesn't define all the PRI[doxu]64 macros.
922 #
923 AC_CHECK_HEADERS(inttypes.h,
924 [
925 #
926 # OK, we have inttypes.h, but does it define those macros?
927 #
928 AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
929 AC_COMPILE_IFELSE(
930 [
931 AC_LANG_SOURCE(
932 [[
933 #include <inttypes.h>
934 #include <stdio.h>
935 #include <sys/types.h>
936 #ifdef HAVE_SYS_BITYPES_H
937 #include <sys/bitypes.h>
938 #endif
939
940 main()
941 {
942 printf("%" PRId64 "\n", (u_int64_t)1);
943 printf("%" PRIo64 "\n", (u_int64_t)1);
944 printf("%" PRIx64 "\n", (u_int64_t)1);
945 printf("%" PRIu64 "\n", (u_int64_t)1);
946 }
947 ]])
948 ],
949 [
950 AC_MSG_RESULT(yes)
951 ac_lbl_inttypes_h_defines_formats=yes
952 ],
953 [
954 AC_MSG_RESULT(no)
955 ac_lbl_inttypes_h_defines_formats=no
956 ])
957 ],
958 [
959 #
960 # We don't have inttypes.h, so it obviously can't define those
961 # macros.
962 #
963 ac_lbl_inttypes_h_defines_formats=no
964 ])
965 if test "$ac_lbl_inttypes_h_defines_formats" = no; then
966 AC_LBL_CHECK_64BIT_FORMAT(l,
967 [
968 AC_LBL_CHECK_64BIT_FORMAT(ll,
969 [
970 AC_LBL_CHECK_64BIT_FORMAT(L,
971 [
972 AC_LBL_CHECK_64BIT_FORMAT(q,
973 [
974 AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
975 ])
976 ])
977 ])
978 ])
979 fi
980
981 AC_PROG_RANLIB
982
983 AC_LBL_DEVEL(V_CCOPT)
984
985 AC_LBL_SOCKADDR_SA_LEN
986
987 AC_LBL_UNALIGNED_ACCESS
988
989 AC_VAR_H_ERRNO
990
991 # Check for SSLeay
992 AC_MSG_CHECKING(whether to use SSLeay libcrypto)
993 # Specify location for both includes and libraries.
994 want_libcrypto=youmama
995 AC_ARG_WITH(crypto,
996 AS_HELP_STRING([--with-crypto@<:@=PATH@:>@],
997 [use SSLeay libcrypto (located in directory PATH, if supplied). @<:@default=yes, if available@:>@]),
998 [
999 if test $withval = no
1000 then
1001 want_libcrypto=no
1002 AC_MSG_RESULT(no)
1003 elif test $withval = yes
1004 then
1005 want_libcrypto=yes
1006 AC_MSG_RESULT(yes)
1007 else
1008 want_libcrypto=yes
1009 AC_MSG_RESULT(yes)
1010 crypto_dir=$withval
1011 fi
1012 ],[
1013 #
1014 # Use libcrypto if it's present, otherwise don't.
1015 #
1016 want_libcrypto=ifavailable
1017 AC_MSG_RESULT([yes, if available])
1018 ])
1019 if test "$want_libcrypto" != "no"; then
1020 ac_cv_ssleay_path=no
1021 incdir=no
1022 if test "x$crypto_dir" = x; then
1023 #
1024 # Location not specified; check the default locations.
1025 #
1026 AC_MSG_CHECKING(where SSLeay is located)
1027 dirs="/usr /usr/local /usr/local/ssl /usr/pkg"
1028 if test "x${host_alias}" != x; then
1029 dirs="/usr/${host_alias} $dirs"
1030 fi
1031 for dir in $dirs; do
1032 AC_LBL_SSLEAY($dir)
1033
1034 if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
1035 break;
1036 else
1037 ac_cv_ssleay_path=no
1038 incdir=no
1039 fi
1040 done
1041 if test "$ac_cv_ssleay_path" != no; then
1042 AC_MSG_RESULT($ac_cv_ssleay_path)
1043 fi
1044 else
1045 AC_MSG_CHECKING(for SSLeay in $crypto_dir)
1046 AC_LBL_SSLEAY($crypto_dir)
1047 if test "$ac_cv_ssleay_path" != no; then
1048 AC_MSG_RESULT(found)
1049 fi
1050 fi
1051 if test "$ac_cv_ssleay_path" != no; then
1052 V_INCLS="$V_INCLS $incdir"
1053 if test "$dir" != "/usr"; then
1054 LDFLAGS="-L$dir/lib $LDFLAGS"
1055 fi
1056 if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
1057 LIBS="$LIBS -lRSAglue"
1058 fi
1059 if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
1060 LIBS="$LIBS -lrsaref"
1061 fi
1062 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
1063
1064 CPPFLAGS="$CPPFLAGS $V_INCLS"
1065 AC_CHECK_HEADERS(openssl/evp.h)
1066 else
1067 #
1068 # Not found. Did the user explicitly ask for it?
1069 #
1070 AC_MSG_RESULT(not found)
1071 if test "$want_libcrypto" = yes; then
1072 AC_MSG_ERROR(SSLeay not found)
1073 fi
1074 fi
1075 fi
1076
1077 dnl
1078 dnl set additional include path if necessary
1079 if test "$missing_includes" = "yes"; then
1080 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
1081 V_INCLS="$V_INCLS -I\$(srcdir)/missing"
1082 fi
1083
1084 AC_SUBST(V_CCOPT)
1085 AC_SUBST(V_DEFS)
1086 AC_SUBST(V_GROUP)
1087 AC_SUBST(V_INCLS)
1088 AC_SUBST(V_PCAPDEP)
1089 AC_SUBST(LOCALSRC)
1090 AC_SUBST(MAN_FILE_FORMATS)
1091 AC_SUBST(MAN_MISC_INFO)
1092
1093 AC_PROG_INSTALL
1094
1095 AC_CONFIG_HEADER(config.h)
1096
1097 AC_OUTPUT_COMMANDS([if test -f .devel; then
1098 echo timestamp > stamp-h
1099 cat Makefile-devel-adds >> Makefile
1100 make depend
1101 fi])
1102 AC_OUTPUT(Makefile tcpdump.1)
1103 exit 0