]> The Tcpdump Group git mirrors - tcpdump/blob - configure.in
Merge pull request #588 from glebius/casper
[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(ENABLE_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 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
229 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
230 fi
231 AC_MSG_CHECKING([whether to sandbox using capsicum])
232 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
233 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
234 AC_MSG_RESULT(yes)
235 else
236 AC_MSG_RESULT(no)
237 fi
238 AC_MSG_CHECKING([whether to sandbox using Casper library])
239 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
240 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
241 AC_MSG_RESULT(yes)
242 else
243 AC_MSG_RESULT(no)
244 fi
245
246 #
247 # We must check this before checking whether to check the OS's IPv6,
248 # support because, on some platforms (such as SunOS 5.x), the test
249 # program requires the extra networking libraries.
250 #
251 AC_LBL_LIBRARY_NET
252
253 #
254 # Check whether AF_INET6 and struct in6_addr are defined.
255 # If they aren't both defined, we don't have sufficient OS
256 # support for IPv6, so we don't look for IPv6 support libraries,
257 # and we define AF_INET6 and struct in6_addr ourselves.
258 #
259 AC_MSG_CHECKING([whether the operating system supports IPv6])
260 AC_COMPILE_IFELSE(
261 [
262 AC_LANG_SOURCE(
263 [[
264 /* AF_INET6 available check */
265 #include <sys/types.h>
266 #include <sys/socket.h>
267 #include <netinet/in.h>
268 #ifdef AF_INET6
269 void
270 foo(struct in6_addr *addr)
271 {
272 memset(addr, 0, sizeof (struct in6_addr));
273 }
274 #else
275 #error "AF_INET6 not defined"
276 #endif
277 ]])
278 ],
279 [
280 AC_MSG_RESULT(yes)
281 AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
282 [define if the OS provides AF_INET6 and struct in6_addr])
283 ipv6=yes
284 ],
285 [
286 AC_MSG_RESULT(no)
287 ipv6=no
288 ]
289 )
290
291 ipv6type=unknown
292 ipv6lib=none
293 ipv6trylibc=no
294
295 if test "$ipv6" = "yes"; then
296 AC_MSG_CHECKING([ipv6 stack type])
297 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
298 case $i in
299 inria)
300 dnl http://www.kame.net/
301 AC_EGREP_CPP(yes,
302 [#include <netinet/in.h>
303 #ifdef IPV6_INRIA_VERSION
304 yes
305 #endif],
306 [ipv6type=$i])
307 ;;
308 kame)
309 dnl http://www.kame.net/
310 AC_EGREP_CPP(yes,
311 [#include <netinet/in.h>
312 #ifdef __KAME__
313 yes
314 #endif],
315 [ipv6type=$i;
316 ipv6lib=inet6;
317 ipv6libdir=/usr/local/v6/lib;
318 ipv6trylibc=yes])
319 ;;
320 linux-glibc)
321 dnl http://www.v6.linux.or.jp/
322 AC_EGREP_CPP(yes,
323 [#include <features.h>
324 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
325 yes
326 #endif],
327 [ipv6type=$i])
328 ;;
329 linux-libinet6)
330 dnl http://www.v6.linux.or.jp/
331 dnl
332 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
333 dnl and possibly other versions of those OSes
334 dnl
335 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
336 ipv6type=$i
337 ipv6lib=inet6
338 ipv6libdir=/usr/inet6/lib
339 ipv6trylibc=yes;
340 CFLAGS="-I/usr/inet6/include $CFLAGS"
341 fi
342 ;;
343 toshiba)
344 AC_EGREP_CPP(yes,
345 [#include <sys/param.h>
346 #ifdef _TOSHIBA_INET6
347 yes
348 #endif],
349 [ipv6type=$i;
350 ipv6lib=inet6;
351 ipv6libdir=/usr/local/v6/lib])
352 ;;
353 v6d)
354 AC_EGREP_CPP(yes,
355 [#include </usr/local/v6/include/sys/v6config.h>
356 #ifdef __V6D__
357 yes
358 #endif],
359 [ipv6type=$i;
360 ipv6lib=v6;
361 ipv6libdir=/usr/local/v6/lib;
362 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
363 ;;
364 zeta)
365 AC_EGREP_CPP(yes,
366 [#include <sys/param.h>
367 #ifdef _ZETA_MINAMI_INET6
368 yes
369 #endif],
370 [ipv6type=$i;
371 ipv6lib=inet6;
372 ipv6libdir=/usr/local/v6/lib])
373 ;;
374 esac
375 if test "$ipv6type" != "unknown"; then
376 break
377 fi
378 done
379 AC_MSG_RESULT($ipv6type)
380 fi
381
382 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
383 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
384 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
385 echo "You have $ipv6lib library, using it"
386 else
387 if test "$ipv6trylibc" = "yes"; then
388 echo "You do not have $ipv6lib library, using libc"
389 else
390 echo 'Fatal: no $ipv6lib library found. cannot continue.'
391 echo "You need to fetch lib$ipv6lib.a from appropriate"
392 echo 'ipv6 kit and compile beforehand.'
393 exit 1
394 fi
395 fi
396 fi
397
398 AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
399 [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
400 [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
401 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
402 td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
403 if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
404 AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
405 [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
406 fi
407
408 AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
409 AC_CHECK_FUNCS(fork vfork strftime)
410 AC_CHECK_FUNCS(setlinebuf alarm)
411
412 needsnprintf=no
413 AC_CHECK_FUNCS(vsnprintf snprintf,,
414 [needsnprintf=yes])
415 if test $needsnprintf = yes; then
416 AC_LIBOBJ(snprintf)
417 fi
418
419 AC_LBL_TYPE_SIGNAL
420
421 AC_SEARCH_LIBS(dnet_htoa, dnet,
422 AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
423
424 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
425
426 dnl Some platforms may need -lnsl for getrpcbynumber.
427 AC_SEARCH_LIBS(getrpcbynumber, nsl,
428 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
429
430 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
431
432 #
433 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
434 # libraries (e.g., "-lsocket -lnsl" on Solaris).
435 #
436 # You are in a twisty little maze of UN*Xes, all different.
437 # Some might not have ether_ntohost().
438 # Some might have it, but not declare it in any header file.
439 # Some might have it, but declare it in <netinet/if_ether.h>.
440 # Some might have it, but declare it in <netinet/ether.h>
441 # (And some might have it but document it as something declared in
442 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
443 #
444 # Before you is a C compiler.
445 #
446 AC_CHECK_FUNCS(ether_ntohost, [
447 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
448 AC_TRY_RUN([
449 #include <netdb.h>
450 #include <sys/types.h>
451 #include <sys/param.h>
452 #include <sys/socket.h>
453
454 int
455 main(int argc, char **argv)
456 {
457 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
458 char name[MAXHOSTNAMELEN];
459
460 ether_ntohost(name, (struct ether_addr *)ea);
461 exit(0);
462 }
463 ], [ac_cv_buggy_ether_ntohost=no],
464 [ac_cv_buggy_ether_ntohost=yes],
465 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
466 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
467 AC_DEFINE(USE_ETHER_NTOHOST, 1,
468 [define if you have ether_ntohost() and it works])
469 fi
470 ])
471 if test "$ac_cv_func_ether_ntohost" = yes -a \
472 "$ac_cv_buggy_ether_ntohost" = "no"; then
473 #
474 # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>?
475 #
476 if test "$ac_cv_header_netinet_if_ether_h" = yes; then
477 #
478 # Yes. Does it declare ether_ntohost()?
479 #
480 AC_CHECK_DECL(ether_ntohost,
481 [
482 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
483 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
484 ],,
485 [
486 #include <sys/types.h>
487 #include <sys/socket.h>
488 #include <netinet/in.h>
489 #include <arpa/inet.h>
490 struct mbuf;
491 struct rtentry;
492 #include <net/if.h>
493 #include <netinet/if_ether.h>
494 ])
495 fi
496 #
497 # Did that succeed?
498 #
499 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
500 #
501 # No, how about <netinet/ether.h>, as on Linux?
502 #
503 AC_CHECK_HEADERS(netinet/ether.h)
504 if test "$ac_cv_header_netinet_ether_h" = yes; then
505 #
506 # We have it - does it declare ether_ntohost()?
507 # Unset ac_cv_have_decl_ether_ntohost so we don't
508 # treat the previous failure as a cached value and
509 # suppress the next test.
510 #
511 unset ac_cv_have_decl_ether_ntohost
512 AC_CHECK_DECL(ether_ntohost,
513 [
514 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
515 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
516 ],,
517 [
518 #include <netinet/ether.h>
519 ])
520 fi
521 fi
522 #
523 # Is ether_ntohost() declared?
524 #
525 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
526 #
527 # No, we'll have to declare it ourselves.
528 # Do we have "struct ether_addr"?
529 #
530 AC_CHECK_TYPES(struct ether_addr,,,
531 [
532 #include <sys/types.h>
533 #include <sys/socket.h>
534 #include <netinet/in.h>
535 #include <arpa/inet.h>
536 struct mbuf;
537 struct rtentry;
538 #include <net/if.h>
539 #include <netinet/if_ether.h>
540 ])
541 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
542 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
543 don't.])
544 else
545 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
546 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
547 don't.])
548 fi
549 fi
550
551 # libdlpi is needed for Solaris 11 and later.
552 AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
553
554 dnl
555 dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
556 dnl and "pcap_datalink_name_to_val()", and use substitute versions
557 dnl if they're not present.
558 dnl
559 AC_CHECK_FUNC(pcap_list_datalinks,
560 [
561 AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
562 [define if libpcap has pcap_list_datalinks()])
563 AC_CHECK_FUNCS(pcap_free_datalinks)
564 ],
565 [
566 AC_LIBOBJ(datalinks)
567 ])
568 AC_CHECK_FUNCS(pcap_set_datalink)
569 AC_CHECK_FUNC(pcap_datalink_name_to_val,
570 [
571 AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
572 [define if libpcap has pcap_datalink_name_to_val()])
573 AC_CHECK_FUNC(pcap_datalink_val_to_description,
574 AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
575 [define if libpcap has pcap_datalink_val_to_description()]),
576 [
577 AC_LIBOBJ(dlnames)
578 ])
579 ],
580 [
581 AC_LIBOBJ(dlnames)
582 ])
583
584 dnl
585 dnl Check for "pcap_breakloop()"; you can't substitute for it if
586 dnl it's absent (it has hooks into the live capture routines),
587 dnl so just define the HAVE_ value if it's there.
588 dnl
589 AC_CHECK_FUNCS(pcap_breakloop)
590
591 dnl
592 dnl Check for "pcap_dump_ftell()" and use a substitute version
593 dnl if it's not present.
594 dnl
595 AC_CHECK_FUNC(pcap_dump_ftell,
596 AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
597 [define if libpcap has pcap_dump_ftell()]),
598 [
599 AC_LIBOBJ(pcap_dump_ftell)
600 ])
601
602 #
603 # Do we have the new open API? Check for pcap_create, and assume that,
604 # if we do, we also have pcap_activate() and the other new routines
605 # introduced in libpcap 1.0.0.
606 #
607 AC_CHECK_FUNCS(pcap_create)
608 if test $ac_cv_func_pcap_create = "yes" ; then
609 #
610 # OK, do we have pcap_set_tstamp_type? If so, assume we have
611 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
612 #
613 AC_CHECK_FUNCS(pcap_set_tstamp_type)
614 #
615 # And do we have pcap_set_tstamp_precision? If so, we assume
616 # we also have pcap_open_offline_with_tstamp_precision.
617 #
618 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
619 fi
620
621 #
622 # Check for a miscellaneous collection of functions which we use
623 # if we have them.
624 #
625 AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode)
626 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
627 dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
628 dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
629 dnl have pcap_if_t.
630 savedcppflags="$CPPFLAGS"
631 CPPFLAGS="$CPPFLAGS $V_INCLS"
632 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
633 CPPFLAGS="$savedcppflags"
634 fi
635
636 if test $ac_cv_func_pcap_lib_version = "no" ; then
637 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
638 AC_TRY_LINK([],
639 [
640 extern char pcap_version[];
641
642 return (int)pcap_version;
643 ],
644 ac_lbl_cv_pcap_version_defined=yes,
645 ac_lbl_cv_pcap_version_defined=no)
646 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
647 AC_MSG_RESULT(yes)
648 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
649 else
650 AC_MSG_RESULT(no)
651 fi
652 fi
653
654 #
655 # Check for special debugging functions
656 #
657 AC_CHECK_FUNCS(pcap_set_parser_debug)
658 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
659 #
660 # OK, we don't have pcap_set_parser_debug() to set the libpcap
661 # filter expression parser debug flag; can we directly set the
662 # flag?
663 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
664 AC_TRY_LINK([],
665 [
666 extern int pcap_debug;
667
668 return pcap_debug;
669 ],
670 ac_lbl_cv_pcap_debug_defined=yes,
671 ac_lbl_cv_pcap_debug_defined=no)
672 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
673 AC_MSG_RESULT(yes)
674 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
675 else
676 AC_MSG_RESULT(no)
677 #
678 # OK, what about "yydebug"?
679 #
680 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
681 AC_TRY_LINK([],
682 [
683 extern int yydebug;
684
685 return yydebug;
686 ],
687 ac_lbl_cv_yydebug_defined=yes,
688 ac_lbl_cv_yydebug_defined=no)
689 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
690 AC_MSG_RESULT(yes)
691 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
692 else
693 AC_MSG_RESULT(no)
694 fi
695 fi
696 fi
697 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
698 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
699
700 V_GROUP=0
701 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
702 V_GROUP=wheel
703 fi
704 #
705 # Assume V7/BSD convention for man pages (file formats in section 5,
706 # miscellaneous info in section 7).
707 #
708 MAN_FILE_FORMATS=5
709 MAN_MISC_INFO=7
710 case "$host_os" in
711
712 aix*)
713 dnl Workaround to enable certain features
714 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
715 ;;
716
717 hpux*)
718 #
719 # Use System V conventions for man pages.
720 #
721 MAN_FILE_FORMATS=4
722 MAN_MISC_INFO=5
723 ;;
724
725 irix*)
726 V_GROUP=sys
727
728 #
729 # Use System V conventions for man pages.
730 #
731 MAN_FILE_FORMATS=4
732 MAN_MISC_INFO=5
733 ;;
734
735 osf*)
736 V_GROUP=system
737
738 #
739 # Use System V conventions for man pages.
740 #
741 MAN_FILE_FORMATS=4
742 MAN_MISC_INFO=5
743 ;;
744
745 solaris*)
746 V_GROUP=sys
747
748 #
749 # Use System V conventions for man pages.
750 #
751 MAN_FILE_FORMATS=4
752 MAN_MISC_INFO=5
753 ;;
754 esac
755
756 if test -f /dev/bpf0 ; then
757 V_GROUP=bpf
758 fi
759
760 #
761 # Make sure we have definitions for all the C99 specified-width types
762 # (regardless of whether the environment is a C99 environment or not).
763 #
764 AC_TYPE_INT8_T
765 AC_TYPE_INT16_T
766 AC_TYPE_INT32_T
767 AC_TYPE_INT64_T
768 AC_TYPE_UINT8_T
769 AC_TYPE_UINT16_T
770 AC_TYPE_UINT32_T
771 AC_TYPE_UINT64_T
772
773 #
774 # Make sure we have a definition for C99's uintptr_t (regardless of
775 # whether the environment is a C99 environment or not).
776 #
777 AC_TYPE_UINTPTR_T
778
779 #
780 # Define the old BSD specified-width types in terms of the C99 types;
781 # we may need them with libpcap include files.
782 #
783 AC_CHECK_TYPE([u_int8_t], ,
784 [AC_DEFINE([u_int8_t], [uint8_t],
785 [Define to `uint8_t' if u_int8_t not defined.])],
786 [AC_INCLUDES_DEFAULT
787 #include <sys/types.h>
788 ])
789 AC_CHECK_TYPE([u_int16_t], ,
790 [AC_DEFINE([u_int16_t], [uint16_t],
791 [Define to `uint16_t' if u_int16_t not defined.])],
792 [AC_INCLUDES_DEFAULT
793 #include <sys/types.h>
794 ])
795 AC_CHECK_TYPE([u_int32_t], ,
796 [AC_DEFINE([u_int32_t], [uint32_t],
797 [Define to `uint32_t' if u_int32_t not defined.])],
798 [AC_INCLUDES_DEFAULT
799 #include <sys/types.h>
800 ])
801 AC_CHECK_TYPE([u_int64_t], ,
802 [AC_DEFINE([u_int64_t], [uint64_t],
803 [Define to `uint64_t' if u_int64_t not defined.])],
804 [AC_INCLUDES_DEFAULT
805 #include <sys/types.h>
806 ])
807
808 #
809 # Check for <inttypes.h>
810 #
811 AC_CHECK_HEADERS(inttypes.h,
812 [
813 #
814 # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
815 # Some systems have an inttypes.h that doesn't define all of them.
816 #
817 AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
818 AC_COMPILE_IFELSE(
819 [
820 AC_LANG_SOURCE(
821 [[
822 #include <inttypes.h>
823 #include <stdio.h>
824 #include <sys/types.h>
825
826 main()
827 {
828 printf("%" PRId64 "\n", (uint64_t)1);
829 printf("%" PRIo64 "\n", (uint64_t)1);
830 printf("%" PRIx64 "\n", (uint64_t)1);
831 printf("%" PRIu64 "\n", (uint64_t)1);
832 }
833 ]])
834 ],
835 [
836 AC_MSG_RESULT(yes)
837 ac_lbl_inttypes_h_defines_formats=yes
838 ],
839 [
840 AC_MSG_RESULT(no)
841 ac_lbl_inttypes_h_defines_formats=no
842 ])
843 ],
844 [
845 #
846 # We don't have inttypes.h, so it obviously can't define those
847 # macros.
848 #
849 ac_lbl_inttypes_h_defines_formats=no
850 ])
851 if test "$ac_lbl_inttypes_h_defines_formats" = no; then
852 AC_LBL_CHECK_64BIT_FORMAT(l,
853 [
854 AC_LBL_CHECK_64BIT_FORMAT(ll,
855 [
856 AC_LBL_CHECK_64BIT_FORMAT(L,
857 [
858 AC_LBL_CHECK_64BIT_FORMAT(q,
859 [
860 AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
861 ])
862 ])
863 ])
864 ])
865 fi
866
867 #
868 # Check for some headers introduced in later versions of libpcap
869 # and used by some printers.
870 #
871 # Those headers use the {u_}intN_t types, so we must do this after
872 # we check for what's needed to get them defined.
873 #
874 savedcppflags="$CPPFLAGS"
875 CPPFLAGS="$CPPFLAGS $V_INCLS"
876 AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"])
877 AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"])
878 AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"])
879 CPPFLAGS="$savedcppflags"
880
881 AC_PROG_RANLIB
882 AC_CHECK_TOOL([AR], [ar])
883
884 AC_LBL_DEVEL(V_CCOPT)
885
886 AC_LBL_SOCKADDR_SA_LEN
887
888 AC_LBL_UNALIGNED_ACCESS
889
890 # Check for OpenSSL/libressl libcrypto
891 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
892 # Specify location for both includes and libraries.
893 want_libcrypto=ifavailable
894 AC_ARG_WITH(crypto,
895 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
896 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
897 [
898 if test $withval = no
899 then
900 # User doesn't want to link with libcrypto.
901 want_libcrypto=no
902 AC_MSG_RESULT(no)
903 elif test $withval = yes
904 then
905 # User wants to link with libcrypto but hasn't specified
906 # a directory.
907 want_libcrypto=yes
908 AC_MSG_RESULT(yes)
909 else
910 # User wants to link with libcrypto and has specified
911 # a directory, so use the provided value.
912 want_libcrypto=yes
913 libcrypto_root=$withval
914 AC_MSG_RESULT([yes, using the version installed in $withval])
915
916 #
917 # Put the subdirectories of the libcrypto root directory
918 # at the front of the header and library search path.
919 #
920 CFLAGS="-I$withval/include $CFLAGS"
921 LIBS="-L$withval/lib $LIBS"
922 fi
923 ],[
924 #
925 # Use libcrypto if it's present, otherwise don't; no directory
926 # was specified.
927 #
928 want_libcrypto=ifavailable
929 AC_MSG_RESULT([yes, if available])
930 ])
931 if test "$want_libcrypto" != "no"; then
932 #
933 # Don't check for libcrypto unless we have its headers;
934 # Apple, bless their pointy little heads, apparently ship
935 # libcrypto as a library, but not the header files, in
936 # El Capitan, probably because they don't want you writing
937 # nasty portable code that could run on other UN*Xes, they
938 # want you writing code that uses their Shiny New Crypto
939 # Library and that only runs on OS X.
940 #
941 AC_CHECK_HEADER(openssl/crypto.h,
942 [
943 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
944 if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
945 AC_CHECK_HEADERS(openssl/evp.h)
946 #
947 # OK, do we have EVP_CIPHER_CTX_new?
948 # If so, we use it to allocate an
949 # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
950 # opaque; otherwise, we allocate it ourselves.
951 #
952 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new)
953 fi
954 ])
955 fi
956
957 # Check for libcap-ng
958 AC_MSG_CHECKING(whether to use libcap-ng)
959 # Specify location for both includes and libraries.
960 want_libcap_ng=ifavailable
961 AC_ARG_WITH(cap_ng,
962 AS_HELP_STRING([--with-cap-ng],
963 [use libcap-ng @<:@default=yes, if available@:>@]),
964 [
965 if test $withval = no
966 then
967 want_libcap_ng=no
968 AC_MSG_RESULT(no)
969 elif test $withval = yes
970 then
971 want_libcap_ng=yes
972 AC_MSG_RESULT(yes)
973 fi
974 ],[
975 #
976 # Use libcap-ng if it's present, otherwise don't.
977 #
978 want_libcap_ng=ifavailable
979 AC_MSG_RESULT([yes, if available])
980 ])
981 if test "$want_libcap_ng" != "no"; then
982 AC_CHECK_LIB(cap-ng, capng_change_id)
983 AC_CHECK_HEADERS(cap-ng.h)
984 fi
985
986 dnl
987 dnl set additional include path if necessary
988 if test "$missing_includes" = "yes"; then
989 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
990 V_INCLS="$V_INCLS -I$srcdir/missing"
991 fi
992
993 AC_SUBST(V_CCOPT)
994 AC_SUBST(V_DEFS)
995 AC_SUBST(V_GROUP)
996 AC_SUBST(V_INCLS)
997 AC_SUBST(V_PCAPDEP)
998 AC_SUBST(LOCALSRC)
999 AC_SUBST(MAN_FILE_FORMATS)
1000 AC_SUBST(MAN_MISC_INFO)
1001
1002 AC_PROG_INSTALL
1003
1004 AC_CONFIG_HEADER(config.h)
1005
1006 AC_OUTPUT_COMMANDS([if test -f .devel; then
1007 echo timestamp > stamp-h
1008 cat Makefile-devel-adds >> Makefile
1009 make depend
1010 fi])
1011 AC_OUTPUT(Makefile tcpdump.1)
1012 exit 0