xref: /NextBSD/contrib/libpcap/configure.in (revision 287e3b14e9552995def1802ec9c5034f4adf28ec)
1dnl
2dnl Copyright (c) 1994, 1995, 1996, 1997
3dnl	The Regents of the University of California.  All rights reserved.
4dnl
5dnl Process this file with autoconf to produce a configure script.
6dnl
7
8#
9# See
10#
11#	http://ftp.gnu.org/gnu/config/README
12#
13# for the URLs to use to fetch new versions of config.guess and
14# config.sub.
15#
16
17AC_PREREQ(2.61)
18AC_INIT(pcap.c)
19
20AC_CANONICAL_SYSTEM
21
22AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
23AC_PROG_CC
24AC_LBL_C_INIT(V_CCOPT, V_INCLS)
25AC_LBL_SHLIBS_INIT
26AC_LBL_C_INLINE
27AC_C___ATTRIBUTE__
28if test "$ac_cv___attribute__" = "yes"; then
29	AC_C___ATTRIBUTE___UNUSED
30	AC_C___ATTRIBUTE___FORMAT
31fi
32
33AC_CHECK_HEADERS(sys/bitypes.h)
34
35AC_CHECK_TYPE([int8_t], ,
36	[AC_DEFINE([int8_t], [signed char],
37	[Define to `signed char' if int8_t not defined.])],
38	[AC_INCLUDES_DEFAULT
39#ifdef HAVE_SYS_BITYPES_H
40#include <sys/bitypes.h>
41#endif])
42AC_CHECK_TYPE([u_int8_t], ,
43	[AC_DEFINE([u_int8_t], [unsigned char],
44	[Define to `unsigned char' if u_int8_t not defined.])],
45	[AC_INCLUDES_DEFAULT
46#ifdef HAVE_SYS_BITYPES_H
47#include <sys/bitypes.h>
48#endif])
49AC_CHECK_TYPE([int16_t], ,
50	[AC_DEFINE([int16_t], [short],
51	[Define to `short' if int16_t not defined.])]
52	[AC_INCLUDES_DEFAULT
53#ifdef HAVE_SYS_BITYPES_H
54#include <sys/bitypes.h>
55#endif])
56AC_CHECK_TYPE([u_int16_t], ,
57	[AC_DEFINE([u_int16_t], [unsigned short],
58	[Define to `unsigned short' if u_int16_t not defined.])],
59	[AC_INCLUDES_DEFAULT
60#ifdef HAVE_SYS_BITYPES_H
61#include <sys/bitypes.h>
62#endif])
63AC_CHECK_TYPE([int32_t], ,
64	[AC_DEFINE([int32_t], [int],
65	[Define to `int' if int32_t not defined.])],
66	[AC_INCLUDES_DEFAULT
67#ifdef HAVE_SYS_BITYPES_H
68#include <sys/bitypes.h>
69#endif])
70AC_CHECK_TYPE([u_int32_t], ,
71	[AC_DEFINE([u_int32_t], [unsigned int],
72	[Define to `unsigned int' if u_int32_t not defined.])],
73	[AC_INCLUDES_DEFAULT
74#ifdef HAVE_SYS_BITYPES_H
75#include <sys/bitypes.h>
76#endif])
77AC_CHECK_TYPE([int64_t], ,
78	[AC_DEFINE([int64_t], [long long],
79	[Define to `long long' if int64_t not defined.])],
80	[AC_INCLUDES_DEFAULT
81#ifdef HAVE_SYS_BITYPES_H
82#include <sys/bitypes.h>
83#endif])
84AC_CHECK_TYPE([u_int64_t], ,
85	[AC_DEFINE([u_int64_t], [unsigned long long],
86	[Define to `unsigned long long' if u_int64_t not defined.])],
87	[AC_INCLUDES_DEFAULT
88#ifdef HAVE_SYS_BITYPES_H
89#include <sys/bitypes.h>
90#endif])
91
92#
93# Try to arrange for large file support.
94#
95AC_SYS_LARGEFILE
96AC_FUNC_FSEEKO
97
98dnl
99dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
100dnl include <sys/ioccom.h>, and we were to drop support for older
101dnl releases without that fix, so that pcap-bpf.c doesn't need to
102dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
103dnl in "aclocal.m4" uses it, so we would still have to test for it
104dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
105dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
106dnl
107AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
108AC_CHECK_HEADERS(linux/types.h)
109AC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h)
110AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
111#include <sys/socket.h>
112#include <net/if.h>])
113if test "$ac_cv_header_net_pfvar_h" = yes; then
114	#
115	# Check for various PF actions.
116	#
117	AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
118	AC_TRY_COMPILE(
119	    [#include <sys/types.h>
120	    #include <sys/socket.h>
121	    #include <net/if.h>
122	    #include <net/pfvar.h>],
123	    [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
124	    [
125		AC_MSG_RESULT(yes)
126		AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
127		    [define if net/pfvar.h defines PF_NAT through PF_NORDR])
128	    ],
129	    AC_MSG_RESULT(no))
130fi
131AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
132#include <sys/socket.h>])
133if test "$ac_cv_header_netinet_if_ether_h" != yes; then
134	#
135	# The simple test didn't work.
136	# Do we need to include <net/if.h> first?
137	# Unset ac_cv_header_netinet_if_ether_h so we don't
138	# treat the previous failure as a cached value and
139	# suppress the next test.
140	#
141	AC_MSG_NOTICE([Rechecking with some additional includes])
142	unset ac_cv_header_netinet_if_ether_h
143	AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
144#include <sys/socket.h>
145#include <netinet/in.h>
146struct mbuf;
147struct rtentry;
148#include <net/if.h>])
149fi
150
151AC_LBL_FIXINCLUDES
152
153AC_CHECK_FUNCS(strerror strlcpy)
154
155needsnprintf=no
156AC_CHECK_FUNCS(vsnprintf snprintf,,
157	[needsnprintf=yes])
158if test $needsnprintf = yes; then
159	AC_LIBOBJ([snprintf])
160fi
161
162#
163# Do this before checking for ether_hostton(), as it's a
164# "gethostbyname() -ish function".
165#
166AC_LBL_LIBRARY_NET
167
168#
169# You are in a twisty little maze of UN*Xes, all different.
170# Some might not have ether_hostton().
171# Some might have it, but not declare it in any header file.
172# Some might have it, but declare it in <netinet/if_ether.h>.
173# Some might have it, but declare it in <netinet/ether.h>
174# (And some might have it but document it as something declared in
175# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
176#
177# Before you is a C compiler.
178#
179AC_CHECK_FUNCS(ether_hostton)
180if test "$ac_cv_func_ether_hostton" = yes; then
181	#
182	# OK, we have ether_hostton().  Do we have <netinet/if_ether.h>?
183	#
184	if test "$ac_cv_header_netinet_if_ether_h" = yes; then
185		#
186		# Yes.  Does it declare ether_hostton()?
187		#
188		AC_CHECK_DECL(ether_hostton,
189		    [
190			AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
191			    [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
192		    ],,
193		    [
194#include <sys/types.h>
195#include <sys/socket.h>
196#include <netinet/in.h>
197#include <arpa/inet.h>
198struct mbuf;
199struct rtentry;
200#include <net/if.h>
201#include <netinet/if_ether.h>
202		    ])
203	fi
204	#
205	# Did that succeed?
206	#
207	if test "$ac_cv_have_decl_ether_hostton" != yes; then
208		#
209		# No, how about <netinet/ether.h>, as on Linux?
210		#
211		AC_CHECK_HEADERS(netinet/ether.h)
212		if test "$ac_cv_header_netinet_ether_h" = yes; then
213			#
214			# We have it - does it declare ether_hostton()?
215			# Unset ac_cv_have_decl_ether_hostton so we don't
216			# treat the previous failure as a cached value and
217			# suppress the next test.
218			#
219			unset ac_cv_have_decl_ether_hostton
220			AC_CHECK_DECL(ether_hostton,
221			    [
222				AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
223				    [Define to 1 if netinet/ether.h declares `ether_hostton'])
224			    ],,
225			    [
226#include <netinet/ether.h>
227			    ])
228		fi
229	fi
230	#
231	# Is ether_hostton() declared?
232	#
233	if test "$ac_cv_have_decl_ether_hostton" != yes; then
234		#
235		# No, we'll have to declare it ourselves.
236		# Do we have "struct ether_addr"?
237		#
238		AC_CHECK_TYPES(struct ether_addr,,,
239		    [
240#include <sys/types.h>
241#include <sys/socket.h>
242#include <netinet/in.h>
243#include <arpa/inet.h>
244struct mbuf;
245struct rtentry;
246#include <net/if.h>
247#include <netinet/if_ether.h>
248		    ])
249		AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 0,
250		    [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
251don't.])
252	else
253		AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
254		    [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
255don't.])
256	fi
257fi
258
259dnl to pacify those who hate protochain insn
260AC_MSG_CHECKING(if --disable-protochain option is specified)
261AC_ARG_ENABLE(protochain,
262AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
263case "x$enable_protochain" in
264xyes)	enable_protochain=enabled	;;
265xno)	enable_protochain=disabled	;;
266x)	enable_protochain=enabled	;;
267esac
268
269if test "$enable_protochain" = "disabled"; then
270	AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
271fi
272AC_MSG_RESULT(${enable_protochain})
273
274#
275# SITA support is mutually exclusive with native capture support;
276# "--with-sita" selects SITA support.
277#
278AC_ARG_WITH(sita,
279AC_HELP_STRING([--with-sita],[include SITA support]),
280[
281	if test ! "x$withval" = "xno" ; then
282		AC_DEFINE(SITA,1,[include ACN support])
283		AC_MSG_NOTICE(Enabling SITA ACN support)
284		V_PCAP=sita
285		V_FINDALLDEVS=sita
286	fi
287],
288[
289dnl
290dnl Not all versions of test support -c (character special) but it's a
291dnl better way of testing since the device might be protected. So we
292dnl check in our normal order using -r and then check the for the /dev
293dnl guys again using -c.
294dnl
295dnl XXX This could be done for cross-compiling, but for now it's not.
296dnl
297if test -z "$with_pcap" && test "$cross_compiling" = yes; then
298	AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...)
299fi
300AC_ARG_WITH(pcap,
301AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
302AC_MSG_CHECKING(packet capture type)
303if test ! -z "$with_pcap" ; then
304	V_PCAP="$withval"
305elif test -r /dev/bpf -o -h /dev/bpf ; then
306	#
307	# Cloning BPF device.
308	#
309	V_PCAP=bpf
310	AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
311elif test -r /dev/bpf0 ; then
312	V_PCAP=bpf
313elif test -r /usr/include/net/pfilt.h ; then
314	V_PCAP=pf
315elif test -r /dev/enet ; then
316	V_PCAP=enet
317elif test -r /dev/nit ; then
318	V_PCAP=snit
319elif test -r /usr/include/sys/net/nit.h ; then
320	V_PCAP=nit
321elif test -r /usr/include/linux/socket.h ; then
322	V_PCAP=linux
323elif test -r /usr/include/net/raw.h ; then
324	V_PCAP=snoop
325elif test -r /usr/include/odmi.h ; then
326	#
327	# On AIX, the BPF devices might not yet be present - they're
328	# created the first time libpcap runs after booting.
329	# We check for odmi.h instead.
330	#
331	V_PCAP=bpf
332elif test -c /dev/bpf0 ; then		# check again in case not readable
333	V_PCAP=bpf
334elif test -r /usr/include/sys/dlpi.h ; then
335	V_PCAP=dlpi
336elif test -c /dev/enet ; then		# check again in case not readable
337	V_PCAP=enet
338elif test -c /dev/nit ; then		# check again in case not readable
339	V_PCAP=snit
340else
341	V_PCAP=null
342fi
343AC_MSG_RESULT($V_PCAP)
344
345#
346# Do capture-mechanism-dependent tests.
347#
348case "$V_PCAP" in
349dlpi)
350	#
351	# Needed for common functions used by pcap-[dlpi,libdlpi].c
352	#
353 	SSRC="dlpisubs.c"
354
355	#
356	# Checks for some header files.
357	#
358	AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
359
360	#
361	# Checks to see if Solaris has the public libdlpi(3LIB) library.
362	# Note: The existence of /usr/include/libdlpi.h does not mean it is the
363	# public libdlpi(3LIB) version. Before libdlpi was made public, a
364	# private version also existed, which did not have the same APIs.
365	# Due to a gcc bug, the default search path for 32-bit libraries does
366	# not include /lib, we add it explicitly here.
367	# [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
368	# Also, due to the bug above applications that link to libpcap with
369	# libdlpi will have to add "-L/lib" option to "configure".
370	#
371	saved_ldflags=$LDFLAGS
372	LDFLAGS="$LIBS -L/lib"
373	AC_CHECK_LIB(dlpi, dlpi_walk,
374		[
375			LIBS="-ldlpi $LIBS"
376			V_PCAP=libdlpi
377			AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
378		],
379		V_PCAP=dlpi)
380	LDFLAGS=$saved_ldflags
381
382	#
383	# Checks whether <sys/dlpi.h> is usable, to catch weird SCO
384	# versions of DLPI.
385	#
386	AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
387	AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
388		AC_TRY_COMPILE(
389		    [
390			#include <sys/types.h>
391			#include <sys/time.h>
392			#include <sys/dlpi.h>
393		    ],
394		    [int i = DL_PROMISC_PHYS;],
395		    ac_cv_sys_dlpi_usable=yes,
396		    ac_cv_sys_dlpi_usable=no))
397	AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
398	if test $ac_cv_sys_dlpi_usable = no ; then
399		AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
400	fi
401
402	#
403	# Check whether we have a /dev/dlpi device or have multiple devices.
404	#
405	AC_MSG_CHECKING(for /dev/dlpi device)
406	if test -c /dev/dlpi ; then
407		AC_MSG_RESULT(yes)
408		AC_DEFINE(HAVE_DEV_DLPI, 1, [define if you have a /dev/dlpi])
409	else
410		AC_MSG_RESULT(no)
411		dir="/dev/dlpi"
412		AC_MSG_CHECKING(for $dir directory)
413		if test -d $dir ; then
414			AC_MSG_RESULT(yes)
415			AC_DEFINE_UNQUOTED(PCAP_DEV_PREFIX, "$dir", [/dev/dlpi directory])
416		else
417			AC_MSG_RESULT(no)
418		fi
419	fi
420
421	#
422	# This check is for Solaris with DLPI support for passive modes.
423	# See dlpi(7P) for more details.
424	#
425	AC_LBL_DL_PASSIVE_REQ_T
426	;;
427
428linux)
429	#
430	# Do we have the wireless extensions?
431	#
432	AC_CHECK_HEADERS(linux/wireless.h, [], [],
433	[
434#include <sys/socket.h>
435#include <linux/if.h>
436#include <linux/types.h>
437	])
438
439	#
440	# Do we have libnl?
441	#
442	AC_ARG_WITH(libnl,
443	AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
444		with_libnl=$withval,,)
445
446	if test x$with_libnl != xno ; then
447		have_any_nl="no"
448
449		#
450		# Try libnl 3.x first.
451		#
452		AC_CHECK_LIB(nl-3, nl_socket_alloc,
453		[
454			#
455			# Yes, we have libnl 3.x.
456			#
457			LIBS="-lnl-genl-3 -lnl-3 $LIBS"
458			AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
459			AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
460			AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
461			AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
462			V_INCLS="$V_INCLS -I/usr/include/libnl3"
463			have_any_nl="yes"
464		])
465
466		if test x$have_any_nl = xno ; then
467			#
468			# Try libnl 2.x
469			#
470			AC_CHECK_LIB(nl, nl_socket_alloc,
471			[
472				#
473				# Yes, we have libnl 2.x.
474				#
475				LIBS="-lnl-genl -lnl $LIBS"
476				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
477				AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
478				AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
479				AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
480				have_any_nl="yes"
481			])
482		fi
483
484		if test x$have_any_nl = xno ; then
485			#
486			# No, we don't; do we have libnl 1.x?
487			#
488			AC_CHECK_LIB(nl, nl_handle_alloc,
489			[
490				#
491				# Yes.
492				#
493				LIBS="-lnl $LIBS"
494				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
495				have_any_nl="yes"
496			])
497		fi
498
499		if test x$have_any_nl = xno ; then
500			#
501			# No, we don't have libnl at all.
502			#
503			if test x$with_libnl = xyes ; then
504				AC_MSG_ERROR([libnl support requested but libnl not found])
505			fi
506		fi
507	fi
508
509	AC_CHECK_HEADERS(linux/ethtool.h,,,
510	    [
511AC_INCLUDES_DEFAULT
512#include <linux/types.h>
513	    ])
514	AC_LBL_TPACKET_STATS
515	AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
516	;;
517
518bpf)
519	#
520	# Check whether we have the *BSD-style ioctls.
521	#
522	AC_CHECK_HEADERS(net/if_media.h)
523
524	AC_MSG_CHECKING(whether the system supports zerocopy BPF)
525	AC_TRY_COMPILE(
526	    [#include <sys/socket.h>
527	    #include <sys/ioctl.h>
528	    #include <net/if.h>
529	    #include <net/bpf.h>],
530	    [return (BIOCROTZBUF + BPF_BUFMODE_ZBUF);],
531	    [
532		AC_MSG_RESULT(yes)
533		AC_DEFINE(HAVE_ZEROCOPY_BPF, 1,
534		[define if the system supports zerocopy BPF])
535	    ],
536	    AC_MSG_RESULT(no))
537
538	    #
539	    # Check whether we have struct BPF_TIMEVAL.
540	    #
541	    AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
542		[
543#include <sys/types.h>
544#include <sys/ioctl.h>
545#ifdef HAVE_SYS_IOCCOM_H
546#include <sys/ioccom.h>
547#endif
548#include <net/bpf.h>
549		    ])
550	;;
551
552dag)
553	V_DEFS="$V_DEFS -DDAG_ONLY"
554	;;
555
556septel)
557	V_DEFS="$V_DEFS -DSEPTEL_ONLY"
558	;;
559
560snf)
561	V_DEFS="$V_DEFS -DSNF_ONLY"
562	;;
563
564null)
565	AC_MSG_WARN(cannot determine packet capture interface)
566	AC_MSG_WARN((see the INSTALL doc for more info))
567	;;
568esac
569
570dnl
571dnl Now figure out how we get a list of interfaces and addresses,
572dnl if we support capturing.  Don't bother if we don't support
573dnl capturing.
574dnl
575if test "$V_PCAP" = null
576then
577	#
578	# We can't capture, so we can't open any capture
579	# devices, so we won't return any interfaces.
580	#
581	V_FINDALLDEVS=null
582else
583	AC_CHECK_FUNC(getifaddrs,[
584		#
585		# We have "getifaddrs()"; make sure we have <ifaddrs.h>
586		# as well, just in case some platform is really weird.
587		#
588		AC_CHECK_HEADER(ifaddrs.h,[
589		    #
590		    # We have the header, so we use "getifaddrs()" to
591		    # get the list of interfaces.
592		    #
593		    V_FINDALLDEVS=getad
594		],[
595		    #
596		    # We don't have the header - give up.
597		    # XXX - we could also fall back on some other
598		    # mechanism, but, for now, this'll catch this
599		    # problem so that we can at least try to figure
600		    # out something to do on systems with "getifaddrs()"
601		    # but without "ifaddrs.h", if there is something
602		    # we can do on those systems.
603		    #
604		    AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
605		])
606	],[
607		#
608		# Well, we don't have "getifaddrs()", so we have to use
609		# some other mechanism; determine what that mechanism is.
610		#
611		# The first thing we use is the type of capture mechanism,
612		# which is somewhat of a proxy for the OS we're using.
613		#
614		case "$V_PCAP" in
615
616		dlpi|libdlpi)
617			#
618			# This might be Solaris 8 or later, with
619			# SIOCGLIFCONF, or it might be some other OS
620			# or some older version of Solaris, with
621			# just SIOCGIFCONF.
622			#
623			AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
624			AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
625			    AC_TRY_COMPILE(
626				[#include <sys/param.h>
627				#include <sys/file.h>
628				#include <sys/ioctl.h>
629				#include <sys/socket.h>
630				#include <sys/sockio.h>],
631				[ioctl(0, SIOCGLIFCONF, (char *)0);],
632				ac_cv_lbl_have_siocglifconf=yes,
633				ac_cv_lbl_have_siocglifconf=no))
634			AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
635			if test $ac_cv_lbl_have_siocglifconf = yes ; then
636				V_FINDALLDEVS=glifc
637			else
638				V_FINDALLDEVS=gifc
639			fi
640			;;
641
642		*)
643			#
644			# Assume we just have SIOCGIFCONF.
645			# (XXX - on at least later Linux kernels, there's
646			# another mechanism, and we should be using that
647			# instead.)
648			#
649			V_FINDALLDEVS=gifc
650			;;
651		esac])
652fi
653])
654
655AC_MSG_CHECKING(for socklen_t)
656AC_TRY_COMPILE([
657	#include <sys/types.h>
658	#include <sys/socket.h>
659	],
660	[ socklen_t x; ],
661	have_socklen_t=yes,
662	have_socklen_t=no)
663if test "x$have_socklen_t" = "xyes"; then
664	AC_DEFINE(HAVE_SOCKLEN_T, 1, [define if socklen_t is defined])
665fi
666AC_MSG_RESULT($have_socklen_t)
667
668AC_ARG_ENABLE(ipv6,
669AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@]),
670    [],
671    [enable_ipv6=ifavailable])
672if test "$enable_ipv6" != "no"; then
673	AC_CHECK_FUNC(getaddrinfo,
674	    [
675		AC_DEFINE(INET6,1,[IPv6])
676	    ],
677	    [
678		if test "$enable_ipv6" != "ifavailable"; then
679			AC_MSG_FAILURE([--enable-ipv6 was given, but getaddrinfo isn't available])
680		fi
681	    ])
682fi
683
684AC_MSG_CHECKING(whether to build optimizer debugging code)
685AC_ARG_ENABLE(optimizer-dbg,
686AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
687if test "$enable_optimizer_dbg" = "yes"; then
688	AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
689fi
690AC_MSG_RESULT(${enable_optimizer_dbg-no})
691
692AC_MSG_CHECKING(whether to build parser debugging code)
693AC_ARG_ENABLE(yydebug,
694AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
695if test "$enable_yydebug" = "yes"; then
696	AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
697fi
698AC_MSG_RESULT(${enable_yydebug-no})
699
700# Check for Endace DAG card support.
701AC_ARG_WITH([dag],
702AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
703[
704	if test "$withval" = no
705	then
706		# User doesn't want DAG support.
707		want_dag=no
708	elif test "$withval" = yes
709	then
710		# User wants DAG support but hasn't specified a directory.
711		want_dag=yes
712	else
713		# User wants DAG support and has specified a directory, so use the provided value.
714		want_dag=yes
715		dag_root=$withval
716	fi
717],[
718	#
719	# Use DAG API if present, otherwise don't
720	#
721	want_dag=ifpresent
722])
723
724AC_ARG_WITH([dag-includes],
725AC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
726[
727	# User wants DAG support and has specified a header directory, so use the provided value.
728	want_dag=yes
729	dag_include_dir=$withval
730],[])
731
732AC_ARG_WITH([dag-libraries],
733AC_HELP_STRING([--with-dag-libraries=DIR],[Endace DAG library directory]),
734[
735	# User wants DAG support and has specified a library directory, so use the provided value.
736	want_dag=yes
737	dag_lib_dir=$withval
738],[])
739
740case "$V_PCAP" in
741linux|bpf|dag)
742	#
743	# We support the DAG API if we're on Linux or BSD, or if we're
744	# building a DAG-only libpcap.
745	#
746	;;
747*)
748	#
749	# If the user explicitly requested DAG, tell them it's not
750	# supported.
751	#
752	# If they expressed no preference, don't include it.
753	#
754	if test $want_dag = yes; then
755		AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types])
756	elif test $want_dag = yes; then
757		want_dag=no
758	fi
759	;;
760esac
761
762ac_cv_lbl_dag_api=no
763if test "$want_dag" != no; then
764
765	AC_MSG_CHECKING([whether we have DAG API headers])
766
767	# If necessary, set default paths for DAG API headers and libraries.
768	if test -z "$dag_root"; then
769	    dag_root=/usr/local
770	fi
771
772	if test -z "$dag_include_dir"; then
773		dag_include_dir="$dag_root/include"
774	fi
775
776	if test -z "$dag_lib_dir"; then
777	    dag_lib_dir="$dag_root/lib"
778	fi
779
780	if test -z "$dag_tools_dir"; then
781	    dag_tools_dir="$dag_root/tools"
782	fi
783
784	if test -r $dag_include_dir/dagapi.h; then
785		ac_cv_lbl_dag_api=yes
786	fi
787	AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
788fi
789
790if test $ac_cv_lbl_dag_api = yes; then
791	V_INCLS="$V_INCLS -I$dag_include_dir"
792
793	if test $V_PCAP != dag ; then
794		 SSRC="pcap-dag.c"
795	fi
796
797	# See if we can find a general version string.
798	# Don't need to save and restore LIBS to prevent -ldag being
799	# included if there's a found-action (arg 3).
800	saved_ldflags=$LDFLAGS
801	LDFLAGS="-L$dag_lib_dir"
802	AC_CHECK_LIB([dag], [dag_attach_stream], [dag_streams="1"], [dag_streams="0"])
803	AC_CHECK_LIB([dag],[dag_get_erf_types], [
804		AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
805	AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
806		AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
807
808	LDFLAGS=$saved_ldflags
809
810	if test "$dag_streams" = 1; then
811		AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
812		LIBS="$LIBS -ldag"
813		LDFLAGS="$LDFLAGS -L$dag_lib_dir"
814
815		AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
816		if test "$ac_dag_have_vdag" = 1; then
817			AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
818			LIBS="$LIBS -lpthread"
819		fi
820	fi
821
822	AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
823fi
824
825AC_MSG_CHECKING(whether we have the DAG API)
826
827if test $ac_cv_lbl_dag_api = no; then
828	AC_MSG_RESULT(no)
829	if test "$want_dag" = yes; then
830        	# User wanted DAG support but we couldn't find it.
831		AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag])
832	fi
833
834	if test "$V_PCAP" = dag; then
835		# User requested "dag" capture type but the DAG API wasn't
836		# found.
837		AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)])
838	fi
839else
840	AC_MSG_RESULT(yes)
841fi
842
843AC_ARG_WITH(septel,
844AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied).  @<:@default=yes, on Linux, if present@:>@]),
845[
846	if test "$withval" = no
847	then
848		want_septel=no
849	elif test "$withval" = yes
850	then
851		want_septel=yes
852		septel_root=
853	else
854		want_septel=yes
855		septel_root=$withval
856	fi
857],[
858	#
859	# Use Septel API if present, otherwise don't
860	#
861	want_septel=ifpresent
862	septel_root=./../septel
863])
864ac_cv_lbl_septel_api=no
865case "$V_PCAP" in
866linux|septel)
867	#
868	# We support the Septel API if we're on Linux, or if we're building
869	# a Septel-only libpcap.
870	#
871	;;
872*)
873	#
874	# If the user explicitly requested Septel, tell them it's not
875	# supported.
876	#
877	# If they expressed no preference, don't include it.
878	#
879	if test $want_septel = yes; then
880		AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types)
881	elif test $want_septel = yes; then
882		want_septel=no
883	fi
884	;;
885esac
886
887if test "$with_septel" != no; then
888	AC_MSG_CHECKING(whether we have Septel API)
889
890	if test -z "$septel_root"; then
891		septel_root=$srcdir/../septel
892	fi
893
894	septel_tools_dir="$septel_root"
895	septel_include_dir="$septel_root/INC"
896
897	ac_cv_lbl_septel_api=no
898	if test -r "$septel_include_dir/msg.h"; then
899		V_INCLS="$V_INCLS -I$septel_include_dir"
900		ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
901		ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
902
903		if test "$V_PCAP" != septel ; then
904			 SSRC="pcap-septel.c"
905		fi
906		ac_cv_lbl_septel_api=yes
907	fi
908
909	AC_MSG_RESULT($ac_cv_lbl_septel_api)
910	if test $ac_cv_lbl_septel_api = no; then
911		if test "$want_septel" = yes; then
912			AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel)
913		fi
914	else
915		AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API])
916	fi
917fi
918
919if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
920	AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
921fi
922
923# Check for Myricom SNF support.
924AC_ARG_WITH([snf],
925AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
926[
927	if test "$withval" = no
928	then
929		# User explicitly doesn't want SNF
930		want_snf=no
931	elif test "$withval" = yes
932	then
933		# User wants SNF support but hasn't specific a directory.
934		want_snf=yes
935	else
936		# User wants SNF support with a specified directory.
937		want_snf=yes
938		snf_root=$withval
939	fi
940],[
941	#
942	# Use Sniffer API if present, otherwise don't
943	#
944	want_snf=ifpresent
945])
946
947AC_ARG_WITH([snf-includes],
948AC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
949[
950	# User wants SNF with specific header directory
951	want_snf=yes
952	snf_include_dir=$withval
953],[])
954
955AC_ARG_WITH([snf-libraries],
956AC_HELP_STRING([--with-snf-libraries=DIR],[Myricom SNF library directory]),
957[
958	# User wants SNF with specific lib directory
959	want_snf=yes
960	snf_lib_dir=$withval
961],[])
962
963case "$V_PCAP" in
964bpf|linux|snf)
965	#
966	# We support the Sniffer API if we're on BSD, Linux, or if we're
967	# building a Sniffer-only libpcap.
968	#
969	;;
970*)
971	#
972	# If the user explicitly requested Sniffer, tell them it's not
973	# supported.
974	#
975	# If they expressed no preference, don't include it.
976	#
977	if test $want_snf = yes; then
978		AC_MSG_ERROR(Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types)
979	elif test $want_snf = yes; then
980		want_snf=no
981	fi
982	;;
983esac
984
985ac_cv_lbl_snf_api=no
986if test "$with_snf" != no; then
987
988	AC_MSG_CHECKING(whether we have Myricom Sniffer API)
989
990	if test -z "$snf_root"; then
991		snf_root=/opt/snf
992	fi
993
994	if test -z "$snf_include_dir"; then
995		snf_include_dir="$snf_root/include"
996	fi
997
998	if test -z "$snf_lib_dir"; then
999		snf_lib_dir="$snf_root/lib"
1000	fi
1001
1002	if test -f "$snf_include_dir/snf.h"; then
1003		ac_cv_lbl_snf_api=yes
1004	fi
1005	AC_MSG_RESULT([$ac_cv_lbl_snf_api ($snf_root)])
1006
1007	if test $ac_cv_lbl_snf_api = no; then
1008		if test "$want_snf" = yes; then
1009			AC_MSG_ERROR(SNF API headers not found under $snf_include_dir; use --without-snf)
1010		fi
1011	else
1012		saved_ldflags=$LDFLAGS
1013		LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1014		AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"], [ac_cv_lbl_snf_api="no"])
1015		LDFLAGS="$saved_ldflags"
1016
1017		if test $ac_cv_lbl_snf_api = no; then
1018			if test "$want_snf" = yes; then
1019				AC_MSG_ERROR(SNF API cannot correctly be linked check config.log; use --without-snf)
1020			fi
1021		else
1022			V_INCLS="$V_INCLS -I$snf_include_dir"
1023			LIBS="$LIBS -lsnf"
1024			LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1025			if test "$V_PCAP" != snf ; then
1026				SSRC="pcap-snf.c"
1027			fi
1028			AC_DEFINE(HAVE_SNF_API, 1, [define if you have Myricom SNF API])
1029		fi
1030	fi
1031fi
1032
1033if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
1034	AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR)
1035fi
1036
1037AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
1038if test "$V_LEX" = lex ; then
1039# Some versions of lex can't handle the definitions section of scanner.l .
1040# Try lexing it and complain if it can't deal.
1041	AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1042		if lex -t scanner.l > /dev/null 2>&1; then
1043			tcpdump_cv_capable_lex=yes
1044		else
1045			tcpdump_cv_capable_lex=insufficient
1046		fi)
1047	if test $tcpdump_cv_capable_lex = insufficient ; then
1048		AC_MSG_ERROR([Your operating system's lex is insufficient to compile
1049 libpcap.  flex is a lex replacement that has many advantages, including
1050 being able to compile libpcap.  For more information, see
1051 http://www.gnu.org/software/flex/flex.html .])
1052	fi
1053fi
1054
1055#
1056# Assume, by default, no support for shared libraries and V7/BSD convention
1057# for man pages (file formats in section 5, miscellaneous info in section 7).
1058# Individual cases can override this.
1059#
1060DYEXT="none"
1061MAN_FILE_FORMATS=5
1062MAN_MISC_INFO=7
1063case "$host_os" in
1064
1065aix*)
1066	dnl Workaround to enable certain features
1067	AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1068
1069	#
1070	# AIX makes it fun to build shared and static libraries,
1071	# because they're *both* ".a" archive libraries.  We
1072	# build the static library for the benefit of the traditional
1073	# scheme of building libpcap and tcpdump in subdirectories of
1074	# the same directory, with tcpdump statically linked with the
1075	# libpcap in question, but we also build a shared library as
1076	# "libpcap.shareda" and install *it*, rather than the static
1077	# library, as "libpcap.a".
1078	#
1079	DYEXT="shareda"
1080
1081	case "$V_PCAP" in
1082
1083	dlpi)
1084		#
1085		# If we're using DLPI, applications will need to
1086		# use /lib/pse.exp if present, as we use the
1087		# STREAMS routines.
1088		#
1089		pseexe="/lib/pse.exp"
1090		AC_MSG_CHECKING(for $pseexe)
1091		if test -f $pseexe ; then
1092			AC_MSG_RESULT(yes)
1093			LIBS="-I:$pseexe"
1094		fi
1095		;;
1096
1097	bpf)
1098		#
1099		# If we're using BPF, we need "-lodm" and "-lcfg", as
1100		# we use them to load the BPF module.
1101		#
1102		LIBS="-lodm -lcfg"
1103		;;
1104	esac
1105	;;
1106
1107darwin*)
1108	DYEXT="dylib"
1109	V_CCOPT="$V_CCOPT -fno-common"
1110	AC_ARG_ENABLE(universal,
1111	AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
1112	if test "$enable_universal" != "no"; then
1113		case "$host_os" in
1114
1115		darwin[0-7].*)
1116			#
1117			# Pre-Tiger.  Build only for 32-bit PowerPC; no
1118			# need for any special compiler or linker flags.
1119			#
1120			;;
1121
1122		darwin8.[0123]*)
1123			#
1124			# Tiger, prior to Intel support.  Build for 32-bit
1125			# PowerPC and 64-bit PowerPC, with 32-bit PowerPC
1126			# first.  (I'm guessing that's what Apple does.)
1127			#
1128			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
1129			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
1130			;;
1131
1132		darwin8.[456]*)
1133			#
1134			# Tiger, subsequent to Intel support but prior to
1135			# x86-64 support.  Build for 32-bit PowerPC, 64-bit
1136			# PowerPC, and x86, with 32-bit PowerPC first.
1137			# (I'm guessing that's what Apple does.)
1138			#
1139			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
1140			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
1141			;;
1142
1143		darwin8.*)
1144			#
1145			# All other Tiger, so subsequent to x86-64
1146			# support. Build for 32-bit PowerPC, 64-bit
1147			# PowerPC, x86, and x86-64, and with 32-bit PowerPC
1148			# first.  (I'm guessing that's what Apple does.)
1149			#
1150			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1151			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1152			;;
1153
1154		darwin9.*)
1155			#
1156			# Leopard.  Build for 32-bit PowerPC, 64-bit
1157			# PowerPC, x86, and x86-64, with 32-bit PowerPC
1158			# first.  (That's what Apple does.)
1159			#
1160			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1161			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1162			;;
1163
1164		darwin10.*)
1165			#
1166			# Snow Leopard.  Build for x86-64, x86, and
1167			# 32-bit PowerPC, with x86-64 first.  (That's
1168			# what Apple does, even though Snow Leopard
1169			# doesn't run on PPC, so PPC libpcap runs under
1170			# Rosetta, and Rosetta doesn't support BPF
1171			# ioctls, so PPC programs can't do live
1172			# captures.)
1173			#
1174			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
1175			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
1176			;;
1177
1178		darwin*)
1179			#
1180			# Post-Snow Leopard.  Build for x86-64 and
1181			# x86, with x86-64 first.  (That's probably what
1182			# Apple does, given that Rosetta is gone.)
1183			# XXX - update if and when Apple drops support
1184			# for 32-bit x86 code.
1185			#
1186			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
1187			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
1188			;;
1189		esac
1190	fi
1191	;;
1192
1193hpux9*)
1194	AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1195
1196	#
1197	# Use System V conventions for man pages.
1198	#
1199	MAN_FILE_FORMATS=4
1200	MAN_MISC_INFO=5
1201	;;
1202
1203hpux10.0*)
1204
1205	#
1206	# Use System V conventions for man pages.
1207	#
1208	MAN_FILE_FORMATS=4
1209	MAN_MISC_INFO=5
1210	;;
1211
1212hpux10.1*)
1213
1214	#
1215	# Use System V conventions for man pages.
1216	#
1217	MAN_FILE_FORMATS=4
1218	MAN_MISC_INFO=5
1219	;;
1220
1221hpux*)
1222	dnl HPUX 10.20 and above is similar to HPUX 9, but
1223	dnl not the same....
1224	dnl
1225	dnl XXX - DYEXT should be set to "sl" if this is building
1226	dnl for 32-bit PA-RISC, but should be left as "so" for
1227	dnl 64-bit PA-RISC or, I suspect, IA-64.
1228	AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1229	if test "`uname -m`" = "ia64"; then
1230		DYEXT="so"
1231	else
1232		DYEXT="sl"
1233	fi
1234
1235	#
1236	# "-b" builds a shared library; "+h" sets the soname.
1237	#
1238	SHLIB_OPT="-b"
1239	SONAME_OPT="+h"
1240
1241	#
1242	# Use System V conventions for man pages.
1243	#
1244	MAN_FILE_FORMATS=4
1245	MAN_MISC_INFO=5
1246	;;
1247
1248irix*)
1249	#
1250	# Use System V conventions for man pages.
1251	#
1252	MAN_FILE_FORMATS=4
1253	MAN_MISC_INFO=5
1254	;;
1255
1256linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
1257	DYEXT="so"
1258
1259	#
1260	# Compiler assumed to be GCC; run-time linker may require a -R
1261	# flag.
1262	#
1263	if test "$libdir" != "/usr/lib"; then
1264		V_RFLAGS=-Wl,-R$libdir
1265	fi
1266	;;
1267
1268osf*)
1269	DYEXT="so"
1270
1271	#
1272	# Use System V conventions for man pages.
1273	#
1274	MAN_FILE_FORMATS=4
1275	MAN_MISC_INFO=5
1276	;;
1277
1278sinix*)
1279	AC_MSG_CHECKING(if SINIX compiler defines sinix)
1280	AC_CACHE_VAL(ac_cv_cc_sinix_defined,
1281		AC_TRY_COMPILE(
1282		    [],
1283		    [int i = sinix;],
1284		    ac_cv_cc_sinix_defined=yes,
1285		    ac_cv_cc_sinix_defined=no))
1286	    AC_MSG_RESULT($ac_cv_cc_sinix_defined)
1287	    if test $ac_cv_cc_sinix_defined = no ; then
1288		    AC_DEFINE(sinix,1,[on sinix])
1289	    fi
1290	;;
1291
1292solaris*)
1293	AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1294
1295	DYEXT="so"
1296	#
1297	# Use System V conventions for man pages.
1298	#
1299	MAN_FILE_FORMATS=4
1300	MAN_MISC_INFO=5
1301	;;
1302esac
1303
1304AC_ARG_ENABLE(shared,
1305AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1306test "x$enable_shared" = "xno" && DYEXT="none"
1307
1308AC_PROG_RANLIB
1309AC_CHECK_TOOL([AR], [ar])
1310
1311AC_PROG_LN_S
1312AC_SUBST(LN_S)
1313
1314AC_LBL_DEVEL(V_CCOPT)
1315
1316AC_LBL_SOCKADDR_SA_LEN
1317
1318AC_LBL_SOCKADDR_STORAGE
1319
1320AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
1321
1322AC_LBL_UNALIGNED_ACCESS
1323
1324#
1325# Makefile.in includes rules to generate version.h, so we assume
1326# that it will be generated if autoconf is used.
1327#
1328AC_DEFINE(HAVE_VERSION_H, 1, [define if version.h is generated in the build procedure])
1329
1330rm -f net
1331ln -s ${srcdir}/bpf/net net
1332
1333AC_SUBST(V_CCOPT)
1334AC_SUBST(V_DEFS)
1335AC_SUBST(V_FINDALLDEVS)
1336AC_SUBST(V_INCLS)
1337AC_SUBST(V_LEX)
1338AC_SUBST(V_PCAP)
1339AC_SUBST(V_SHLIB_CMD)
1340AC_SUBST(V_SHLIB_OPT)
1341AC_SUBST(V_SONAME_OPT)
1342AC_SUBST(V_RPATH_OPT)
1343AC_SUBST(V_YACC)
1344AC_SUBST(ADDLOBJS)
1345AC_SUBST(ADDLARCHIVEOBJS)
1346AC_SUBST(SSRC)
1347AC_SUBST(DYEXT)
1348AC_SUBST(MAN_FILE_FORMATS)
1349AC_SUBST(MAN_MISC_INFO)
1350
1351dnl check for USB sniffing support
1352AC_MSG_CHECKING(for USB sniffing support)
1353case "$host_os" in
1354linux*)
1355	AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1356	USB_SRC=pcap-usb-linux.c
1357	AC_MSG_RESULT(yes)
1358	ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1359	if test $? -ne 0 ; then
1360	  ac_usb_dev_name="usbmon"
1361	fi
1362	AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1363	AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1364	#
1365	# Do we have a version of <linux/compiler.h> available?
1366	# If so, we might need it for <linux/usbdevice_fs.h>.
1367	#
1368	AC_CHECK_HEADERS(linux/compiler.h)
1369	if test "$ac_cv_header_linux_compiler_h" = yes; then
1370	  #
1371	  # Yes - include it when testing for <linux/usbdevice_fs.h>.
1372	  #
1373	  AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
1374	else
1375	  AC_CHECK_HEADERS(linux/usbdevice_fs.h)
1376	fi
1377	if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
1378	  #
1379	  # OK, does it define bRequestType?  Older versions of the kernel
1380	  # define fields with names like "requesttype, "request", and
1381	  # "value", rather than "bRequestType", "bRequest", and
1382	  # "wValue".
1383	  #
1384	  AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member)
1385	  AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType,
1386	    AC_TRY_COMPILE([
1387AC_INCLUDES_DEFAULT
1388#ifdef HAVE_SYS_BITYPES_H
1389#include <sys/bitypes.h>
1390#endif
1391#ifdef HAVE_LINUX_COMPILER_H
1392#include <linux/compiler.h>
1393#endif
1394#include <linux/usbdevice_fs.h>],
1395	      [u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)],
1396	      ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes,
1397	      ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no))
1398	    AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType)
1399	    if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then
1400	      AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1,
1401	        [if struct usbdevfs_ctrltransfer has bRequestType])
1402	    fi
1403	fi
1404	;;
1405*)
1406	AC_MSG_RESULT(no)
1407	;;
1408esac
1409AC_SUBST(PCAP_SUPPORT_USB)
1410AC_SUBST(USB_SRC)
1411
1412dnl check for netfilter sniffing support
1413AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
1414case "$host_os" in
1415linux*)
1416	AC_MSG_RESULT(yes)
1417	#
1418	# Life's too short to deal with trying to get this to compile
1419	# if you don't get the right types defined with
1420	# __KERNEL_STRICT_NAMES getting defined by some other include.
1421	#
1422	# Check whether the includes Just Work.  If not, don't turn on
1423	# netfilter support.
1424	#
1425	AC_MSG_CHECKING(whether we can compile the netfilter support)
1426	AC_CACHE_VAL(ac_cv_netfilter_can_compile,
1427	  AC_TRY_COMPILE([
1428AC_INCLUDES_DEFAULT
1429#include <sys/socket.h>
1430#include <netinet/in.h>
1431#include <linux/types.h>
1432
1433#include <linux/netlink.h>
1434#include <linux/netfilter.h>
1435#include <linux/netfilter/nfnetlink.h>
1436#include <linux/netfilter/nfnetlink_log.h>
1437#include <linux/netfilter/nfnetlink_queue.h>],
1438	    [],
1439	    ac_cv_netfilter_can_compile=yes,
1440	    ac_cv_netfilter_can_compile=no))
1441	AC_MSG_RESULT($ac_cv_netfilter_can_compile)
1442	if test $ac_cv_netfilter_can_compile = yes ; then
1443	  AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
1444	    [target host supports netfilter sniffing])
1445	  NETFILTER_SRC=pcap-netfilter-linux.c
1446	fi
1447	;;
1448*)
1449	AC_MSG_RESULT(no)
1450	;;
1451esac
1452AC_SUBST(PCAP_SUPPORT_NETFILTER)
1453AC_SUBST(NETFILTER_SRC)
1454
1455AC_ARG_ENABLE([bluetooth],
1456[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
1457    [],
1458    [enable_bluetooth=ifsupportavailable])
1459
1460if test "x$enable_bluetooth" != "xno" ; then
1461	dnl check for Bluetooth sniffing support
1462	case "$host_os" in
1463	linux*)
1464		AC_CHECK_HEADER(bluetooth/bluetooth.h,
1465		[
1466		  AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
1467		  BT_SRC=pcap-bt-linux.c
1468		  AC_MSG_NOTICE(Bluetooth sniffing is supported)
1469
1470		  #
1471		  # OK, does struct sockaddr_hci have an hci_channel
1472		  # member?
1473		  #
1474		  AC_MSG_CHECKING(if struct sockaddr_hci has hci_channel member)
1475		  AC_CACHE_VAL(ac_cv_lbl_sockaddr_hci_has_hci_channel,
1476		    AC_TRY_COMPILE(
1477[
1478#include <bluetooth/bluetooth.h>
1479#include <bluetooth/hci.h>
1480],
1481		      [u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel)],
1482		      ac_cv_lbl_sockaddr_hci_has_hci_channel=yes,
1483		      ac_cv_lbl_sockaddr_hci_has_hci_channel=no))
1484		    AC_MSG_RESULT($ac_cv_lbl_sockaddr_hci_has_hci_channel)
1485		    if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then
1486		      AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,,
1487			[if struct sockaddr_hci has hci_channel member])
1488
1489		      #
1490		      # OK, is HCI_CHANNEL_MONITOR defined?
1491		      #
1492		      AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
1493		      AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
1494		      AC_TRY_COMPILE(
1495[
1496#include <bluetooth/bluetooth.h>
1497#include <bluetooth/hci.h>
1498],
1499			[u_int i = HCI_CHANNEL_MONITOR],
1500			ac_cv_lbl_hci_channel_monitor_is_defined=yes,
1501			ac_cv_lbl_hci_channel_monitor_is_defined=no))
1502		      AC_MSG_RESULT($ac_cv_lbl_hci_channel_monitor_is_defined)
1503		      if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then
1504			AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
1505			  [target host supports Bluetooth Monitor])
1506			BT_MONITOR_SRC=pcap-bt-monitor-linux.c
1507		      fi
1508		    fi
1509		    ac_lbl_bluetooth_available=yes
1510		],
1511		ac_lbl_bluetooth_available=no
1512		)
1513		if test "x$ac_lbl_bluetooth_available" == "xno" ; then
1514		    if test "x$enable_bluetooth" = "xyes" ; then
1515			AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1516		    else
1517			AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1518		    fi
1519		fi
1520		;;
1521	*)
1522		if test "x$enable_bluetooth" = "xyes" ; then
1523		    AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
1524		else
1525		    AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
1526		fi
1527		;;
1528	esac
1529	AC_SUBST(PCAP_SUPPORT_BT)
1530	AC_SUBST(BT_SRC)
1531	AC_SUBST(BT_MONITOR_SRC)
1532fi
1533
1534AC_ARG_ENABLE([canusb],
1535[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])],
1536    [],
1537    [enable_canusb=ifsupportavailable])
1538
1539if test "x$enable_canusb" != "xno" ; then
1540	dnl check for canusb support
1541	case "$host_os" in
1542	linux*)
1543		AC_CHECK_HEADER(libusb-1.0/libusb.h,
1544		[
1545		    AC_CHECK_LIB(usb-1.0, libusb_init,
1546		    [
1547			AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb])
1548			CANUSB_SRC=pcap-canusb-linux.c
1549			LIBS="-lusb-1.0 -lpthread $LIBS"
1550			ac_lbl_has_libusb=yes
1551		    ],
1552		    ac_lbl_has_libusb=no
1553		    )
1554		],
1555		ac_lbl_has_libusb=no
1556		)
1557		if test "x$ac_lbl_has_libusb" = "xyes" ; then
1558		    AC_MSG_NOTICE(canusb sniffing is supported)
1559		else
1560		    if test "x$enable_canusb" = "xyes" ; then
1561			AC_MSG_ERROR(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
1562		    else
1563			AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
1564		    fi
1565		fi
1566		;;
1567	*)
1568		if test "x$enable_canusb" = "xyes" ; then
1569		    AC_MSG_ERROR(no canusb support implemented for $host_os)
1570		else
1571		    AC_MSG_NOTICE(no canusb support implemented for $host_os)
1572		fi
1573		;;
1574	esac
1575	AC_SUBST(PCAP_SUPPORT_CANUSB)
1576	AC_SUBST(CANUSB_SRC)
1577fi
1578
1579AC_ARG_ENABLE([can],
1580[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])],
1581    [],
1582    [enable_can=ifsupportavailable])
1583
1584if test "x$enable_can" != "xno" ; then
1585	dnl check for CAN sniffing support
1586	case "$host_os" in
1587	linux*)
1588		AC_CHECK_HEADER(linux/can.h,
1589			[
1590			    AC_DEFINE(PCAP_SUPPORT_CAN, 1, [target host supports CAN sniffing])
1591			    CAN_SRC=pcap-can-linux.c
1592			    AC_MSG_NOTICE(CAN sniffing is supported)
1593			],
1594			[
1595			    if test "x$enable_can" = "xyes" ; then
1596				AC_MSG_ERROR(CAN sniffing is not supported)
1597			    else
1598				AC_MSG_NOTICE(CAN sniffing is not supported)
1599			    fi
1600			],
1601			[#include <sys/socket.h>]
1602		   )
1603		;;
1604	*)
1605		if test "x$enable_can" = "xyes" ; then
1606		    AC_MSG_ERROR(no CAN sniffing support implemented for $host_os)
1607		else
1608		    AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os)
1609		fi
1610		;;
1611	esac
1612	AC_SUBST(PCAP_SUPPORT_CAN)
1613	AC_SUBST(CAN_SRC)
1614fi
1615
1616AC_ARG_ENABLE([dbus],
1617[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
1618    [],
1619    [enable_dbus=ifavailable])
1620
1621if test "x$enable_dbus" != "xno"; then
1622	if test "x$enable_dbus" = "xyes"; then
1623		case "$host_os" in
1624
1625		darwin*)
1626			#
1627			# https://bugs.freedesktop.org/show_bug.cgi?id=74029
1628			#
1629			AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X])
1630			;;
1631		esac
1632	else
1633		case "$host_os" in
1634
1635		darwin*)
1636			#
1637			# https://bugs.freedesktop.org/show_bug.cgi?id=74029
1638			#
1639			;;
1640
1641		*)
1642			AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
1643			if test "x$PKGCONFIG" != "xno"; then
1644				AC_MSG_CHECKING([for D-Bus])
1645				if "$PKGCONFIG" dbus-1; then
1646					AC_MSG_RESULT([yes])
1647					DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
1648					DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
1649					save_CFLAGS="$CFLAGS"
1650					save_LIBS="$LIBS"
1651					CFLAGS="$CFLAGS $DBUS_CFLAGS"
1652					LIBS="$LIBS $DBUS_LIBS"
1653					AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
1654					AC_TRY_LINK(
1655					    [#include <string.h>
1656
1657					     #include <time.h>
1658					     #include <sys/time.h>
1659
1660					     #include <dbus/dbus.h>],
1661					    [return dbus_connection_read_write(NULL, 0);],
1662					    [
1663						AC_MSG_RESULT([yes])
1664						AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
1665						DBUS_SRC=pcap-dbus.c
1666						V_INCLS="$V_INCLS $DBUS_CFLAGS"
1667					    ],
1668					    [
1669						AC_MSG_RESULT([no])
1670						if test "x$enable_dbus" = "xyes"; then
1671						    AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
1672						fi
1673						LIBS="$save_LIBS"
1674					     ])
1675					CFLAGS="$save_CFLAGS"
1676				else
1677					AC_MSG_RESULT([no])
1678					if test "x$enable_dbus" = "xyes"; then
1679						AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
1680					fi
1681				fi
1682			fi
1683			;;
1684		esac
1685	fi
1686	AC_SUBST(PCAP_SUPPORT_DBUS)
1687	AC_SUBST(DBUS_SRC)
1688fi
1689
1690dnl check for hardware timestamp support
1691case "$host_os" in
1692linux*)
1693	AC_CHECK_HEADERS([linux/net_tstamp.h])
1694	;;
1695*)
1696	AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1697	;;
1698esac
1699
1700AC_PROG_INSTALL
1701
1702AC_CONFIG_HEADER(config.h)
1703
1704AC_OUTPUT_COMMANDS([if test -f .devel; then
1705	echo timestamp > stamp-h
1706	cat Makefile-devel-adds >> Makefile
1707	make depend
1708fi])
1709AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
1710	pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
1711	pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
1712	pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
1713	pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
1714	pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap
1715	pcap_set_tstamp_type.3pcap)
1716exit 0
1717