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