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