dnl Process this file with autoconf to produce a configure script.

AC_INIT(scli/scli.c)
dnl Every other copy of the package version number gets its value from here
AM_INIT_AUTOMAKE(scli, 0.2.8)

dnl create a config.h file (Automake will add -DHAVE_CONFIG_H)
AM_CONFIG_HEADER(config.h)

AC_SUBST(VERSION)

ISODATE=`date +%Y-%m-%d`
AC_SUBST(ISODATE)

AC_CANONICAL_HOST

dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_RANLIB
AC_CHECK_PROG(SMIDUMP, smidump, smidump)
AC_SUBST(SMIDUMP)

AC_DEFINE_UNQUOTED(SCLI_PLUGIN_PATH, "${exec_prefix}/lib/scli")

AC_MSG_CHECKING([whether to enable -Wall])
AC_ARG_ENABLE(warnings,
[  --enable-warnings       Enable -Wall if using gcc.],
[ if test -n "$GCC"; then 
    AC_MSG_RESULT(adding -Wall to CFLAGS.)
    CFLAGS="$CFLAGS -Wall"
  fi],AC_MSG_RESULT(no))


dnl Checks for libraries.

AM_PATH_GLIB(1.2.0,,AC_MSG_ERROR(scli needs GLIB),gmodule)dnl
dnl AM_PATH_GTK(1.2.0,,AC_MSG_ERROR(scli needs GTK))dnl
AM_PATH_XML2(2.0.0,,AC_MSG_ERROR(scli needs libxml2))dnl
AC_CHECK_LIB(ncurses, initscr, , 
  AC_CHECK_LIB(curses, initscr, ,
    AC_MSG_ERROR([scli requires curses functions; install curses first])
  )
)
AC_CHECK_LIB(readline, readline, ,
  AC_MSG_ERROR([scli requires readline functions; install libreadline first])
)

dnl Checks for header files.

AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h sys/ioctl.h sys/time.h termios.h ncurses.h netinet/if_ether.h netinet/ether.h)
dnl AC_EGREP_HEADER(TIOCGWINSZ,sys/ioctl.h,AC_DEFINE(HAVE_TIOCGWINSZ))

dnl Checks for typedefs, structures, and compiler characteristics.

dnl defines HAVE_TM_ZONE if struct tm has tm_zone
AC_STRUCT_TIMEZONE

dnl Checks for library functions.

AC_CHECK_FUNC(gethostbyname)
if test $ac_cv_func_gethostbyname = no; then
  AC_CHECK_LIB(nsl, gethostbyname)
fi

AC_CHECK_FUNC(connect)
if test $ac_cv_func_connect = no; then
  AC_CHECK_LIB(socket, connect)
fi

AC_CHECK_FUNCS(resizeterm getaddrinfo ether_ntohost)
AC_CHECK_FUNCS(rl_completion_matches)

dnl Check for configure options

AC_ARG_ENABLE(dmalloc,
[  --enable-dmalloc        enable dmalloc debugging (www.dmalloc.com)],
  AC_CHECK_HEADERS(dmalloc.h)
  AC_CHECK_LIB(dmalloc, malloc) 
)

dnl Create all the Makefiles we need and we are done.

AC_OUTPUT(Makefile snmp/Makefile stub/Makefile proc/Makefile scli/Makefile doc/Makefile)
