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