]> The Tcpdump Group git mirrors - tcpdump/blob - configure.ac
d47b2fdcf7713f4ab76f3742b122f6ab7917f4da
[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)
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)
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, but not declare it in any header file.
438 # Some might have it, but declare it in <netinet/if_ether.h>.
439 # Some might have it, but declare it in <netinet/ether.h>
440 # (And some might have it but document it as something declared in
441 # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
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(). Do we have <netinet/if_ether.h>?
474 #
475 AC_CHECK_HEADERS(netinet/if_ether.h, , , [
476 #include <sys/types.h>
477 #include <sys/socket.h>
478 #include <netinet/in.h>
479 struct mbuf;
480 struct rtentry;
481 #include <net/if.h>])
482 if test "$ac_cv_header_netinet_if_ether_h" = yes; then
483 #
484 # Yes. Does it declare ether_ntohost()?
485 #
486 AC_CHECK_DECL(ether_ntohost,
487 [
488 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
489 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
490 ],,
491 [
492 #include <sys/types.h>
493 #include <sys/socket.h>
494 #include <netinet/in.h>
495 #include <arpa/inet.h>
496 struct mbuf;
497 struct rtentry;
498 #include <net/if.h>
499 #include <netinet/if_ether.h>
500 ])
501 fi
502 #
503 # Did that succeed?
504 #
505 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
506 #
507 # No, how about <netinet/ether.h>, as on Linux?
508 #
509 AC_CHECK_HEADERS(netinet/ether.h)
510 if test "$ac_cv_header_netinet_ether_h" = yes; then
511 #
512 # We have it - does it declare ether_ntohost()?
513 # Unset ac_cv_have_decl_ether_ntohost so we don't
514 # treat the previous failure as a cached value and
515 # suppress the next test.
516 #
517 unset ac_cv_have_decl_ether_ntohost
518 AC_CHECK_DECL(ether_ntohost,
519 [
520 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
521 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
522 ],,
523 [
524 #include <netinet/ether.h>
525 ])
526 fi
527 fi
528 #
529 # Is ether_ntohost() declared?
530 #
531 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
532 #
533 # No, we'll have to declare it ourselves.
534 # Do we have "struct ether_addr"?
535 #
536 AC_CHECK_TYPES(struct ether_addr,,,
537 [
538 #include <sys/types.h>
539 #include <sys/socket.h>
540 #include <netinet/in.h>
541 #include <arpa/inet.h>
542 struct mbuf;
543 struct rtentry;
544 #include <net/if.h>
545 #include <netinet/if_ether.h>
546 ])
547 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
548 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
549 don't.])
550 else
551 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
552 [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
553 don't.])
554 fi
555 fi
556
557 dnl
558 dnl Check for "pcap_list_datalinks()" and use a substitute version if
559 dnl it's not present. If it is present, check for "pcap_free_datalinks()";
560 dnl if it's not present, we don't replace it for now. (We could do so
561 dnl on UN*X, but not on Windows, where hilarity ensues if a program
562 dnl built with one version of the MSVC support library tries to free
563 dnl something allocated by a library built with another version of
564 dnl the MSVC support library.)
565 dnl
566 AC_CHECK_FUNC(pcap_list_datalinks,
567 [
568 AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
569 [define if libpcap has pcap_list_datalinks()])
570 AC_CHECK_FUNCS(pcap_free_datalinks)
571 ],
572 [
573 AC_LIBOBJ(datalinks)
574 ])
575
576 dnl
577 dnl Check for "pcap_datalink_name_to_val()", and use a substitute
578 dnl version if it's not present. If it is present, check for
579 dnl "pcap_datalink_val_to_description()", and if we don't have it,
580 dnl use a substitute version.
581 dnl
582 AC_CHECK_FUNC(pcap_datalink_name_to_val,
583 [
584 AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
585 [define if libpcap has pcap_datalink_name_to_val()])
586 AC_CHECK_FUNC(pcap_datalink_val_to_description,
587 AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
588 [define if libpcap has pcap_datalink_val_to_description()]),
589 [
590 AC_LIBOBJ(dlnames)
591 ])
592 ],
593 [
594 AC_LIBOBJ(dlnames)
595 ])
596
597 dnl
598 dnl Check for "pcap_set_datalink()"; you can't substitute for it if
599 dnl it's absent (it has hooks into libpcap), so just define the
600 dnl HAVE_ value if it's there.
601 dnl
602 AC_CHECK_FUNCS(pcap_set_datalink)
603
604 dnl
605 dnl Check for "pcap_breakloop()"; you can't substitute for it if
606 dnl it's absent (it has hooks into the live capture routines),
607 dnl so just define the HAVE_ value if it's there.
608 dnl
609 AC_CHECK_FUNCS(pcap_breakloop)
610
611 dnl
612 dnl Check for "pcap_dump_ftell()" and use a substitute version
613 dnl if it's not present.
614 dnl
615 AC_CHECK_FUNC(pcap_dump_ftell,
616 AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
617 [define if libpcap has pcap_dump_ftell()]),
618 [
619 AC_LIBOBJ(pcap_dump_ftell)
620 ])
621
622 #
623 # Do we have the new open API? Check for pcap_create, and assume that,
624 # if we do, we also have pcap_activate() and the other new routines
625 # introduced in libpcap 1.0.0.
626 #
627 AC_CHECK_FUNCS(pcap_create)
628 if test $ac_cv_func_pcap_create = "yes" ; then
629 #
630 # OK, do we have pcap_set_tstamp_type? If so, assume we have
631 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
632 #
633 AC_CHECK_FUNCS(pcap_set_tstamp_type)
634 #
635 # And do we have pcap_set_tstamp_precision? If so, we assume
636 # we also have pcap_open_offline_with_tstamp_precision.
637 #
638 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
639 fi
640
641 #
642 # Check for a miscellaneous collection of functions which we use
643 # if we have them.
644 #
645 AC_CHECK_FUNCS(pcap_findalldevs)
646 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
647 dnl Check for libpcap having pcap_findalldevs() but the pcap.h header
648 dnl not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
649 dnl from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
650 dnl pcap.h didn't have pcap_if_t.
651 savedcppflags="$CPPFLAGS"
652 CPPFLAGS="$CPPFLAGS $V_INCLS"
653 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
654 CPPFLAGS="$savedcppflags"
655 fi
656 AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
657 if test $ac_cv_func_pcap_lib_version = "no" ; then
658 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
659 AC_TRY_LINK([],
660 [
661 extern char pcap_version[];
662
663 return (int)pcap_version;
664 ],
665 ac_lbl_cv_pcap_version_defined=yes,
666 ac_lbl_cv_pcap_version_defined=no)
667 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
668 AC_MSG_RESULT(yes)
669 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
670 else
671 AC_MSG_RESULT(no)
672 fi
673 fi
674 AC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
675 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
676
677 #
678 # Check for special debugging functions
679 #
680 AC_CHECK_FUNCS(pcap_set_parser_debug)
681 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
682 #
683 # OK, we don't have pcap_set_parser_debug() to set the libpcap
684 # filter expression parser debug flag; can we directly set the
685 # flag?
686 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
687 AC_TRY_LINK([],
688 [
689 extern int pcap_debug;
690
691 return pcap_debug;
692 ],
693 ac_lbl_cv_pcap_debug_defined=yes,
694 ac_lbl_cv_pcap_debug_defined=no)
695 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
696 AC_MSG_RESULT(yes)
697 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
698 else
699 AC_MSG_RESULT(no)
700 #
701 # OK, what about "yydebug"?
702 #
703 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
704 AC_TRY_LINK([],
705 [
706 extern int yydebug;
707
708 return yydebug;
709 ],
710 ac_lbl_cv_yydebug_defined=yes,
711 ac_lbl_cv_yydebug_defined=no)
712 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
713 AC_MSG_RESULT(yes)
714 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
715 else
716 AC_MSG_RESULT(no)
717 fi
718 fi
719 fi
720 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
721 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
722
723 V_GROUP=0
724 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
725 V_GROUP=wheel
726 fi
727 #
728 # Assume V7/BSD convention for man pages (file formats in section 5,
729 # miscellaneous info in section 7).
730 #
731 MAN_FILE_FORMATS=5
732 MAN_MISC_INFO=7
733 case "$host_os" in
734
735 aix*)
736 dnl Workaround to enable certain features
737 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
738 ;;
739
740 hpux*)
741 #
742 # Use System V conventions for man pages.
743 #
744 MAN_FILE_FORMATS=4
745 MAN_MISC_INFO=5
746 ;;
747
748 irix*)
749 V_GROUP=sys
750
751 #
752 # Use System V conventions for man pages.
753 #
754 MAN_FILE_FORMATS=4
755 MAN_MISC_INFO=5
756 ;;
757
758 osf*)
759 V_GROUP=system
760
761 #
762 # Use System V conventions for man pages.
763 #
764 MAN_FILE_FORMATS=4
765 MAN_MISC_INFO=5
766 ;;
767
768 solaris*)
769 V_GROUP=sys
770
771 #
772 # Use System V conventions for man pages.
773 #
774 MAN_FILE_FORMATS=4
775 MAN_MISC_INFO=5
776 ;;
777 esac
778
779 if test -f /dev/bpf0 ; then
780 V_GROUP=bpf
781 fi
782
783 #
784 # Make sure we have a definition for C99's uintptr_t (regardless of
785 # whether the environment is a C99 environment or not).
786 #
787 AC_TYPE_UINTPTR_T
788
789 #
790 # Check whether we have pcap/pcap-inttypes.h.
791 # If we do, we use that to get the C99 types defined.
792 #
793 savedcppflags="$CPPFLAGS"
794 CPPFLAGS="$CPPFLAGS $V_INCLS"
795 AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
796 CPPFLAGS="$savedcppflags"
797
798 #
799 # Define the old BSD specified-width types in terms of the C99 types;
800 # we may need them with libpcap include files.
801 #
802 AC_CHECK_TYPE([u_int8_t], ,
803 [AC_DEFINE([u_int8_t], [uint8_t],
804 [Define to `uint8_t' if u_int8_t not defined.])],
805 [AC_INCLUDES_DEFAULT
806 #include <sys/types.h>
807 ])
808 AC_CHECK_TYPE([u_int16_t], ,
809 [AC_DEFINE([u_int16_t], [uint16_t],
810 [Define to `uint16_t' if u_int16_t not defined.])],
811 [AC_INCLUDES_DEFAULT
812 #include <sys/types.h>
813 ])
814 AC_CHECK_TYPE([u_int32_t], ,
815 [AC_DEFINE([u_int32_t], [uint32_t],
816 [Define to `uint32_t' if u_int32_t not defined.])],
817 [AC_INCLUDES_DEFAULT
818 #include <sys/types.h>
819 ])
820 AC_CHECK_TYPE([u_int64_t], ,
821 [AC_DEFINE([u_int64_t], [uint64_t],
822 [Define to `uint64_t' if u_int64_t not defined.])],
823 [AC_INCLUDES_DEFAULT
824 #include <sys/types.h>
825 ])
826
827 #
828 # Check for some headers introduced in later versions of libpcap
829 # and used by some printers.
830 #
831 # Those headers might use the {u_}intN_t types, so we must do this
832 # after we check for what's needed to get them defined.
833 #
834 savedcppflags="$CPPFLAGS"
835 CPPFLAGS="$CPPFLAGS $V_INCLS"
836 AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"])
837 AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"])
838 CPPFLAGS="$savedcppflags"
839
840 AC_PROG_RANLIB
841 AC_CHECK_TOOL([AR], [ar])
842
843 AC_LBL_DEVEL(V_CCOPT)
844
845 # Check for OpenSSL/libressl libcrypto
846 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
847 # Specify location for both includes and libraries.
848 want_libcrypto=ifavailable
849 AC_ARG_WITH(crypto,
850 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
851 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
852 [
853 if test $withval = no
854 then
855 # User doesn't want to link with libcrypto.
856 want_libcrypto=no
857 AC_MSG_RESULT(no)
858 elif test $withval = yes
859 then
860 # User wants to link with libcrypto but hasn't specified
861 # a directory.
862 want_libcrypto=yes
863 AC_MSG_RESULT(yes)
864 else
865 # User wants to link with libcrypto and has specified
866 # a directory, so use the provided value.
867 want_libcrypto=yes
868 libcrypto_root=$withval
869 AC_MSG_RESULT([yes, using the version installed in $withval])
870
871 #
872 # Put the subdirectories of the libcrypto root directory
873 # at the front of the header and library search path.
874 #
875 CFLAGS="-I$withval/include $CFLAGS"
876 LIBS="-L$withval/lib $LIBS"
877 fi
878 ],[
879 #
880 # Use libcrypto if it's present, otherwise don't; no directory
881 # was specified.
882 #
883 want_libcrypto=ifavailable
884 AC_MSG_RESULT([yes, if available])
885 ])
886 if test "$want_libcrypto" != "no"; then
887 #
888 # Don't check for libcrypto unless we have its headers;
889 # Apple, bless their pointy little heads, apparently ship
890 # libcrypto as a library, but not the header files, in
891 # El Capitan, probably because they don't want you writing
892 # nasty portable code that could run on other UN*Xes, they
893 # want you writing code that uses their Shiny New Crypto
894 # Library and that only runs on macOS.
895 #
896 AC_CHECK_HEADER(openssl/crypto.h,
897 [
898 AC_CHECK_LIB(crypto, DES_cbc_encrypt)
899 if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
900 AC_CHECK_HEADERS(openssl/evp.h)
901 #
902 # OK, then:
903 #
904 # 1) do we have EVP_CIPHER_CTX_new?
905 # If so, we use it to allocate an
906 # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
907 # opaque; otherwise, we allocate it ourselves.
908 #
909 # 2) do we have EVP_CipherInit_ex()?
910 # If so, we use it, because we need to be
911 # able to make two "initialize the cipher"
912 # calls, one with the cipher and key, and
913 # one with the IV, and, as of OpenSSL 1.1,
914 # You Can't Do That with EVP_CipherInit(),
915 # because a call to EVP_CipherInit() will
916 # unconditionally clear the context, and
917 # if you don't supply a cipher, it'll
918 # clear the cipher, rendering the context
919 # unusable and causing a crash.
920 #
921 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_CipherInit_ex)
922 fi
923 ])
924 fi
925
926 # Check for libcap-ng
927 AC_MSG_CHECKING(whether to use libcap-ng)
928 # Specify location for both includes and libraries.
929 want_libcap_ng=ifavailable
930 AC_ARG_WITH(cap_ng,
931 AS_HELP_STRING([--with-cap-ng],
932 [use libcap-ng @<:@default=yes, if available@:>@]),
933 [
934 if test $withval = no
935 then
936 want_libcap_ng=no
937 AC_MSG_RESULT(no)
938 elif test $withval = yes
939 then
940 want_libcap_ng=yes
941 AC_MSG_RESULT(yes)
942 fi
943 ],[
944 #
945 # Use libcap-ng if it's present, otherwise don't.
946 #
947 want_libcap_ng=ifavailable
948 AC_MSG_RESULT([yes, if available])
949 ])
950 if test "$want_libcap_ng" != "no"; then
951 AC_CHECK_LIB(cap-ng, capng_change_id)
952 AC_CHECK_HEADERS(cap-ng.h)
953 fi
954
955 dnl
956 dnl set additional include path if necessary
957 if test "$missing_includes" = "yes"; then
958 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
959 V_INCLS="$V_INCLS -I$srcdir/missing"
960 fi
961
962 AC_SUBST(V_CCOPT)
963 AC_SUBST(V_DEFS)
964 AC_SUBST(V_GROUP)
965 AC_SUBST(V_INCLS)
966 AC_SUBST(V_PCAPDEP)
967 AC_SUBST(LOCALSRC)
968 AC_SUBST(MAN_FILE_FORMATS)
969 AC_SUBST(MAN_MISC_INFO)
970
971 AC_PROG_INSTALL
972
973 AC_CONFIG_HEADER(config.h)
974
975 AC_OUTPUT_COMMANDS([if test -f .devel; then
976 echo timestamp > stamp-h
977 cat Makefile-devel-adds >> Makefile
978 make depend
979 fi])
980 AC_OUTPUT(Makefile tcpdump.1)
981 exit 0