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