]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/libpcap/configure.in
This commit was generated by cvs2svn to compensate for changes in r143439,
[FreeBSD/FreeBSD.git] / contrib / libpcap / configure.in
1 dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.100.2.4 2004/03/28 21:43:34 fenner Exp $ (LBL)
2 dnl
3 dnl Copyright (c) 1994, 1995, 1996, 1997
4 dnl     The Regents of the University of California.  All rights reserved.
5 dnl
6 dnl Process this file with autoconf to produce a configure script.
7 dnl
8
9 AC_REVISION($Revision: 1.100.2.4 $)
10 AC_PREREQ(2.50)
11 AC_INIT(pcap.c)
12
13 AC_CANONICAL_SYSTEM
14
15 AC_LBL_C_INIT(V_CCOPT, V_INCLS, V_LIBS)
16 AC_LBL_C_INLINE
17 AC_C___ATTRIBUTE__
18
19 AC_LBL_CHECK_TYPE(u_int8_t, u_char)
20 AC_LBL_CHECK_TYPE(u_int16_t, u_short)
21 AC_LBL_CHECK_TYPE(u_int32_t, u_int)
22
23 dnl
24 dnl libpcap doesn't itself use <sys/ioccom.h>; however, the test program
25 dnl in "AC_LBL_FIXINCLUDES" in "aclocal.m4" uses it, so we have to
26 dnl test for it and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
27 dnl "AC_LBL_FIXINCLUDES" won't work on some platforms such as Solaris.
28 dnl
29 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h ifaddrs.h limits.h)
30 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
31 #include <sys/socket.h>])
32
33 AC_LBL_FIXINCLUDES
34
35 AC_CHECK_FUNCS(ether_hostton strerror strlcpy)
36
37 needsnprintf=no
38 AC_CHECK_FUNCS(vsnprintf snprintf,,
39         [needsnprintf=yes])
40 if test $needsnprintf = yes; then
41         AC_LIBOBJ(snprintf)
42 fi
43
44 dnl to pacify those who hate protochain insn
45 AC_MSG_CHECKING(if --disable-protochain option is specified)
46 AC_ARG_ENABLE(protochain, [  --disable-protochain    disable \"protochain\" insn])
47 case "x$enable_protochain" in
48 xyes)   enable_protochain=enabled       ;;
49 xno)    enable_protochain=disabled      ;;
50 x)      enable_protochain=enabled       ;;
51 esac
52
53 if test "$enable_protochain" = "disabled"; then
54         AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
55 fi
56 AC_MSG_RESULT(${enable_protochain})
57
58 dnl
59 dnl Not all versions of test support -c (character special) but it's a
60 dnl better way of testing since the device might be protected. So we
61 dnl check in our normal order using -r and then check the for the /dev
62 dnl guys again using -c.
63 dnl
64 dnl XXX This could be done for cross-compiling, but for now it's not.
65 dnl
66 if test -z "$with_pcap" && test "$cross_compiling" = yes; then
67         AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...)
68 fi
69 AC_ARG_WITH(pcap, [  --with-pcap=TYPE        use packet capture TYPE])
70 AC_MSG_CHECKING(packet capture type)
71 if test ! -z "$with_pcap" ; then
72         V_PCAP="$withval"
73 elif test -r /dev/bpf0 ; then
74         V_PCAP=bpf
75 elif test -r /usr/include/net/pfilt.h ; then
76         V_PCAP=pf
77 elif test -r /dev/enet ; then
78         V_PCAP=enet
79 elif test -r /dev/nit ; then
80         V_PCAP=snit
81 elif test -r /usr/include/sys/net/nit.h ; then
82         V_PCAP=nit
83 elif test -r /usr/include/linux/socket.h ; then
84         V_PCAP=linux
85 elif test -r /usr/include/net/raw.h ; then
86         V_PCAP=snoop
87 elif test -r /usr/include/odmi.h ; then
88         #
89         # On AIX, the BPF devices might not yet be present - they're
90         # created the first time libpcap runs after booting.
91         # We check for odmi.h instead.
92         #
93         V_PCAP=bpf
94 elif test -r /usr/include/sys/dlpi.h ; then
95         V_PCAP=dlpi
96 elif test -c /dev/bpf0 ; then           # check again in case not readable
97         V_PCAP=bpf
98 elif test -c /dev/enet ; then           # check again in case not readable
99         V_PCAP=enet
100 elif test -c /dev/nit ; then            # check again in case not readable
101         V_PCAP=snit
102 else
103         V_PCAP=null
104 fi
105 AC_MSG_RESULT($V_PCAP)
106
107 dnl
108 dnl Now figure out how we get a list of interfaces and addresses.
109 dnl
110 AC_CHECK_FUNC(getifaddrs,[
111         #
112         # We have "getifaddrs()", so we use that to get the list
113         #
114         V_FINDALLDEVS=getad
115 ],[
116         #
117         # Well, we don't have "getifaddrs()", so we have to use some
118         # other mechanism; determine what that mechanism is.
119         #
120         # The first thing we use is the type of capture mechanism,
121         # which is somewhat of a proxy for the OS we're using.
122         #
123         case "$V_PCAP" in
124
125         dlpi)
126                 #
127                 # This might be Solaris 8 or later, with SIOCGLIFCONF,
128                 # or it might be some other OS, with just SIOCGIFCONF.
129                 #
130                 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
131                 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
132                     AC_TRY_COMPILE(
133                         [#include <sys/param.h>
134                         #include <sys/file.h>
135                         #include <sys/ioctl.h>
136                         #include <sys/socket.h>
137                         #include <sys/sockio.h>],
138                         [ioctl(0, SIOCGLIFCONF, (char *)0);],
139                         ac_cv_lbl_have_siocglifconf=yes,
140                         ac_cv_lbl_have_siocglifconf=no))
141                 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
142                 if test $ac_cv_lbl_have_siocglifconf = yes ; then
143                         V_FINDALLDEVS=glifc
144                 else
145                         V_FINDALLDEVS=gifc
146                 fi
147                 ;;
148
149         null)
150                 #
151                 # We can't capture, so we can't open any capture
152                 # devices, so we won't return any interfaces.
153                 #
154                 V_FINDALLDEVS=null
155                 ;;
156
157         *)
158                 #
159                 # Assume we just have SIOCGIFCONF.
160                 # (XXX - on at least later Linux kernels, there's
161                 # another mechanism, and we should be using that
162                 # instead.)
163                 #
164                 V_FINDALLDEVS=gifc
165                 ;;
166         esac])
167
168 AC_MSG_CHECKING(if --enable-ipv6 option is specified)
169 AC_ARG_ENABLE(ipv6, [  --enable-ipv6           build IPv6-capable version])
170 if test "$enable_ipv6" = "yes"; then
171         AC_DEFINE(INET6,1,[IPv6])
172 fi
173 AC_MSG_RESULT(${enable_ipv6-no})
174
175 AC_MSG_CHECKING(whether to build optimizer debugging code)
176 AC_ARG_ENABLE(optimizer-dbg, [  --enable-optimizer-dbg  build optimizer debugging code])
177 if test "$enable_optimizer_dbg" = "yes"; then
178         AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
179 fi
180 AC_MSG_RESULT(${enable_optimizer_dbg-no})
181
182 AC_MSG_CHECKING(whether to build parser debugging code)
183 AC_ARG_ENABLE(yydebug, [  --enable-yydebug        build parser debugging code])
184 if test "$enable_yydebug" = "yes"; then
185         AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
186 fi
187 AC_MSG_RESULT(${enable_yydebug-no})
188
189 case "$V_PCAP" in
190
191 dlpi)
192         AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
193         AC_MSG_CHECKING(for /dev/dlpi device)
194         if test -c /dev/dlpi ; then
195                 AC_MSG_RESULT(yes)
196                 AC_DEFINE(HAVE_DEV_DLPI, 1, [define if you have a /dev/dlpi])
197         else
198                 AC_MSG_RESULT(no)
199                 dir="/dev/dlpi"
200                 AC_MSG_CHECKING(for $dir directory)
201                 if test -d $dir ; then
202                         AC_MSG_RESULT(yes)
203                         AC_DEFINE_UNQUOTED(PCAP_DEV_PREFIX, "$dir", [/dev/dlpi directory])
204                 else
205                         AC_MSG_RESULT(no)
206                 fi
207         fi
208         ;;
209
210 linux)
211         AC_MSG_CHECKING(Linux kernel version)
212         if test "$cross_compiling" = yes; then
213                 AC_CACHE_VAL(ac_cv_linux_vers,
214                     ac_cv_linux_vers=unknown)
215         else
216                 AC_CACHE_VAL(ac_cv_linux_vers,
217                     ac_cv_linux_vers=`uname -r 2>&1 | \
218                         sed -n -e '$s/.* //' -e '$s/\..*//p'`)
219         fi
220         AC_MSG_RESULT($ac_cv_linux_vers)
221         if test $ac_cv_linux_vers = unknown ; then
222                 AC_MSG_ERROR(cannot determine linux version when cross-compiling)
223         fi
224         if test $ac_cv_linux_vers -lt 2 ; then
225                 AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
226         fi
227         AC_LBL_TPACKET_STATS
228         ;;
229
230 dag)
231         V_DEFS="$V_DEFS -DDAG_ONLY"
232         ;;      
233
234 null)
235         AC_MSG_WARN(cannot determine packet capture interface)
236         AC_MSG_WARN((see the INSTALL doc for more info))
237         ;;
238
239 esac
240
241 AC_MSG_CHECKING(whether we have /proc/net/dev)
242 if test -r /proc/net/dev ; then
243         ac_cv_lbl_proc_net_dev=yes
244 else
245         ac_cv_lbl_proc_net_dev=no
246 fi
247 if test $ac_cv_lbl_proc_net_dev = yes; then
248         AC_DEFINE(HAVE_PROC_NET_DEV, 1, [define if you have a /proc/net/dev])
249 fi
250 AC_MSG_RESULT($ac_cv_lbl_proc_net_dev)
251
252 AC_ARG_WITH(dag, [  --with-dag[=DIR]        include DAG support (located in directory DIR, if supplied).  [default=yes, on BSD and Linux, if present]],
253 [
254         if test "$withval" = no
255         then
256                 want_dag=no
257         elif test "$withval" = yes
258         then
259                 want_dag=yes
260                 dag_root=
261         else
262                 want_dag=yes
263                 dag_root=$withval
264         fi
265 ],[
266         #
267         # Use DAG API if present, otherwise don't
268         #
269         want_dag=ifpresent
270         dag_root=/root/dag
271 ])
272 ac_cv_lbl_dag_api=no
273 case "$V_PCAP" in
274 linux|bpf|dag)
275         #
276         # We support the DAG API on Linux or BSD, or if we're building a
277         # DAG-only libpcap.
278         #
279         ;;
280 *)
281         #
282         # If the user explicitly requested DAG, tell them it's not
283         # supported.
284         #
285         # If they expressed no preference, don't include it.
286         #
287         if test $want_dag = yes; then
288                 AC_MSG_ERROR(DAG support only available with 'linux' 'bpf' and 'dag' packet capture types)
289         elif test $want_dag = yes; then
290                 want_dag=no
291         fi
292         ;;
293 esac
294
295 if test "$with_dag" != no; then
296         AC_MSG_CHECKING(whether we have DAG API)
297
298         if test -z "$dag_root"; then
299                 dag_root=$srcdir/../dag
300         fi
301
302         if test -r "$dag_root/tools" -a -r "$dag_root/include"; then
303                 dag_tools_dir="$dag_root/tools"
304                 dag_include_dir="$dag_root/include"
305         else
306                 dag_tools_dir="$dag_root"
307                 dag_include_dir="$dag_root"
308         fi
309
310         ac_cv_lbl_dag_api=no
311         if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_tools_dir/dagapi.o" -a -r "$dag_tools_dir/dagopts.o"; then
312                 V_INCLS="$V_INCLS -I $dag_include_dir"
313                 V_LIBS="$V_LIBS $dag_tools_dir/dagapi.o $dag_tools_dir/dagopts.o"
314                 if test "$V_PCAP" != dag ; then
315                          SSRC="pcap-dag.c"
316                 fi
317                 ac_cv_lbl_dag_api=yes
318         fi
319         if test -r "$dag_root/lib/dagreg.c"; then # DAG 2.5.x
320                 if test -r "$dag_tools_dir/dagreg.o"; then
321                         V_LIBS="$V_LIBS $dag_tools_dir/dagreg.o"
322                 else
323                         ac_cv_lbl_dag_api=no
324                 fi
325         fi
326         dag_version=
327         if test $ac_cv_lbl_dag_api = yes -a -r "$dag_root/VERSION"; then
328                 dag_version=" (`cat $dag_root/VERSION`)"
329         fi
330         AC_MSG_RESULT($ac_cv_lbl_dag_api$dag_version)
331         if test $ac_cv_lbl_dag_api = no; then
332                 if test "$want_dag" = yes; then
333                         AC_MSG_ERROR(DAG API not found under directory $dag_root; use --without-dag)
334                 fi
335         else
336                 AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API])
337         fi
338 fi
339
340 if test "$V_PCAP" = dag -a "$ac_cv_lbl_dag_api" = no; then
341         AC_MSG_ERROR(Specifying the capture type as 'dag' requires the DAG API to be present; use --with-dag=DIR)
342 fi
343
344
345 AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
346 if test "$V_LEX" = lex ; then
347 # Some versions of lex can't handle the definitions section of scanner.l .
348 # Try lexing it and complain if it can't deal.
349         AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
350                 if lex -t scanner.l > /dev/null 2>&1; then
351                         tcpdump_cv_capable_lex=yes
352                 else
353                         tcpdump_cv_capable_lex=insufficient
354                 fi)
355         if test $tcpdump_cv_capable_lex = insufficient ; then
356                 AC_MSG_ERROR([Your operating system's lex is insufficient to compile
357  libpcap.  flex is a lex replacement that has many advantages, including
358  being able to compile libpcap.  For more information, see
359  http://www.gnu.org/software/flex/flex.html .])
360         fi
361 fi
362
363 case "$host_os" in
364
365 aix*)
366         dnl Workaround to enable certain features
367         AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
368         ;;
369
370 hpux9*)
371         AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
372         ;;
373
374 hpux10.0*)
375         ;;
376
377 hpux10.1*)
378         ;;
379
380 hpux*)
381         dnl HPUX 10.20 and above is similar to HPUX 9...
382         AC_DEFINE(HAVE_HPUX10_20,1,[on HP-UX 10.20])
383         ;;
384
385 sinix*)
386         AC_MSG_CHECKING(if SINIX compiler defines sinix)
387         AC_CACHE_VAL(ac_cv_cc_sinix_defined,
388                 AC_TRY_COMPILE(
389                     [],
390                     [int i = sinix;],
391                     ac_cv_cc_sinix_defined=yes,
392                     ac_cv_cc_sinix_defined=no))
393             AC_MSG_RESULT($ac_cv_cc_sinix_defined)
394             if test $ac_cv_cc_sinix_defined = no ; then
395                     AC_DEFINE(sinix,1,[on sinix])
396             fi
397         ;;
398
399 solaris*)
400         AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
401         ;;
402 esac
403
404 AC_PROG_RANLIB
405
406 AC_LBL_DEVEL(V_CCOPT)
407
408 AC_LBL_SOCKADDR_SA_LEN
409
410 AC_LBL_SOCKADDR_STORAGE
411
412 AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
413
414 AC_LBL_UNALIGNED_ACCESS
415
416 rm -f net
417 ln -s ${srcdir}/bpf/net net
418
419 AC_SUBST(V_CCOPT)
420 AC_SUBST(V_DEFS)
421 AC_SUBST(V_INCLS)
422 AC_SUBST(V_LIBS)
423 AC_SUBST(V_LEX)
424 AC_SUBST(V_PCAP)
425 AC_SUBST(V_FINDALLDEVS)
426 AC_SUBST(V_RANLIB)
427 AC_SUBST(V_YACC)
428 AC_SUBST(SSRC)
429
430 AC_PROG_INSTALL
431
432 AC_CONFIG_HEADER(config.h)
433
434 AC_OUTPUT(Makefile)
435
436 if test -f .devel ; then
437         make depend
438 fi
439 exit 0