1dnl @(#) Id: aclocal.m4 616 2009-10-10 00:08:08Z leres (LBL) 2dnl 3dnl Copyright (c) 2008, 2009 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 Determine which compiler we're using (cc or gcc) 27dnl If using gcc, determine the version number 28dnl If using cc, require that it support ansi prototypes 29dnl If using gcc, use -O3 (otherwise use -O) 30dnl If using cc, explicitly specify /usr/local/include 31dnl 32dnl usage: 33dnl 34dnl AC_LBL_C_INIT(copt, incls) 35dnl 36dnl results: 37dnl 38dnl $1 (copt set) 39dnl $2 (incls set) 40dnl CC 41dnl LDFLAGS set 42dnl 43AC_DEFUN(AC_LBL_C_INIT, 44 [AC_PREREQ(2.12) 45 AC_ARG_ENABLE([optimization], 46 [AS_HELP_STRING([--disable-optimization], 47 [turn off gcc optimization])], 48 ac_cv_without_optimization=${withval}) 49 AC_BEFORE([$0], [AC_PROG_CC]) 50 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) 51 AC_BEFORE([$0], [AC_LBL_DEVEL]) 52 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc]) 53 AC_USE_SYSTEM_EXTENSIONS 54 $1="" 55 if test "${ac_cv_without_optimization+set}" != set; then 56 $1="-O" 57 fi 58 $2="" 59 if test "${srcdir}" != "." ; then 60 $2="-I\$\(srcdir\)" 61 fi 62 if test -z "$CC" ; then 63 case "$target_os" in 64 65 bsdi*) 66 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no) 67 if test $SHLICC2 = yes ; then 68 CC=shlicc2 69 export CC 70 fi 71 ;; 72 esac 73 fi 74 if test -z "$CC" -a "$with_gcc" = no ; then 75 CC=cc 76 export CC 77 fi 78 AC_PROG_CC 79 AC_SYS_LARGEFILE 80 if test "$GCC" != yes ; then 81 AC_MSG_CHECKING(that $CC handles ansi prototypes) 82 AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes, 83 AC_TRY_COMPILE( 84 [#include <sys/types.h>], 85 [int frob(int, char *)], 86 ac_cv_lbl_cc_ansi_prototypes=yes, 87 ac_cv_lbl_cc_ansi_prototypes=no)) 88 AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes) 89 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then 90 case "$target_os" in 91 92 hpux*) 93 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)) 94 savedcflags="$CFLAGS" 95 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" 96 AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa, 97 AC_TRY_COMPILE( 98 [#include <sys/types.h>], 99 [int frob(int, char *)], 100 ac_cv_lbl_cc_hpux_cc_aa=yes, 101 ac_cv_lbl_cc_hpux_cc_aa=no)) 102 AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa) 103 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then 104 AC_MSG_ERROR(see the INSTALL doc for more info) 105 fi 106 CFLAGS="$savedcflags" 107 $1="-Aa $$1" 108 AC_DEFINE(_HPUX_SOURCE,,[HP-UX ansi compiler]) 109 ;; 110 111 *) 112 AC_MSG_ERROR(see the INSTALL doc for more info) 113 ;; 114 esac 115 fi 116 $2="$$2 -I/usr/local/include" 117 LDFLAGS="$LDFLAGS -L/usr/local/lib" 118 119 case "$target_os" in 120 121 irix*) 122 $1="$$1 -xansi -signed -g3" 123 ;; 124 125 osf*) 126 $1="$$1 -std1 -g3" 127 ;; 128 129 ultrix*) 130 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes) 131 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto, 132 AC_TRY_COMPILE( 133 [#include <sys/types.h>], 134 [struct a { int b; }; 135 void c(const struct a *)], 136 ac_cv_lbl_cc_const_proto=yes, 137 ac_cv_lbl_cc_const_proto=no)) 138 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto) 139 if test $ac_cv_lbl_cc_const_proto = no ; then 140 AC_DEFINE(const,,[ultrix can't hack const]) 141 fi 142 ;; 143 esac 144 fi 145]) 146 147AC_LBL_ENABLE_CHECK(brov6 activemapping expire-dfa-states) 148dnl 149dnl This allows us to check for bogus configure enable/disable 150dnl command line options 151dnl 152dnl usage: 153dnl 154dnl AC_LBL_ENABLE_CHECK(opt ...) 155dnl 156AC_DEFUN(AC_LBL_ENABLE_CHECK, 157 [set | 158 sed -n -e 's/^enable_\([[^=]]*\)=[[^=]]*$/\1/p' | 159 while read var; do 160 ok=0 161 for o in $1; do 162 if test "${o}" = "${var}" ; then 163 ok=1 164 break 165 fi 166 done 167 if test ${ok} -eq 0 ; then 168 # It's hard to kill configure script from subshell! 169 AC_MSG_ERROR(unknown enable option: ${var}) 170 exit 1 171 fi 172 done 173 if test $? -ne 0 ; then 174 exit 1 175 fi]) 176 177dnl 178dnl Use pfopen.c if available and pfopen() not in standard libraries 179dnl Require libpcap 180dnl Look for libpcap in .. 181dnl Use the installed libpcap if there is no local version 182dnl 183dnl usage: 184dnl 185dnl AC_LBL_LIBPCAP(pcapdep, incls) 186dnl 187dnl results: 188dnl 189dnl $1 (pcapdep set) 190dnl $2 (incls appended) 191dnl LIBS 192dnl LDFLAGS 193dnl LBL_LIBS 194dnl 195AC_DEFUN(AC_LBL_LIBPCAP, 196 [AC_REQUIRE([AC_LBL_LIBRARY_NET]) 197 dnl 198 dnl save a copy before locating libpcap.a 199 dnl 200 LBL_LIBS="$LIBS" 201 pfopen=/usr/examples/packetfilter/pfopen.c 202 if test -f $pfopen ; then 203 AC_CHECK_FUNCS(pfopen) 204 if test $ac_cv_func_pfopen = "no" ; then 205 AC_MSG_RESULT(Using $pfopen) 206 LIBS="$LIBS $pfopen" 207 fi 208 fi 209 AC_MSG_CHECKING(for local pcap library) 210 libpcap=FAIL 211 lastdir=FAIL 212 places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \ 213 egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'` 214 for dir in $places ../libpcap libpcap ; do 215 basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'` 216 if test $lastdir = $basedir ; then 217 dnl skip alphas when an actual release is present 218 continue; 219 fi 220 lastdir=$dir 221 if test -r $dir/pcap.c ; then 222 libpcap=$dir/libpcap.a 223 d=$dir 224 dnl continue and select the last one that exists 225 fi 226 done 227 if test "x$libpcap" = xFAIL ; then 228 AC_MSG_RESULT(not found) 229 AC_CHECK_LIB(pcap, pcap_open_live, libpcap="-lpcap") 230 unset ac_cv_lib_pcap_pcap_open_live 231 if test "x$libpcap" = xFAIL ; then 232 CFLAGS="$CFLAGS -I/usr/local/include" 233 LIBS="$LIBS -L/usr/local/lib" 234 AC_CHECK_LIB(pcap, pcap_open_live, libpcap="-lpcap") 235 unset ac_cv_lib_pcap_pcap_open_live 236 if test "x$libpcap" = xFAIL ; then 237 AC_MSG_ERROR(see the INSTALL doc for more info) 238 fi 239 $2="$$2 -I/usr/local/include" 240 fi 241 LIBS="$LIBS -lpcap" 242 else 243 $1=$libpcap 244 $2="-I$d $$2" 245 AC_MSG_RESULT($libpcap) 246 fi 247 if test "x$libpcap" != "x-lpcap" ; then 248 LIBS="$libpcap $LIBS" 249 fi 250 case "$target_os" in 251 252 aix*) 253 pseexe="/lib/pse.exp" 254 AC_MSG_CHECKING(for $pseexe) 255 if test -f $pseexe ; then 256 AC_MSG_RESULT(yes) 257 LIBS="$LIBS -I:$pseexe" 258 fi 259 ;; 260 esac]) 261 262dnl 263dnl Define RETSIGTYPE and RETSIGVAL 264dnl 265dnl usage: 266dnl 267dnl AC_LBL_TYPE_SIGNAL 268dnl 269dnl results: 270dnl 271dnl RETSIGTYPE (defined) 272dnl RETSIGVAL (defined) 273dnl 274AC_DEFUN(AC_LBL_TYPE_SIGNAL, 275 [AC_BEFORE([$0], [AC_LBL_LIBPCAP]) 276 AC_TYPE_SIGNAL 277 if test "$ac_cv_type_signal" = void ; then 278 AC_DEFINE(RETSIGVAL,,[signal function return value]) 279 else 280 AC_DEFINE(RETSIGVAL,(0)) 281 fi 282 case "$target_os" in 283 284 irix*) 285 AC_DEFINE(_BSD_SIGNALS,,[irix's BSD style signals]) 286 ;; 287 288 *) 289 dnl prefer sigset() to sigaction() 290 AC_CHECK_FUNCS(sigset) 291 if test $ac_cv_func_sigset = yes ; then 292 AC_DEFINE(signal,sigset,[use sigset() instead of signal()]) 293 else 294 AC_CHECK_FUNCS(sigaction) 295 fi 296 ;; 297 esac]) 298 299dnl 300dnl If using gcc, make sure we have ANSI ioctl definitions 301dnl 302dnl usage: 303dnl 304dnl AC_LBL_FIXINCLUDES 305dnl 306AC_DEFUN(AC_LBL_FIXINCLUDES, 307 [if test "$GCC" = yes ; then 308 AC_MSG_CHECKING(for ANSI ioctl definitions) 309 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes, 310 AC_TRY_COMPILE( 311 [/* 312 * This generates a "duplicate case value" when fixincludes 313 * has not be run. 314 */ 315# include <sys/types.h> 316# include <sys/time.h> 317# include <sys/ioctl.h> 318# ifdef HAVE_SYS_IOCCOM_H 319# include <sys/ioccom.h> 320# endif], 321 [switch (0) { 322 case _IO('A', 1):; 323 case _IO('B', 1):; 324 }], 325 ac_cv_lbl_gcc_fixincludes=yes, 326 ac_cv_lbl_gcc_fixincludes=no)) 327 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes) 328 if test $ac_cv_lbl_gcc_fixincludes = no ; then 329 # Don't cache failure 330 unset ac_cv_lbl_gcc_fixincludes 331 AC_MSG_ERROR(see the INSTALL for more info) 332 fi 333 fi]) 334 335dnl 336dnl Check for flex, default to lex 337dnl Require flex 2.4 or higher 338dnl Check for bison, default to yacc 339dnl Default to lex/yacc if both flex and bison are not available 340dnl Define the yy prefix string if using flex and bison 341dnl 342dnl usage: 343dnl 344dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) 345dnl 346dnl results: 347dnl 348dnl $1 (lex set) 349dnl $2 (yacc appended) 350dnl $3 (optional flex and bison -P prefix) 351dnl 352AC_DEFUN(AC_LBL_LEX_AND_YACC, 353 [AC_ARG_WITH(flex, [ --without-flex don't use flex]) 354 AC_ARG_WITH(bison, [ --without-bison don't use bison]) 355 if test "$with_flex" = no ; then 356 $1=lex 357 else 358 AC_CHECK_PROGS($1, flex, lex) 359 fi 360 if test "$$1" = flex ; then 361 # The -V flag was added in 2.4 362 AC_MSG_CHECKING(for flex 2.4 or higher) 363 AC_CACHE_VAL(ac_cv_lbl_flex_v24, 364 if flex -V >/dev/null 2>&1; then 365 ac_cv_lbl_flex_v24=yes 366 else 367 ac_cv_lbl_flex_v24=no 368 fi) 369 AC_MSG_RESULT($ac_cv_lbl_flex_v24) 370 if test $ac_cv_lbl_flex_v24 = no ; then 371 s="2.4 or higher required" 372 AC_MSG_WARN(ignoring obsolete flex executable ($s)) 373 $1=lex 374 fi 375 fi 376 if test "$with_bison" = no ; then 377 $2=yacc 378 else 379 AC_CHECK_PROGS($2, bison, yacc) 380 fi 381 if test "$$2" = bison ; then 382 $2="$$2 -y" 383 fi 384 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then 385 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) 386 $1=lex 387 $2=yacc 388 fi 389 if test "$$1" = flex -a -n "$3" ; then 390 $1="$$1 -P$3" 391 $2="$$2 -p $3" 392 fi]) 393 394dnl 395dnl Checks to see if union wait is used with WEXITSTATUS() 396dnl 397dnl usage: 398dnl 399dnl AC_LBL_UNION_WAIT 400dnl 401dnl results: 402dnl 403dnl DECLWAITSTATUS (defined) 404dnl 405AC_DEFUN(AC_LBL_UNION_WAIT, 406 [AC_MSG_CHECKING(if union wait is used) 407 AC_CACHE_VAL(ac_cv_lbl_union_wait, 408 AC_TRY_COMPILE([ 409# include <sys/types.h> 410# include <sys/wait.h>], 411 [int status; 412 u_int i = WEXITSTATUS(status); 413 u_int j = waitpid(0, &status, 0);], 414 ac_cv_lbl_union_wait=no, 415 ac_cv_lbl_union_wait=yes)) 416 AC_MSG_RESULT($ac_cv_lbl_union_wait) 417 if test $ac_cv_lbl_union_wait = yes ; then 418 AC_DEFINE(DECLWAITSTATUS,union wait) 419 else 420 AC_DEFINE(DECLWAITSTATUS,int) 421 fi]) 422 423dnl 424dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member 425dnl 426dnl usage: 427dnl 428dnl AC_LBL_SOCKADDR_SA_LEN 429dnl 430dnl results: 431dnl 432dnl HAVE_SOCKADDR_SA_LEN (defined) 433dnl 434AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, 435 [AC_CHECK_MEMBERS(struct sockaddr.sa_len,,,[ 436# include <sys/types.h> 437# include <sys/socket.h>])]) 438 439dnl 440dnl Makes sure socklen_t is defined 441dnl 442dnl usage: 443dnl 444dnl AC_LBL_SOCKLEN_T 445dnl 446dnl results: 447dnl 448dnl socklen_t (defined if missing) 449dnl 450AC_DEFUN(AC_LBL_SOCKLEN_T, 451 [AC_MSG_CHECKING(for socklen_t in sys/socket.h using $CC) 452 AC_CACHE_VAL(ac_cv_lbl_socklen_t, 453 AC_TRY_COMPILE([ 454# include "confdefs.h" 455# include <sys/types.h> 456# include <sys/socket.h> 457# if STDC_HEADERS 458# include <stdlib.h> 459# include <stddef.h> 460# endif], 461 [socklen_t i], 462 ac_cv_lbl_socklen_t=yes, 463 ac_cv_lbl_socklen_t=no)) 464 AC_MSG_RESULT($ac_cv_lbl_socklen_t) 465 if test $ac_cv_lbl_socklen_t = no ; then 466 AC_DEFINE(socklen_t, int, [Define socklen_t if missing]) 467 fi]) 468 469dnl 470dnl Checks to see if the IFF_LOOPBACK exists as a define or enum 471dnl 472dnl (stupidly some versions of linux use an enum...) 473dnl 474dnl usage: 475dnl 476dnl AC_LBL_IFF_LOOPBACK 477dnl 478dnl results: 479dnl 480dnl HAVE_IFF_LOOPBACK (defined) 481dnl 482AC_DEFUN(AC_LBL_IFF_LOOPBACK, 483 [AC_MSG_CHECKING(for IFF_LOOPBACK define/enum) 484 AC_CACHE_VAL(ac_cv_lbl_have_iff_loopback, 485 AC_TRY_COMPILE([ 486# include <sys/param.h> 487# include <sys/file.h> 488# include <sys/ioctl.h> 489# include <sys/socket.h> 490# ifdef HAVE_SYS_SOCKIO_H 491# include <sys/sockio.h> 492# endif 493# include <sys/time.h> 494# include <net/if.h> 495# include <netinet/in.h>], 496 [int i = IFF_LOOPBACK], 497 ac_cv_lbl_have_iff_loopback=yes, 498 ac_cv_lbl_have_iff_loopback=no)) 499 AC_MSG_RESULT($ac_cv_lbl_have_iff_loopback) 500 if test $ac_cv_lbl_have_iff_loopback = yes ; then 501 AC_DEFINE(HAVE_IFF_LOOPBACK,, [Have IFF_LOOPBACK define/enum]) 502 fi]) 503 504dnl 505dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless. 506dnl 507dnl usage: 508dnl 509dnl AC_LBL_CHECK_TYPE 510dnl 511dnl results: 512dnl 513dnl int32_t (defined) 514dnl u_int32_t (defined) 515dnl 516AC_DEFUN(AC_LBL_CHECK_TYPE, 517 [AC_MSG_CHECKING(for $1 using $CC) 518 AC_CACHE_VAL(ac_cv_lbl_have_$1, 519 AC_TRY_COMPILE([ 520# include "confdefs.h" 521# include <sys/types.h> 522# if STDC_HEADERS 523# include <stdlib.h> 524# include <stddef.h> 525# endif], 526 [$1 i], 527 ac_cv_lbl_have_$1=yes, 528 ac_cv_lbl_have_$1=no)) 529 AC_MSG_RESULT($ac_cv_lbl_have_$1) 530 if test $ac_cv_lbl_have_$1 = no ; then 531 AC_DEFINE($1, $2, Define $1) 532 fi]) 533 534dnl 535dnl Checks to see if unaligned memory accesses fail 536dnl 537dnl usage: 538dnl 539dnl AC_LBL_UNALIGNED_ACCESS 540dnl 541dnl results: 542dnl 543dnl LBL_ALIGN (DEFINED) 544dnl 545AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, 546 [AC_MSG_CHECKING(if unaligned accesses fail) 547 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, 548 [case "$target_cpu" in 549 550 alpha|hp*|mips|sparc) 551 ac_cv_lbl_unaligned_fail=yes 552 ;; 553 554 *) 555 cat >conftest.c <<EOF 556# include <sys/types.h> 557# include <sys/wait.h> 558# include <stdio.h> 559 unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; 560 main() { 561 unsigned int i; 562 pid_t pid; 563 int status; 564 /* avoid "core dumped" message */ 565 pid = fork(); 566 if (pid < 0) 567 exit(2); 568 if (pid > 0) { 569 /* parent */ 570 pid = waitpid(pid, &status, 0); 571 if (pid < 0) 572 exit(3); 573 exit(!WIFEXITED(status)); 574 } 575 /* child */ 576 i = *(unsigned int *)&a[[1]]; 577 printf("%d\n", i); 578 exit(0); 579 } 580EOF 581 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ 582 conftest.c $LIBS >/dev/null 2>&1 583 if test ! -x conftest ; then 584 dnl failed to compile for some reason 585 ac_cv_lbl_unaligned_fail=yes 586 else 587 ./conftest >conftest.out 588 if test ! -s conftest.out ; then 589 ac_cv_lbl_unaligned_fail=yes 590 else 591 ac_cv_lbl_unaligned_fail=no 592 fi 593 fi 594 rm -f conftest* core core.conftest 595 ;; 596 esac]) 597 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) 598 if test $ac_cv_lbl_unaligned_fail = yes ; then 599 AC_DEFINE(LBL_ALIGN) 600 fi]) 601 602dnl 603dnl add all warning option to CFLAGS 604dnl 605dnl usage: 606dnl 607dnl AC_LBL_CHECK_WALL(copt) 608dnl 609dnl results: 610dnl 611dnl $1 (copt appended) 612dnl ac_cv_lbl_gcc_vers 613dnl 614AC_DEFUN(AC_LBL_CHECK_WALL, 615 [ if test "$GCC" = yes ; then 616 if test "$SHLICC2" = yes ; then 617 ac_cv_lbl_gcc_vers=2 618 $1="`echo $$1 | sed -e 's/-O/-O3/'`" 619 else 620 AC_MSG_CHECKING(gcc version) 621 AC_CACHE_VAL(ac_cv_lbl_gcc_vers, 622 # Gag, the gcc folks keep changing the output... 623 # try to grab N.N.N 624 ac_cv_lbl_gcc_vers=`$CC --version 2>&1 | 625 sed -e '1!d' -e 's/[[[^0-9]]]*\([[[0-9]]][[[0-9]]]*\)\.[[[0-9\]]][[[0-9]]]*\.[[[0-9]]][[[0-9]]]*.*/\1/'`) 626 AC_MSG_RESULT($ac_cv_lbl_gcc_vers) 627 if test "$ac_cv_lbl_gcc_vers" -gt 1 ; then 628 $1="`echo $$1 | sed -e 's/-O/-O3/'`" 629 fi 630 fi 631 if test "$ac_cv_prog_cc_g" = yes ; then 632 $1="-g $$1" 633 fi 634 $1="$$1 -Wall" 635 if test "$ac_cv_lbl_gcc_vers" -gt 1 ; then 636 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes" 637 if [[ "`uname -s`" = "FreeBSD" ]]; then 638 $1="$$1 -Werror" 639 fi 640 fi 641 else 642 case "$target_os" in 643 644 irix6*) 645 $1="$$1 -fullwarn -n32" 646 ;; 647 648 *) 649 ;; 650 esac 651 fi]) 652 653dnl 654dnl If using gcc and the file .devel exists: 655dnl Compile with -g (if supported) and -Wall 656dnl If using gcc 2, do extra prototype checking 657dnl If an os prototype include exists, symlink os-proto.h to it 658dnl 659dnl usage: 660dnl 661dnl AC_LBL_DEVEL(copt) 662dnl 663dnl results: 664dnl 665dnl $1 (copt appended) 666dnl HAVE_OS_PROTO_H (defined) 667dnl os-proto.h (symlinked) 668dnl 669AC_DEFUN(AC_LBL_DEVEL,[ 670 AC_BEFORE([$0], [AC_LBL_LD_RUN_PATH]) 671 rm -f os-proto.h 672 if test -f .devel ; then 673 AC_LBL_CHECK_WALL($1) 674 os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'` 675 name="lbl/os-$os.h" 676 if test -f $name ; then 677 ln -s $name os-proto.h 678 AC_DEFINE(HAVE_OS_PROTO_H,,[have os-proto.h]) 679 else 680 AC_MSG_WARN(can't find $name) 681 fi 682 fi]) 683 684dnl 685dnl Improved version of AC_CHECK_LIB 686dnl 687dnl Thanks to John Hawkinson (jhawk@mit.edu) 688dnl 689dnl usage: 690dnl 691dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, 692dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) 693dnl 694dnl results: 695dnl 696dnl LIBS 697dnl 698 699define(AC_LBL_CHECK_LIB, 700[AC_MSG_CHECKING([for $2 in -l$1]) 701dnl Use a cache variable name containing both the library and function name, 702dnl because the test really is for library $1 defining function $2, not 703dnl just for library $1. Separate tests with the same $1 and different $2's 704dnl may have different results. 705ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'` 706AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var, 707[ac_save_LIBS="$LIBS" 708LIBS="-l$1 $5 $LIBS" 709AC_TRY_LINK(dnl 710ifelse([$2], [main], , dnl Avoid conflicting decl of main. 711[/* Override any gcc2 internal prototype to avoid an error. */ 712]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus 713extern "C" 714#endif 715])dnl 716[/* We use char because int might match the return type of a gcc2 717 builtin and then its argument prototype would still apply. */ 718char $2(); 719]), 720 [$2()], 721 eval "ac_cv_lbl_lib_$ac_lib_var=yes", 722 eval "ac_cv_lbl_lib_$ac_lib_var=no") 723LIBS="$ac_save_LIBS" 724])dnl 725if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then 726 AC_MSG_RESULT(yes) 727 ifelse([$3], , 728[changequote(, )dnl 729 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ 730 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` 731changequote([, ])dnl 732 AC_DEFINE_UNQUOTED($ac_tr_lib) 733 LIBS="-l$1 $LIBS" 734], [$3]) 735else 736 AC_MSG_RESULT(no) 737ifelse([$4], , , [$4 738])dnl 739fi 740]) 741 742dnl 743dnl AC_LBL_LIBRARY_NET 744dnl 745dnl This test is for network applications that need socket() and 746dnl gethostbyname() -ish functions. Under Solaris, those applications 747dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link 748dnl with "-lnsl" but should *not* link with "-lsocket" because 749dnl libsocket.a breaks a number of things (for instance: 750dnl gethostbyname() under IRIX 5.2, and snoop sockets under most 751dnl versions of IRIX). 752dnl 753dnl Unfortunately, many application developers are not aware of this, 754dnl and mistakenly write tests that cause -lsocket to be used under 755dnl IRIX. It is also easy to write tests that cause -lnsl to be used 756dnl under operating systems where neither are necessary (or useful), 757dnl such as SunOS 4.1.4, which uses -lnsl for TLI. 758dnl 759dnl This test exists so that every application developer does not test 760dnl this in a different, and subtly broken fashion. 761 762dnl It has been argued that this test should be broken up into two 763dnl seperate tests, one for the resolver libraries, and one for the 764dnl libraries necessary for using Sockets API. Unfortunately, the two 765dnl are carefully intertwined and allowing the autoconf user to use 766dnl them independantly potentially results in unfortunate ordering 767dnl dependancies -- as such, such component macros would have to 768dnl carefully use indirection and be aware if the other components were 769dnl executed. Since other autoconf macros do not go to this trouble, 770dnl and almost no applications use sockets without the resolver, this 771dnl complexity has not been implemented. 772dnl 773dnl The check for libresolv is in case you are attempting to link 774dnl statically and happen to have a libresolv.a lying around (and no 775dnl libnsl.a). 776dnl 777AC_DEFUN(AC_LBL_LIBRARY_NET, [ 778 # Most operating systems have gethostbyname() in the default searched 779 # libraries (i.e. libc): 780 AC_CHECK_FUNC(gethostbyname, , 781 # Some OSes (eg. Solaris) place it in libnsl: 782 AC_CHECK_LIB(nsl, gethostbyname, , 783 # Some strange OSes (SINIX) have it in libsocket: 784 AC_CHECK_LIB(socket, gethostbyname, , 785 # Unfortunately libsocket sometimes depends on libnsl. 786 # AC_CHECK_LIB's API is essentially broken so the 787 # following ugliness is necessary: 788 AC_CHECK_LIB(socket, gethostbyname, 789 LIBS="-lsocket -lnsl $LIBS", 790 AC_CHECK_LIB(resolv, gethostbyname), 791 -lnsl)))) 792 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, , 793 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , 794 -lnsl))) 795 # DLPI needs putmsg under HPUX so test for -lstr while we're at it 796 AC_CHECK_LIB(str, putmsg) 797 ]) 798 799dnl 800dnl AC_LBL_RUN_PATH 801dnl 802dnl Extracts -L directories from LIBS; if any are found they are 803dnl converted to a LD_RUN_PATH and put in V_ENVIRONMENT 804dnl 805dnl usage: 806dnl 807dnl AC_LBL_RUN_PATH 808dnl 809dnl results: 810dnl 811dnl V_ENVIRONMENT 812dnl 813AC_DEFUN(AC_LBL_LD_RUN_PATH, [ 814 AC_MSG_CHECKING(LD_RUN_PATH) 815 AC_SUBST(V_ENVIRONMENT) 816 dnl 817 dnl Split out -L directories 818 dnl 819 ldirs="" 820 for x in ${LIBS}; do 821 case x${x} in 822 823 x-L*) 824 ldirs="${ldirs} ${x}" 825 ;; 826 827 *) 828 ;; 829 esac 830 done 831 832 dnl 833 dnl Build LD_RUN_PATH 834 dnl 835 if test -n "${ldirs}"; then 836 V_ENVIRONMENT="LD_RUN_PATH=\"`echo \"${ldirs}\" | sed -e 's,-L,,g' -e 's,^ *,,' -e 's, ,:,g'`\"" 837 AC_MSG_RESULT(${V_ENVIRONMENT}) 838 else 839 AC_MSG_RESULT(empty) 840 fi]) 841 842dnl 843dnl AC_LBL_BROCCOLI 844dnl 845dnl Include Broccoli support 846dnl 847dnl usage: 848dnl 849dnl AC_LBL_BROCCOLI(copt, incls, [min-vers]) 850dnl 851dnl results: 852dnl 853dnl $1 (copt variable appended) 854dnl $2 (incls variable appended) 855dnl $3 minimum version (optional) 856dnl 857AC_DEFUN(AC_LBL_BROCCOLI, [ 858 AC_BEFORE([$0], [AC_LBL_LD_RUN_PATH]) 859 dnl 860 dnl configure flags 861 dnl 862 AC_ARG_WITH([broccoli], 863 [AS_HELP_STRING([--without-broccoli], 864 [disable Broccoli support @<:@default=check@:>@])], 865 ac_cv_with_broccoli=${withval}) 866 dnl 867 dnl Network application libraries 868 dnl 869 AC_LBL_LIBRARY_NET 870 871 AC_MSG_CHECKING(for broccoli) 872 if test "${ac_cv_with_broccoli}" = "" -o \ 873 "${ac_cv_with_broccoli}" = yes ; then 874 cflags="" 875 libs="" 876 dnl 877 dnl Our entire path 878 dnl 879 dirs="`echo ${PATH} | sed -e 's/:/ /g'`" 880 dnl 881 dnl Add in default Bro install bin directory 882 dnl 883 dirs="${dirs} /usr/local/bro/bin" 884 for d in ${dirs}; do 885 if test -x ${d}/broccoli-config ; then 886 broccoli_config_path="${d}/broccoli-config" 887 cflags="`${broccoli_config_path} --cflags`" 888 libs="`${broccoli_config_path} --libs`" 889 break 890 fi 891 done 892 if test -n "${cflags}" ; then 893 ac_cv_have_broccoli=yes 894 else 895 ac_cv_have_broccoli=no 896 fi 897 AC_MSG_RESULT($ac_cv_have_broccoli) 898 if test "${ac_cv_with_broccoli}" = yes -a \ 899 ${ac_cv_have_broccoli} = "no" ; then 900 AC_MSG_ERROR(Broccoli explicitly enabled but not supported) 901 fi 902 else 903 AC_MSG_RESULT([disabled]) 904 fi 905 906 dnl 907 dnl Optionally check for minimum Broccoli version 908 dnl 909 if test "$ac_cv_have_broccoli" = yes -a -n "$3"; then 910 AC_MSG_CHECKING(Broccoli >= $3) 911 BROCCOLI_VERSION="`${broccoli_config_path} --version`" 912 AC_MSG_RESULT(${BROCCOLI_VERSION}) 913 dnl 914 dnl Sort the two versions; the desired version should 915 dnl appear first (or perhaps 1st and 2nd) 916 dnl 917 tvers="`(echo "$3" ; echo ${BROCCOLI_VERSION}) | 918 sort -t. +0 -1n +1 -2n +2 -3n +3 -4n | 919 head -1`" 920 if test "${tvers}" != "$3"; then 921 if test "${ac_cv_with_broccoli}" = yes; then 922 AC_MSG_ERROR(Broccoli $3 or higher is required) 923 fi 924 AC_MSG_NOTICE(Broccoli support disabled) 925 ac_cv_have_broccoli="no" 926 fi 927 fi 928 929 dnl 930 dnl Broccoli ho! 931 dnl 932 if test "$ac_cv_have_broccoli" = yes ; then 933 AC_DEFINE(HAVE_BROCCOLI) 934 dnl 935 dnl Split out -I directories 936 dnl 937 for x in ${cflags}; do 938 case x${x} in 939 940 x-I*) 941 eval "$2=\"\$$2 ${x}\"" 942 ;; 943 944 *) 945 eval "$1=\"\$$1 ${x}\"" 946 ;; 947 esac 948 done 949 950 dnl 951 dnl Add in Broccoli libs 952 dnl 953 LIBS="$LIBS ${libs}" 954 955 dnl 956 dnl Look for the libs in DIR or DIR/lib 957 dnl 958 AC_ARG_WITH([openssl], 959 [AS_HELP_STRING([--with-openssl=DIR], 960 [Use OpenSSL installation in DIR])], 961 [eval "$2=\"-I${withval}/include \$$2\"" 962 for x in ${withval}/lib ${withval}; do 963 if test -r ${x}/libssl.a; then 964 LIBS="-L${x} ${LIBS}" 965 break 966 fi 967 done]) 968 969 dnl 970 dnl -lssl needs to come first on some systems! 971 dnl 972 AC_CHECK_LIB(ssl, OPENSSL_add_all_algorithms_conf, 973 [LIBS="${LIBS} -lssl -lcrypto"],,-lcrypto) 974 dnl 975 dnl Newer versions of 1.4.0 and anything higher needs bro_init() 976 dnl 977 AC_CHECK_LIB(broccoli, bro_init, [AC_DEFINE(HAVE_BRO_INIT)]) 978 fi]) 979