dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/ber.C)
AM_INIT_AUTOMAKE(snmpkit, 0.9)
AM_CONFIG_HEADER(config.h)
AC_LANG_CPLUSPLUS

WARNS=""
AC_ARG_ENABLE(debug, [  --enable-debug turn on debugging (assumes gcc/gdb) [default=no]],WARNS="-W -Wall -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wshadow -O0 -ggdb3",AC_DEFINE(NDEBUG))
AC_SUBST(WARNS)

dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_CXX
AM_PROG_LIBTOOL

dnl Checks for libraries.

dnl Checks for header files.
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_HEADER_TIME

dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_REPLACE_FUNCS(snprintf)
AC_CHECK_FUNCS(select socket strdup strtol)

# Under sysV68, socket and friends are provided by the C library.
# -linet does not provide socket, but causes multiple definition
# errors at link-time.  It is thus better to only use the C library.
# So don't add -linet to the link list unless it's necessary
AC_CHECK_FUNC(socket,
    AC_MSG_RESULT(using libc's socket),
    AC_CHECK_LIB(socket,socket)
    AC_CHECK_LIB(inet,socket))

# The condition in this test copes with the presence of inet_addr in libc6.
AC_CHECK_FUNC(inet_addr,
    AC_MSG_RESULT(using libc's inet_addr),
    AC_CHECK_LIB(nsl,inet_addr))

AC_CHECK_FUNC(pthread_join,
    AC_MSG_RESULT(using libc's pthread_join),
    AC_CHECK_LIB(pthread, pthread_join))

dnl AC_MSG_CHECKING(if libstdc++ can handle unsigned strings)
dnl AC_TRY_COMPILE([#include <string>],[
dnl   basic_string<unsigned char> ustring;
dnl   ustring.c_str();
dnl ],[AC_MSG_RESULT(yes)],[
dnl AC_MSG_RESULT(no)
dnl AC_MSG_ERROR(The version of libstdc++ installed on your computer has a bug in it that 
dnl can't be worked around by autoconf. Please look at the README file supplied 
dnl with snmpkit for instructions on how to patch your library to fix this
dnl problem..)])

AC_OUTPUT(Makefile src/Makefile doc/Makefile snmpkit.spec)
