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