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