dnl Process this file with autoconf to produce a configure script.
dnl configure.in for sys-mon created by torbjorn-sysmon@EU.net
dnl modified by jared mauch (jared@puck.nether.net)

dnl initialize
AC_INIT(src/config.h)
AC_CONFIG_HEADER(src/defines.h:autoconf/defines.h.in)
AC_PREREQ(2.10)
AC_PREFIX_DEFAULT(/usr/local)
AC_CONFIG_AUX_DIR(autoconf)
AC_PROG_MAKE_SET

dnl some new options to configure
#AC_ARG_ENABLE(ssl, [ --disable-ssl  don't support ssl], , enable_ssl=yes)
AC_ARG_ENABLE(mail, [ --disable-mail  don't support mail], , enable_mail=yes)
AC_ARG_ENABLE(clients, [ --disable-clients  no clients], , enable_clients=yes)
AC_ARG_ENABLE(daemon, [ --disable-daemon  no daemon], , enable_daemon=yes)

dnl find some programs
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PATH_PROGS(SENDMAIL, sendmail, no, $PATH:/usr/sbin:/usr/lib)

dnl find some libraries
AC_CHECK_LIB(curses, refresh)
AC_CHECK_LIB(ncurses, refresh)
AC_CHECK_LIB(nsl, inet_ntoa)
AC_CHECK_LIB(socket, getpeername)
AC_CHECK_LIB(resolv, gethostname)
#AC_CHECK_LIB(c, snprintf, SNP="-DHAVE_SNPRINTF")
AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF))
AC_CHECK_LIB(bsd, revoke)
#AC_CHECK_LIB(ssl, main, SSL="-DHAVE_SSL -I/usr/local/ssl/include")

dnl some checks
if test "$SENDMAIL" = no; then
	AC_MSG_WARN(without sendmail there is no support for alert messages)
	SENDMAIL=-DMAIL=''
else
	SENDMAIL=-DMAIL='"'$SENDMAIL'"'
fi
#if test -z "$SSL" ; then
#	AC_MSG_WARN(without SSLeay there is no support for https://)
#else
#	LIBS="$LIBS -lssl -lcrypto"
#fi
if test "$enable_daemon" = yes; then
	PROGS="$PROGS sysmond"
else
	AC_MSG_WARN(daemon not compiled on user request)
fi
if test "$enable_clients" = yes; then
	PROGS="$PROGS block sysmon"
else
	AC_MSG_WARN(clients not compiled on user request)
fi


dnl need these
#AC_SUBST(SSL)
AC_SUBST(SENDMAIL)
AC_SUBST(PROGS)

dnl write out the Makefile
AC_OUTPUT(src/Makefile:autoconf/Makefile.in)

dnl write out some helpful text
cat <<EOT

Configuration complete, now:
cd src
make 
make install

Then read ALL the documentation in docs/ :)

If this is your first time using sysmon, please register it.  That can
be done by typing:
make register

If you have problems, or have questions that are not in the docs,
send e-mail to sysmon@puck.nether.net
EOT
