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