dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(nox, 0.9.1~APPS_ID~beta, contact@noxrepo.org)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)

NX_BUILDNR
AH_BOTTOM([/* NOX version with build number, e.g. "1.2.3+build456". */
#define NOX_VERSION VERSION BUILDNR_SUFFIX])

AM_INIT_AUTOMAKE([tar-ustar])

AM_SILENT_RULES([yes])

AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP

AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE

AC_DISABLE_STATIC
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL

CHECK_OPENFLOW

AC_CHECK_FUNCS([fdatasync ppoll])
AC_CONFIG_SRCDIR([src/])
AC_CONFIG_HEADER([config.h])

AX_BOOST_BASE([1.34.1])

AX_BOOST_SYSTEM
if test "$ax_cv_boost_system" != "yes"; then
   AC_MSG_ERROR([cannot find the Boost::System library])
fi

AX_BOOST_FILESYSTEM
if test "$ax_cv_boost_filesystem" != "yes"; then
   AC_MSG_ERROR([cannot find the Boost::Filesystem library])
fi

dnl AX_LIB_XERCES([2.7.0])
dnl if test "x$HAVE_XERCES" != "xyes"; then
dnl   AC_MSG_ERROR([cannot find the Apache Xerces library])
dnl fi

CHECK_PCAP
CHECK_SSL
FIGURE_SSL_CONST
CHECK_NDEBUG
CHECK_PROFILING
CHECK_COVERAGE
CHECK_NETLINK
CHECK_THREAD_LOCAL
CHECK_WITH_VM
CHECK_LTDL
CHECK_MALLOC_HOOKS

AC_PROG_SPHINX
AC_PROG_DOXYGEN

dnl Add your module here to have it grouped into a package

ACI_PACKAGE([coreapps],[core application set],
               [testharness coretests pyrt 
		simple_c_app simple_c_py_app simple_py_app
               	hub switch examples messenger snmp
               	#add coreapps component here
		],
               [yes])
ACI_PACKAGE([netapps],[misc network apps],
               [storage authenticator 
               	routing user_event_log tests topology discovery 
               	bindings_storage switchstats flow_fetcher data
               	switch_management networkstate hoststate tablog 
               	route lavi monitoring spanning_tree flowtracer
                #add netapps component here
		],
               [TURN_ON_NETAPPS])
ACI_PACKAGE([webapps],[misc ui apps],
               [webserver webservice webserviceclient
               	miscws
               	#add webapps component here
		],
               [TURN_ON_WEBAPPS])

AC_SUBST(ACTIVE_PACKAGES)
AC_SUBST(MODULES_coreapps)               
AC_SUBST(MODULES_netapps)               
AC_SUBST(MODULES_webapps)               

AM_CONDITIONAL([HAVE_NETAPPS], [test -n "$MODULES_netapps"])
AM_CONDITIONAL([HAVE_WEBAPPS], [test -n "$MODULES_webapps"])

dnl
dnl Conditional checks based on what modules have been turned on.
dnl

if test "$HAVE_coreapps" = "yes"; then
    CHECK_TWISTED
    dnl only check for swig if python was enabled
    if test -n "$PYTHON"; then
        AC_PROG_SWIG(1.3.0)
        if test -z "$SWIG"; then
            AC_MSG_ERROR([When configured with python, NOX requires swig 1.3.0 or later to be installed])
        fi
        SWIG_ENABLE_CXX
        SWIG_PYTHON
    fi    
fi

if test "$HAVE_netapps" = "yes"; then
    AX_BOOST_UNIT_TEST_FRAMEWORK
    if test "$ax_cv_boost_unit_test_framework" != "yes"; then
       AC_MSG_ERROR([cannot find the Boost::Unit_Test_Framework library])
    fi
fi

AC_ARG_ENABLE(
  [noext],
  [AC_HELP_STRING([--enable-noext],
                  [Ignore ext directory even if it exists])],
  [case "${enableval}" in # (
     yes) noext=true ;; # (
     no)  noext=false ;; # (
     *) AC_MSG_ERROR([bad value ${enableval} for --enable-noext]) ;;
   esac],
  [noext=false]
)

# AC_CONFIG_FILES and AC_CONFIG_SUBDIRS GENERATED BY ./boot.sh Don't
# put anything below this line!
