]> The Tcpdump Group git mirrors - tcpdump/blob - configure.in
Don't require IPv6 library support in order to support IPv6 addresses.
[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 AC_CHECK_HEADERS(net/if_pflog.h, , , [#include <sys/types.h>
41 #include <sys/socket.h>
42 #include <net/if.h>
43 #include <net/pfvar.h>])
44 if test "$ac_cv_header_net_if_pflog_h" = yes; then
45 LOCALSRC="print-pflog.c $LOCALSRC"
46 fi
47 fi
48 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
49 #include <sys/socket.h>])
50 if test "$ac_cv_header_netinet_if_ether_h" != yes; then
51 #
52 # The simple test didn't work.
53 # Do we need to include <net/if.h> first?
54 # Unset ac_cv_header_netinet_if_ether_h so we don't
55 # treat the previous failure as a cached value and
56 # suppress the next test.
57 #
58 AC_MSG_NOTICE([Rechecking with some additional includes])
59 unset ac_cv_header_netinet_if_ether_h
60 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
61 #include <sys/socket.h>
62 #include <netinet/in.h>
63 struct mbuf;
64 struct rtentry;
65 #include <net/if.h>])
66 fi
67
68 AC_HEADER_TIME
69
70 case "$host_os" in
71
72 darwin*)
73 AC_ARG_ENABLE(universal,
74 AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
75 if test "$enable_universal" != "no"; then
76 case "$host_os" in
77
78 darwin9.*)
79 #
80 # Leopard. Build for x86 and 32-bit PowerPC, with
81 # x86 first. (That's what Apple does.)
82 #
83 V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
84 LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
85 ;;
86
87 darwin10.*)
88 #
89 # Snow Leopard. Build for x86-64 and x86, with
90 # x86-64 first. (That's what Apple does.)
91 #
92 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
93 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
94 ;;
95 esac
96 fi
97 ;;
98 esac
99
100
101 AC_ARG_WITH(smi,
102 [ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
103 --without-smi don't link with libsmi],,
104 with_smi=yes)
105
106 if test "x$with_smi" != "xno" ; then
107 AC_CHECK_HEADER(smi.h,
108 [
109 #
110 # OK, we found smi.h. Do we have libsmi with smiInit?
111 #
112 AC_CHECK_LIB(smi, smiInit,
113 [
114 #
115 # OK, we have libsmi with smiInit. Can we use it?
116 #
117 AC_MSG_CHECKING([whether to enable libsmi])
118 savedlibs="$LIBS"
119 LIBS="-lsmi $LIBS"
120 AC_TRY_RUN(
121 [
122 /* libsmi available check */
123 #include <smi.h>
124 main()
125 {
126 int current, revision, age, n;
127 const int required = 2;
128 if (smiInit(""))
129 exit(1);
130 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
131 exit(2);
132 n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
133 if (n != 3)
134 exit(3);
135 if (required < current - age || required > current)
136 exit(4);
137 exit(0);
138 }
139 ],
140 [
141 AC_MSG_RESULT(yes)
142 AC_DEFINE(USE_LIBSMI, 1,
143 [Define if you enable support for libsmi])
144 ],
145 [
146 dnl autoconf documentation says that
147 dnl $? contains the exit value.
148 dnl reality is that it does not.
149 dnl We leave this in just in case
150 dnl autoconf ever comes back to
151 dnl 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 LIBS="$savedlibs"
160 ],
161 [
162 AC_MSG_RESULT(not when cross-compiling)
163 LIBS="$savedlibs"
164 ]
165 )
166 ])
167 ])
168 fi
169
170 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
171 AC_ARG_ENABLE(smb,
172 [ --enable-smb enable possibly-buggy SMB printer [default=yes]
173 --disable-smb disable possibly-buggy SMB printer],,
174 enableval=yes)
175 case "$enableval" in
176 yes) AC_MSG_RESULT(yes)
177 AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
178 AC_DEFINE(TCPDUMP_DO_SMB, 1,
179 [define if you want to build the possibly-buggy SMB printer])
180 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
181 ;;
182 *) AC_MSG_RESULT(no)
183 ;;
184 esac
185
186 AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
187 AC_MSG_CHECKING([whether to drop root privileges by default])
188 if test ! -z "$with_user" ; then
189 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
190 [define if should drop privileges by default])
191 AC_MSG_RESULT(to \"$withval\")
192 else
193 AC_MSG_RESULT(no)
194 fi
195
196 AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
197 AC_MSG_CHECKING([whether to chroot])
198 if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
199 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
200 [define if should chroot when dropping privileges])
201 AC_MSG_RESULT(to \"$withval\")
202 else
203 AC_MSG_RESULT(no)
204 fi
205
206 AC_ARG_WITH(sandbox-capsicum,
207 AS_HELP_STRING([--with-sandbox-capsicum],
208 [use Capsicum security functions @<:@default=yes, if available@:>@]))
209 #
210 # Check whether various functions are available. If any are, set
211 # ac_lbl_capsicum_function_seen to yes; if any are not, set
212 # ac_lbl_capsicum_function_not_seen to yes.
213 #
214 # We don't check cap_rights_init(), as it's a macro, wrapping another
215 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
216 # doesn't handle that.
217 #
218 # All of the ones we check for must be available in order to enable
219 # capsicum sandboxing.
220 #
221 # XXX - do we need to check for all of them, or are there some that, if
222 # present, imply others are present?
223 #
224 if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
225 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
226 ac_lbl_capsicum_function_seen=yes,
227 ac_lbl_capsicum_function_not_seen=yes)
228 fi
229 AC_MSG_CHECKING([whether to sandbox using capsicum])
230 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
231 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
232 AC_MSG_RESULT(yes)
233 else
234 AC_MSG_RESULT(no)
235 fi
236
237 #
238 # We must check this before checking whether to check the OS's IPv6,
239 # support because, on some platforms (such as SunOS 5.x), the test
240 # program requires the extra networking libraries.
241 #
242 AC_LBL_LIBRARY_NET
243
244 #
245 # Check whether AF_INET6 and struct in6_addr are defined.
246 # If they aren't both defined, we don't have sufficient OS
247 # support for IPv6, so we don't look for IPv6 support libraries,
248 # and we define AF_INET6 and struct in6_addr ourselves.
249 #
250 AC_MSG_CHECKING([whether the operating system supports IPv6])
251 AC_COMPILE_IFELSE(
252 [
253 AC_LANG_SOURCE(
254 [[
255 /* AF_INET6 available check */
256 #include <sys/types.h>
257 #include <sys/socket.h>
258 #include <netinet/in.h>
259 #ifdef AF_INET6
260 void
261 foo(struct in6_addr *addr)
262 {
263 memset(addr, 0, sizeof (struct in6_addr));
264 }
265 #else
266 #error "AF_INET6 not defined"
267 #endif
268 ]])
269 ],
270 [
271 AC_MSG_RESULT(yes)
272 AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
273 [define if the OS provides AF_INET6 and struct in6_addr])
274 ipv6=yes
275 ],
276 [
277 AC_MSG_RESULT(no)
278 ipv6=no
279 ]
280 )
281
282 ipv6type=unknown
283 ipv6lib=none
284 ipv6trylibc=no
285
286 if test "$ipv6" = "yes"; then
287 AC_MSG_CHECKING([ipv6 stack type])
288 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
289 case $i in
290 inria)
291 dnl http://www.kame.net/
292 AC_EGREP_CPP(yes,
293 [#include <netinet/in.h>
294 #ifdef IPV6_INRIA_VERSION
295 yes
296 #endif],
297 [ipv6type=$i])
298 ;;
299 kame)
300 dnl http://www.kame.net/
301 AC_EGREP_CPP(yes,
302 [#include <netinet/in.h>
303 #ifdef __KAME__
304 yes
305 #endif],
306 [ipv6type=$i;
307 ipv6lib=inet6;
308 ipv6libdir=/usr/local/v6/lib;
309 ipv6trylibc=yes])
310 ;;
311 linux-glibc)
312 dnl http://www.v6.linux.or.jp/
313 AC_EGREP_CPP(yes,
314 [#include <features.h>
315 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
316 yes
317 #endif],
318 [ipv6type=$i])
319 ;;
320 linux-libinet6)
321 dnl http://www.v6.linux.or.jp/
322 dnl
323 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
324 dnl and possibly other versions of those OSes
325 dnl
326 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
327 ipv6type=$i
328 ipv6lib=inet6
329 ipv6libdir=/usr/inet6/lib
330 ipv6trylibc=yes;
331 CFLAGS="-I/usr/inet6/include $CFLAGS"
332 fi
333 ;;
334 toshiba)
335 AC_EGREP_CPP(yes,
336 [#include <sys/param.h>
337 #ifdef _TOSHIBA_INET6
338 yes
339 #endif],
340 [ipv6type=$i;
341 ipv6lib=inet6;
342 ipv6libdir=/usr/local/v6/lib])
343 ;;
344 v6d)
345 AC_EGREP_CPP(yes,
346 [#include </usr/local/v6/include/sys/v6config.h>
347 #ifdef __V6D__
348 yes
349 #endif],
350 [ipv6type=$i;
351 ipv6lib=v6;
352 ipv6libdir=/usr/local/v6/lib;
353 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
354 ;;
355 zeta)
356 AC_EGREP_CPP(yes,
357 [#include <sys/param.h>
358 #ifdef _ZETA_MINAMI_INET6
359 yes
360 #endif],
361 [ipv6type=$i;
362 ipv6lib=inet6;
363 ipv6libdir=/usr/local/v6/lib])
364 ;;
365 esac
366 if test "$ipv6type" != "unknown"; then
367 break
368 fi
369 done
370 AC_MSG_RESULT($ipv6type)
371 fi
372
373 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
374 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
375 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
376 echo "You have $ipv6lib library, using it"
377 else
378 if test "$ipv6trylibc" = "yes"; then
379 echo "You do not have $ipv6lib library, using libc"
380 else
381 echo 'Fatal: no $ipv6lib library found. cannot continue.'
382 echo "You need to fetch lib$ipv6lib.a from appropriate"
383 echo 'ipv6 kit and compile beforehand.'
384 exit 1
385 fi
386 fi
387 fi
388
389 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
390 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
391 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
392 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
393 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
394 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
395 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
396 [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
397 fi
398
399 AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
400 AC_CHECK_FUNCS(fork vfork strftime)
401 AC_CHECK_FUNCS(setlinebuf alarm)
402
403 needsnprintf=no
404 AC_CHECK_FUNCS(vsnprintf snprintf,,
405 [needsnprintf=yes])
406 if test $needsnprintf = yes; then
407 AC_LIBOBJ(snprintf)
408 fi
409
410 AC_LBL_TYPE_SIGNAL
411
412 AC_SEARCH_LIBS(dnet_htoa, dnet,
413 AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
414
415 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
416
417 dnl Some platforms may need -lnsl for getrpcbynumber.
418 AC_SEARCH_LIBS(getrpcbynumber, nsl,
419 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
420
421 dnl AC_CHECK_LIB(z, uncompress)
422 dnl AC_CHECK_HEADERS(zlib.h)
423
424 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
425
426 #
427 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
428 # libraries (e.g., "-lsocket -lnsl" on Solaris).
429 #
430 # You are in a twisty little maze of UN*Xes, all different.
431 # Some might not have ether_ntohost().
432 # Some might have it, but not declare it in any header file.
433 # Some might have it, but declare it in <netinet/if_ether.h>.
434 # Some might have it, but declare it in <netinet/ether.h>
435 # (And some might have it but document it as something declared in
436 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
437 #
438 # Before you is a C compiler.
439 #
440 AC_CHECK_FUNCS(ether_ntohost, [
441 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
442 AC_TRY_RUN([
443 #include <netdb.h>
444 #include <sys/types.h>
445 #include <sys/param.h>
446 #include <sys/socket.h>
447
448 int
449 main(int argc, char **argv)
450 {
451 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
452 char name[MAXHOSTNAMELEN];
453
454 ether_ntohost(name, (struct ether_addr *)ea);
455 exit(0);
456 }
457 ], [ac_cv_buggy_ether_ntohost=no],
458 [ac_cv_buggy_ether_ntohost=yes],
459 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
460 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
461 AC_DEFINE(USE_ETHER_NTOHOST, 1,
462 [define if you have ether_ntohost() and it works])
463 fi
464 ])
465 if test "$ac_cv_func_ether_ntohost" = yes -a \
466 "$ac_cv_buggy_ether_ntohost" = "no"; then
467 #
468 # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>?
469 #
470 if test "$ac_cv_header_netinet_if_ether_h" = yes; then
471 #
472 # Yes. Does it declare ether_ntohost()?
473 #
474 AC_CHECK_DECL(ether_ntohost,
475 [
476 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
477 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
478 ],,
479 [
480 #include <sys/types.h>
481 #include <sys/socket.h>
482 #include <netinet/in.h>
483 #include <arpa/inet.h>
484 struct mbuf;
485 struct rtentry;
486 #include <net/if.h>
487 #include <netinet/if_ether.h>
488 ])
489 fi
490 #
491 # Did that succeed?
492 #
493 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
494 #
495 # No, how about <netinet/ether.h>, as on Linux?
496 #
497 AC_CHECK_HEADERS(netinet/ether.h)
498 if test "$ac_cv_header_netinet_ether_h" = yes; then
499 #
500 # We have it - does it declare ether_ntohost()?
501 # Unset ac_cv_have_decl_ether_ntohost so we don't
502 # treat the previous failure as a cached value and
503 # suppress the next test.
504 #
505 unset ac_cv_have_decl_ether_ntohost
506 AC_CHECK_DECL(ether_ntohost,
507 [
508 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
509 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
510 ],,
511 [
512 #include <netinet/ether.h>
513 ])
514 fi
515 fi
516 #
517 # Is ether_ntohost() declared?
518 #
519 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
520 #
521 # No, we'll have to declare it ourselves.
522 # Do we have "struct ether_addr"?
523 #
524 AC_CHECK_TYPES(struct ether_addr,,,
525 [
526 #include <sys/types.h>
527 #include <sys/socket.h>
528 #include <netinet/in.h>
529 #include <arpa/inet.h>
530 struct mbuf;
531 struct rtentry;
532 #include <net/if.h>
533 #include <netinet/if_ether.h>
534 ])
535 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
536 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
537 don't.])
538 else
539 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
540 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
541 don't.])
542 fi
543 fi
544
545 # libdlpi is needed for Solaris 11 and later.
546 AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
547
548 dnl
549 dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
550 dnl and "pcap_datalink_name_to_val()", and use substitute versions
551 dnl if they're not present.
552 dnl
553 AC_CHECK_FUNC(pcap_list_datalinks,
554 [
555 AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
556 [define if libpcap has pcap_list_datalinks()])
557 AC_CHECK_FUNCS(pcap_free_datalinks)
558 ],
559 [
560 AC_LIBOBJ(datalinks)
561 ])
562 AC_CHECK_FUNCS(pcap_set_datalink)
563 AC_CHECK_FUNC(pcap_datalink_name_to_val,
564 [
565 AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
566 [define if libpcap has pcap_datalink_name_to_val()])
567 AC_CHECK_FUNC(pcap_datalink_val_to_description,
568 AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
569 [define if libpcap has pcap_datalink_val_to_description()]),
570 [
571 AC_LIBOBJ(dlnames)
572 ])
573 ],
574 [
575 AC_LIBOBJ(dlnames)
576 ])
577
578 dnl
579 dnl Check for "pcap_breakloop()"; you can't substitute for it if
580 dnl it's absent (it has hooks into the live capture routines),
581 dnl so just define the HAVE_ value if it's there.
582 dnl
583 AC_CHECK_FUNCS(pcap_breakloop)
584
585 dnl
586 dnl Check for "pcap_dump_ftell()" and use a substitute version
587 dnl if it's not present.
588 dnl
589 AC_CHECK_FUNC(pcap_dump_ftell,
590 AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
591 [define if libpcap has pcap_dump_ftell()]),
592 [
593 AC_LIBOBJ(pcap_dump_ftell)
594 ])
595
596 #
597 # Do we have the new open API? Check for pcap_create, and assume that,
598 # if we do, we also have pcap_activate() and the other new routines
599 # introduced in libpcap 1.0.0.
600 #
601 AC_CHECK_FUNCS(pcap_create)
602 if test $ac_cv_func_pcap_create = "yes" ; then
603 #
604 # OK, do we have pcap_set_tstamp_type? If so, assume we have
605 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
606 #
607 AC_CHECK_FUNCS(pcap_set_tstamp_type)
608 #
609 # And do we have pcap_set_tstamp_precision? If so, we assume
610 # we also have pcap_open_offline_with_tstamp_precision.
611 #
612 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
613 fi
614
615 #
616 # Check for a miscellaneous collection of functions which we use
617 # if we have them.
618 #
619 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode)
620 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
621 dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
622 dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
623 dnl have pcap_if_t.
624 savedcppflags="$CPPFLAGS"
625 CPPFLAGS="$CPPFLAGS $V_INCLS"
626 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
627 CPPFLAGS="$savedcppflags"
628 fi
629
630 if test $ac_cv_func_pcap_lib_version = "no" ; then
631 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
632 AC_TRY_LINK([],
633 [
634 extern char pcap_version[];
635
636 return (int)pcap_version;
637 ],
638 ac_lbl_cv_pcap_version_defined=yes,
639 ac_lbl_cv_pcap_version_defined=no)
640 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
641 AC_MSG_RESULT(yes)
642 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
643 else
644 AC_MSG_RESULT(no)
645 fi
646 fi
647 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
648 AC_TRY_LINK([],
649 [
650 extern int pcap_debug;
651
652 return pcap_debug;
653 ],
654 ac_lbl_cv_pcap_debug_defined=yes,
655 ac_lbl_cv_pcap_debug_defined=no)
656 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
657 AC_MSG_RESULT(yes)
658 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
659 else
660 AC_MSG_RESULT(no)
661 #
662 # OK, what about "yydebug"?
663 #
664 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
665 AC_TRY_LINK([],
666 [
667 extern int yydebug;
668
669 return yydebug;
670 ],
671 ac_lbl_cv_yydebug_defined=yes,
672 ac_lbl_cv_yydebug_defined=no)
673 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
674 AC_MSG_RESULT(yes)
675 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
676 else
677 AC_MSG_RESULT(no)
678 fi
679 fi
680 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
681
682 V_GROUP=0
683 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
684 V_GROUP=wheel
685 fi
686 #
687 # Assume V7/BSD convention for man pages (file formats in section 5,
688 # miscellaneous info in section 7).
689 #
690 MAN_FILE_FORMATS=5
691 MAN_MISC_INFO=7
692 case "$host_os" in
693
694 aix*)
695 dnl Workaround to enable certain features
696 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
697 ;;
698
699 hpux*)
700 #
701 # Use System V conventions for man pages.
702 #
703 MAN_FILE_FORMATS=4
704 MAN_MISC_INFO=5
705 ;;
706
707 irix*)
708 V_GROUP=sys
709
710 #
711 # Use System V conventions for man pages.
712 #
713 MAN_FILE_FORMATS=4
714 MAN_MISC_INFO=5
715 ;;
716
717 osf*)
718 V_GROUP=system
719
720 #
721 # Use System V conventions for man pages.
722 #
723 MAN_FILE_FORMATS=4
724 MAN_MISC_INFO=5
725 ;;
726
727 solaris*)
728 V_GROUP=sys
729
730 #
731 # Use System V conventions for man pages.
732 #
733 MAN_FILE_FORMATS=4
734 MAN_MISC_INFO=5
735 ;;
736 esac
737
738 if test -f /dev/bpf0 ; then
739 V_GROUP=bpf
740 fi
741
742 #
743 # Make sure we have definitions for all the C99 specified-width types
744 # (regardless of whether the environment is a C99 environment or not).
745 #
746 AC_TYPE_INT8_T
747 AC_TYPE_INT16_T
748 AC_TYPE_INT32_T
749 AC_TYPE_INT64_T
750 AC_TYPE_UINT8_T
751 AC_TYPE_UINT16_T
752 AC_TYPE_UINT32_T
753 AC_TYPE_UINT64_T
754
755 #
756 # Make sure we have a definition for C99's uintptr_t (regardless of
757 # whether the environment is a C99 environment or not).
758 #
759 AC_TYPE_UINTPTR_T
760
761 #
762 # Define the old BSD specified-width types in terms of the C99 types;
763 # we may need them with libpcap include files.
764 #
765 AC_CHECK_TYPE([u_int8_t], ,
766 [AC_DEFINE([u_int8_t], [uint8_t],
767 [Define to `uint8_t' if u_int8_t not defined.])],
768 [AC_INCLUDES_DEFAULT
769 #include <sys/types.h>
770 ])
771 AC_CHECK_TYPE([u_int16_t], ,
772 [AC_DEFINE([u_int16_t], [uint16_t],
773 [Define to `uint16_t' if u_int16_t not defined.])],
774 [AC_INCLUDES_DEFAULT
775 #include <sys/types.h>
776 ])
777 AC_CHECK_TYPE([u_int32_t], ,
778 [AC_DEFINE([u_int32_t], [uint32_t],
779 [Define to `uint32_t' if u_int32_t not defined.])],
780 [AC_INCLUDES_DEFAULT
781 #include <sys/types.h>
782 ])
783 AC_CHECK_TYPE([u_int64_t], ,
784 [AC_DEFINE([u_int64_t], [uint64_t],
785 [Define to `uint64_t' if u_int64_t not defined.])],
786 [AC_INCLUDES_DEFAULT
787 #include <sys/types.h>
788 ])
789
790 #
791 # Check for <inttypes.h>
792 #
793 AC_CHECK_HEADERS(inttypes.h,
794 [
795 #
796 # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
797 # Some systems have an inttypes.h that doesn't define all of them.
798 #
799 AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
800 AC_COMPILE_IFELSE(
801 [
802 AC_LANG_SOURCE(
803 [[
804 #include <inttypes.h>
805 #include <stdio.h>
806 #include <sys/types.h>
807
808 main()
809 {
810 printf("%" PRId64 "\n", (uint64_t)1);
811 printf("%" PRIo64 "\n", (uint64_t)1);
812 printf("%" PRIx64 "\n", (uint64_t)1);
813 printf("%" PRIu64 "\n", (uint64_t)1);
814 }
815 ]])
816 ],
817 [
818 AC_MSG_RESULT(yes)
819 ac_lbl_inttypes_h_defines_formats=yes
820 ],
821 [
822 AC_MSG_RESULT(no)
823 ac_lbl_inttypes_h_defines_formats=no
824 ])
825 ],
826 [
827 #
828 # We don't have inttypes.h, so it obviously can't define those
829 # macros.
830 #
831 ac_lbl_inttypes_h_defines_formats=no
832 ])
833 if test "$ac_lbl_inttypes_h_defines_formats" = no; then
834 AC_LBL_CHECK_64BIT_FORMAT(l,
835 [
836 AC_LBL_CHECK_64BIT_FORMAT(ll,
837 [
838 AC_LBL_CHECK_64BIT_FORMAT(L,
839 [
840 AC_LBL_CHECK_64BIT_FORMAT(q,
841 [
842 AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
843 ])
844 ])
845 ])
846 ])
847 fi
848
849 #
850 # Check for some headers introduced in later versions of libpcap
851 # and used by some printers.
852 #
853 # Those headers use the {u_}intN_t types, so we must do this after
854 # we check for what's needed to get them defined.
855 #
856 savedcppflags="$CPPFLAGS"
857 CPPFLAGS="$CPPFLAGS $V_INCLS"
858 AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"])
859 AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"])
860 AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"])
861 CPPFLAGS="$savedcppflags"
862
863 AC_PROG_RANLIB
864 AC_CHECK_TOOL([AR], [ar])
865
866 AC_LBL_DEVEL(V_CCOPT)
867
868 AC_LBL_SOCKADDR_SA_LEN
869
870 AC_LBL_UNALIGNED_ACCESS
871
872 # Check for OpenSSL libcrypto
873 AC_MSG_CHECKING(whether to use OpenSSL libcrypto)
874 # Specify location for both includes and libraries.
875 want_libcrypto=ifavailable
876 AC_ARG_WITH(crypto,
877 AS_HELP_STRING([--with-crypto],
878 [use OpenSSL libcrypto @<:@default=yes, if available@:>@]),
879 [
880 if test $withval = no
881 then
882 want_libcrypto=no
883 AC_MSG_RESULT(no)
884 elif test $withval = yes
885 then
886 want_libcrypto=yes
887 AC_MSG_RESULT(yes)
888 fi
889 ],[
890 #
891 # Use libcrypto if it's present, otherwise don't.
892 #
893 want_libcrypto=ifavailable
894 AC_MSG_RESULT([yes, if available])
895 ])
896 if test "$want_libcrypto" != "no"; then
897 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
898 AC_CHECK_HEADERS(openssl/evp.h)
899 fi
900
901 # Check for libcap-ng
902 AC_MSG_CHECKING(whether to use libcap-ng)
903 # Specify location for both includes and libraries.
904 want_libcap_ng=ifavailable
905 AC_ARG_WITH(cap_ng,
906 AS_HELP_STRING([--with-cap-ng],
907 [use libcap-ng @<:@default=yes, if available@:>@]),
908 [
909 if test $withval = no
910 then
911 want_libcap_ng=no
912 AC_MSG_RESULT(no)
913 elif test $withval = yes
914 then
915 want_libcap_ng=yes
916 AC_MSG_RESULT(yes)
917 fi
918 ],[
919 #
920 # Use libcap-ng if it's present, otherwise don't.
921 #
922 want_libcap_ng=ifavailable
923 AC_MSG_RESULT([yes, if available])
924 ])
925 if test "$want_libcap_ng" != "no"; then
926 AC_CHECK_LIB(cap-ng, capng_change_id)
927 AC_CHECK_HEADERS(cap-ng.h)
928 fi
929
930 dnl
931 dnl set additional include path if necessary
932 if test "$missing_includes" = "yes"; then
933 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
934 V_INCLS="$V_INCLS -I$srcdir/missing"
935 fi
936
937 AC_SUBST(V_CCOPT)
938 AC_SUBST(V_DEFS)
939 AC_SUBST(V_GROUP)
940 AC_SUBST(V_INCLS)
941 AC_SUBST(V_PCAPDEP)
942 AC_SUBST(LOCALSRC)
943 AC_SUBST(MAN_FILE_FORMATS)
944 AC_SUBST(MAN_MISC_INFO)
945
946 AC_PROG_INSTALL
947
948 AC_CONFIG_HEADER(config.h)
949
950 AC_OUTPUT_COMMANDS([if test -f .devel; then
951 echo timestamp > stamp-h
952 cat Makefile-devel-adds >> Makefile
953 make depend
954 fi])
955 AC_OUTPUT(Makefile tcpdump.1)
956 exit 0