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