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