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