dnl Process this file with autoconf to produce a configure script.
AC_INIT(kme.c)
AM_INIT_AUTOMAKE(kme, 2.0.0)

dnl  AM_PROG_LIBTOOL
AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_INSTALL

dnl Checks for libraries.
AC_CHECK_LIB(elf, nlist)
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(ncurses, initscr)
case "$LIBS" in
*ncurses*);;
*) AC_CHECK_LIB(curses, initscr);;
esac

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(libelf/nlist.h nlist.h string.h strings.h fcntl.h stropts.h sys/ksym.h sys/ptrace.h sys/time.h stdlib.h termio.h unistd.h wait.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_OFF_T
AC_HEADER_TIME

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MMAP
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(getksym nlist ptrace select socket strtoul)

dnl Test for features we can't automatically configure
dnl AC_ARG_ENABLE(hp, [  --enable-hp		Enable HP Analyzer support], AC_DEFINE(USE_HP_ANALYZER))
AC_ARG_ENABLE(hp,
    [  --enable-hp    Enable HP Analyzer aupport],
    [case "${enableval}" in
    yes) hp=true ; AC_DEFINE(USE_HP_ANALYZER);;
    no)  hp=false ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-hp) ;;
    esac],[hpanalyzer=false])
    AM_CONDITIONAL(USE_HP_ANALYZER, test x$hpanalyzer = xtrue)

if test "$ac_cv_lib_dl_dlopen" = "yes"; then
    if test $ac_cv_prog_gcc = yes; then 
	DYNAMIC="-rdynamic"
    else
	# Really should go into a per-OS case statement.  Here, we just
	# default to the OSR5/SVR4/SVR5 standard.
	DYNAMIC="-Bexport"
    fi
fi

AC_SUBST(DYNAMIC)

AC_OUTPUT(Makefile)
