dnl Helder Correia <helder.correia@netcabo.pt>

dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/main.cpp)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(nload, 0.4.0)
AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL

dnl Checks for libraries.
AC_CHECK_LIB(ncurses, initscr)
AC_CHECK_LIB(form, new_form)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([limits.h stdlib.h sys/param.h sys/socket.h sys/time.h])

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

dnl Use some gcc specific options.
if test "$GCC" = "yes" ; then
     CFLAGS="$CFLAGS -Wall"
     CXXFLAGS="$CXXFLAGS -Wall"
fi

dnl System dependant jobs
case $target in
    *linux*)
         AC_DEFINE(HAVE_LINUX, 1)
         ;;
    *bsd*)
        AC_DEFINE(HAVE_BSD, 1)
        ;;
    *solaris*)
        AC_CHECK_LIB(rt, main)
        AC_CHECK_LIB(kstat, kstat_open)
        AC_DEFINE(HAVE_SOLARIS, 1)
        ;;
esac

dnl Adds extra arguments to configure script.
AC_ARG_ENABLE(debug,[  --enable-debug          enable runtime debugging [no]], [], LDFLAGS="$LDFLAGS -s")

dnl Checks for library functions.
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([gettimeofday memset pow])

AC_OUTPUT([
Makefile
docs/Makefile
docs/nload.1
nload.spec
src/Makefile
])

