AC_INIT(log4cpp, 0.3.2)

# autoconf 2.50 or higher to rebuild aclocal.m4, because the
# AC_CREATE_PREFIX_CONFIG_H macro needs the AS_DIRNAME macro.
AC_PREREQ(2.50)

#
# +1 : ? : +1  == new interface that does not break old one
# +1 : ? : 0   == new interface that breaks old one
#  ? : ? : 0   == no new interfaces, but breaks apps
#  ? :+1 : ?   == just some internal changes, nothing breaks but might work 
#                 better
# CURRENT : REVISION : AGE
LT_VERSION=4:2:0

AC_SUBST(LT_VERSION)

#AC_CONFIG_SRCDIR(configure.in)
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(include/config.h)

AM_INIT_AUTOMAKE

# General "with" options
# ----------------------------------------------------------------------------
AC_ARG_WITH(idsa, [  --with-idsa             include idsa support])

# Checks for programs
# ----------------------------------------------------------------------------
AC_CANONICAL_HOST

AM_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_MAKE_SET

AC_PROG_CXX([g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC QCC])

AC_PROG_CXXCPP
AC_LANG(C++)

# CXX fine tuning
case "$host" in
    *-dec-osf*)	  
	CXXFLAGS="$CXXFLAGS -std strict_ansi_errors" 
	;;
    *)	
	;;
esac

PETI_PEDANTIC_GCC

# Checks header files
# ----------------------------------------------------------------------------
AC_CHECK_HEADERS([unistd.h])
AC_CHECK_HEADERS([io.h])

# Checks local idioms
# ----------------------------------------------------------------------------
AC_C_INT64_T
AC_CXX_HAVE_SSTREAM
AC_FUNC_SNPRINTF

# syslog_test
AC_CHECK_FUNCS([syslog])
AC_CHECK_FUNCS([gettimeofday])
AC_CHECK_FUNCS([ftime])

# Checks for libraries
# ----------------------------------------------------------------------------

# for RemoteSyslogAppender
AC_CHECK_LIB(socket,socket, LIBS="-lsocket $LIBS",,)
AC_CHECK_LIB(nsl,gethostbyname, LIBS="-lnsl $LIBS",,)

# idsa_test
if test "x$with_idsa" = xyes; then
    AC_CHECK_LIB([idsa], [idsa_open])
    if test "$ac_cv_lib_idsa_idsa_open" = no; then
        AC_MSG_ERROR([could not locate idsa library])
    fi
fi

# check for doxygen
# ----------------------------------------------------------------------------
BB_ENABLE_DOXYGEN

# check for omnithreads
BB_CHECK_OMNITHREADS
BB_CHECK_PTHREADS

# Create files
# ----------------------------------------------------------------------------

AC_CREATE_GENERIC_CONFIG

AC_CONFIG_FILES([
Makefile
log4cpp.spec
config/Makefile
doc/Makefile
doc/Doxyfile
doc/html/Makefile
src/Makefile
include/Makefile
include/log4cpp/Makefile
include/log4cpp/threading/Makefile
tests/Makefile
debian/Makefile
msvc6/Makefile
msvc6/log4cpp/Makefile
msvc6/log4cppDLL/Makefile
msvc6/testCategory/Makefile
msvc6/testDLL/Makefile
msvc6/testMain/Makefile
msvc6/testNDC/Makefile
msvc6/testNTEventLog/Makefile
msvc6/testPattern/Makefile
bcb5/Makefile
bcb5/log4cpp/Makefile
bcb5/testCategory/Makefile
bcb5/testConfig/Makefile
bcb5/testFixedContextCategory/Makefile
bcb5/testmain/Makefile
bcb5/testNDC/Makefile
bcb5/testPattern/Makefile
openvms/Makefile
])
AC_OUTPUT

AC_CREATE_PREFIX_CONFIG_H([include/log4cpp/config.h], 
        $PACKAGE_TARNAME, [include/config.h])
