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