]> The Tcpdump Group git mirrors - tcpdump/blob - configure.in
NDOize VRRP decoder
[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_COMPILE_IFELSE(
225 [
226 AC_LANG_SOURCE(
227 [[/* AF_INET6 available check */
228 #include <sys/types.h>
229 #include <sys/socket.h>
230 #include <netinet/in.h>
231 #ifdef AF_INET6
232 void
233 foo(struct in6_addr *addr)
234 {
235 memset(addr, 0, sizeof (struct in6_addr));
236 }
237 #else
238 #error "AF_INET6 not defined"
239 #endif
240 ]])
241 ],
242 [ AC_MSG_RESULT(yes)
243 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"
244 AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
245 ipv6=yes],
246 [ AC_MSG_RESULT(no)
247 ipv6=no],
248 [ AC_MSG_RESULT(no)
249 ipv6=no]
250 ))
251
252 ipv6type=unknown
253 ipv6lib=none
254 ipv6trylibc=no
255
256 if test "$ipv6" = "yes"; then
257 AC_MSG_CHECKING([ipv6 stack type])
258 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
259 case $i in
260 inria)
261 dnl http://www.kame.net/
262 AC_EGREP_CPP(yes,
263 [#include <netinet/in.h>
264 #ifdef IPV6_INRIA_VERSION
265 yes
266 #endif],
267 [ipv6type=$i;
268 CFLAGS="-DINET6 $CFLAGS"])
269 ;;
270 kame)
271 dnl http://www.kame.net/
272 AC_EGREP_CPP(yes,
273 [#include <netinet/in.h>
274 #ifdef __KAME__
275 yes
276 #endif],
277 [ipv6type=$i;
278 ipv6lib=inet6;
279 ipv6libdir=/usr/local/v6/lib;
280 ipv6trylibc=yes;
281 CFLAGS="-DINET6 $CFLAGS"])
282 ;;
283 linux-glibc)
284 dnl http://www.v6.linux.or.jp/
285 AC_EGREP_CPP(yes,
286 [#include <features.h>
287 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
288 yes
289 #endif],
290 [ipv6type=$i;
291 CFLAGS="-DINET6 $CFLAGS"])
292 ;;
293 linux-libinet6)
294 dnl http://www.v6.linux.or.jp/
295 dnl
296 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
297 dnl and possibly other versions of those OSes
298 dnl
299 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
300 ipv6type=$i
301 ipv6lib=inet6
302 ipv6libdir=/usr/inet6/lib
303 ipv6trylibc=yes;
304 CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
305 fi
306 ;;
307 toshiba)
308 AC_EGREP_CPP(yes,
309 [#include <sys/param.h>
310 #ifdef _TOSHIBA_INET6
311 yes
312 #endif],
313 [ipv6type=$i;
314 ipv6lib=inet6;
315 ipv6libdir=/usr/local/v6/lib;
316 CFLAGS="-DINET6 $CFLAGS"])
317 ;;
318 v6d)
319 AC_EGREP_CPP(yes,
320 [#include </usr/local/v6/include/sys/v6config.h>
321 #ifdef __V6D__
322 yes
323 #endif],
324 [ipv6type=$i;
325 ipv6lib=v6;
326 ipv6libdir=/usr/local/v6/lib;
327 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
328 ;;
329 zeta)
330 AC_EGREP_CPP(yes,
331 [#include <sys/param.h>
332 #ifdef _ZETA_MINAMI_INET6
333 yes
334 #endif],
335 [ipv6type=$i;
336 ipv6lib=inet6;
337 ipv6libdir=/usr/local/v6/lib;
338 CFLAGS="-DINET6 $CFLAGS"])
339 ;;
340 esac
341 if test "$ipv6type" != "unknown"; then
342 break
343 fi
344 done
345 AC_MSG_RESULT($ipv6type)
346 fi
347
348 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
349 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
350 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
351 echo "You have $ipv6lib library, using it"
352 else
353 if test "$ipv6trylibc" = "yes"; then
354 echo "You do not have $ipv6lib library, using libc"
355 else
356 echo 'Fatal: no $ipv6lib library found. cannot continue.'
357 echo "You need to fetch lib$ipv6lib.a from appropriate"
358 echo 'ipv6 kit and compile beforehand.'
359 exit 1
360 fi
361 fi
362 fi
363
364
365 if test "$ipv6" = "yes"; then
366 #
367 # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
368 # function in libc; there are "ngetaddrinfo()" and
369 # "ogetaddrinfo()" functions, and <netdb.h> #defines
370 # "getaddrinfo" to be either "ngetaddrinfo" or
371 # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
372 # or _XOPEN_SOURCE_EXTENDED are defined or not.
373 #
374 # So this test doesn't work on Tru64 5.1, and possibly
375 # on other 5.x releases. This causes the configure
376 # script to become confused, and results in libpcap
377 # being unbuildable.
378 #
379 AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
380 AC_MSG_CHECKING(getaddrinfo bug)
381 AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
382 #include <sys/types.h>
383 #include <netdb.h>
384 #include <string.h>
385 #include <sys/socket.h>
386 #include <netinet/in.h>
387
388 main()
389 {
390 int passive, gaierr, inet4 = 0, inet6 = 0;
391 struct addrinfo hints, *ai, *aitop;
392 char straddr[INET6_ADDRSTRLEN], strport[16];
393
394 for (passive = 0; passive <= 1; passive++) {
395 memset(&hints, 0, sizeof(hints));
396 hints.ai_family = AF_UNSPEC;
397 hints.ai_flags = passive ? AI_PASSIVE : 0;
398 hints.ai_socktype = SOCK_STREAM;
399 hints.ai_protocol = IPPROTO_TCP;
400 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
401 (void)gai_strerror(gaierr);
402 goto bad;
403 }
404 for (ai = aitop; ai; ai = ai->ai_next) {
405 if (ai->ai_addr == NULL ||
406 ai->ai_addrlen == 0 ||
407 getnameinfo(ai->ai_addr, ai->ai_addrlen,
408 straddr, sizeof(straddr), strport, sizeof(strport),
409 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
410 goto bad;
411 }
412 switch (ai->ai_family) {
413 case AF_INET:
414 if (strcmp(strport, "54321") != 0) {
415 goto bad;
416 }
417 if (passive) {
418 if (strcmp(straddr, "0.0.0.0") != 0) {
419 goto bad;
420 }
421 } else {
422 if (strcmp(straddr, "127.0.0.1") != 0) {
423 goto bad;
424 }
425 }
426 inet4++;
427 break;
428 case AF_INET6:
429 if (strcmp(strport, "54321") != 0) {
430 goto bad;
431 }
432 if (passive) {
433 if (strcmp(straddr, "::") != 0) {
434 goto bad;
435 }
436 } else {
437 if (strcmp(straddr, "::1") != 0) {
438 goto bad;
439 }
440 }
441 inet6++;
442 break;
443 case AF_UNSPEC:
444 goto bad;
445 break;
446 #ifdef AF_UNIX
447 case AF_UNIX:
448 #else
449 #ifdef AF_LOCAL
450 case AF_LOCAL:
451 #endif
452 #endif
453 default:
454 /* another family support? */
455 break;
456 }
457 }
458 }
459
460 /* supported family should be 2, unsupported family should be 0 */
461 if (!(inet4 == 0 || inet4 == 2))
462 goto bad;
463 if (!(inet6 == 0 || inet6 == 2))
464 goto bad;
465
466 if (aitop)
467 freeaddrinfo(aitop);
468 exit(0);
469
470 bad:
471 if (aitop)
472 freeaddrinfo(aitop);
473 exit(1);
474 }
475 ],
476 td_cv_buggygetaddrinfo=no,
477 td_cv_buggygetaddrinfo=yes,
478 td_cv_buggygetaddrinfo=yes)])
479 if test "$td_cv_buggygetaddrinfo" = no; then
480 AC_MSG_RESULT(good)
481 else
482 AC_MSG_RESULT(buggy)
483 fi
484
485 if test "$td_cv_buggygetaddrinfo" = "yes"; then
486 #
487 # XXX - it doesn't appear that "ipv6type" can ever be
488 # set to "linux". Should this be testing for
489 # "linux-glibc", or for that *or* "linux-libinet6"?
490 # If the latter, note that "linux-libinet6" is also
491 # the type given to some non-Linux OSes.
492 #
493 if test "$ipv6type" != "linux"; then
494 echo 'Fatal: You must get working getaddrinfo() function.'
495 echo ' or you can specify "--disable-ipv6"'.
496 exit 1
497 else
498 echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
499 echo ' Better upgrade your system library to newest version'
500 echo ' of GNU C library (aka glibc).'
501 fi
502 fi
503 ])
504 AC_REPLACE_FUNCS(getnameinfo)
505 fi
506
507 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
508 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
509 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
510 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
511 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
512 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
513 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
514 [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
515 fi
516
517 dnl
518 dnl Checks for addrinfo structure
519 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
520 if test "$ac_cv_addrinfo" = no; then
521 missing_includes=yes
522 fi
523
524 dnl
525 dnl Checks for NI_MAXSERV
526 AC_NI_MAXSERV(ac_cv_maxserv)
527 if test "$ac_cv_maxserv" = no; then
528 missing_includes=yes
529 fi
530
531 dnl
532 dnl Checks for NI_NAMEREQD
533 AC_NI_NAMEREQD(ac_cv_namereqd)
534 if test "$ac_cv_namereqd" = no; then
535 missing_includes=yes
536 fi
537
538 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
539 AC_CHECK_FUNCS(fork vfork strftime)
540 AC_CHECK_FUNCS(setlinebuf alarm)
541
542 needsnprintf=no
543 AC_CHECK_FUNCS(vsnprintf snprintf,,
544 [needsnprintf=yes])
545 if test $needsnprintf = yes; then
546 AC_LIBOBJ(snprintf)
547 fi
548
549 AC_LBL_TYPE_SIGNAL
550
551 AC_SEARCH_LIBS(dnet_htoa, dnet,
552 AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
553
554 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
555
556 dnl Some platforms may need -lnsl for getrpcbynumber.
557 AC_SEARCH_LIBS(getrpcbynumber, nsl,
558 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
559
560 dnl AC_CHECK_LIB(z, uncompress)
561 dnl AC_CHECK_HEADERS(zlib.h)
562
563 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
564
565 #
566 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
567 # libraries (e.g., "-lsocket -lnsl" on Solaris).
568 #
569 # We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
570 # use AC_CHECK_FUNC which doesn't let us specify the right #includes
571 # to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
572 # resolver, and the way it defines inet_{ntop,pton} is rather strange;
573 # it does not ship with a libc symbol "inet_ntop()", it ships with
574 # "_inet_ntop()", and has a #define macro in one of the system headers
575 # to rename it.
576 #
577 dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
578 AC_MSG_CHECKING(for inet_ntop)
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[4], dst[128];
583 inet_ntop(AF_INET, src, dst, sizeof(dst));],
584 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
585 AC_LIBOBJ(inet_ntop)])
586 AC_MSG_CHECKING(for inet_pton)
587 AC_TRY_LINK([#include <sys/types.h>
588 #include <sys/socket.h>
589 #include <netinet/in.h>
590 #include <arpa/inet.h>], [char src[128], dst[4];
591 inet_pton(AF_INET, src, dst);],
592 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
593 AC_LIBOBJ(inet_pton)])
594 AC_MSG_CHECKING(for inet_aton)
595 AC_TRY_LINK([#include <sys/types.h>
596 #include <netinet/in.h>
597 #include <arpa/inet.h>], [char src[128];
598 struct in_addr dst;
599 inet_aton(src, &dst);],
600 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
601 AC_LIBOBJ(inet_aton)])
602
603 #
604 # Check for these after AC_LBL_LIBPCAP, for the same reason.
605 #
606 # You are in a twisty little maze of UN*Xes, all different.
607 # Some might not have ether_ntohost().
608 # Some might have it, but not declare it in any header file.
609 # Some might have it, but declare it in <netinet/if_ether.h>.
610 # Some might have it, but declare it in <netinet/ether.h>
611 # (And some might have it but document it as something declared in
612 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
613 #
614 # Before you is a C compiler.
615 #
616 AC_CHECK_FUNCS(ether_ntohost, [
617 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
618 AC_TRY_RUN([
619 #include <netdb.h>
620 #include <sys/types.h>
621 #include <sys/param.h>
622 #include <sys/socket.h>
623
624 int
625 main(int argc, char **argv)
626 {
627 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
628 char name[MAXHOSTNAMELEN];
629
630 ether_ntohost(name, (struct ether_addr *)ea);
631 exit(0);
632 }
633 ], [ac_cv_buggy_ether_ntohost=no],
634 [ac_cv_buggy_ether_ntohost=yes],
635 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
636 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
637 AC_DEFINE(USE_ETHER_NTOHOST, 1,
638 [define if you have ether_ntohost() and it works])
639 fi
640 ])
641 if test "$ac_cv_func_ether_ntohost" = yes -a \
642 "$ac_cv_buggy_ether_ntohost" = "no"; then
643 #
644 # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>?
645 #
646 if test "$ac_cv_header_netinet_if_ether_h" = yes; then
647 #
648 # Yes. Does it declare ether_ntohost()?
649 #
650 AC_CHECK_DECL(ether_ntohost,
651 [
652 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
653 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
654 ],,
655 [
656 #include <sys/types.h>
657 #include <sys/socket.h>
658 #include <netinet/in.h>
659 #include <arpa/inet.h>
660 struct mbuf;
661 struct rtentry;
662 #include <net/if.h>
663 #include <netinet/if_ether.h>
664 ])
665 fi
666 #
667 # Did that succeed?
668 #
669 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
670 #
671 # No, how about <netinet/ether.h>, as on Linux?
672 #
673 AC_CHECK_HEADERS(netinet/ether.h)
674 if test "$ac_cv_header_netinet_ether_h" = yes; then
675 #
676 # We have it - does it declare ether_ntohost()?
677 # Unset ac_cv_have_decl_ether_ntohost so we don't
678 # treat the previous failure as a cached value and
679 # suppress the next test.
680 #
681 unset ac_cv_have_decl_ether_ntohost
682 AC_CHECK_DECL(ether_ntohost,
683 [
684 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
685 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
686 ],,
687 [
688 #include <netinet/ether.h>
689 ])
690 fi
691 fi
692 #
693 # Is ether_ntohost() declared?
694 #
695 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
696 #
697 # No, we'll have to declare it ourselves.
698 # Do we have "struct ether_addr"?
699 #
700 AC_CHECK_TYPES(struct ether_addr,,,
701 [
702 #include <sys/types.h>
703 #include <sys/socket.h>
704 #include <netinet/in.h>
705 #include <arpa/inet.h>
706 struct mbuf;
707 struct rtentry;
708 #include <net/if.h>
709 #include <netinet/if_ether.h>
710 ])
711 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
712 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
713 don't.])
714 else
715 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
716 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
717 don't.])
718 fi
719 fi
720
721 # libdlpi is needed for Solaris 11 and later.
722 AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
723
724 dnl portability macros for getaddrinfo/getnameinfo
725 dnl
726 dnl Check for sa_len
727 AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
728 if test "$ac_cv_sockaddr_has_sa_len" = no; then
729 missing_includes=yes
730 fi
731
732 #
733 # Do we have the new open API? Check for pcap_create, and assume that,
734 # if we do, we also have pcap_activate() and the other new routines
735 # introduced in libpcap 1.0.0.
736 #
737 AC_CHECK_FUNCS(pcap_create)
738 if test $ac_cv_func_pcap_create = "yes" ; then
739 #
740 # OK, do we have pcap_set_tstamp_type? If so, assume we have
741 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
742 #
743 AC_CHECK_FUNCS(pcap_set_tstamp_type)
744 fi
745
746 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection)
747 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
748 dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
749 dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
750 dnl have pcap_if_t.
751 savedcppflags="$CPPFLAGS"
752 CPPFLAGS="$CPPFLAGS $V_INCLS"
753 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
754 CPPFLAGS="$savedcppflags"
755 fi
756
757 if test $ac_cv_func_pcap_lib_version = "no" ; then
758 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
759 AC_TRY_LINK([],
760 [
761 extern char pcap_version[];
762
763 return (int)pcap_version;
764 ],
765 ac_lbl_cv_pcap_version_defined=yes,
766 ac_lbl_cv_pcap_version_defined=no)
767 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
768 AC_MSG_RESULT(yes)
769 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
770 else
771 AC_MSG_RESULT(no)
772 fi
773 fi
774 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
775 AC_TRY_LINK([],
776 [
777 extern int pcap_debug;
778
779 return pcap_debug;
780 ],
781 ac_lbl_cv_pcap_debug_defined=yes,
782 ac_lbl_cv_pcap_debug_defined=no)
783 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
784 AC_MSG_RESULT(yes)
785 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
786 else
787 AC_MSG_RESULT(no)
788 #
789 # OK, what about "yydebug"?
790 #
791 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
792 AC_TRY_LINK([],
793 [
794 extern int yydebug;
795
796 return yydebug;
797 ],
798 ac_lbl_cv_yydebug_defined=yes,
799 ac_lbl_cv_yydebug_defined=no)
800 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
801 AC_MSG_RESULT(yes)
802 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
803 else
804 AC_MSG_RESULT(no)
805 fi
806 fi
807 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
808
809 V_GROUP=0
810 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
811 V_GROUP=wheel
812 fi
813 #
814 # Assume V7/BSD convention for man pages (file formats in section 5,
815 # miscellaneous info in section 7).
816 #
817 MAN_FILE_FORMATS=5
818 MAN_MISC_INFO=7
819 case "$host_os" in
820
821 aix*)
822 dnl Workaround to enable certain features
823 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
824 ;;
825
826 hpux*)
827 #
828 # Use System V conventions for man pages.
829 #
830 MAN_FILE_FORMATS=4
831 MAN_MISC_INFO=5
832 ;;
833
834 irix*)
835 V_GROUP=sys
836
837 #
838 # Use System V conventions for man pages.
839 #
840 MAN_FILE_FORMATS=4
841 MAN_MISC_INFO=5
842 ;;
843
844 osf*)
845 V_GROUP=system
846
847 #
848 # Use System V conventions for man pages.
849 #
850 MAN_FILE_FORMATS=4
851 MAN_MISC_INFO=5
852 ;;
853
854 solaris*)
855 V_GROUP=sys
856
857 #
858 # Use System V conventions for man pages.
859 #
860 MAN_FILE_FORMATS=4
861 MAN_MISC_INFO=5
862 ;;
863 esac
864
865 if test -f /dev/bpf0 ; then
866 V_GROUP=bpf
867 fi
868
869 #
870 # Make sure we have definitions for all the C99 specified-width types
871 # (regardless of whether the environment is a C99 environment or not).
872 AC_TYPE_INT8_T
873 AC_TYPE_INT16_T
874 AC_TYPE_INT32_T
875 AC_TYPE_INT64_T
876 AC_TYPE_UINT8_T
877 AC_TYPE_UINT16_T
878 AC_TYPE_UINT32_T
879 AC_TYPE_UINT64_T
880
881 #
882 # For now, we're using the old BSD-style u_intXX_t types, so check for
883 # them.
884 #
885 # We should probably migrate to the standard C uintXX_t types.
886 #
887 AC_CHECK_HEADERS(sys/bitypes.h)
888
889 AC_CHECK_TYPE([u_int8_t], ,
890 [AC_DEFINE([u_int8_t], [unsigned char],
891 [Define to `unsigned char' if u_int8_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_int16_t], ,
897 [AC_DEFINE([u_int16_t], [unsigned short],
898 [Define to `unsigned short' if u_int16_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([u_int64_t], ,
911 [AC_DEFINE([u_int64_t], [unsigned long long],
912 [Define to `unsigned long long' if u_int64_t not defined.])],
913 [AC_INCLUDES_DEFAULT
914 #ifdef HAVE_SYS_BITYPES_H
915 #include <sys/bitypes.h>
916 #endif])
917
918 #
919 # Check for <inttypes.h>
920 #
921 AC_CHECK_HEADERS(inttypes.h,
922 [
923 #
924 # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
925 # Some systems have an inttypes.h that doesn't define all of them.
926 #
927 AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
928 AC_COMPILE_IFELSE(
929 [
930 AC_LANG_SOURCE(
931 [[
932 #include <inttypes.h>
933 #include <stdio.h>
934 #include <sys/types.h>
935 #ifdef HAVE_SYS_BITYPES_H
936 #include <sys/bitypes.h>
937 #endif
938
939 main()
940 {
941 printf("%" PRId64 "\n", (u_int64_t)1);
942 printf("%" PRIo64 "\n", (u_int64_t)1);
943 printf("%" PRIx64 "\n", (u_int64_t)1);
944 printf("%" PRIu64 "\n", (u_int64_t)1);
945 }
946 ]])
947 ],
948 [
949 AC_MSG_RESULT(yes)
950 ac_lbl_inttypes_h_defines_formats=yes
951 ],
952 [
953 AC_MSG_RESULT(no)
954 ac_lbl_inttypes_h_defines_formats=no
955 ])
956 ],
957 [
958 #
959 # We don't have inttypes.h, so it obviously can't define those
960 # macros.
961 #
962 ac_lbl_inttypes_h_defines_formats=no
963 ])
964 if test "$ac_lbl_inttypes_h_defines_formats" = no; then
965 AC_LBL_CHECK_64BIT_FORMAT(l,
966 [
967 AC_LBL_CHECK_64BIT_FORMAT(ll,
968 [
969 AC_LBL_CHECK_64BIT_FORMAT(L,
970 [
971 AC_LBL_CHECK_64BIT_FORMAT(q,
972 [
973 AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
974 ])
975 ])
976 ])
977 ])
978 fi
979
980 #
981 # Check for some headers introduced in later versions of libpcap
982 # and used by some printers.
983 #
984 # Those headers use the {u_}intN_t types, so we must do this after
985 # we check for what's needed to get them defined.
986 #
987 savedcppflags="$CPPFLAGS"
988 CPPFLAGS="$CPPFLAGS $V_INCLS"
989 AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "tcpdump-stdinc.h"])
990 AC_CHECK_HEADERS(pcap/nflog.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 AC_CHECK_TOOL([AR], [ar])
996
997 AC_LBL_DEVEL(V_CCOPT)
998
999 AC_LBL_SOCKADDR_SA_LEN
1000
1001 AC_LBL_UNALIGNED_ACCESS
1002
1003 AC_VAR_H_ERRNO
1004
1005 # Check for OpenSSL libcrypto
1006 AC_MSG_CHECKING(whether to use OpenSSL libcrypto)
1007 # Specify location for both includes and libraries.
1008 want_libcrypto=ifavailable
1009 AC_ARG_WITH(crypto,
1010 AS_HELP_STRING([--with-crypto],
1011 [use OpenSSL libcrypto @<:@default=yes, if available@:>@]),
1012 [
1013 if test $withval = no
1014 then
1015 want_libcrypto=no
1016 AC_MSG_RESULT(no)
1017 elif test $withval = yes
1018 then
1019 want_libcrypto=yes
1020 AC_MSG_RESULT(yes)
1021 fi
1022 ],[
1023 #
1024 # Use libcrypto if it's present, otherwise don't.
1025 #
1026 want_libcrypto=ifavailable
1027 AC_MSG_RESULT([yes, if available])
1028 ])
1029 if test "$want_libcrypto" != "no"; then
1030 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
1031 AC_CHECK_HEADERS(openssl/evp.h)
1032 fi
1033
1034 dnl
1035 dnl set additional include path if necessary
1036 if test "$missing_includes" = "yes"; then
1037 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1038 V_INCLS="$V_INCLS -I$srcdir/missing"
1039 fi
1040
1041 AC_SUBST(V_CCOPT)
1042 AC_SUBST(V_DEFS)
1043 AC_SUBST(V_GROUP)
1044 AC_SUBST(V_INCLS)
1045 AC_SUBST(V_PCAPDEP)
1046 AC_SUBST(LOCALSRC)
1047 AC_SUBST(MAN_FILE_FORMATS)
1048 AC_SUBST(MAN_MISC_INFO)
1049
1050 AC_PROG_INSTALL
1051
1052 AC_CONFIG_HEADER(config.h)
1053
1054 AC_OUTPUT_COMMANDS([if test -f .devel; then
1055 echo timestamp > stamp-h
1056 cat Makefile-devel-adds >> Makefile
1057 make depend
1058 fi])
1059 AC_OUTPUT(Makefile tcpdump.1)
1060 exit 0