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