dnl Process this file with autoconf to produce a configure script.

dnl $Id: configure.in,v 1.13 2001/02/16 21:16:41 dplonka Exp $
dnl Dave Plonka <plonka@doit.wisc.edu>

AC_INIT(install-sh)
AC_CANONICAL_HOST

if test 'NONE' = "$prefix"
then
   prefix=/usr/local
fi

dnl Checks for programs.

AC_PATH_PROG(FIND_PATH, find)
AC_PATH_PROG(GZIP_PATH, gzip)
AC_PATH_PROG(KSH_PATH, ksh)
if test "$ac_cv_path_KSH_PATH" = ""; then
   AC_MSG_ERROR(ksh not found!)
fi
AC_PATH_PROG(LN_PATH, ln)
AC_PATH_PROG(LS_PATH, ls)
AC_PATH_PROG(MKDIR_PATH, mkdir)

AC_PATH_PROG(PERL_PATH, perl)
if test "$ac_cv_path_PERL_PATH" = ""; then
   AC_MSG_ERROR(perl not found!)
fi
AC_MSG_CHECKING(perl version)
if $PERL_PATH -e 'require 5.004' 1>/dev/null 2>&1; then
   AC_MSG_RESULT(ok)
else
   AC_MSG_RESULT(not)
   AC_PATH_PROG(PERL5_PATH, perl5)
   if test "$ac_cv_path_PERL5_PATH" = ""; then
      AC_MSG_ERROR(perl5 not found either!)
   fi
   AC_MSG_CHECKING(perl5 version)
   if $PERL5_PATH -e 'require 5.004' 1>/dev/null 2>&1; then
      AC_MSG_RESULT(ok)
   else
      AC_MSG_RESULT(not)
      AC_MSG_ERROR(perl5 is not version 5.004.)
   fi
   PERL_PATH=$PERL5_PATH
fi

AC_PATH_PROG(RM_PATH, rm)
AC_PATH_PROG(RCS_PATH, rcs)

AC_PATH_PROG(RRDTOOL_PATH, rrdtool)
if test "$ac_cv_path_RRDTOOL_PATH" = ""; then
   AC_MSG_ERROR(rrdtool not found!)
fi

AC_PATH_PROG(SED_PATH, sed)
AC_PATH_PROG(TAR_PATH, tar)
AC_PATH_PROG(TOUCH_PATH, touch)
AC_PATH_PROG(XARGS_PATH, xargs)

# These are required for util/add_txrx:
AC_PATH_PROG(HEAD_PATH, head)
AC_PATH_PROG(GREP_PATH, grep)
AC_PATH_PROG(MV_PATH, mv)
AC_PATH_PROG(RM_PATH, rm)
AC_PATH_PROG(CP_PATH, cp)

# AC_PROG_INSTALL
# install-sh is more predictable, "installbsd -c" under AIX caused lots of probs
# We enforced that it exists with AC_INIT
INSTALL_SH=`cd $srcdir && pwd`/install-sh
AC_SUBST(INSTALL_SH)

dnl Checks for libraries.

dnl Checks for header files.

if test -z "$perllib"
then
   perllib=.
fi

AC_MSG_CHECKING(for RRDs)
if $PERL_PATH -I$perllib -MRRDs -e 1 1>/dev/null 2>&1; then
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   AC_MSG_ERROR(Must be able to use RRDs!)
fi

AC_MSG_CHECKING(for Boulder::Stream)
if $PERL_PATH -I$perllib -MBoulder::Stream -e 1 1>/dev/null 2>&1; then
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   AC_MSG_ERROR(Must be able to use Boulder::Stream!)
fi

AC_MSG_CHECKING(for Net::Patricia >= 1.010)
if $PERL_PATH -I$perllib -M'Net::Patricia 1.010' -e 1 1>/dev/null 2>&1; then
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   AC_MSG_ERROR(Must have Net::Patricia >= 1.010!)
fi

AC_MSG_CHECKING(for ConfigReader::DirectiveStyle)
if $PERL_PATH -I$perllib -MConfigReader::DirectiveStyle -e 1 1>/dev/null 2>&1; then
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   AC_MSG_ERROR(Must be able to use ConfigReader::DirectiveStyle!)
fi

AC_MSG_CHECKING(for Cflow >= 1.024)
if $PERL_PATH -I$perllib -M'Cflow 1.024' -e 1 1>/dev/null 2>&1; then
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   AC_MSG_ERROR(Must have Cflow >= 1.024!)
fi

AC_MSG_CHECKING(for HTML::Table)
if $PERL_PATH -I$perllib -MHTML::Table -e 1 1>/dev/null 2>&1; then
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   AC_MSG_WARN(Must be able to use HTML::Table for "Top Talker" reports!)
fi

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.

dnl Checks for misc.

AC_MSG_CHECKING(that service name for 80/tcp is http)
if $PERL_PATH -I$perllib -MSocket -e 'exit("http" eq getservbyport(80, "tcp")? 0 : 1)'
then
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
   AC_MSG_ERROR(Please change /etc/services so that the service name for 80/tcp is http with alias www, www-http)
fi

AC_OUTPUT(Makefile flowscan graphs.mf example/crontab util/locker util/add_ds.pl util/add_txrx util/event2vrule util/ip2hostname)
