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