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

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])

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(
        l7vs-includedir,
        [        --with-l7vs-includedir=DIR      l7vs headerfile is to be installed in DIR.

                                                                [default=${includedir}/l7vs]
],
        [       l7vs_includedir="$withval" ],
        [       l7vs_includedir="${includedir}/l7vs" ]
)

AC_ARG_WITH(
	l7vsadm-sockdir,
	[	--with-l7vsadm-sockdir=DIR	l7vsadm sockfile PATH.
									[default=${localstatedir}/run/l7vs] ],
	[	l7vsadm_sockdir="$withval" ],
	[	l7vsadm_sockdir="${localstatedir}/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=${sysconfdir}/l7vs] ],
	[	l7vs_config="$withval" ],
	[	l7vs_config="${sysconfdir}/l7vs"	]
)

AC_SUBST(CC,g++)
AC_SUBST(l7vsadm_sockdir)
AC_SUBST(l7vs_moddir)
AC_SUBST(l7vs_includedir) 
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]
		[doc/man/Makefile]
		[doc/moduledevel/Makefile]
		[doc/moduledevel/sample/Makefile]
		[doc/moduledevel/sample/protocol/Makefile]
		[doc/moduledevel/sample/schedule/Makefile]
                [l7directord/Makefile]
                [l7vsd/Makefile]
                [l7vsd/init.d/Makefile]
                [l7vsd/module/Makefile]
                [l7vsd/module/protocol/Makefile]
                [l7vsd/module/schedule/Makefile]
                [l7vsd/src/Makefile]
		[l7vsd/include/Makefile]
                [Makefile])

AC_OUTPUT
