]> The Tcpdump Group git mirrors - tcpdump/blob - configure.ac
Fix spaces
[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_DEFINE(ENABLE_SMB, 1,
149 [define if you want to build the possibly-buggy SMB printer])
150 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
151 ;;
152 *) AC_MSG_RESULT(no)
153 ;;
154 esac
155
156 AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
157 AC_MSG_CHECKING([whether to drop root privileges by default])
158 if test ! -z "$with_user" ; then
159 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
160 [define if should drop privileges by default])
161 AC_MSG_RESULT(to \"$withval\")
162 else
163 AC_MSG_RESULT(no)
164 fi
165
166 AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
167 AC_MSG_CHECKING([whether to chroot])
168 if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
169 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
170 [define if should chroot when dropping privileges])
171 AC_MSG_RESULT(to \"$withval\")
172 else
173 AC_MSG_RESULT(no)
174 fi
175
176 AC_ARG_WITH(sandbox-capsicum,
177 AS_HELP_STRING([--with-sandbox-capsicum],
178 [use Capsicum security functions @<:@default=yes, if available@:>@]))
179 #
180 # Check whether various functions are available. If any are, set
181 # ac_lbl_capsicum_function_seen to yes; if any are not, set
182 # ac_lbl_capsicum_function_not_seen to yes.
183 #
184 # We don't check cap_rights_init(), as it's a macro, wrapping another
185 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
186 # doesn't handle that.
187 #
188 # All of the ones we check for must be available in order to enable
189 # capsicum sandboxing.
190 #
191 # XXX - do we need to check for all of them, or are there some that, if
192 # present, imply others are present?
193 #
194 if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
195 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
196 ac_lbl_capsicum_function_seen=yes,
197 ac_lbl_capsicum_function_not_seen=yes)
198 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
199 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
200 fi
201 AC_MSG_CHECKING([whether to sandbox using capsicum])
202 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
203 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
204 AC_MSG_RESULT(yes)
205 else
206 AC_MSG_RESULT(no)
207 fi
208 AC_MSG_CHECKING([whether to sandbox using Casper library])
209 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
210 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
211 AC_MSG_RESULT(yes)
212 else
213 AC_MSG_RESULT(no)
214 fi
215
216 #
217 # We must check this before checking whether to check the OS's IPv6,
218 # support because, on some platforms (such as SunOS 5.x), the test
219 # program requires the extra networking libraries.
220 #
221 AC_LBL_LIBRARY_NET
222
223 #
224 # Check whether AF_INET6 and struct in6_addr are defined.
225 # If they aren't both defined, we don't have sufficient OS
226 # support for IPv6, so we don't look for IPv6 support libraries,
227 # and we define AF_INET6 and struct in6_addr ourselves.
228 #
229 AC_MSG_CHECKING([whether the operating system supports IPv6])
230 AC_COMPILE_IFELSE(
231 [
232 AC_LANG_SOURCE(
233 [[
234 /* AF_INET6 available check */
235 #include <sys/types.h>
236 #ifdef _WIN32
237 #include <ws2tcpip.h>
238 #else
239 #include <sys/socket.h>
240 #include <netinet/in.h>
241 #endif
242 #ifdef AF_INET6
243 void
244 foo(struct in6_addr *addr)
245 {
246 memset(addr, 0, sizeof (struct in6_addr));
247 }
248 #else
249 #error "AF_INET6 not defined"
250 #endif
251 ]])
252 ],
253 [
254 AC_MSG_RESULT(yes)
255 AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
256 [define if the OS provides AF_INET6 and struct in6_addr])
257 ipv6=yes
258 ],
259 [
260 AC_MSG_RESULT(no)
261 ipv6=no
262 ]
263 )
264
265 ipv6type=unknown
266 ipv6lib=none
267 ipv6trylibc=no
268
269 if test "$ipv6" = "yes"; then
270 AC_MSG_CHECKING([ipv6 stack type])
271 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
272 case $i in
273 inria)
274 dnl http://www.kame.net/
275 AC_EGREP_CPP(yes,
276 [#include <netinet/in.h>
277 #ifdef IPV6_INRIA_VERSION
278 yes
279 #endif],
280 [ipv6type=$i])
281 ;;
282 kame)
283 dnl http://www.kame.net/
284 AC_EGREP_CPP(yes,
285 [#include <netinet/in.h>
286 #ifdef __KAME__
287 yes
288 #endif],
289 [ipv6type=$i;
290 ipv6lib=inet6;
291 ipv6libdir=/usr/local/v6/lib;
292 ipv6trylibc=yes])
293 ;;
294 linux-glibc)
295 dnl http://www.v6.linux.or.jp/
296 AC_EGREP_CPP(yes,
297 [#include <features.h>
298 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
299 yes
300 #endif],
301 [ipv6type=$i])
302 ;;
303 linux-libinet6)
304 dnl http://www.v6.linux.or.jp/
305 dnl
306 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
307 dnl and possibly other versions of those OSes
308 dnl
309 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
310 ipv6type=$i
311 ipv6lib=inet6
312 ipv6libdir=/usr/inet6/lib
313 ipv6trylibc=yes;
314 CFLAGS="-I/usr/inet6/include $CFLAGS"
315 fi
316 ;;
317 toshiba)
318 AC_EGREP_CPP(yes,
319 [#include <sys/param.h>
320 #ifdef _TOSHIBA_INET6
321 yes
322 #endif],
323 [ipv6type=$i;
324 ipv6lib=inet6;
325 ipv6libdir=/usr/local/v6/lib])
326 ;;
327 v6d)
328 AC_EGREP_CPP(yes,
329 [#include </usr/local/v6/include/sys/v6config.h>
330 #ifdef __V6D__
331 yes
332 #endif],
333 [ipv6type=$i;
334 ipv6lib=v6;
335 ipv6libdir=/usr/local/v6/lib;
336 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
337 ;;
338 zeta)
339 AC_EGREP_CPP(yes,
340 [#include <sys/param.h>
341 #ifdef _ZETA_MINAMI_INET6
342 yes
343 #endif],
344 [ipv6type=$i;
345 ipv6lib=inet6;
346 ipv6libdir=/usr/local/v6/lib])
347 ;;
348 esac
349 if test "$ipv6type" != "unknown"; then
350 break
351 fi
352 done
353 AC_MSG_RESULT($ipv6type)
354 fi
355
356 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
357 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
358 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
359 echo "You have $ipv6lib library, using it"
360 else
361 if test "$ipv6trylibc" = "yes"; then
362 echo "You do not have $ipv6lib library, using libc"
363 else
364 echo 'Fatal: no $ipv6lib library found. cannot continue.'
365 echo "You need to fetch lib$ipv6lib.a from appropriate"
366 echo 'ipv6 kit and compile beforehand.'
367 exit 1
368 fi
369 fi
370 fi
371
372 AC_SEARCH_LIBS(dnet_htoa, dnet,
373 [
374 AC_DEFINE(HAVE_DNET_HTOA, 1,
375 [define if you have the dnet_htoa function])
376 #
377 # OK, we have dnet_htoa(). Do we have netdnet/dnetdb.h?
378 #
379 AC_CHECK_HEADERS(netdnet/dnetdb.h)
380 if test "$ac_cv_header_netdnet_dnetdb_h" = "yes"; then
381 #
382 # Yes. Does it declare dnet_htoa()?
383 #
384 AC_CHECK_DECL(dnet_htoa,
385 [
386 # Yes.
387 AC_DEFINE(NETDNET_DNETDB_H_DECLARES_DNET_HTOA,,
388 [Define to 1 if netenet/dnetdb.h declares `dnet_htoa'])
389 ],,
390 [
391 AC_INCLUDES_DEFAULT
392 #include <netdnet/dnetdb.h>
393 ])
394 fi
395
396 #
397 # Do we have netdnet/dn.h?
398 #
399 AC_CHECK_HEADERS(netdnet/dn.h)
400 if test "$ac_cv_header_netdnet_dn_h" = "yes"; then
401 #
402 # Yes. Does it declare struct dn_naddr?
403 #
404 AC_CHECK_TYPES(struct dn_naddr,,,
405 [
406 #include <netdnet/dn.h>
407 ])
408 fi
409 ])
410
411 AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
412 AC_CHECK_FUNCS(fork vfork strftime)
413 AC_CHECK_FUNCS(setlinebuf)
414
415 needsnprintf=no
416 AC_CHECK_FUNCS(vsnprintf snprintf,,
417 [needsnprintf=yes])
418 if test $needsnprintf = yes; then
419 AC_LIBOBJ(snprintf)
420 fi
421
422 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
423
424 dnl Some platforms may need -lnsl for getrpcbynumber.
425 AC_SEARCH_LIBS(getrpcbynumber, nsl,
426 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
427
428 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
429
430 #
431 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
432 # libraries (e.g., "-lsocket -lnsl" on Solaris).
433 #
434 # You are in a twisty little maze of UN*Xes, all different.
435 # Some might not have ether_ntohost().
436 # Some might have it and declare it in <net/ethernet.h>.
437 # Some might have it and declare it in <netinet/ether.h>
438 # Some might have it and declare it in <sys/ethernet.h>.
439 # Some might have it and declare it in <arpa/inet.h>.
440 # Some might have it and declare it in <netinet/if_ether.h>.
441 # Some might have it and not declare it in any header file.
442 #
443 # Before you is a C compiler.
444 #
445 AC_CHECK_FUNCS(ether_ntohost, [
446 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
447 AC_TRY_RUN([
448 #include <netdb.h>
449 #include <sys/types.h>
450 #include <sys/param.h>
451 #include <sys/socket.h>
452
453 int
454 main(int argc, char **argv)
455 {
456 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
457 char name[MAXHOSTNAMELEN];
458
459 ether_ntohost(name, (struct ether_addr *)ea);
460 exit(0);
461 }
462 ], [ac_cv_buggy_ether_ntohost=no],
463 [ac_cv_buggy_ether_ntohost=yes],
464 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
465 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
466 AC_DEFINE(USE_ETHER_NTOHOST, 1,
467 [define if you have ether_ntohost() and it works])
468 fi
469 ])
470 if test "$ac_cv_func_ether_ntohost" = yes -a \
471 "$ac_cv_buggy_ether_ntohost" = "no"; then
472 #
473 # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
474 #
475 # This test fails if we don't have <net/ethernet.h> or if we do
476 # but it doesn't declare ether_ntohost().
477 #
478 AC_CHECK_DECL(ether_ntohost,
479 [
480 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
481 [Define to 1 if net/ethernet.h declares `ether_ntohost'])
482 ],,
483 [
484 #include <net/ethernet.h>
485 ])
486 #
487 # Did that succeed?
488 #
489 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
490 #
491 # No, how about <netinet/ether.h>, as on Linux?
492 #
493 # This test fails if we don't have <netinet/ether.h>
494 # or if we do but it doesn't declare ether_ntohost().
495 #
496 # Unset ac_cv_have_decl_ether_ntohost so we don't
497 # treat the previous failure as a cached value and
498 # suppress the next test.
499 #
500 unset ac_cv_have_decl_ether_ntohost
501 AC_CHECK_DECL(ether_ntohost,
502 [
503 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
504 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
505 ],,
506 [
507 #include <netinet/ether.h>
508 ])
509 fi
510 #
511 # Did that succeed?
512 #
513 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
514 #
515 # No, how about <sys/ethernet.h>, as on Solaris 10
516 # and later?
517 #
518 # This test fails if we don't have <sys/ethernet.h>
519 # or if we do but it doesn't declare ether_ntohost().
520 #
521 # Unset ac_cv_have_decl_ether_ntohost so we don't
522 # treat the previous failure as a cached value and
523 # suppress the next test.
524 #
525 unset ac_cv_have_decl_ether_ntohost
526 AC_CHECK_DECL(ether_ntohost,
527 [
528 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
529 [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
530 ],,
531 [
532 #include <sys/ethernet.h>
533 ])
534 fi
535 #
536 # Did that succeed?
537 #
538 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
539 #
540 # No, how about <arpa/inet.h>, as in AIX?
541 #
542 # This test fails if we don't have <arpa/inet.h>
543 # (if we have ether_ntohost(), we should have
544 # networking, and if we have networking, we should
545 # have <arpa/inet.h>) or if we do but it doesn't
546 # declare ether_ntohost().
547 #
548 # Unset ac_cv_have_decl_ether_ntohost so we don't
549 # treat the previous failure as a cached value and
550 # suppress the next test.
551 #
552 unset ac_cv_have_decl_ether_ntohost
553 AC_CHECK_DECL(ether_ntohost,
554 [
555 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
556 [Define to 1 if arpa/inet.h declares `ether_ntohost'])
557 ],,
558 [
559 #include <arpa/inet.h>
560 ])
561 fi
562 #
563 # Did that succeed?
564 #
565 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
566 #
567 # No, how about <netinet/if_ether.h>?
568 # On some platforms, it requires <net/if.h> and
569 # <netinet/in.h>, and we always include it with
570 # both of them, so test it with both of them.
571 #
572 # This test fails if we don't have <netinet/if_ether.h>
573 # and the headers we include before it, or if we do but
574 # <netinet/if_ether.h> doesn't declare ether_hostton().
575 #
576 # Unset ac_cv_have_decl_ether_ntohost so we don't
577 # treat the previous failure as a cached value and
578 # suppress the next test.
579 #
580 unset ac_cv_have_decl_ether_ntohost
581 AC_CHECK_DECL(ether_ntohost,
582 [
583 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
584 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
585 ],,
586 [
587 #include <sys/types.h>
588 #include <sys/socket.h>
589 #include <net/if.h>
590 #include <netinet/in.h>
591 #include <netinet/if_ether.h>
592 ])
593 fi
594 #
595 # After all that, is ether_ntohost() declared?
596 #
597 if test "$ac_cv_have_decl_ether_ntohost" = yes; then
598 #
599 # Yes.
600 #
601 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
602 [Define to 1 if you have the declaration of `ether_ntohost'])
603 else
604 #
605 # No, we'll have to declare it ourselves.
606 # Do we have "struct ether_addr" if we include
607 # <netinet/if_ether.h>?
608 #
609 AC_CHECK_TYPES(struct ether_addr,,,
610 [
611 #include <sys/types.h>
612 #include <sys/socket.h>
613 #include <net/if.h>
614 #include <netinet/in.h>
615 #include <netinet/if_ether.h>
616 ])
617 fi
618 fi
619
620 dnl
621 dnl Check for "pcap_list_datalinks()" and use a substitute version if
622 dnl it's not present. If it is present, check for "pcap_free_datalinks()";
623 dnl if it's not present, we don't replace it for now. (We could do so
624 dnl on UN*X, but not on Windows, where hilarity ensues if a program
625 dnl built with one version of the MSVC support library tries to free
626 dnl something allocated by a library built with another version of
627 dnl the MSVC support library.)
628 dnl
629 AC_CHECK_FUNC(pcap_list_datalinks,
630 [
631 AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
632 [define if libpcap has pcap_list_datalinks()])
633 AC_CHECK_FUNCS(pcap_free_datalinks)
634 ],
635 [
636 AC_LIBOBJ(datalinks)
637 ])
638
639 dnl
640 dnl Check for "pcap_datalink_name_to_val()", and use a substitute
641 dnl version if it's not present. If it is present, check for
642 dnl "pcap_datalink_val_to_description()", and if we don't have it,
643 dnl use a substitute version.
644 dnl
645 AC_CHECK_FUNC(pcap_datalink_name_to_val,
646 [
647 AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
648 [define if libpcap has pcap_datalink_name_to_val()])
649 AC_CHECK_FUNC(pcap_datalink_val_to_description,
650 AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
651 [define if libpcap has pcap_datalink_val_to_description()]),
652 [
653 AC_LIBOBJ(dlnames)
654 ])
655 ],
656 [
657 AC_LIBOBJ(dlnames)
658 ])
659
660 dnl
661 dnl Check for "pcap_set_datalink()"; you can't substitute for it if
662 dnl it's absent (it has hooks into libpcap), so just define the
663 dnl HAVE_ value if it's there.
664 dnl
665 AC_CHECK_FUNCS(pcap_set_datalink)
666
667 dnl
668 dnl Check for "pcap_breakloop()"; you can't substitute for it if
669 dnl it's absent (it has hooks into the live capture routines),
670 dnl so just define the HAVE_ value if it's there.
671 dnl
672 AC_CHECK_FUNCS(pcap_breakloop)
673
674 #
675 # Do we have the new open API? Check for pcap_create, and assume that,
676 # if we do, we also have pcap_activate() and the other new routines
677 # introduced in libpcap 1.0.0.
678 #
679 AC_CHECK_FUNCS(pcap_create)
680 if test $ac_cv_func_pcap_create = "yes" ; then
681 #
682 # OK, do we have pcap_set_tstamp_type? If so, assume we have
683 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
684 #
685 AC_CHECK_FUNCS(pcap_set_tstamp_type)
686 #
687 # And do we have pcap_set_tstamp_precision? If so, we assume
688 # we also have pcap_open_offline_with_tstamp_precision.
689 #
690 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
691 fi
692
693 #
694 # Check for a miscellaneous collection of functions which we use
695 # if we have them.
696 #
697 AC_CHECK_FUNCS(pcap_findalldevs)
698 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
699 dnl Check for libpcap having pcap_findalldevs() but the pcap.h header
700 dnl not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
701 dnl from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
702 dnl pcap.h didn't have pcap_if_t.
703 savedcppflags="$CPPFLAGS"
704 CPPFLAGS="$CPPFLAGS $V_INCLS"
705 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
706 CPPFLAGS="$savedcppflags"
707 fi
708 AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
709 if test $ac_cv_func_pcap_lib_version = "no" ; then
710 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
711 AC_TRY_LINK([],
712 [
713 extern char pcap_version[];
714
715 return (int)pcap_version;
716 ],
717 ac_lbl_cv_pcap_version_defined=yes,
718 ac_lbl_cv_pcap_version_defined=no)
719 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
720 AC_MSG_RESULT(yes)
721 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
722 else
723 AC_MSG_RESULT(no)
724 fi
725 fi
726 AC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
727 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
728 AC_REPLACE_FUNCS(pcap_dump_ftell)
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