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