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