1 dnl @(#) Id: aclocal.m4 616 2009-10-10 00:08:08Z leres (LBL)
3 dnl Copyright (c) 2008, 2009
4 dnl The Regents of the University of California. All rights reserved.
6 dnl Redistribution and use in source and binary forms, with or without
7 dnl modification, are permitted provided that: (1) source code distributions
8 dnl retain the above copyright notice and this paragraph in its entirety, (2)
9 dnl distributions including binary code include the above copyright notice and
10 dnl this paragraph in its entirety in the documentation or other materials
11 dnl provided with the distribution, and (3) all advertising materials mentioning
12 dnl features or use of this software display the following acknowledgement:
13 dnl ``This product includes software developed by the University of California,
14 dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 dnl the University nor the names of its contributors may be used to endorse
16 dnl or promote products derived from this software without specific prior
17 dnl written permission.
18 dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 dnl LBL autoconf macros
26 dnl Determine which compiler we're using (cc or gcc)
27 dnl If using gcc, determine the version number
28 dnl If using cc, require that it support ansi prototypes
29 dnl If using gcc, use -O3 (otherwise use -O)
30 dnl If using cc, explicitly specify /usr/local/include
34 dnl AC_LBL_C_INIT(copt, incls)
43 AC_DEFUN(AC_LBL_C_INIT,
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
55 if test "${ac_cv_without_optimization+set}" != set; then
59 if test "${srcdir}" != "." ; then
62 if test -z "$CC" ; then
66 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
67 if test $SHLICC2 = yes ; then
74 if test -z "$CC" -a "$with_gcc" = no ; then
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,
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
93 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
95 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
96 AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
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)
106 CFLAGS="$savedcflags"
108 AC_DEFINE(_HPUX_SOURCE,,[HP-UX ansi compiler])
112 AC_MSG_ERROR(see the INSTALL doc for more info)
116 $2="$$2 -I/usr/local/include"
117 LDFLAGS="$LDFLAGS -L/usr/local/lib"
122 $1="$$1 -xansi -signed -g3"
130 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
131 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
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])
147 AC_LBL_ENABLE_CHECK(brov6 activemapping expire-dfa-states)
149 dnl This allows us to check for bogus configure enable/disable
150 dnl command line options
154 dnl AC_LBL_ENABLE_CHECK(opt ...)
156 AC_DEFUN(AC_LBL_ENABLE_CHECK,
158 sed -n -e 's/^enable_\([[^=]]*\)=[[^=]]*$/\1/p' |
162 if test "${o}" = "${var}" ; then
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})
173 if test $? -ne 0 ; then
178 dnl Use pfopen.c if available and pfopen() not in standard libraries
180 dnl Look for libpcap in ..
181 dnl Use the installed libpcap if there is no local version
185 dnl AC_LBL_LIBPCAP(pcapdep, incls)
190 dnl $2 (incls appended)
195 AC_DEFUN(AC_LBL_LIBPCAP,
196 [AC_REQUIRE([AC_LBL_LIBRARY_NET])
198 dnl save a copy before locating libpcap.a
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)
209 AC_MSG_CHECKING(for local pcap library)
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
221 if test -r $dir/pcap.c ; then
222 libpcap=$dir/libpcap.a
224 dnl continue and select the last one that exists
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)
239 $2="$$2 -I/usr/local/include"
245 AC_MSG_RESULT($libpcap)
247 if test "x$libpcap" != "x-lpcap" ; then
248 LIBS="$libpcap $LIBS"
253 pseexe="/lib/pse.exp"
254 AC_MSG_CHECKING(for $pseexe)
255 if test -f $pseexe ; then
257 LIBS="$LIBS -I:$pseexe"
263 dnl Define RETSIGTYPE and RETSIGVAL
267 dnl AC_LBL_TYPE_SIGNAL
271 dnl RETSIGTYPE (defined)
272 dnl RETSIGVAL (defined)
274 AC_DEFUN(AC_LBL_TYPE_SIGNAL,
275 [AC_BEFORE([$0], [AC_LBL_LIBPCAP])
277 if test "$ac_cv_type_signal" = void ; then
278 AC_DEFINE(RETSIGVAL,,[signal function return value])
280 AC_DEFINE(RETSIGVAL,(0))
285 AC_DEFINE(_BSD_SIGNALS,,[irix's BSD style signals])
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()])
294 AC_CHECK_FUNCS(sigaction)
300 dnl If using gcc, make sure we have ANSI ioctl definitions
304 dnl AC_LBL_FIXINCLUDES
306 AC_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,
312 * This generates a "duplicate case value" when fixincludes
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>
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)
336 dnl Check for flex, default to lex
337 dnl Require flex 2.4 or higher
338 dnl Check for bison, default to yacc
339 dnl Default to lex/yacc if both flex and bison are not available
340 dnl Define the yy prefix string if using flex and bison
344 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
349 dnl $2 (yacc appended)
350 dnl $3 (optional flex and bison -P prefix)
352 AC_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
358 AC_CHECK_PROGS($1, flex, lex)
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
367 ac_cv_lbl_flex_v24=no
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))
376 if test "$with_bison" = no ; then
379 AC_CHECK_PROGS($2, bison, yacc)
381 if test "$$2" = bison ; then
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)
389 if test "$$1" = flex -a -n "$3" ; then
395 dnl Checks to see if union wait is used with WEXITSTATUS()
399 dnl AC_LBL_UNION_WAIT
403 dnl DECLWAITSTATUS (defined)
405 AC_DEFUN(AC_LBL_UNION_WAIT,
406 [AC_MSG_CHECKING(if union wait is used)
407 AC_CACHE_VAL(ac_cv_lbl_union_wait,
409 # include <sys/types.h>
410 # include <sys/wait.h>],
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)
420 AC_DEFINE(DECLWAITSTATUS,int)
424 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
428 dnl AC_LBL_SOCKADDR_SA_LEN
432 dnl HAVE_SOCKADDR_SA_LEN (defined)
434 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
435 [AC_CHECK_MEMBERS(struct sockaddr.sa_len,,,[
436 # include <sys/types.h>
437 # include <sys/socket.h>])])
440 dnl Makes sure socklen_t is defined
448 dnl socklen_t (defined if missing)
450 AC_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,
454 # include "confdefs.h"
455 # include <sys/types.h>
456 # include <sys/socket.h>
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])
470 dnl Checks to see if the IFF_LOOPBACK exists as a define or enum
472 dnl (stupidly some versions of linux use an enum...)
476 dnl AC_LBL_IFF_LOOPBACK
480 dnl HAVE_IFF_LOOPBACK (defined)
482 AC_DEFUN(AC_LBL_IFF_LOOPBACK,
483 [AC_MSG_CHECKING(for IFF_LOOPBACK define/enum)
484 AC_CACHE_VAL(ac_cv_lbl_have_iff_loopback,
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>
493 # include <sys/time.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])
505 dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless.
509 dnl AC_LBL_CHECK_TYPE
513 dnl int32_t (defined)
514 dnl u_int32_t (defined)
516 AC_DEFUN(AC_LBL_CHECK_TYPE,
517 [AC_MSG_CHECKING(for $1 using $CC)
518 AC_CACHE_VAL(ac_cv_lbl_have_$1,
520 # include "confdefs.h"
521 # include <sys/types.h>
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)
535 dnl Checks to see if unaligned memory accesses fail
539 dnl AC_LBL_UNALIGNED_ACCESS
543 dnl LBL_ALIGN (DEFINED)
545 AC_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
550 alpha|hp*|mips|sparc)
551 ac_cv_lbl_unaligned_fail=yes
555 cat >conftest.c <<EOF
556 # include <sys/types.h>
557 # include <sys/wait.h>
559 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
564 /* avoid "core dumped" message */
570 pid = waitpid(pid, &status, 0);
573 exit(!WIFEXITED(status));
576 i = *(unsigned int *)&a[[1]];
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
587 ./conftest >conftest.out
588 if test ! -s conftest.out ; then
589 ac_cv_lbl_unaligned_fail=yes
591 ac_cv_lbl_unaligned_fail=no
594 rm -f conftest* core core.conftest
597 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
598 if test $ac_cv_lbl_unaligned_fail = yes ; then
603 dnl add all warning option to CFLAGS
607 dnl AC_LBL_CHECK_WALL(copt)
611 dnl $1 (copt appended)
612 dnl ac_cv_lbl_gcc_vers
614 AC_DEFUN(AC_LBL_CHECK_WALL,
615 [ if test "$GCC" = yes ; then
616 if test "$SHLICC2" = yes ; then
618 $1="`echo $$1 | sed -e 's/-O/-O3/'`"
620 AC_MSG_CHECKING(gcc version)
621 AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
622 # Gag, the gcc folks keep changing the output...
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/'`"
631 if test "$ac_cv_prog_cc_g" = yes ; then
635 if test "$ac_cv_lbl_gcc_vers" -gt 1 ; then
636 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
637 if [[ "`uname -s`" = "FreeBSD" ]]; then
645 $1="$$1 -fullwarn -n32"
654 dnl If using gcc and the file .devel exists:
655 dnl Compile with -g (if supported) and -Wall
656 dnl If using gcc 2, do extra prototype checking
657 dnl If an os prototype include exists, symlink os-proto.h to it
661 dnl AC_LBL_DEVEL(copt)
665 dnl $1 (copt appended)
666 dnl HAVE_OS_PROTO_H (defined)
667 dnl os-proto.h (symlinked)
669 AC_DEFUN(AC_LBL_DEVEL,[
670 AC_BEFORE([$0], [AC_LBL_LD_RUN_PATH])
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/'`
676 if test -f $name ; then
677 ln -s $name os-proto.h
678 AC_DEFINE(HAVE_OS_PROTO_H,,[have os-proto.h])
680 AC_MSG_WARN(can't find $name)
685 dnl Improved version of AC_CHECK_LIB
687 dnl Thanks to John Hawkinson (jhawk@mit.edu)
691 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
692 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
699 define(AC_LBL_CHECK_LIB,
700 [AC_MSG_CHECKING([for $2 in -l$1])
701 dnl Use a cache variable name containing both the library and function name,
702 dnl because the test really is for library $1 defining function $2, not
703 dnl just for library $1. Separate tests with the same $1 and different $2's
704 dnl may have different results.
705 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
706 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
707 [ac_save_LIBS="$LIBS"
710 ifelse([$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
716 [/* We use char because int might match the return type of a gcc2
717 builtin and then its argument prototype would still apply. */
721 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
722 eval "ac_cv_lbl_lib_$ac_lib_var=no")
725 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
729 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
730 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
732 AC_DEFINE_UNQUOTED($ac_tr_lib)
743 dnl AC_LBL_LIBRARY_NET
745 dnl This test is for network applications that need socket() and
746 dnl gethostbyname() -ish functions. Under Solaris, those applications
747 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
748 dnl with "-lnsl" but should *not* link with "-lsocket" because
749 dnl libsocket.a breaks a number of things (for instance:
750 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
751 dnl versions of IRIX).
753 dnl Unfortunately, many application developers are not aware of this,
754 dnl and mistakenly write tests that cause -lsocket to be used under
755 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
756 dnl under operating systems where neither are necessary (or useful),
757 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
759 dnl This test exists so that every application developer does not test
760 dnl this in a different, and subtly broken fashion.
762 dnl It has been argued that this test should be broken up into two
763 dnl seperate tests, one for the resolver libraries, and one for the
764 dnl libraries necessary for using Sockets API. Unfortunately, the two
765 dnl are carefully intertwined and allowing the autoconf user to use
766 dnl them independantly potentially results in unfortunate ordering
767 dnl dependancies -- as such, such component macros would have to
768 dnl carefully use indirection and be aware if the other components were
769 dnl executed. Since other autoconf macros do not go to this trouble,
770 dnl and almost no applications use sockets without the resolver, this
771 dnl complexity has not been implemented.
773 dnl The check for libresolv is in case you are attempting to link
774 dnl statically and happen to have a libresolv.a lying around (and no
777 AC_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),
792 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
793 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
795 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
796 AC_CHECK_LIB(str, putmsg)
802 dnl Extracts -L directories from LIBS; if any are found they are
803 dnl converted to a LD_RUN_PATH and put in V_ENVIRONMENT
813 AC_DEFUN(AC_LBL_LD_RUN_PATH, [
814 AC_MSG_CHECKING(LD_RUN_PATH)
815 AC_SUBST(V_ENVIRONMENT)
817 dnl Split out -L directories
824 ldirs="${ldirs} ${x}"
833 dnl Build LD_RUN_PATH
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})
845 dnl Include Broccoli support
849 dnl AC_LBL_BROCCOLI(copt, incls, [min-vers])
853 dnl $1 (copt variable appended)
854 dnl $2 (incls variable appended)
855 dnl $3 minimum version (optional)
857 AC_DEFUN(AC_LBL_BROCCOLI, [
858 AC_BEFORE([$0], [AC_LBL_LD_RUN_PATH])
862 AC_ARG_WITH([broccoli],
863 [AS_HELP_STRING([--without-broccoli],
864 [disable Broccoli support @<:@default=check@:>@])],
865 ac_cv_with_broccoli=${withval})
867 dnl Network application libraries
871 AC_MSG_CHECKING(for broccoli)
872 if test "${ac_cv_with_broccoli}" = "" -o \
873 "${ac_cv_with_broccoli}" = yes ; then
879 dirs="`echo ${PATH} | sed -e 's/:/ /g'`"
881 dnl Add in default Bro install bin directory
883 dirs="${dirs} /usr/local/bro/bin"
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`"
892 if test -n "${cflags}" ; then
893 ac_cv_have_broccoli=yes
895 ac_cv_have_broccoli=no
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)
903 AC_MSG_RESULT([disabled])
907 dnl Optionally check for minimum Broccoli version
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})
914 dnl Sort the two versions; the desired version should
915 dnl appear first (or perhaps 1st and 2nd)
917 tvers="`(echo "$3" ; echo ${BROCCOLI_VERSION}) |
918 sort -t. +0 -1n +1 -2n +2 -3n +3 -4n |
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)
924 AC_MSG_NOTICE(Broccoli support disabled)
925 ac_cv_have_broccoli="no"
932 if test "$ac_cv_have_broccoli" = yes ; then
933 AC_DEFINE(HAVE_BROCCOLI)
935 dnl Split out -I directories
937 for x in ${cflags}; do
941 eval "$2=\"\$$2 ${x}\""
945 eval "$1=\"\$$1 ${x}\""
951 dnl Add in Broccoli libs
956 dnl Look for the libs in DIR or DIR/lib
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}"
970 dnl -lssl needs to come first on some systems!
972 AC_CHECK_LIB(ssl, OPENSSL_add_all_algorithms_conf,
973 [LIBS="${LIBS} -lssl -lcrypto"],,-lcrypto)
975 dnl Newer versions of 1.4.0 and anything higher needs bro_init()
977 AC_CHECK_LIB(broccoli, bro_init, [AC_DEFINE(HAVE_BRO_INIT)])