configure.in revision 127664
1dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.100.2.4 2004/03/28 21:43:34 fenner Exp $ (LBL) 2dnl 3dnl Copyright (c) 1994, 1995, 1996, 1997 4dnl The Regents of the University of California. All rights reserved. 5dnl 6dnl Process this file with autoconf to produce a configure script. 7dnl 8 9AC_REVISION($Revision: 1.100.2.4 $) 10AC_PREREQ(2.50) 11AC_INIT(pcap.c) 12 13AC_CANONICAL_SYSTEM 14 15AC_LBL_C_INIT(V_CCOPT, V_INCLS, V_LIBS) 16AC_LBL_C_INLINE 17AC_C___ATTRIBUTE__ 18 19AC_LBL_CHECK_TYPE(u_int8_t, u_char) 20AC_LBL_CHECK_TYPE(u_int16_t, u_short) 21AC_LBL_CHECK_TYPE(u_int32_t, u_int) 22 23dnl 24dnl libpcap doesn't itself use <sys/ioccom.h>; however, the test program 25dnl in "AC_LBL_FIXINCLUDES" in "aclocal.m4" uses it, so we have to 26dnl test for it and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise 27dnl "AC_LBL_FIXINCLUDES" won't work on some platforms such as Solaris. 28dnl 29AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h ifaddrs.h limits.h) 30AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h> 31#include <sys/socket.h>]) 32 33AC_LBL_FIXINCLUDES 34 35AC_CHECK_FUNCS(ether_hostton strerror strlcpy) 36 37needsnprintf=no 38AC_CHECK_FUNCS(vsnprintf snprintf,, 39 [needsnprintf=yes]) 40if test $needsnprintf = yes; then 41 AC_LIBOBJ(snprintf) 42fi 43 44dnl to pacify those who hate protochain insn 45AC_MSG_CHECKING(if --disable-protochain option is specified) 46AC_ARG_ENABLE(protochain, [ --disable-protochain disable \"protochain\" insn]) 47case "x$enable_protochain" in 48xyes) enable_protochain=enabled ;; 49xno) enable_protochain=disabled ;; 50x) enable_protochain=enabled ;; 51esac 52 53if test "$enable_protochain" = "disabled"; then 54 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain]) 55fi 56AC_MSG_RESULT(${enable_protochain}) 57 58dnl 59dnl Not all versions of test support -c (character special) but it's a 60dnl better way of testing since the device might be protected. So we 61dnl check in our normal order using -r and then check the for the /dev 62dnl guys again using -c. 63dnl 64dnl XXX This could be done for cross-compiling, but for now it's not. 65dnl 66if test -z "$with_pcap" && test "$cross_compiling" = yes; then 67 AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...) 68fi 69AC_ARG_WITH(pcap, [ --with-pcap=TYPE use packet capture TYPE]) 70AC_MSG_CHECKING(packet capture type) 71if test ! -z "$with_pcap" ; then 72 V_PCAP="$withval" 73elif test -r /dev/bpf0 ; then 74 V_PCAP=bpf 75elif test -r /usr/include/net/pfilt.h ; then 76 V_PCAP=pf 77elif test -r /dev/enet ; then 78 V_PCAP=enet 79elif test -r /dev/nit ; then 80 V_PCAP=snit 81elif test -r /usr/include/sys/net/nit.h ; then 82 V_PCAP=nit 83elif test -r /usr/include/linux/socket.h ; then 84 V_PCAP=linux 85elif test -r /usr/include/net/raw.h ; then 86 V_PCAP=snoop 87elif 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 94elif test -r /usr/include/sys/dlpi.h ; then 95 V_PCAP=dlpi 96elif test -c /dev/bpf0 ; then # check again in case not readable 97 V_PCAP=bpf 98elif test -c /dev/enet ; then # check again in case not readable 99 V_PCAP=enet 100elif test -c /dev/nit ; then # check again in case not readable 101 V_PCAP=snit 102else 103 V_PCAP=null 104fi 105AC_MSG_RESULT($V_PCAP) 106 107dnl 108dnl Now figure out how we get a list of interfaces and addresses. 109dnl 110AC_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 168AC_MSG_CHECKING(if --enable-ipv6 option is specified) 169AC_ARG_ENABLE(ipv6, [ --enable-ipv6 build IPv6-capable version]) 170if test "$enable_ipv6" = "yes"; then 171 AC_DEFINE(INET6,1,[IPv6]) 172fi 173AC_MSG_RESULT(${enable_ipv6-no}) 174 175AC_MSG_CHECKING(whether to build optimizer debugging code) 176AC_ARG_ENABLE(optimizer-dbg, [ --enable-optimizer-dbg build optimizer debugging code]) 177if test "$enable_optimizer_dbg" = "yes"; then 178 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging]) 179fi 180AC_MSG_RESULT(${enable_optimizer_dbg-no}) 181 182AC_MSG_CHECKING(whether to build parser debugging code) 183AC_ARG_ENABLE(yydebug, [ --enable-yydebug build parser debugging code]) 184if test "$enable_yydebug" = "yes"; then 185 AC_DEFINE(YYDEBUG,1,[Enable parser debugging]) 186fi 187AC_MSG_RESULT(${enable_yydebug-no}) 188 189case "$V_PCAP" in 190 191dlpi) 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 210linux) 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 230dag) 231 V_DEFS="$V_DEFS -DDAG_ONLY" 232 ;; 233 234null) 235 AC_MSG_WARN(cannot determine packet capture interface) 236 AC_MSG_WARN((see the INSTALL doc for more info)) 237 ;; 238 239esac 240 241AC_MSG_CHECKING(whether we have /proc/net/dev) 242if test -r /proc/net/dev ; then 243 ac_cv_lbl_proc_net_dev=yes 244else 245 ac_cv_lbl_proc_net_dev=no 246fi 247if 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]) 249fi 250AC_MSG_RESULT($ac_cv_lbl_proc_net_dev) 251 252AC_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]) 272ac_cv_lbl_dag_api=no 273case "$V_PCAP" in 274linux|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 ;; 293esac 294 295if 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 338fi 339 340if 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) 342fi 343 344 345AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_) 346if 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 361fi 362 363case "$host_os" in 364 365aix*) 366 dnl Workaround to enable certain features 367 AC_DEFINE(_SUN,1,[define on AIX to get certain functions]) 368 ;; 369 370hpux9*) 371 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x]) 372 ;; 373 374hpux10.0*) 375 ;; 376 377hpux10.1*) 378 ;; 379 380hpux*) 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 385sinix*) 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 399solaris*) 400 AC_DEFINE(HAVE_SOLARIS,1,[On solaris]) 401 ;; 402esac 403 404AC_PROG_RANLIB 405 406AC_LBL_DEVEL(V_CCOPT) 407 408AC_LBL_SOCKADDR_SA_LEN 409 410AC_LBL_SOCKADDR_STORAGE 411 412AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1 413 414AC_LBL_UNALIGNED_ACCESS 415 416rm -f net 417ln -s ${srcdir}/bpf/net net 418 419AC_SUBST(V_CCOPT) 420AC_SUBST(V_DEFS) 421AC_SUBST(V_INCLS) 422AC_SUBST(V_LIBS) 423AC_SUBST(V_LEX) 424AC_SUBST(V_PCAP) 425AC_SUBST(V_FINDALLDEVS) 426AC_SUBST(V_RANLIB) 427AC_SUBST(V_YACC) 428AC_SUBST(SSRC) 429 430AC_PROG_INSTALL 431 432AC_CONFIG_HEADER(config.h) 433 434AC_OUTPUT(Makefile) 435 436if test -f .devel ; then 437 make depend 438fi 439exit 0 440