home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / hf-1.2.tar.gz / hf-1.2.tar / hf-1.2 / aclocal.m4 next >
M4 Source File  |  2009-12-13  |  25KB  |  980 lines

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