AC_PREREQ(2.59)
AC_INIT(l7vsd)
PACKAGENAME=l7vsd
VERSION=3.0.4

AM_INIT_AUTOMAKE($PACKAGENAME, $VERSION, no-define )
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

# Checks for libraries.
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(log4cxx, main, :,
	[AC_MSG_ERROR( l7vsd require log4cxx library. )] )
AC_CHECK_LIB(rt, main, :,
	[AC_MSG_ERROR( l7vsd require rt library. )] )
AC_CHECK_LIB(boost_thread-mt, main, :,
	[AC_MSG_ERROR( l7vsd require boost library. )] )
AC_CHECK_LIB(boost_system-mt, main, :,
	[AC_MSG_ERROR( l7vsd require boost library. )] )
AC_CHECK_LIB([netsnmp], main, :,
	[AC_MSG_ERROR( l7vsd require netsnmp library. )] )

# Checks for header files.
AC_CHECK_HEADERS([limits.h unistd.h])

# Checks for declarations.
AC_CHECK_DECLS([IP_TRANSPARENT], [], [], [[
	#include <sys/socket.h>
	#include <linux/in.h>
]])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_STRUCT_TM

# Checks for library functions.
AC_HEADER_STDC
AC_FUNC_MKTIME
AC_FUNC_STRFTIME
AC_CHECK_FUNCS([gethostname localtime_r memset])

# application-specific option
if test `uname -m` == "x86_64"; then
	AC_SUBST( libdir, [/usr/lib64] )
else
	AC_SUBST( libdir, [/usr/lib] )
	AC_SUBST( CXXFLAGS, -march=i686 )
fi

AC_ARG_WITH(
	l7vs-moddir,
	[	--with-l7vs-moddir=DIR	l7vs module is to be installed in DIR.
								[default=LIBDIR/l7vs] ],
	[	l7vs_moddir="$withval" ],
	[	l7vs_moddir="${libdir}/l7vs" ]
)

AC_ARG_WITH(
	l7vsadm-sockdir,
	[	--with-l7vsadm-sockdir=DIR	l7vsadm sockfile PATH.
									[default=/var/run/l7vs] ],
	[	l7vsadm_sockdir="$withval" ],
	[	l7vsadm_sockdir="/var/run/l7vs" ]
)

AC_ARG_WITH(
	l7vs-buffer-size,
	[	--with-l7vs-buffer-size=NUM	l7vsd using heap buffer size.
									[default=4096] ],
	[	l7vs_max_buffer_size="$withval" ],
	[	l7vs_max_buffer_size=4096 ]
)

AC_ARG_WITH(
	l7vs-config-dir,
	[	--with-l7vs-config-dir=DIR	l7vs configfile PATH.
									[default=/etc/l7vs/l7vs.cf] ],
	[	l7vs_config="$withval" ],
	[	l7vs_config="/etc/l7vs/l7vs.cf"	]
)

AC_SUBST(CC,g++)
AC_SUBST(exec_prefix, [/usr] )
AC_SUBST(l7vsadm_sockdir)
AC_SUBST(l7vs_moddir)
AC_SUBST(l7vs_max_buffer_size)
AC_SUBST(l7vs_config)
AC_SUBST(MANDIR)
AC_SUBST(external_agent_libs, `net-snmp-config --external-agent-libs`)
AC_SUBST(ultramonkeyl7_version,ultramonkeyl7-$VERSION)

AC_CONFIG_FILES([doc/Makefile]
                [doc/conf/Makefile]
                [doc/sslfiles/Makefile]
                [doc/heartbeat-ra/Makefile]
		[doc/mibs/Makefile]
                [l7directord/Makefile]
                [l7vsd/Makefile]
                [l7vsd/init.d/Makefile]
                [l7vsd/module/Makefile]
                [l7vsd/module/protocol/Makefile]
                [l7vsd/module/schedule/Makefile]
                [l7vsd/src/Makefile]
                [Makefile])

AC_OUTPUT
