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