dnl Edit in -*- shell-script -*- mode
dnl
dnl Copyright (C) 2000 by Kevin L. Mitchell <klmitch@mit.edu>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
dnl
dnl @(#)$Id: configure.in,v 1.5 2000/08/09 19:17:47 klmitch Exp $

AC_INIT(lib/hornet/hornet_int.h)
AM_INIT_AUTOMAKE(hornet, 0.1)
AM_CONFIG_HEADER(config.h)

# $prefix can == NONE--very annoying :/
if test "x${prefix}" = xNONE; then
    subs_prefix=/usr/local
else
    subs_prefix=${prefix}
fi

# $exec_prefix can also == NONE
if test "x${exec_prefix}" = xNONE; then
    subs_exec_prefix=${subs_prefix}
else
    subs_exec_prefix=${exec_prefix}
fi

dnl Checks for options
AC_ARG_WITH(search,
[  --with-search=<path>    specifies the default config file search path],
[AC_MSG_CHECKING([for default config file search path])
if test "x${withval}" != "xyes"; then
    horn_cv_option_search="${withval}"
fi
AC_MSG_RESULT([$horn_cv_option_search])
],
[AC_CACHE_CHECK([for default config file search path], horn_cv_option_search,
[# temporarily store the final prefix for evaluation of sysconfdir...
save_prefix=${prefix}
prefix=${subs_prefix}

# eval sysconfdir and reset the prefix
t_sysconfdir=`eval echo "${sysconfdir}"`
prefix=${save_prefix}

# finally, set the search path...
horn_cv_option_search="${t_sysconfdir}/hornet.conf:~/.hornetrc"
])])

AC_DEFINE_UNQUOTED(HORN_DEFAULT_CONF, "${horn_cv_option_search}",
[
   Default path to search for the config file; all files found will be read
   in order, and later directives will override earlier directives.
])

# temporarily store the final exec_prefix for evaluation of libdir
save_exec_prefix=${exec_prefix}
exec_prefix=${subs_exec_prefix}

# eval libdir and reset exec_prefix
t_libdir=`eval echo "${libdir}"`
exec_prefix=${save_exec_prefix}

MODDIR="${t_libdir}/${PACKAGE}"

AC_DEFINE_UNQUOTED(HORN_DEFAULT_MODDIR, "${MODDIR}/",
[
   Default module directory; must end in /
])

AC_SUBST(MODDIR)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_AWK
AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
AC_PROG_MAKE_SET

dnl Checks for libraries.
KLM_COM_ERR_LIB
KLM_HASH_LIB
KLM_MOD_LIB
KLM_STR_LIB

dnl Checks for header files.
KLM_COM_ERR_INC
KLM_HASH_INC
KLM_MOD_INC
KLM_STR_INC

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.

AC_OUTPUT(Makefile lib/Makefile lib/hornet/Makefile doc/Makefile
	  doc/hornet.conf)
