dnl This is the configure script for the procmail module
AC_INIT(recipes.template)

echo "----------------------------------------------------------------------"
echo "----------------------------------------------------------------------"
echo "Please note that the configure script for procmail has to be run on"
echo "your mailhost! This is important, since the mailhost may have separate"
echo "file systems, and thus have other programs, than your current host!"
echo "If this is not your mail host, please rlogin to it and run"
echo "Modules/procmail/configure on it, or edit Modules/procmail/system.tcl"
echo "accordingly!"
echo "----------------------------------------------------------------------"
echo "----------------------------------------------------------------------"


AC_PATH_PROGS(TCLSH, tclsh7.6 tclsh7.5 tclsh7.4 tclsh, no)
if test "$TCLSH" = no; then
        AC_MSG_ERROR(I couldn't find 'tclsh' please insert it into your pa
th and try again)
fi

AC_PATH_PROGS(FORMAIL, formail,)
if test "$FORMAIL" = ""; then
  AC_MSG_ERROR(I couldn't find the program formail, it should be in the procmail distribution. Please insert it into the path.)
fi

AC_PATH_PROGS(SED,sed,)
if test "$SED" = ""; then
  AC_MSG_ERROR(The program sed was not found, please insert it into your path)
fi

AC_PATH_PROGS(GZIP, gzip,)
if test "$GZIP" = ""; then
  AC_MSG_WARN(The program gzip was not found, some features will be disabled!)
fi

AC_PATH_PROGS(SH,sh ksh bash,)
if test "$SH" = ""; then
  AC_MSG_ERROR(I couldn't find an sh shell. Please insert on into your path)
fi

AC_PATH_PROGS(ECHO, echo,echo)
if test "$ECHO" = "echo"; then
  AC_MSG_WARN(I couldn't find the program echo, the generated code will use echo without a prefix, which requires that it is accesable in the path. It might be a good idea to insert echo into the path and rerun configure!)
fi

AC_PATH_PROGS(CAT, cat,cat)
if test "$CAT" = "cat"; then
  AC_MSG_WARN(I couldn't find the program cat, the generated code will use cat without a prefix, which requires that it is accesable in the path. It might be a good idea to insert cat into the path and rerun configure!)
fi

AC_PATH_PROGS(MKDIR, mkdir,mkdir)
if test "$MKDIR" = "mkdir"; then
  AC_MSG_WARN(I couldn't find the program mkdir, the generated code will use mkdir without a prefix, which requires that it is accesable in the path. It might be a good idea to insert mkdir into the path and rerun configure!)
fi

AC_PATH_PROGS(DIRNAME,dirname,)
if test "$DIRNAME" = ""; then
  AC_MSG_ERROR(I couldn't find the program dirname. Please insert on into your path)
fi

AC_PATH_PROGS(FALSE,false,)
if test "$SH" = ""; then
  AC_MSG_WARN(I couldn't find the program false. It should work fine though.)
fi

echo $ac_n "checking for date..."
DATE=""
IFS="${IFS}:"
for dir in $PATH; do
  if test -f $dir/date; then
    if ($dir/date +%s >> /dev/null) then
      DATE=$dir/date
      break
    fi
  fi
done
if test "$DATE" = ""; then
  echo ""
  echo "I could not find a version of gnu date! One can be found eg. at"
  echo "ftp://prep.ai.mit.edu:/pub/gnu/sh-utils-1.16.tar.gz."
  echo "If you have very good reason, not to have this installed, please mail me"
  echo "(blackie@imada.ou.dk) and I'll reconsider this requirement"
  AC_MSG_ERROR(gnu date not found)
else
  echo $DATE
fi
AC_SUBST(DATE)

AC_OUTPUT(system.tcl logcheck filter mkdirhier)
chmod 755 logcheck
chmod 755 filter
chmod 755 mkdirhier
rm config.cache
