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