]> The Tcpdump Group git mirrors - tcpdump/blob - configure.in
Use getopt_long().
[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
93 linux*)
94 AC_MSG_CHECKING(Linux kernel version)
95 if test "$cross_compiling" = yes; then
96 AC_CACHE_VAL(ac_cv_linux_vers,
97 ac_cv_linux_vers=unknown)
98 else
99 AC_CACHE_VAL(ac_cv_linux_vers,
100 ac_cv_linux_vers=`uname -r 2>&1 | \
101 sed -n -e '$s/.* //' -e '$s/\..*//p'`)
102 fi
103 AC_MSG_RESULT($ac_cv_linux_vers)
104 if test $ac_cv_linux_vers = unknown ; then
105 AC_MSG_ERROR(cannot determine linux version when cross-compiling)
106 fi
107 if test $ac_cv_linux_vers -lt 2 ; then
108 AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
109 fi
110 ;;
111
112 *)
113 ;;
114 esac
115
116
117 AC_ARG_WITH(smi,
118 [ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
119 --without-smi don't link with libsmi],,
120 with_smi=yes)
121
122 if test "x$with_smi" != "xno" ; then
123 AC_CHECK_HEADERS(smi.h)
124 AC_CHECK_LIB(smi, smiInit)
125 if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
126 then
127 AC_MSG_CHECKING([whether to enable libsmi])
128 AC_TRY_RUN([ /* libsmi available check */
129 #include <smi.h>
130 main()
131 {
132 int current, revision, age, n;
133 const int required = 2;
134 if (smiInit(""))
135 exit(1);
136 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
137 exit(2);
138 n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
139 if (n != 3)
140 exit(3);
141 if (required < current - age || required > current)
142 exit(4);
143 exit(0);
144 }
145 ],
146 [ AC_MSG_RESULT(yes)
147 AC_DEFINE(LIBSMI, 1, [Define if you enable support for libsmi])
148 libsmi=yes],
149 dnl autoconf documentation says that $? contains the exit value.
150 dnl reality is that it does not. We leave this in just in case
151 dnl autoconf ever comes back to 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 libsmi=no],
160 [ AC_MSG_RESULT(not when cross-compiling)
161 libsmi=no]
162 )
163 fi
164 fi
165
166 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
167 AC_ARG_ENABLE(smb,
168 [ --enable-smb enable possibly-buggy SMB printer [default=yes]
169 --disable-smb disable possibly-buggy SMB printer],,
170 enableval=yes)
171 case "$enableval" in
172 yes) AC_MSG_RESULT(yes)
173 AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
174 AC_DEFINE(TCPDUMP_DO_SMB, 1,
175 [define if you want to build the possibly-buggy SMB printer])
176 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
177 ;;
178 *) AC_MSG_RESULT(no)
179 ;;
180 esac
181
182 AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
183 AC_MSG_CHECKING([whether to drop root privileges by default])
184 if test ! -z "$with_user" ; then
185 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
186 [define if should drop privileges by default])
187 AC_MSG_RESULT(to \"$withval\")
188 else
189 AC_MSG_RESULT(no)
190 fi
191
192 AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
193 AC_MSG_CHECKING([whether to chroot])
194 if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
195 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
196 [define if should chroot when dropping privileges])
197 AC_MSG_RESULT(to \"$withval\")
198 else
199 AC_MSG_RESULT(no)
200 fi
201
202 #
203 # We must check this before checking whether to enable IPv6, because,
204 # on some platforms (such as SunOS 5.x), the test program requires
205 # the extra networking libraries.
206 #
207 AC_LBL_LIBRARY_NET
208
209 AC_MSG_CHECKING([whether to enable ipv6])
210 AC_ARG_ENABLE(ipv6,
211 [ --enable-ipv6 enable ipv6 (with ipv4) support
212 --disable-ipv6 disable ipv6 support],
213 [ case "$enableval" in
214 yes) 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 print-babel.c $LOCALSRC"
216 AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
217 ipv6=yes
218 ;;
219 *)
220 AC_MSG_RESULT(no)
221 ipv6=no
222 ;;
223 esac ],
224
225 AC_COMPILE_IFELSE(
226 [
227 AC_LANG_SOURCE(
228 [[/* AF_INET6 available check */
229 #include <sys/types.h>
230 #include <sys/socket.h>
231 #include <netinet/in.h>
232 #ifdef AF_INET6
233 void
234 foo(struct in6_addr *addr)
235 {
236 memset(addr, 0, sizeof (struct in6_addr));
237 }
238 #else
239 #error "AF_INET6 not defined"
240 #endif
241 ]])
242 ],
243 [ AC_MSG_RESULT(yes)
244 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"
245 AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
246 ipv6=yes],
247 [ AC_MSG_RESULT(no)
248 ipv6=no],
249 [ AC_MSG_RESULT(no)
250 ipv6=no]
251 ))
252
253 ipv6type=unknown
254 ipv6lib=none
255 ipv6trylibc=no
256
257 if test "$ipv6" = "yes"; then
258 AC_MSG_CHECKING([ipv6 stack type])
259 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
260 case $i in
261 inria)
262 dnl http://www.kame.net/
263 AC_EGREP_CPP(yes,
264 [#include <netinet/in.h>
265 #ifdef IPV6_INRIA_VERSION
266 yes
267 #endif],
268 [ipv6type=$i;
269 CFLAGS="-DINET6 $CFLAGS"])
270 ;;
271 kame)
272 dnl http://www.kame.net/
273 AC_EGREP_CPP(yes,
274 [#include <netinet/in.h>
275 #ifdef __KAME__
276 yes
277 #endif],
278 [ipv6type=$i;
279 ipv6lib=inet6;
280 ipv6libdir=/usr/local/v6/lib;
281 ipv6trylibc=yes;
282 CFLAGS="-DINET6 $CFLAGS"])
283 ;;
284 linux-glibc)
285 dnl http://www.v6.linux.or.jp/
286 AC_EGREP_CPP(yes,
287 [#include <features.h>
288 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
289 yes
290 #endif],
291 [ipv6type=$i;
292 CFLAGS="-DINET6 $CFLAGS"])
293 ;;
294 linux-libinet6)
295 dnl http://www.v6.linux.or.jp/
296 dnl
297 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
298 dnl and possibly other versions of those OSes
299 dnl
300 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
301 ipv6type=$i
302 ipv6lib=inet6
303 ipv6libdir=/usr/inet6/lib
304 ipv6trylibc=yes;
305 CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
306 fi
307 ;;
308 toshiba)
309 AC_EGREP_CPP(yes,
310 [#include <sys/param.h>
311 #ifdef _TOSHIBA_INET6
312 yes
313 #endif],
314 [ipv6type=$i;
315 ipv6lib=inet6;
316 ipv6libdir=/usr/local/v6/lib;
317 CFLAGS="-DINET6 $CFLAGS"])
318 ;;
319 v6d)
320 AC_EGREP_CPP(yes,
321 [#include </usr/local/v6/include/sys/v6config.h>
322 #ifdef __V6D__
323 yes
324 #endif],
325 [ipv6type=$i;
326 ipv6lib=v6;
327 ipv6libdir=/usr/local/v6/lib;
328 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
329 ;;
330 zeta)
331 AC_EGREP_CPP(yes,
332 [#include <sys/param.h>
333 #ifdef _ZETA_MINAMI_INET6
334 yes
335 #endif],
336 [ipv6type=$i;
337 ipv6lib=inet6;
338 ipv6libdir=/usr/local/v6/lib;
339 CFLAGS="-DINET6 $CFLAGS"])
340 ;;
341 esac
342 if test "$ipv6type" != "unknown"; then
343 break
344 fi
345 done
346 AC_MSG_RESULT($ipv6type)
347 fi
348
349 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
350 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
351 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
352 echo "You have $ipv6lib library, using it"
353 else
354 if test "$ipv6trylibc" = "yes"; then
355 echo "You do not have $ipv6lib library, using libc"
356 else
357 echo 'Fatal: no $ipv6lib library found. cannot continue.'
358 echo "You need to fetch lib$ipv6lib.a from appropriate"
359 echo 'ipv6 kit and compile beforehand.'
360 exit 1
361 fi
362 fi
363 fi
364
365
366 if test "$ipv6" = "yes"; then
367 #
368 # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
369 # function in libc; there are "ngetaddrinfo()" and
370 # "ogetaddrinfo()" functions, and <netdb.h> #defines
371 # "getaddrinfo" to be either "ngetaddrinfo" or
372 # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
373 # or _XOPEN_SOURCE_EXTENDED are defined or not.
374 #
375 # So this test doesn't work on Tru64 5.1, and possibly
376 # on other 5.x releases. This causes the configure
377 # script to become confused, and results in libpcap
378 # being unbuildable.
379 #
380 AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
381 AC_MSG_CHECKING(getaddrinfo bug)
382 AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
383 #include <sys/types.h>
384 #include <netdb.h>
385 #include <string.h>
386 #include <sys/socket.h>
387 #include <netinet/in.h>
388
389 main()
390 {
391 int passive, gaierr, inet4 = 0, inet6 = 0;
392 struct addrinfo hints, *ai, *aitop;
393 char straddr[INET6_ADDRSTRLEN], strport[16];
394
395 for (passive = 0; passive <= 1; passive++) {
396 memset(&hints, 0, sizeof(hints));
397 hints.ai_family = AF_UNSPEC;
398 hints.ai_flags = passive ? AI_PASSIVE : 0;
399 hints.ai_socktype = SOCK_STREAM;
400 hints.ai_protocol = IPPROTO_TCP;
401 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
402 (void)gai_strerror(gaierr);
403 goto bad;
404 }
405 for (ai = aitop; ai; ai = ai->ai_next) {
406 if (ai->ai_addr == NULL ||
407 ai->ai_addrlen == 0 ||
408 getnameinfo(ai->ai_addr, ai->ai_addrlen,
409 straddr, sizeof(straddr), strport, sizeof(strport),
410 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
411 goto bad;
412 }
413 switch (ai->ai_family) {
414 case AF_INET:
415 if (strcmp(strport, "54321") != 0) {
416 goto bad;
417 }
418 if (passive) {
419 if (strcmp(straddr, "0.0.0.0") != 0) {
420 goto bad;
421 }
422 } else {
423 if (strcmp(straddr, "127.0.0.1") != 0) {
424 goto bad;
425 }
426 }
427 inet4++;
428 break;
429 case AF_INET6:
430 if (strcmp(strport, "54321") != 0) {
431 goto bad;
432 }
433 if (passive) {
434 if (strcmp(straddr, "::") != 0) {
435 goto bad;
436 }
437 } else {
438 if (strcmp(straddr, "::1") != 0) {
439 goto bad;
440 }
441 }
442 inet6++;
443 break;
444 case AF_UNSPEC:
445 goto bad;
446 break;
447 #ifdef AF_UNIX
448 case AF_UNIX:
449 #else
450 #ifdef AF_LOCAL
451 case AF_LOCAL:
452 #endif
453 #endif
454 default:
455 /* another family support? */
456 break;
457 }
458 }
459 }
460
461 /* supported family should be 2, unsupported family should be 0 */
462 if (!(inet4 == 0 || inet4 == 2))
463 goto bad;
464 if (!(inet6 == 0 || inet6 == 2))
465 goto bad;
466
467 if (aitop)
468 freeaddrinfo(aitop);
469 exit(0);
470
471 bad:
472 if (aitop)
473 freeaddrinfo(aitop);
474 exit(1);
475 }
476 ],
477 td_cv_buggygetaddrinfo=no,
478 td_cv_buggygetaddrinfo=yes,
479 td_cv_buggygetaddrinfo=yes)])
480 if test "$td_cv_buggygetaddrinfo" = no; then
481 AC_MSG_RESULT(good)
482 else
483 AC_MSG_RESULT(buggy)
484 fi
485
486 if test "$td_cv_buggygetaddrinfo" = "yes"; then
487 #
488 # XXX - it doesn't appear that "ipv6type" can ever be
489 # set to "linux". Should this be testing for
490 # "linux-glibc", or for that *or* "linux-libinet6"?
491 # If the latter, note that "linux-libinet6" is also
492 # the type given to some non-Linux OSes.
493 #
494 if test "$ipv6type" != "linux"; then
495 echo 'Fatal: You must get working getaddrinfo() function.'
496 echo ' or you can specify "--disable-ipv6"'.
497 exit 1
498 else
499 echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
500 echo ' Better upgrade your system library to newest version'
501 echo ' of GNU C library (aka glibc).'
502 fi
503 fi
504 ])
505 AC_REPLACE_FUNCS(getnameinfo)
506 fi
507
508 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
509 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
510 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
511 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
512 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
513 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
514 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
515 [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
516 fi
517
518 dnl
519 dnl Checks for addrinfo structure
520 AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
521 if test "$ac_cv_addrinfo" = no; then
522 missing_includes=yes
523 fi
524
525 dnl
526 dnl Checks for NI_MAXSERV
527 AC_NI_MAXSERV(ac_cv_maxserv)
528 if test "$ac_cv_maxserv" = no; then
529 missing_includes=yes
530 fi
531
532 dnl
533 dnl Checks for NI_NAMEREQD
534 AC_NI_NAMEREQD(ac_cv_namereqd)
535 if test "$ac_cv_namereqd" = no; then
536 missing_includes=yes
537 fi
538
539 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep getopt_long)
540 AC_CHECK_FUNCS(fork vfork strftime)
541 AC_CHECK_FUNCS(setlinebuf alarm)
542
543 needsnprintf=no
544 AC_CHECK_FUNCS(vsnprintf snprintf,,
545 [needsnprintf=yes])
546 if test $needsnprintf = yes; then
547 AC_LIBOBJ(snprintf)
548 fi
549
550 AC_LBL_TYPE_SIGNAL
551
552 AC_SEARCH_LIBS(dnet_htoa, dnet,
553 AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
554
555 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
556
557 dnl Some platforms may need -lnsl for getrpcbynumber.
558 AC_SEARCH_LIBS(getrpcbynumber, nsl,
559 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
560
561 dnl AC_CHECK_LIB(z, uncompress)
562 dnl AC_CHECK_HEADERS(zlib.h)
563
564 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
565
566 #
567 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
568 # libraries (e.g., "-lsocket -lnsl" on Solaris).
569 #
570 # We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
571 # use AC_CHECK_FUNC which doesn't let us specify the right #includes
572 # to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
573 # resolver, and the way it defines inet_{ntop,pton} is rather strange;
574 # it does not ship with a libc symbol "inet_ntop()", it ships with
575 # "_inet_ntop()", and has a #define macro in one of the system headers
576 # to rename it.
577 #
578 dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
579 AC_MSG_CHECKING(for inet_ntop)
580 AC_TRY_LINK([#include <sys/types.h>
581 #include <sys/socket.h>
582 #include <netinet/in.h>
583 #include <arpa/inet.h>], [char src[4], dst[128];
584 inet_ntop(AF_INET, src, dst, sizeof(dst));],
585 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
586 AC_LIBOBJ(inet_ntop)])
587 AC_MSG_CHECKING(for inet_pton)
588 AC_TRY_LINK([#include <sys/types.h>
589 #include <sys/socket.h>
590 #include <netinet/in.h>
591 #include <arpa/inet.h>], [char src[128], dst[4];
592 inet_pton(AF_INET, src, dst);],
593 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
594 AC_LIBOBJ(inet_pton)])
595 AC_MSG_CHECKING(for inet_aton)
596 AC_TRY_LINK([#include <sys/types.h>
597 #include <netinet/in.h>
598 #include <arpa/inet.h>], [char src[128];
599 struct in_addr dst;
600 inet_aton(src, &dst);],
601 [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
602 AC_LIBOBJ(inet_aton)])
603
604 #
605 # Check for these after AC_LBL_LIBPCAP, for the same reason.
606 #
607 # You are in a twisty little maze of UN*Xes, all different.
608 # Some might not have ether_ntohost().
609 # Some might have it, but not declare it in any header file.
610 # Some might have it, but declare it in <netinet/if_ether.h>.
611 # Some might have it, but declare it in <netinet/ether.h>
612 # (And some might have it but document it as something declared in
613 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
614 #
615 # Before you is a C compiler.
616 #
617 AC_CHECK_FUNCS(ether_ntohost, [
618 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
619 AC_TRY_RUN([
620 #include <netdb.h>
621 #include <sys/types.h>
622 #include <sys/param.h>
623 #include <sys/socket.h>
624
625 int
626 main(int argc, char **argv)
627 {
628 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
629 char name[MAXHOSTNAMELEN];
630
631 ether_ntohost(name, (struct ether_addr *)ea);
632 exit(0);
633 }
634 ], [ac_cv_buggy_ether_ntohost=no],
635 [ac_cv_buggy_ether_ntohost=yes],
636 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
637 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
638 AC_DEFINE(USE_ETHER_NTOHOST, 1,
639 [define if you have ether_ntohost() and it works])
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 # introduced in libpcap 1.0.0.
737 #
738 AC_CHECK_FUNCS(pcap_create)
739 if test $ac_cv_func_pcap_create = "yes" ; then
740 #
741 # OK, do we have pcap_set_tstamp_type? If so, assume we have
742 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
743 #
744 AC_CHECK_FUNCS(pcap_set_tstamp_type)
745 fi
746
747 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection)
748 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
749 dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
750 dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
751 dnl have pcap_if_t.
752 savedcppflags="$CPPFLAGS"
753 CPPFLAGS="$CPPFLAGS $V_INCLS"
754 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
755 CPPFLAGS="$savedcppflags"
756 fi
757
758 if test $ac_cv_func_pcap_lib_version = "no" ; then
759 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
760 AC_TRY_LINK([],
761 [
762 extern char pcap_version[];
763
764 return (int)pcap_version;
765 ],
766 ac_lbl_cv_pcap_version_defined=yes,
767 ac_lbl_cv_pcap_version_defined=no)
768 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
769 AC_MSG_RESULT(yes)
770 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
771 else
772 AC_MSG_RESULT(no)
773 fi
774 fi
775 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
776 AC_TRY_LINK([],
777 [
778 extern int pcap_debug;
779
780 return pcap_debug;
781 ],
782 ac_lbl_cv_pcap_debug_defined=yes,
783 ac_lbl_cv_pcap_debug_defined=no)
784 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
785 AC_MSG_RESULT(yes)
786 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
787 else
788 AC_MSG_RESULT(no)
789 #
790 # OK, what about "yydebug"?
791 #
792 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
793 AC_TRY_LINK([],
794 [
795 extern int yydebug;
796
797 return yydebug;
798 ],
799 ac_lbl_cv_yydebug_defined=yes,
800 ac_lbl_cv_yydebug_defined=no)
801 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
802 AC_MSG_RESULT(yes)
803 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
804 else
805 AC_MSG_RESULT(no)
806 fi
807 fi
808 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
809
810 V_GROUP=0
811 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
812 V_GROUP=wheel
813 fi
814 #
815 # Assume V7/BSD convention for man pages (file formats in section 5,
816 # miscellaneous info in section 7).
817 #
818 MAN_FILE_FORMATS=5
819 MAN_MISC_INFO=7
820 case "$host_os" in
821
822 aix*)
823 dnl Workaround to enable certain features
824 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
825 ;;
826
827 hpux*)
828 #
829 # Use System V conventions for man pages.
830 #
831 MAN_FILE_FORMATS=4
832 MAN_MISC_INFO=5
833 ;;
834
835 irix*)
836 V_GROUP=sys
837
838 #
839 # Use System V conventions for man pages.
840 #
841 MAN_FILE_FORMATS=4
842 MAN_MISC_INFO=5
843 ;;
844
845 osf*)
846 V_GROUP=system
847
848 #
849 # Use System V conventions for man pages.
850 #
851 MAN_FILE_FORMATS=4
852 MAN_MISC_INFO=5
853 ;;
854
855 solaris*)
856 V_GROUP=sys
857
858 #
859 # Use System V conventions for man pages.
860 #
861 MAN_FILE_FORMATS=4
862 MAN_MISC_INFO=5
863 ;;
864 esac
865
866 if test -f /dev/bpf0 ; then
867 V_GROUP=bpf
868 fi
869
870 #
871 # Make sure we have definitions for all the C99 specified-width types
872 # (regardless of whether the environment is a C99 environment or not).
873 #
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 # Define the old BSD specified-width types in terms of the C99 types;
885 # we may need them with libpcap include files.
886 #
887 AC_CHECK_TYPE([u_int8_t], ,
888 [AC_DEFINE([u_int8_t], [uint8_t],
889 [Define to `uint8_t' if u_int8_t not defined.])],
890 [AC_INCLUDES_DEFAULT
891 #include <sys/types.h>
892 ])
893 AC_CHECK_TYPE([u_int16_t], ,
894 [AC_DEFINE([u_int16_t], [uint16_t],
895 [Define to `uint16_t' if u_int16_t not defined.])],
896 [AC_INCLUDES_DEFAULT
897 #include <sys/types.h>
898 ])
899 AC_CHECK_TYPE([u_int32_t], ,
900 [AC_DEFINE([u_int32_t], [uint32_t],
901 [Define to `uint32_t' if u_int32_t not defined.])],
902 [AC_INCLUDES_DEFAULT
903 #include <sys/types.h>
904 ])
905 AC_CHECK_TYPE([u_int64_t], ,
906 [AC_DEFINE([u_int64_t], [uint64_t],
907 [Define to `uint64_t' if u_int64_t not defined.])],
908 [AC_INCLUDES_DEFAULT
909 #include <sys/types.h>
910 ])
911
912 #
913 # Check for <inttypes.h>
914 #
915 AC_CHECK_HEADERS(inttypes.h,
916 [
917 #
918 # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
919 # Some systems have an inttypes.h that doesn't define all of them.
920 #
921 AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
922 AC_COMPILE_IFELSE(
923 [
924 AC_LANG_SOURCE(
925 [[
926 #include <inttypes.h>
927 #include <stdio.h>
928 #include <sys/types.h>
929
930 main()
931 {
932 printf("%" PRId64 "\n", (uint64_t)1);
933 printf("%" PRIo64 "\n", (uint64_t)1);
934 printf("%" PRIx64 "\n", (uint64_t)1);
935 printf("%" PRIu64 "\n", (uint64_t)1);
936 }
937 ]])
938 ],
939 [
940 AC_MSG_RESULT(yes)
941 ac_lbl_inttypes_h_defines_formats=yes
942 ],
943 [
944 AC_MSG_RESULT(no)
945 ac_lbl_inttypes_h_defines_formats=no
946 ])
947 ],
948 [
949 #
950 # We don't have inttypes.h, so it obviously can't define those
951 # macros.
952 #
953 ac_lbl_inttypes_h_defines_formats=no
954 ])
955 if test "$ac_lbl_inttypes_h_defines_formats" = no; then
956 AC_LBL_CHECK_64BIT_FORMAT(l,
957 [
958 AC_LBL_CHECK_64BIT_FORMAT(ll,
959 [
960 AC_LBL_CHECK_64BIT_FORMAT(L,
961 [
962 AC_LBL_CHECK_64BIT_FORMAT(q,
963 [
964 AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
965 ])
966 ])
967 ])
968 ])
969 fi
970
971 #
972 # Check for some headers introduced in later versions of libpcap
973 # and used by some printers.
974 #
975 # Those headers use the {u_}intN_t types, so we must do this after
976 # we check for what's needed to get them defined.
977 #
978 savedcppflags="$CPPFLAGS"
979 CPPFLAGS="$CPPFLAGS $V_INCLS"
980 AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "tcpdump-stdinc.h"])
981 AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "tcpdump-stdinc.h"])
982 AC_CHECK_HEADERS(pcap/usb.h,,,[#include "tcpdump-stdinc.h"])
983 CPPFLAGS="$savedcppflags"
984
985 AC_PROG_RANLIB
986 AC_CHECK_TOOL([AR], [ar])
987
988 AC_LBL_DEVEL(V_CCOPT)
989
990 AC_LBL_SOCKADDR_SA_LEN
991
992 AC_LBL_UNALIGNED_ACCESS
993
994 AC_VAR_H_ERRNO
995
996 # Check for OpenSSL libcrypto
997 AC_MSG_CHECKING(whether to use OpenSSL libcrypto)
998 # Specify location for both includes and libraries.
999 want_libcrypto=ifavailable
1000 AC_ARG_WITH(crypto,
1001 AS_HELP_STRING([--with-crypto],
1002 [use OpenSSL libcrypto @<:@default=yes, if available@:>@]),
1003 [
1004 if test $withval = no
1005 then
1006 want_libcrypto=no
1007 AC_MSG_RESULT(no)
1008 elif test $withval = yes
1009 then
1010 want_libcrypto=yes
1011 AC_MSG_RESULT(yes)
1012 fi
1013 ],[
1014 #
1015 # Use libcrypto if it's present, otherwise don't.
1016 #
1017 want_libcrypto=ifavailable
1018 AC_MSG_RESULT([yes, if available])
1019 ])
1020 if test "$want_libcrypto" != "no"; then
1021 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
1022 AC_CHECK_HEADERS(openssl/evp.h)
1023 fi
1024
1025 dnl
1026 dnl set additional include path if necessary
1027 if test "$missing_includes" = "yes"; then
1028 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1029 V_INCLS="$V_INCLS -I$srcdir/missing"
1030 fi
1031
1032 AC_SUBST(V_CCOPT)
1033 AC_SUBST(V_DEFS)
1034 AC_SUBST(V_GROUP)
1035 AC_SUBST(V_INCLS)
1036 AC_SUBST(V_PCAPDEP)
1037 AC_SUBST(LOCALSRC)
1038 AC_SUBST(MAN_FILE_FORMATS)
1039 AC_SUBST(MAN_MISC_INFO)
1040
1041 AC_PROG_INSTALL
1042
1043 AC_CONFIG_HEADER(config.h)
1044
1045 AC_OUTPUT_COMMANDS([if test -f .devel; then
1046 echo timestamp > stamp-h
1047 cat Makefile-devel-adds >> Makefile
1048 make depend
1049 fi])
1050 AC_OUTPUT(Makefile tcpdump.1)
1051 exit 0