1dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.93 2008-11-18 07:29:48 guy Exp $ (LBL) 2dnl 3dnl Copyright (c) 1995, 1996, 1997, 1998 4dnl The Regents of the University of California. All rights reserved. 5dnl 6dnl Redistribution and use in source and binary forms, with or without 7dnl modification, are permitted provided that: (1) source code distributions 8dnl retain the above copyright notice and this paragraph in its entirety, (2) 9dnl distributions including binary code include the above copyright notice and 10dnl this paragraph in its entirety in the documentation or other materials 11dnl provided with the distribution, and (3) all advertising materials mentioning 12dnl features or use of this software display the following acknowledgement: 13dnl ``This product includes software developed by the University of California, 14dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15dnl the University nor the names of its contributors may be used to endorse 16dnl or promote products derived from this software without specific prior 17dnl written permission. 18dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21dnl 22dnl LBL autoconf macros 23dnl 24 25dnl 26dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC. 27dnl 28dnl It appears that newer versions of autoconf (2.64 and later) will, 29dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the 30dnl beginning of the macro, even if the macro itself calls AC_PROG_CC. 31dnl See the "Prerequisite Macros" and "Expanded Before Required" sections 32dnl in the Autoconf documentation. 33dnl 34dnl This causes a steaming heap of fail in our case, as we were, in 35dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC, 36dnl calling AC_PROG_CC, and then doing the tests we now do in 37dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC, 38dnl and AC_LBL_C_INIT at the top level. 39dnl 40AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC, 41 [AC_PREREQ(2.50) 42 AC_BEFORE([$0], [AC_LBL_C_INIT]) 43 AC_BEFORE([$0], [AC_PROG_CC]) 44 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) 45 AC_BEFORE([$0], [AC_LBL_DEVEL]) 46 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc]) 47 $1="-O" 48 $2="" 49 if test "${srcdir}" != "." ; then 50 $2="-I\$(srcdir)" 51 fi 52 if test "${CFLAGS+set}" = set; then 53 LBL_CFLAGS="$CFLAGS" 54 fi 55 if test -z "$CC" ; then 56 case "$host_os" in 57 58 bsdi*) 59 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no) 60 if test $SHLICC2 = yes ; then 61 CC=shlicc2 62 export CC 63 fi 64 ;; 65 esac 66 fi 67 if test -z "$CC" -a "$with_gcc" = no ; then 68 CC=cc 69 export CC 70 fi 71]) 72 73dnl 74dnl Determine which compiler we're using (cc or gcc) 75dnl If using gcc, determine the version number 76dnl If using cc, require that it support ansi prototypes 77dnl If using gcc, use -O2 (otherwise use -O) 78dnl If using cc, explicitly specify /usr/local/include 79dnl 80dnl usage: 81dnl 82dnl AC_LBL_C_INIT(copt, incls) 83dnl 84dnl results: 85dnl 86dnl $1 (copt set) 87dnl $2 (incls set) 88dnl CC 89dnl LDFLAGS 90dnl ac_cv_lbl_gcc_vers 91dnl LBL_CFLAGS 92dnl 93AC_DEFUN(AC_LBL_C_INIT, 94 [AC_PREREQ(2.50) 95 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) 96 AC_BEFORE([$0], [AC_LBL_DEVEL]) 97 AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT]) 98 if test "$GCC" = yes ; then 99 if test "$SHLICC2" = yes ; then 100 ac_cv_lbl_gcc_vers=2 101 $1="-O2" 102 else 103 AC_MSG_CHECKING(gcc version) 104 AC_CACHE_VAL(ac_cv_lbl_gcc_vers, 105 ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ 106 sed -e '/^gcc version /!d' \ 107 -e 's/^gcc version //' \ 108 -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \ 109 -e 's/\..*//'`) 110 AC_MSG_RESULT($ac_cv_lbl_gcc_vers) 111 if test $ac_cv_lbl_gcc_vers -gt 1 ; then 112 $1="-O2" 113 fi 114 fi 115 else 116 AC_MSG_CHECKING(that $CC handles ansi prototypes) 117 AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes, 118 AC_TRY_COMPILE( 119 [#include <sys/types.h>], 120 [int frob(int, char *)], 121 ac_cv_lbl_cc_ansi_prototypes=yes, 122 ac_cv_lbl_cc_ansi_prototypes=no)) 123 AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes) 124 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then 125 case "$host_os" in 126 127 hpux*) 128 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)) 129 savedcflags="$CFLAGS" 130 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" 131 AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa, 132 AC_TRY_COMPILE( 133 [#include <sys/types.h>], 134 [int frob(int, char *)], 135 ac_cv_lbl_cc_hpux_cc_aa=yes, 136 ac_cv_lbl_cc_hpux_cc_aa=no)) 137 AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa) 138 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then 139 AC_MSG_ERROR(see the INSTALL doc for more info) 140 fi 141 CFLAGS="$savedcflags" 142 $1="-Aa $$1" 143 AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX]) 144 ;; 145 146 osf*) 147 AC_MSG_CHECKING(for ansi mode in DEC compiler ($CC -std1)) 148 savedcflags="$CFLAGS" 149 CFLAGS="-std1" 150 AC_CACHE_VAL(ac_cv_lbl_cc_osf1_cc_std1, 151 AC_TRY_COMPILE( 152 [#include <sys/types.h>], 153 [int frob(int, char *)], 154 ac_cv_lbl_cc_osf1_cc_std1=yes, 155 ac_cv_lbl_cc_osf1_cc_std1=no)) 156 AC_MSG_RESULT($ac_cv_lbl_cc_osf1_cc_std1) 157 if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then 158 AC_MSG_ERROR(see the INSTALL doc for more info) 159 fi 160 CFLAGS="$savedcflags" 161 $1="-std1 $$1" 162 ;; 163 164 *) 165 AC_MSG_ERROR(see the INSTALL doc for more info) 166 ;; 167 esac 168 fi 169 $2="$$2 -I/usr/local/include" 170 LDFLAGS="$LDFLAGS -L/usr/local/lib" 171 172 case "$host_os" in 173 174 irix*) 175 $1="$$1 -xansi -signed -g3" 176 ;; 177 178 osf*) 179 # 180 # Presumed to be DEC OSF/1, Digital UNIX, or 181 # Tru64 UNIX. 182 # 183 $1="$$1 -g3" 184 ;; 185 186 ultrix*) 187 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes) 188 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto, 189 AC_TRY_COMPILE( 190 [#include <sys/types.h>], 191 [struct a { int b; }; 192 void c(const struct a *)], 193 ac_cv_lbl_cc_const_proto=yes, 194 ac_cv_lbl_cc_const_proto=no)) 195 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto) 196 if test $ac_cv_lbl_cc_const_proto = no ; then 197 AC_DEFINE(const,[], 198 [to handle Ultrix compilers that don't support const in prototypes]) 199 fi 200 ;; 201 esac 202 fi 203]) 204 205dnl 206dnl Determine what options are needed to build a shared library 207dnl 208dnl usage: 209dnl 210dnl AC_LBL_SHLIBS_INIT 211dnl 212dnl results: 213dnl 214dnl V_CCOPT (modified to build position-independent code) 215dnl V_SHLIB_CMD 216dnl V_SHLIB_OPT 217dnl V_SONAME_OPT 218dnl V_RPATH_OPT 219dnl 220AC_DEFUN(AC_LBL_SHLIBS_INIT, 221 [AC_PREREQ(2.50) 222 if test "$GCC" = yes ; then 223 # 224 # On platforms where we build a shared library: 225 # 226 # add options to generate position-independent code, 227 # if necessary (it's the default in AIX and Darwin/OS X); 228 # 229 # define option to set the soname of the shared library, 230 # if the OS supports that; 231 # 232 # add options to specify, at link time, a directory to 233 # add to the run-time search path, if that's necessary. 234 # 235 V_SHLIB_CMD="\$(CC)" 236 V_SHLIB_OPT="-shared" 237 case "$host_os" in 238 239 aix*) 240 ;; 241 242 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*) 243 # 244 # Platforms where the linker is the GNU linker 245 # or accepts command-line arguments like 246 # those the GNU linker accepts. 247 # 248 # Some instruction sets require -fPIC on some 249 # operating systems. Check for them. If you 250 # have a combination that requires it, add it 251 # here. 252 # 253 PIC_OPT=-fpic 254 case "$host_cpu" in 255 256 sparc64*) 257 case "$host_os" in 258 259 freebsd*|openbsd*) 260 PIC_OPT=-fPIC 261 ;; 262 esac 263 ;; 264 esac 265 V_CCOPT="$V_CCOPT $PIC_OPT" 266 V_SONAME_OPT="-Wl,-soname," 267 V_RPATH_OPT="-Wl,-rpath," 268 ;; 269 270 hpux*) 271 V_CCOPT="$V_CCOPT -fpic" 272 # 273 # XXX - this assumes GCC is using the HP linker, 274 # rather than the GNU linker, and that the "+h" 275 # option is used on all HP-UX platforms, both .sl 276 # and .so. 277 # 278 V_SONAME_OPT="-Wl,+h," 279 # 280 # By default, directories specifed with -L 281 # are added to the run-time search path, so 282 # we don't add them in pcap-config. 283 # 284 ;; 285 286 solaris*) 287 V_CCOPT="$V_CCOPT -fpic" 288 # 289 # XXX - this assumes GCC is using the Sun linker, 290 # rather than the GNU linker. 291 # 292 V_SONAME_OPT="-Wl,-h," 293 V_RPATH_OPT="-Wl,-R," 294 ;; 295 esac 296 else 297 # 298 # Set the appropriate compiler flags and, on platforms 299 # where we build a shared library: 300 # 301 # add options to generate position-independent code, 302 # if necessary (it's the default in Darwin/OS X); 303 # 304 # if we generate ".so" shared libraries, define the 305 # appropriate options for building the shared library; 306 # 307 # add options to specify, at link time, a directory to 308 # add to the run-time search path, if that's necessary. 309 # 310 # Note: spaces after V_SONAME_OPT are significant; on 311 # some platforms the soname is passed with a GCC-like 312 # "-Wl,-soname,{soname}" option, with the soname part 313 # of the option, while on other platforms the C compiler 314 # driver takes it as a regular option with the soname 315 # following the option. The same applies to V_RPATH_OPT. 316 # 317 case "$host_os" in 318 319 aix*) 320 V_SHLIB_CMD="\$(CC)" 321 V_SHLIB_OPT="-G -bnoentry -bexpall" 322 ;; 323 324 freebsd*|netbsd*|openbsd*|dragonfly*|linux*) 325 # 326 # "cc" is GCC. 327 # 328 V_CCOPT="$V_CCOPT -fpic" 329 V_SHLIB_CMD="\$(CC)" 330 V_SHLIB_OPT="-shared" 331 V_SONAME_OPT="-Wl,-soname," 332 V_RPATH_OPT="-Wl,-rpath," 333 ;; 334 335 hpux*) 336 V_CCOPT="$V_CCOPT +z" 337 V_SHLIB_CMD="\$(LD)" 338 V_SHLIB_OPT="-b" 339 V_SONAME_OPT="+h " 340 # 341 # By default, directories specifed with -L 342 # are added to the run-time search path, so 343 # we don't add them in pcap-config. 344 # 345 ;; 346 347 osf*) 348 # 349 # Presumed to be DEC OSF/1, Digital UNIX, or 350 # Tru64 UNIX. 351 # 352 V_SHLIB_CMD="\$(CC)" 353 V_SHLIB_OPT="-shared" 354 V_SONAME_OPT="-soname " 355 V_RPATH_OPT="-rpath " 356 ;; 357 358 solaris*) 359 V_CCOPT="$V_CCOPT -Kpic" 360 V_SHLIB_CMD="\$(CC)" 361 V_SHLIB_OPT="-G" 362 V_SONAME_OPT="-h " 363 V_RPATH_OPT="-R" 364 ;; 365 esac 366 fi 367]) 368 369# 370# Try compiling a sample of the type of code that appears in 371# gencode.c with "inline", "__inline__", and "__inline". 372# 373# Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough, 374# as it just tests whether a function returning "int" can be inlined; 375# at least some versions of HP's C compiler can inline that, but can't 376# inline a function that returns a struct pointer. 377# 378# Make sure we use the V_CCOPT flags, because some of those might 379# disable inlining. 380# 381AC_DEFUN(AC_LBL_C_INLINE, 382 [AC_MSG_CHECKING(for inline) 383 save_CFLAGS="$CFLAGS" 384 CFLAGS="$V_CCOPT" 385 AC_CACHE_VAL(ac_cv_lbl_inline, [ 386 ac_cv_lbl_inline="" 387 ac_lbl_cc_inline=no 388 for ac_lbl_inline in inline __inline__ __inline 389 do 390 AC_TRY_COMPILE( 391 [#define inline $ac_lbl_inline 392 static inline struct iltest *foo(void); 393 struct iltest { 394 int iltest1; 395 int iltest2; 396 }; 397 398 static inline struct iltest * 399 foo() 400 { 401 static struct iltest xxx; 402 403 return &xxx; 404 }],,ac_lbl_cc_inline=yes,) 405 if test "$ac_lbl_cc_inline" = yes ; then 406 break; 407 fi 408 done 409 if test "$ac_lbl_cc_inline" = yes ; then 410 ac_cv_lbl_inline=$ac_lbl_inline 411 fi]) 412 CFLAGS="$save_CFLAGS" 413 if test ! -z "$ac_cv_lbl_inline" ; then 414 AC_MSG_RESULT($ac_cv_lbl_inline) 415 else 416 AC_MSG_RESULT(no) 417 fi 418 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])]) 419 420dnl 421dnl If using gcc, make sure we have ANSI ioctl definitions 422dnl 423dnl usage: 424dnl 425dnl AC_LBL_FIXINCLUDES 426dnl 427AC_DEFUN(AC_LBL_FIXINCLUDES, 428 [if test "$GCC" = yes ; then 429 AC_MSG_CHECKING(for ANSI ioctl definitions) 430 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes, 431 AC_TRY_COMPILE( 432 [/* 433 * This generates a "duplicate case value" when fixincludes 434 * has not be run. 435 */ 436# include <sys/types.h> 437# include <sys/time.h> 438# include <sys/ioctl.h> 439# ifdef HAVE_SYS_IOCCOM_H 440# include <sys/ioccom.h> 441# endif], 442 [switch (0) { 443 case _IO('A', 1):; 444 case _IO('B', 1):; 445 }], 446 ac_cv_lbl_gcc_fixincludes=yes, 447 ac_cv_lbl_gcc_fixincludes=no)) 448 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes) 449 if test $ac_cv_lbl_gcc_fixincludes = no ; then 450 # Don't cache failure 451 unset ac_cv_lbl_gcc_fixincludes 452 AC_MSG_ERROR(see the INSTALL for more info) 453 fi 454 fi]) 455 456dnl 457dnl Check for flex, default to lex 458dnl Require flex 2.4 or higher 459dnl Check for bison, default to yacc 460dnl Default to lex/yacc if both flex and bison are not available 461dnl 462dnl If we're using flex and bison, pass -P to flex and -p to bison 463dnl to define a prefix string for the lexer and parser 464dnl 465dnl If we're not using flex and bison, don't pass those options 466dnl (as they might not work - although if "lex" is a wrapper for 467dnl Flex and "yacc" is a wrapper for Bison, they will work), and 468dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check 469dnl whether the wrapper is needed, as some people apparently, for 470dnl some unknown reason, choose to use --without-flex and 471dnl --without-bison on systems that have Flex and Bison, which 472dnl means that the "yacc" they end up using is a wrapper that 473dnl runs "bison -y", and at least some versions of Bison define 474dnl YYBISON even if run with "-y", so we end up not compiling 475dnl the yyparse wrapper and end up with a libpcap that doesn't 476dnl define pcap_parse()) 477dnl 478dnl usage: 479dnl 480dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) 481dnl 482dnl results: 483dnl 484dnl $1 (lex set) 485dnl $2 (yacc appended) 486dnl $3 (optional flex and bison -P prefix) 487dnl 488AC_DEFUN(AC_LBL_LEX_AND_YACC, 489 [AC_ARG_WITH(flex, [ --without-flex don't use flex]) 490 AC_ARG_WITH(bison, [ --without-bison don't use bison]) 491 if test "$with_flex" = no ; then 492 $1=lex 493 else 494 AC_CHECK_PROGS($1, flex, lex) 495 fi 496 if test "$$1" = flex ; then 497 # The -V flag was added in 2.4 498 AC_MSG_CHECKING(for flex 2.4 or higher) 499 AC_CACHE_VAL(ac_cv_lbl_flex_v24, 500 if flex -V >/dev/null 2>&1; then 501 ac_cv_lbl_flex_v24=yes 502 else 503 ac_cv_lbl_flex_v24=no 504 fi) 505 AC_MSG_RESULT($ac_cv_lbl_flex_v24) 506 if test $ac_cv_lbl_flex_v24 = no ; then 507 s="2.4 or higher required" 508 AC_MSG_WARN(ignoring obsolete flex executable ($s)) 509 $1=lex 510 fi 511 fi 512 if test "$with_bison" = no ; then 513 $2=yacc 514 else 515 AC_CHECK_PROGS($2, bison, yacc) 516 fi 517 if test "$$2" = bison ; then 518 $2="$$2 -y" 519 fi 520 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then 521 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) 522 $1=lex 523 $2=yacc 524 fi 525 if test "$$1" = flex -a -n "$3" ; then 526 $1="$$1 -P$3" 527 $2="$$2 -p $3" 528 else 529 AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse]) 530 fi]) 531 532dnl 533dnl Checks to see if union wait is used with WEXITSTATUS() 534dnl 535dnl usage: 536dnl 537dnl AC_LBL_UNION_WAIT 538dnl 539dnl results: 540dnl 541dnl DECLWAITSTATUS (defined) 542dnl 543AC_DEFUN(AC_LBL_UNION_WAIT, 544 [AC_MSG_CHECKING(if union wait is used) 545 AC_CACHE_VAL(ac_cv_lbl_union_wait, 546 AC_TRY_COMPILE([ 547# include <sys/types.h> 548# include <sys/wait.h>], 549 [int status; 550 u_int i = WEXITSTATUS(status); 551 u_int j = waitpid(0, &status, 0);], 552 ac_cv_lbl_union_wait=no, 553 ac_cv_lbl_union_wait=yes)) 554 AC_MSG_RESULT($ac_cv_lbl_union_wait) 555 if test $ac_cv_lbl_union_wait = yes ; then 556 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait]) 557 else 558 AC_DEFINE(DECLWAITSTATUS,int,[type for wait]) 559 fi]) 560 561dnl 562dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member 563dnl 564dnl usage: 565dnl 566dnl AC_LBL_SOCKADDR_SA_LEN 567dnl 568dnl results: 569dnl 570dnl HAVE_SOCKADDR_SA_LEN (defined) 571dnl 572AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, 573 [AC_MSG_CHECKING(if sockaddr struct has the sa_len member) 574 AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len, 575 AC_TRY_COMPILE([ 576# include <sys/types.h> 577# include <sys/socket.h>], 578 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], 579 ac_cv_lbl_sockaddr_has_sa_len=yes, 580 ac_cv_lbl_sockaddr_has_sa_len=no)) 581 AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len) 582 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then 583 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member]) 584 fi]) 585 586dnl 587dnl Checks to see if there's a sockaddr_storage structure 588dnl 589dnl usage: 590dnl 591dnl AC_LBL_SOCKADDR_STORAGE 592dnl 593dnl results: 594dnl 595dnl HAVE_SOCKADDR_STORAGE (defined) 596dnl 597AC_DEFUN(AC_LBL_SOCKADDR_STORAGE, 598 [AC_MSG_CHECKING(if sockaddr_storage struct exists) 599 AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage, 600 AC_TRY_COMPILE([ 601# include <sys/types.h> 602# include <sys/socket.h>], 603 [u_int i = sizeof (struct sockaddr_storage)], 604 ac_cv_lbl_has_sockaddr_storage=yes, 605 ac_cv_lbl_has_sockaddr_storage=no)) 606 AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage) 607 if test $ac_cv_lbl_has_sockaddr_storage = yes ; then 608 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists]) 609 fi]) 610 611dnl 612dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00 613dnl dl_module_id_1 member 614dnl 615dnl usage: 616dnl 617dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1 618dnl 619dnl results: 620dnl 621dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined) 622dnl 623dnl NOTE: any compile failure means we conclude that it doesn't have 624dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h> 625dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type, 626dnl we conclude it doesn't have that member (which is OK, as either we 627dnl won't be using code that would use that member, or we wouldn't 628dnl compile in any case). 629dnl 630AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1, 631 [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member) 632 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1, 633 AC_TRY_COMPILE([ 634# include <sys/types.h> 635# include <sys/dlpi.h> 636# include <sys/dlpi_ext.h>], 637 [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)], 638 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes, 639 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no)) 640 AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1) 641 if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then 642 AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists]) 643 fi]) 644 645dnl 646dnl Checks to see if -R is used 647dnl 648dnl usage: 649dnl 650dnl AC_LBL_HAVE_RUN_PATH 651dnl 652dnl results: 653dnl 654dnl ac_cv_lbl_have_run_path (yes or no) 655dnl 656AC_DEFUN(AC_LBL_HAVE_RUN_PATH, 657 [AC_MSG_CHECKING(for ${CC-cc} -R) 658 AC_CACHE_VAL(ac_cv_lbl_have_run_path, 659 [echo 'main(){}' > conftest.c 660 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1 661 if test ! -s conftest.out ; then 662 ac_cv_lbl_have_run_path=yes 663 else 664 ac_cv_lbl_have_run_path=no 665 fi 666 rm -f -r conftest*]) 667 AC_MSG_RESULT($ac_cv_lbl_have_run_path) 668 ]) 669 670dnl 671dnl Checks to see if unaligned memory accesses fail 672dnl 673dnl usage: 674dnl 675dnl AC_LBL_UNALIGNED_ACCESS 676dnl 677dnl results: 678dnl 679dnl LBL_ALIGN (DEFINED) 680dnl 681AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, 682 [AC_MSG_CHECKING(if unaligned accesses fail) 683 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, 684 [case "$host_cpu" in 685 686 # 687 # These are CPU types where: 688 # 689 # the CPU faults on an unaligned access, but at least some 690 # OSes that support that CPU catch the fault and simulate 691 # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) - 692 # the simulation is slow, so we don't want to use it; 693 # 694 # the CPU, I infer (from the old 695 # 696 # XXX: should also check that they don't do weird things (like on arm) 697 # 698 # comment) doesn't fault on unaligned accesses, but doesn't 699 # do a normal unaligned fetch, either (e.g., presumably, ARM); 700 # 701 # for whatever reason, the test program doesn't work 702 # (this has been claimed to be the case for several of those 703 # CPUs - I don't know what the problem is; the problem 704 # was reported as "the test program dumps core" for SuperH, 705 # but that's what the test program is *supposed* to do - 706 # it dumps core before it writes anything, so the test 707 # for an empty output file should find an empty output 708 # file and conclude that unaligned accesses don't work). 709 # 710 # This run-time test won't work if you're cross-compiling, so 711 # in order to support cross-compiling for a particular CPU, 712 # we have to wire in the list of CPU types anyway, as far as 713 # I know, so perhaps we should just have a set of CPUs on 714 # which we know it doesn't work, a set of CPUs on which we 715 # know it does work, and have the script just fail on other 716 # cpu types and update it when such a failure occurs. 717 # 718 alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1) 719 ac_cv_lbl_unaligned_fail=yes 720 ;; 721 722 *) 723 cat >conftest.c <<EOF 724# include <sys/types.h> 725# include <sys/wait.h> 726# include <stdio.h> 727 unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; 728 main() { 729 unsigned int i; 730 pid_t pid; 731 int status; 732 /* avoid "core dumped" message */ 733 pid = fork(); 734 if (pid < 0) 735 exit(2); 736 if (pid > 0) { 737 /* parent */ 738 pid = waitpid(pid, &status, 0); 739 if (pid < 0) 740 exit(3); 741 exit(!WIFEXITED(status)); 742 } 743 /* child */ 744 i = *(unsigned int *)&a[[1]]; 745 printf("%d\n", i); 746 exit(0); 747 } 748EOF 749 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ 750 conftest.c $LIBS >/dev/null 2>&1 751 if test ! -x conftest ; then 752 dnl failed to compile for some reason 753 ac_cv_lbl_unaligned_fail=yes 754 else 755 ./conftest >conftest.out 756 if test ! -s conftest.out ; then 757 ac_cv_lbl_unaligned_fail=yes 758 else 759 ac_cv_lbl_unaligned_fail=no 760 fi 761 fi 762 rm -f -r conftest* core core.conftest 763 ;; 764 esac]) 765 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) 766 if test $ac_cv_lbl_unaligned_fail = yes ; then 767 AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails]) 768 fi]) 769 770dnl 771dnl If using gcc and the file .devel exists: 772dnl Compile with -g (if supported) and -Wall 773dnl If using gcc 2 or later, do extra prototype checking 774dnl If an os prototype include exists, symlink os-proto.h to it 775dnl 776dnl usage: 777dnl 778dnl AC_LBL_DEVEL(copt) 779dnl 780dnl results: 781dnl 782dnl $1 (copt appended) 783dnl HAVE_OS_PROTO_H (defined) 784dnl os-proto.h (symlinked) 785dnl 786AC_DEFUN(AC_LBL_DEVEL, 787 [rm -f os-proto.h 788 if test "${LBL_CFLAGS+set}" = set; then 789 $1="$$1 ${LBL_CFLAGS}" 790 fi 791 if test -f .devel ; then 792 if test "$GCC" = yes ; then 793 if test "${LBL_CFLAGS+set}" != set; then 794 if test "$ac_cv_prog_cc_g" = yes ; then 795 $1="-g $$1" 796 fi 797 $1="$$1 -Wall" 798 if test $ac_cv_lbl_gcc_vers -gt 1 ; then 799 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes" 800 fi 801 fi 802 else 803 case "$host_os" in 804 805 irix6*) 806 V_CCOPT="$V_CCOPT -n32" 807 ;; 808 809 *) 810 ;; 811 esac 812 fi 813 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'` 814 name="lbl/os-$os.h" 815 if test -f $name ; then 816 ln -s $name os-proto.h 817 AC_DEFINE(HAVE_OS_PROTO_H, 1, 818 [if there's an os_proto.h for this platform, to use additional prototypes]) 819 else 820 AC_MSG_WARN(can't find $name) 821 fi 822 fi]) 823 824dnl 825dnl Improved version of AC_CHECK_LIB 826dnl 827dnl Thanks to John Hawkinson (jhawk@mit.edu) 828dnl 829dnl usage: 830dnl 831dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, 832dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) 833dnl 834dnl results: 835dnl 836dnl LIBS 837dnl 838dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS" 839dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more. 840dnl We keep it around for reference purposes in case it's ever 841dnl useful in the future. 842dnl 843 844define(AC_LBL_CHECK_LIB, 845[AC_MSG_CHECKING([for $2 in -l$1]) 846dnl Use a cache variable name containing the library, function 847dnl name, and extra libraries to link with, because the test really is 848dnl for library $1 defining function $2, when linked with potinal 849dnl library $5, not just for library $1. Separate tests with the same 850dnl $1 and different $2's or $5's may have different results. 851ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'` 852AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var, 853[ac_save_LIBS="$LIBS" 854LIBS="-l$1 $5 $LIBS" 855AC_TRY_LINK(dnl 856ifelse([$2], [main], , dnl Avoid conflicting decl of main. 857[/* Override any gcc2 internal prototype to avoid an error. */ 858]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus 859extern "C" 860#endif 861])dnl 862[/* We use char because int might match the return type of a gcc2 863 builtin and then its argument prototype would still apply. */ 864char $2(); 865]), 866 [$2()], 867 eval "ac_cv_lbl_lib_$ac_lib_var=yes", 868 eval "ac_cv_lbl_lib_$ac_lib_var=no") 869LIBS="$ac_save_LIBS" 870])dnl 871if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then 872 AC_MSG_RESULT(yes) 873 ifelse([$3], , 874[changequote(, )dnl 875 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ 876 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` 877changequote([, ])dnl 878 AC_DEFINE_UNQUOTED($ac_tr_lib) 879 LIBS="-l$1 $LIBS" 880], [$3]) 881else 882 AC_MSG_RESULT(no) 883ifelse([$4], , , [$4 884])dnl 885fi 886]) 887 888dnl 889dnl AC_LBL_LIBRARY_NET 890dnl 891dnl This test is for network applications that need socket() and 892dnl gethostbyname() -ish functions. Under Solaris, those applications 893dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link 894dnl with "-lnsl" but should *not* link with "-lsocket" because 895dnl libsocket.a breaks a number of things (for instance: 896dnl gethostbyname() under IRIX 5.2, and snoop sockets under most 897dnl versions of IRIX). 898dnl 899dnl Unfortunately, many application developers are not aware of this, 900dnl and mistakenly write tests that cause -lsocket to be used under 901dnl IRIX. It is also easy to write tests that cause -lnsl to be used 902dnl under operating systems where neither are necessary (or useful), 903dnl such as SunOS 4.1.4, which uses -lnsl for TLI. 904dnl 905dnl This test exists so that every application developer does not test 906dnl this in a different, and subtly broken fashion. 907 908dnl It has been argued that this test should be broken up into two 909dnl seperate tests, one for the resolver libraries, and one for the 910dnl libraries necessary for using Sockets API. Unfortunately, the two 911dnl are carefully intertwined and allowing the autoconf user to use 912dnl them independantly potentially results in unfortunate ordering 913dnl dependancies -- as such, such component macros would have to 914dnl carefully use indirection and be aware if the other components were 915dnl executed. Since other autoconf macros do not go to this trouble, 916dnl and almost no applications use sockets without the resolver, this 917dnl complexity has not been implemented. 918dnl 919dnl The check for libresolv is in case you are attempting to link 920dnl statically and happen to have a libresolv.a lying around (and no 921dnl libnsl.a). 922dnl 923AC_DEFUN(AC_LBL_LIBRARY_NET, [ 924 # Most operating systems have gethostbyname() in the default searched 925 # libraries (i.e. libc): 926 # Some OSes (eg. Solaris) place it in libnsl 927 # Some strange OSes (SINIX) have it in libsocket: 928 AC_SEARCH_LIBS(gethostbyname, nsl socket resolv) 929 # Unfortunately libsocket sometimes depends on libnsl and 930 # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. 931 if test "$ac_cv_search_gethostbyname" = "no" 932 then 933 AC_CHECK_LIB(socket, gethostbyname, 934 LIBS="-lsocket -lnsl $LIBS", , -lnsl) 935 fi 936 AC_SEARCH_LIBS(socket, socket, , 937 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)) 938 # DLPI needs putmsg under HPUX so test for -lstr while we're at it 939 AC_SEARCH_LIBS(putmsg, str) 940 ]) 941 942dnl 943dnl Test for __attribute__ 944dnl 945 946AC_DEFUN(AC_C___ATTRIBUTE__, [ 947AC_MSG_CHECKING(for __attribute__) 948AC_CACHE_VAL(ac_cv___attribute__, [ 949AC_COMPILE_IFELSE( 950 AC_LANG_SOURCE([[ 951#include <stdlib.h> 952 953static void foo(void) __attribute__ ((noreturn)); 954 955static void 956foo(void) 957{ 958 exit(1); 959} 960 961int 962main(int argc, char **argv) 963{ 964 foo(); 965} 966 ]]), 967ac_cv___attribute__=yes, 968ac_cv___attribute__=no)]) 969if test "$ac_cv___attribute__" = "yes"; then 970 AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) 971 V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" 972else 973 V_DEFS="$V_DEFS -D_U_=\"\"" 974fi 975AC_MSG_RESULT($ac_cv___attribute__) 976]) 977 978dnl 979dnl Checks to see if tpacket_stats is defined in linux/if_packet.h 980dnl If so then pcap-linux.c can use this to report proper statistics. 981dnl 982dnl -Scott Barron 983dnl 984AC_DEFUN(AC_LBL_TPACKET_STATS, 985 [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined) 986 AC_CACHE_VAL(ac_cv_lbl_tpacket_stats, 987 AC_TRY_COMPILE([ 988# include <linux/if_packet.h>], 989 [struct tpacket_stats stats], 990 ac_cv_lbl_tpacket_stats=yes, 991 ac_cv_lbl_tpacket_stats=no)) 992 AC_MSG_RESULT($ac_cv_lbl_tpacket_stats) 993 if test $ac_cv_lbl_tpacket_stats = yes; then 994 AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined]) 995 fi]) 996 997dnl 998dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member. 999dnl 1000dnl usage: 1001dnl 1002dnl AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1003dnl 1004dnl results: 1005dnl 1006dnl HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined) 1007dnl 1008dnl NOTE: any compile failure means we conclude that it doesn't have 1009dnl that member, so if we don't have tpacket_auxdata, we conclude it 1010dnl doesn't have that member (which is OK, as either we won't be using 1011dnl code that would use that member, or we wouldn't compile in any case). 1012dnl 1013AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI, 1014 [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member) 1015 AC_CACHE_VAL(ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci, 1016 AC_TRY_COMPILE([ 1017# include <sys/types.h> 1018# include <linux/if_packet.h>], 1019 [u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)], 1020 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes, 1021 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no)) 1022 AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci) 1023 if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then 1024 HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci 1025 AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA) 1026 AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists]) 1027 fi]) 1028 1029dnl 1030dnl Checks to see if Solaris has the dl_passive_req_t struct defined 1031dnl in <sys/dlpi.h>. 1032dnl 1033dnl usage: 1034dnl 1035dnl AC_LBL_DL_PASSIVE_REQ_T 1036dnl 1037dnl results: 1038dnl 1039dnl HAVE_DLPI_PASSIVE (defined) 1040dnl 1041AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T, 1042 [AC_MSG_CHECKING(if dl_passive_req_t struct exists) 1043 AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t, 1044 AC_TRY_COMPILE([ 1045# include <sys/types.h> 1046# include <sys/dlpi.h>], 1047 [u_int i = sizeof(dl_passive_req_t)], 1048 ac_cv_lbl_has_dl_passive_req_t=yes, 1049 ac_cv_lbl_has_dl_passive_req_t=no)) 1050 AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t) 1051 if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then 1052 AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive 1053 exists]) 1054 fi]) 1055