home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / ipsearch-1.0.tar.gz / ipsearch-1.0.tar / ipsearch-1.0 / aclocal.m4 next >
M4 Source File  |  2011-07-06  |  25KB  |  981 lines

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