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