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