dnl
dnl SellaNMS
dnl $Id: configure.in,v 2.83 2005/08/09 05:34:15 sella Exp $
dnl Copyright (c) 2001-2004 Digital Genesis Software. All Rights Reserved.
dnl Released under the GPL Version 2 License.
dnl http://www.digitalgenesis.com
dnl

dnl Redefine AC_REVISION to print some copyright info. (Borrowed from OpenLDAP)
define([AC_REVISION], [
term_norm=`./shtool echo -n -e %b`
term_bold=`./shtool echo -n -e %B`

echo "${term_bold}SellaNMS by James M. Sella and William T. Sella <sellanms@digitalgenesis.com>"
echo "Copyright (c) 2001-2005 Digital Genesis Software. All Rights Reserved."
echo "Released under the GPL Version 2 License.${term_norm}"
echo ""
])

dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.13)
AC_INIT(SellaNMS, v2.0.0, sellanms@digitalgenesis.com, sella_nms)
AC_COPYRIGHT([Copyright (c) 2001-2005 Digital Genesis Software. All Rights Reserved.])
AC_REVISION($Revision: 2.83 $)
AC_CANONICAL_SYSTEM
AC_CONFIG_HEADER(config.h)
AC_PREFIX_DEFAULT(/usr/local/sella_nms)

dnl Set up some operating system specific options (Borrowed from Licq)
case "$host" in
	*-*-linux*)
		CPPFLAGS="$CPPFLAGS -fPIC -DPIC -D_REENTRANT"
		echo "Setting Linux compilation options"
		;;
	*-*-freebsd*)
		CFLAGS="$CFLAGS -pthread"
		CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
		CXXFLAGS="$CXXFLAGS -pthread"
		echo "Setting FreeBSD compilation options"
		;;
	*-*-openbsd*)
		CFLAGS="$CFLAGS -pthread"
		CPPFLAGS="$CPPFLAGS -D_REENTRANT"
		CXXFLAGS="$CXXFLAGS -pthread"
		echo "Setting OpenBSD compilation options"
		;;
	*-*-solaris*)
		CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_SOLARIS -DPIC -fPIC"
		echo "Setting Solaris compilation options"
		;;
        *-*-aix*)
		CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
		LIBS="$LIBS -lc_r"
		echo "Setting AIX compilation options"
		;;
	*)
		echo "Unknown operating system. ${PACKAGE_NAME} might not compile on this system."
		CPPFLAGS="$CPPFLAGS -fPIC -DPIC -D_REENTRANT"
		;;
esac

dnl Checks for programs.
BOLD_MSG([Checking programs...])
AC_PROG_CC
AC_PROG_CXX
AC_CHECK_CXXVER
AC_PROG_CPP
AC_WITH_MARCH
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib, :)
dnl AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PATH_PROG(STRIP, strip, :, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(MKDIR, mkdir, :, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(FIND, find, find, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(TEST, test, test, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(HEAD, head, head, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(XARGS, xargs, xargs, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(WC, wc, wc, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(RM, rm, rm, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(CP, cp, cp, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(MV, mv, mv, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(SED, sed, sed, $PATH:/bin:/usr/bin:/usr/local/bin)
AC_PATH_PROG(CHKCONFIG, chkconfig, chkconfig, $PATH:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin)

dnl Checks for header files.
BOLD_MSG([Checking system characteristics...])
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h sys/time.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_FUNC_MEMCMP

dnl SellaNMS specific options
BOLD_MSG([Checking ${PACKAGE_NAME} specific options...])
AC_CHECK_DISCOVERY
AC_CHECK_MONITOR
AC_CHECK_OUTPUT
AC_CHECK_DUMMY
AC_CHECK_STATIC
AC_CHECK_DEBUG
AC_CHECK_PROFILE
AC_CHECK_SETPROCTITLE
AC_CHECK_INITSCRIPT
AC_CHECK_ARENA
AC_CHECK_STLP_SAFE_STL
AC_WITH_STLPORT
AC_CHECK_SELLA_NMS_OPTIONS
AC_RESOLVE_CONFIGURE_PATHS

dnl Checks for libraries.
BOLD_MSG([Checking libraries...])
AC_CHECK_LIB(dl, dlsym)
AC_CHECK_LIB(pthread, pthread_create)
AC_CHECK_LIB(stdc, main)
AC_CHECK_LIBUCDSNMP
AC_CHECK_LIBDBI
dnl AC_WITH_HOARD
dnl AC_WITH_CCMALLOC
dnl AC_WITH_DMALLOC
dnl AM_WITH_MPATROL

dnl Prefix Hack - Start
if test "x${prefix}" = "xNONE"; then
  real_prefix="${ac_default_prefix}"
else
  real_prefix="${prefix}"
fi
prefix="@prefix_hack@"
prefix_hack="@prefix@"
AC_SUBST(real_prefix)
AC_SUBST(prefix_hack)
dnl Prefix Hack - End

BOLD_MSG([Generating files...])
AC_SUBST(term_norm)
AC_SUBST(term_bold)
AC_OUTPUT(Makefile libs/Makefile libs/common/Makefile libs/state/Makefile libs/storage/Makefile libs/policy_framework/Makefile libs/configuration/Makefile libs/configuration/flatfile/Makefile discovery/Makefile discovery/icmp/Makefile discovery/snmp/Makefile discovery/topology/Makefile monitor/Makefile monitor/icmp/Makefile monitor/state/Makefile monitor/snmptrap/Makefile monitor/syslog/Makefile output/Makefile output/tidy/Makefile output/gui/Makefile output/syslog/Makefile output/email/Makefile watchdog/Makefile daemon/Makefile ../html/config/config.php ../support/sella_nms.conf ../support/policy-statements.conf ../support/format-statements.conf ../support/map-statements.conf ../support/policy.d/arbor.conf ../support/policy.d/bgp.conf ../support/policy.d/cisco.conf ../support/policy.d/extreme.conf ../support/policy.d/juniper.conf ../support/policy.d/netscreen.conf ../support/policy.d/netsnmp.conf ../support/policy.d/ospf.conf ../support/admin-sella_nms.sh ../support/sella_nms-mysql.sql ../support/sella_nms.init.d ../support/sella_nms.man ../support/sella_nms.conf.man ../support/policy-statements.conf.man ../support/format-statements.conf.man ../support/map-statements.conf.man)
BOLD_MSG([${PACKAGE_STRING} - http://www.digitalgenesis.com])
echo "
Configuration Options:

  compiler    : $CXX
  debug       : $WITH_DEBUG
  proctitle   : $WITH_SETPROCTITLE
  init-script : $WITH_INITSCRIPT
  arena mem   : $WITH_ARENA
  stlport     : $WITH_STLPORT $STLPORT
  snmp        : $WITH_SNMP
  libdbi      : $WITH_DBI

Install Locations:

  prefix      : $real_prefix
  daemon dir  : $resolved_sbindir
  config dir  : $resolved_sysconfdir
  data dir    : $resolved_datadir
  state dir   : $resolved_localstatedir
  Web GUI     : $resolved_htmldir

Database Options:

  Server      : $sella_nms_server
  Port        : $sella_nms_port
  Database    : $sella_nms_database
  Username    : $sella_nms_username
  Password    : $sella_nms_password"
BOLD_MSG([Run 'make all' followed by 'make install'.])
