misc changes
[public/netxms.git] / configure.ac
index b810845..79de817 100644 (file)
@@ -4,7 +4,7 @@
 # Configure script
 #
 
-AC_INIT([NetXMS], [1.2.15], [bugs@netxms.org])
+AC_INIT([NetXMS], [2.0-RC2], [bugs@netxms.org])
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_HEADERS(config.h)
 AM_INIT_AUTOMAKE
@@ -26,6 +26,17 @@ check_substr()
        return 1
 }
 
+find_existing_dir()
+{
+       for d in "$@"; do
+               if test -d "$d"; then
+                       __dir="$d"
+                       return 0;
+               fi
+       done
+       return 1
+}
+
 
 #--------------------------------------------------------------------
 # Initialize variables
@@ -59,6 +70,7 @@ SERVER_TOOLS=""
 SERVER_INCLUDE=""
 SMSDRV_DIRS=""
 HDLINK_DIRS=""
+PDSDRV_DIRS=""
 TOP_LEVEL_MODULES=""
 CONTRIB_MODULES=""
 CLIENT_COMPONENTS=""
@@ -68,6 +80,7 @@ USE_INTERNAL_LIBTRE="no"
 FORCE_INTERNAL_LIBTRE="no"
 FORCE_INTERNAL_JANSSON="no"
 FORCE_INTERNAL_ZLIB="no"
+FORCE_INTERNAL_SQLITE="no"
 FORCE_32BIT_BUILD="no"
 FORCE_INTERNAL_GETOPT="no"
 LDFLAGS_PREFIX=""
@@ -79,6 +92,12 @@ RUNTIME_PREFIX=""
 HPUX_HPPA="no"
 XMPP_SUPPORT="yes"
 LDAP_SUPPORT="yes"
+DISABLE_READLINE="no"
+TUXEDO_LIBS=""
+MONGODB_LIBS=""
+DISABLE_IPV6="no"
+IPV6_SUPPORT="no"
+INSTALL_LIBPATH=""
 
 
 #--------------------------------------------------------------------
@@ -101,7 +120,7 @@ AC_ARG_WITH(runtime-prefix,
 AC_ARG_WITH(server,
 [AS_HELP_STRING(--with-server,build server)],
 [
-       COMPONENTS="$COMPONENTS sqlite snmp server agent"
+       COMPONENTS="$COMPONENTS sqlite snmp server agent sqlite_drv"
 ])
 
 AC_ARG_WITH(snmp,
@@ -125,13 +144,18 @@ AC_ARG_WITH(client-proxy,
 AC_ARG_WITH(agent,
 [AS_HELP_STRING(--with-agent,build agent)],
 [
-       COMPONENTS="$COMPONENTS sqlite agent"
+       COMPONENTS="$COMPONENTS sqlite snmp agent sqlite_drv"
 ])
 
 AC_ARG_WITH(static-agent,
 [AS_HELP_STRING(--with-static-agent,build statically linked agent)],
 [
-       COMPONENTS="$COMPONENTS sqlite static-agent"
+       COMPONENTS="$COMPONENTS sqlite snmp static-agent sqlite_drv"
+       FORCE_INTERNAL_EXPAT="yes"
+       FORCE_INTERNAL_JANSSON="yes"
+       FORCE_INTERNAL_LIBTRE="yes"
+       FORCE_INTERNAL_SQLITE="yes"
+       FORCE_INTERNAL_ZLIB="yes"
 ])
 
 AC_ARG_WITH(ipso-agent,
@@ -195,6 +219,12 @@ AC_ARG_WITH(internal-zlib,
        FORCE_INTERNAL_ZLIB="yes"
 ])
 
+AC_ARG_WITH(internal-sqlite,
+[AS_HELP_STRING(--with-internal-sqlite,force use of bundled sqlite)],
+[
+       FORCE_INTERNAL_SQLITE="yes"
+])
+
 AC_ARG_WITH(internal-getopt,
 [AS_HELP_STRING(--with-internal-getopt,force use of bundled getopt)],
 [
@@ -208,7 +238,7 @@ AC_ARG_WITH(all-static,
 ])
 
 AC_ARG_WITH(static-subagents,
-[AS_HELP_STRING(--with-static-subagents=list,define list of static subagents (separated by spaces))],
+[AS_HELP_STRING(--with-static-subagents-list,define list of static subagents (separated by spaces))],
 [
        PROPOSED_STATIC_SUBAGENTS="$withval"
 ])
@@ -224,6 +254,24 @@ AC_ARG_WITH(jdk,
        COMPONENTS="$COMPONENTS java"
 fi ])
 
+AC_ARG_WITH(tuxedo,
+[AS_HELP_STRING(--with-tuxedo,build Tuxedo-dependent components)],
+[ if test "x$withval" != "xno" ; then
+       if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
+               TUXEDO_BASE="$withval"
+       fi
+       COMPONENTS="$COMPONENTS tuxedo"
+fi ])
+
+AC_ARG_WITH(mongodb,
+[AS_HELP_STRING(--with-mongodb,build MongoDB-dependent components)],
+[ if test "x$withval" != "xno" ; then
+       if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
+               MONGODB_BASE="$withval"
+       fi
+       COMPONENTS="$COMPONENTS mongodb"
+fi ])
+
 AC_ARG_WITH(sqlite,
 [AS_HELP_STRING(--with-sqlite,build SQLite database driver)],
 [ if test "x$withval" != "xno" ; then
@@ -246,19 +294,26 @@ fi ])
 AC_ARG_WITH(oracle,
 [AS_HELP_STRING(--with-oracle,build Oracle database driver)],
 [ if test "x$withval" != "xno" ; then
+       ORABASE="$ORACLE_HOME"
        if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
-               if test -x "$withval/lib" ; then
-                       ORACLE_LD_RUN_PATH="${withval}/lib"   
-                       ORACLE_LDFLAGS="-L${withval}/lib"
+               ORABASE="$withval"
+       fi
+       if test "x$ORABASE" != "x"; then
+               if test -x "$ORABASE/lib" ; then
+                       ORACLE_LD_RUN_PATH="${ORABASE}/lib"   
+                       ORACLE_LDFLAGS="-L${ORABASE}/lib"
                else
-                       ORACLE_LD_RUN_PATH="${withval}"   
-                       ORACLE_LDFLAGS="-L${withval}"
+                       ORACLE_LD_RUN_PATH="${ORABASE}"   
+                       ORACLE_LDFLAGS="-L${ORABASE}"
                fi
-               if test -x "$withval/include" ; then
-                       ORACLE_CPPFLAGS="-I${withval}/include"
+               if test -x "$ORABASE/include" ; then
+                       ORACLE_CPPFLAGS="-I${ORABASE}/include"
+               fi
+               if test -x "$ORABASE/sdk/include" ; then
+                       ORACLE_CPPFLAGS="-I${ORABASE}/sdk/include"
                fi
-               if test -x "$withval/sdk/include" ; then
-                       ORACLE_CPPFLAGS="-I${withval}/sdk/include"
+               if test -x "$ORABASE/rdbms/public" ; then
+                       ORACLE_CPPFLAGS="-I${ORABASE}/rdbms/public"
                fi
        fi
        COMPONENTS="$COMPONENTS oracle"
@@ -269,13 +324,21 @@ AC_ARG_WITH(mysql,
 [AS_HELP_STRING(--with-mysql,build MySQL database driver)],
 [ if test "x$withval" != "xno" ; then
        if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
-               LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"   
-               LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/mysql -L${withval}/mysql/lib"
-               CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
+               if find_existing_dir "${withval}/lib" "${withval}/lib/mysql" "${withval}/mysql/lib"; then
+                       MYSQL_LD_RUN_PATH="$__dir$"    
+                       MYSQL_LDFLAGS="-L$__dir"
+               fi
+               if find_existing_dir "${withval}/include" "${withval}/include/mysql" "${withval}/mysql/include"; then
+                       MYSQL_CPPFLAGS="-I$__dir"
+               fi
        else
-               LD_RUN_PATH="/usr/local/mysql/lib:/usr/local/mysql/lib/mysql:/usr/lib64/mysql:/usr/lib/mysql:/usr/mysql/lib:/usr/mysql/lib/mysql:/usr/local/lib/mysql:${LD_RUN_PATH:+:}${LD_RUN_PATH}"
-               LDFLAGS="$LDFLAGS -L/usr/local/mysql/lib -L/usr/lib64/mysql -L/usr/lib/mysql -L/usr/mysql/lib -L/usr/local/lib/mysql -L/usr/local/mysql/lib/mysql -L/usr/mysql/lib/mysql"
-               CPPFLAGS="$CPPFLAGS -I/usr/local/mysql/include -I/usr/include/mysql -I/usr/mysql/include -I/usr/local/include/mysql -I/usr/local/mysql/include/mysql -I/usr/mysql/include/mysql"
+               if find_existing_dir "/usr/local/mysql/lib" "/usr/local/mysql/lib/mysql" "/usr/lib64/mysql" "/usr/lib/mysql" "/usr/mysql/lib" "/usr/mysql/lib/mysql" "/usr/local/lib/mysql"; then
+                       MYSQL_LD_RUN_PATH="$__dir$"    
+                       MYSQL_LDFLAGS="-L$__dir"
+               fi
+               if find_existing_dir "/usr/local/mysql/include" "/usr/include/mysql" "/usr/mysql/include" "/usr/local/include/mysql" "/usr/local/mysql/include/mysql" "/usr/mysql/include/mysql"; then
+                       MYSQL_CPPFLAGS="-I$__dir"
+               fi
        fi
        COMPONENTS="$COMPONENTS mysql"
        DBDRIVER_SELECTED="yes"
@@ -285,13 +348,21 @@ AC_ARG_WITH(pgsql,
 [AS_HELP_STRING(--with-pgsql,build PostgreSQL database driver)],
 [ if test "x$withval" != "xno" ; then
        if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
-               LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"    
-               LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/pgsql -L${withval}/lib/postgresql -L${withval}/pgsql/lib -L${withval}/postgresql/lib"
-               CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/pgsql -I${withval}/include/postgresql -I${withval}/pgsql/include -I${withval}/postgresql/include"
+               if find_existing_dir "${withval}/lib" "${withval}/lib/pgsql" "${withval}/lib/postgresql" "${withval}/pgsql/lib" "${withval}/postgresql/lib"; then
+                       PGSQL_LD_RUN_PATH="$__dir$"    
+                       PGSQL_LDFLAGS="-L$__dir"
+               fi
+               if find_existing_dir "${withval}/include" "${withval}/include/pgsql" "${withval}/include/postgresql" "${withval}/pgsql/include" "${withval}/postgresql/include"; then
+                       PGSQL_CPPFLAGS="-I$__dir"
+               fi
        else
-               LD_RUN_PATH="/usr/local/pgsql/lib:/usr/local/pgsql/lib/pgsql:/usr/lib64/pgsql:/usr/lib/pgsql:/usr/pgsql/lib:/usr/pgsql/lib/pgsql:/usr/local/lib/pgsql:/usr/local/postgresql/lib:/usr/local/postgresql/lib/postgresql:/usr/lib/postgresql:/usr/postgresql/lib:/usr/postgresql/lib/postgresql:/usr/local/lib/postgresql:${LD_RUN_PATH:+:}${LD_RUN_PATH}"
-               LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib -L/usr/lib64/pgsql -L/usr/lib/pgsql -L/usr/pgsql/lib -L/usr/local/lib/pgsql -L/usr/local/pgsql/lib/pgsql -L/usr/pgsql/lib/pgsql -L/usr/local/postgresql/lib -L/usr/lib/postgresql -L/usr/postgresql/lib -L/usr/local/lib/postgresql -L/usr/local/postgresql/lib/postgresql -L/usr/postgresql/lib/postgresql"
-               CPPFLAGS="$CPPFLAGS -I/usr/local/pgsql/include -I/usr/include/pgsql -I/usr/pgsql/include -I/usr/local/include/pgsql -I/usr/local/pgsql/include/pgsql -I/usr/pgsql/include/pgsql -I/usr/local/postgresql/include -I/usr/include/postgresql -I/usr/postgresql/include -I/usr/local/include/postgresql -I/usr/local/postgresql/include/postgresql -I/usr/postgresql/include/postgresql"
+               if find_existing_dir "/usr/local/pgsql/lib" "/usr/local/pgsql/lib/pgsql" "/usr/lib64/pgsql" "/usr/lib/pgsql" "/usr/pgsql/lib" "/usr/pgsql/lib/pgsql" "/usr/local/lib/pgsql" "/usr/local/postgresql/lib" "/usr/local/postgresql/lib/postgresql" "/usr/lib/postgresql" "/usr/postgresql/lib" "/usr/postgresql/lib/postgresql" "/usr/local/lib/postgresql"; then
+                       PGSQL_LD_RUN_PATH="$__dir$"    
+                       PGSQL_LDFLAGS="-L$__dir"
+               fi
+               if find_existing_dir "/usr/local/pgsql/include" "/usr/include/pgsql" "/usr/pgsql/include" "/usr/local/include/pgsql" "/usr/local/pgsql/include/pgsql" "/usr/pgsql/include/pgsql" "/usr/local/postgresql/include" "/usr/include/postgresql" "/usr/postgresql/include" "/usr/local/include/postgresql" "/usr/local/postgresql/include/postgresql" "/usr/postgresql/include/postgresql"; then
+                       PGSQL_CPPFLAGS="-I$__dir"
+               fi
        fi
        COMPONENTS="$COMPONENTS pgsql"
        DBDRIVER_SELECTED="yes"
@@ -362,12 +433,42 @@ AC_ARG_WITH(openssl,
        fi
 ])
 
+AC_ARG_WITH(jemalloc,
+[AS_HELP_STRING(--with-jemalloc,specify libjemalloc location)],
+[
+       if test "x$withval" != "xno" ; then
+               if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
+                       LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"   
+                       LDFLAGS="$LDFLAGS -L${withval}/lib"
+                       CPPFLAGS="$CPPFLAGS -I${withval}/include"
+                       INSTALL_LIBPATH="${withval}/lib${INSTALL_LIBPATH:+:}${INSTALL_LIBPATH}"
+               fi
+       fi
+])
+
 AC_ARG_ENABLE(iconv,
 [AS_HELP_STRING(--disable-iconv,do not use iconv() for text conversions)],
 [
        DISABLE_ICONV="yes"
 ])
 
+AC_ARG_ENABLE(ipv6,
+[AS_HELP_STRING(--disable-ipv6,disable IPv6 support)],
+[
+       DISABLE_IPV6="yes"
+])
+
+AC_ARG_ENABLE(iconv-cache,
+[AS_HELP_STRING([--enable-iconv-cache=@<:@yes/no/auto@:>@],
+[cache iconv descriptors [default=auto]])],,
+[enable_iconv_cache=auto])
+
+AC_ARG_ENABLE(readline,
+[AS_HELP_STRING(--disable-readline,do not use libreadline)],
+[
+       DISABLE_READLINE="yes"
+])
+
 AC_ARG_ENABLE(encryption,
 [AS_HELP_STRING(--disable-encryption,disable encryption support)],
 [
@@ -422,15 +523,16 @@ AC_ARG_ENABLE(64bit,
 AC_ARG_WITH(dist,
 [AS_HELP_STRING(--with-dist,for maintainers only)],
        DB_DRIVERS=" mysql pgsql odbc mssql sqlite oracle db2 informix"
-       MODULES="jansson libexpat libstrophe libtre zlib libnetxms install sqlite snmp libnxsl libnxlp db server agent libnxmap libnxcl client nxscript nxcproxy tools"
-       SUBAGENT_DIRS="linux freebsd openbsd netbsd sunos aix ipso hpux odbcquery informix oracle lmsensors darwin rpi java netsvc db2"
-       SMSDRV_DIRS="websms"
+       MODULES="appagent jansson libexpat libstrophe libtre zlib libnetxms install sqlite snmp libnxsl libnxmb libnxlp libnxcc db server agent libnxmap client nxscript nxcproxy nxlptest tools"
+       SUBAGENT_DIRS="linux ds18x20 freebsd openbsd netbsd sunos aix ipso hpux odbcquery informix oracle lmsensors darwin rpi java ubntlw netsvc db2 tuxedo mongodb"
+       SMSDRV_DIRS="kannel slack text2reach websms"
    HDLINK_DIRS="jira"
+   PDSDRV_DIRS="rrdtool"
        NXCONFIG="nxconfig"
-       TOP_LEVEL_MODULES="include sql images"
+       TOP_LEVEL_MODULES="include sql images tests"
        SERVER_INCLUDE="include"
-       CONTRIB_MODULES="mibs backgrounds"
-       CLIENT_COMPONENTS="nxalarm nxevent nxlexer nxpush nxsms scilexer windows"
+       CONTRIB_MODULES="mibs backgrounds music"
+       CLIENT_COMPONENTS="nxalarm nxevent nxpush nxsms"
        SERVER_TOOLS="nxconfig"
 )
 
@@ -440,12 +542,19 @@ AC_ARG_WITH(rpi-agent,
        COMPONENTS="$COMPONENTS raspberrypi"
 ])
 
+AC_ARG_WITH(tests,
+[AS_HELP_STRING(--with-tests,build tests)],
+[
+       TOP_LEVEL_MODULES="$TOP_LEVEL_MODULES tests"
+])
+
 
 #--------------------------------------------------------------------
 # Set LD_LIBRARY_PATH from LD_RUN_PATH because on some systems
 # LD_RUN_PATH ignored by linker and some tests may fail
 #--------------------------------------------------------------------
 
+export LD_RUN_PATH
 if test "x$LD_RUN_PATH" != "x"; then
        LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}${LD_RUN_PATH}"
        export LD_LIBRARY_PATH
@@ -456,28 +565,29 @@ fi
 # Validate command line parameters and set various checking options
 #--------------------------------------------------------------------
 
-check_substr "$COMPONENTS" "sqlite"
+check_substr "$COMPONENTS" "snmp"
 if test $? = 0; then
-       MODULES="$MODULES sqlite"
+       NEED_ZLIB="yes"
+       MODULES="$MODULES snmp"
 fi
 
 check_substr "$COMPONENTS" "static-agent"
 if test $? = 0; then
-       if test "x$COMPONENTS" != "x sqlite static-agent"; then
+       if test "x$COMPONENTS" != "x sqlite snmp static-agent sqlite_drv"; then
                AC_MSG_ERROR(Static agent and other components are mutually exclusive.)
        fi
        STATIC_BUILD="yes"
        BUILD_STATIC_AGENT="yes"
-       MODULES="$MODULES libnxlp db agent"
+       MODULES="$MODULES appagent libnxlp db agent"
        DISABLE_ICONV="yes"
        CPPFLAGS="$CPPFLAGS -D_STATIC_AGENT"
        if test "x$PROPOSED_STATIC_SUBAGENTS" = "xdefault"; then
-               STATIC_SUBAGENT_LIST="ecs logwatch ping portcheck ups"
+               STATIC_SUBAGENT_LIST="ecs filemgr logwatch ping portcheck ups"
        else
                STATIC_SUBAGENT_LIST="$PROPOSED_STATIC_SUBAGENTS"
        fi
 
-       SUBAGENT_LIBS="../subagents/ecs/ecs.la ../subagents/logwatch/logwatch.la ../subagents/ping/ping.la ../subagents/portCheck/portcheck.la ../subagents/ups/ups.la"
+       SUBAGENT_LIBS="../subagents/ecs/ecs.la ../subagents/filemgr/filemgr.la ../subagents/logwatch/logwatch.la ../subagents/ping/ping.la ../subagents/portCheck/portcheck.la ../subagents/ups/ups.la"
 
        check_substr "$STATIC_SUBAGENT_LIST" "odbcquery"
        if test $? = 0; then
@@ -505,9 +615,9 @@ if test $? = 0; then
 
        case "$PLATFORM" in
                Linux)
-                       SUBAGENT_DIRS="linux"
-                       SUBAGENT_LIBS="$SUBAGENT_LIBS ../subagents/linux/linux.la"
-                       STATIC_SUBAGENT_LIST="linux $STATIC_SUBAGENT_LIST"
+                       SUBAGENT_DIRS="linux ds18x20"
+                       SUBAGENT_LIBS="$SUBAGENT_LIBS ../subagents/linux/linux.la ../subagents/ds18x20/ds18x20.la"
+                       STATIC_SUBAGENT_LIST="linux ds18x20 $STATIC_SUBAGENT_LIST"
                        ;;
                FreeBSD)
                        SUBAGENT_DIRS="freebsd"
@@ -559,56 +669,22 @@ if test $? = 0; then
        BUILD_STATIC_AGENT="yes"
        DISABLE_ICONV="yes"
        USE_PTH="yes"
-       MODULES="$MODULES libnxlp db agent"
-       CPPFLAGS="$CPPFLAGS -D_STATIC_AGENT -D_IPSO -D_USE_GNU_PTH -DSQLITE_THREADSAFE=0 -I/usr/local/include"
+       MODULES="$MODULES appagent libnxlp db agent"
+       CPPFLAGS="$CPPFLAGS -D_STATIC_AGENT -D_IPSO -DSQLITE_THREADSAFE=0 -I/usr/local/include"
        LDFLAGS="$LDFLAGS -all-static"
        STATIC_SUBAGENT_LIST="ecs ipso logwatch ping portcheck ups"
        SUBAGENT_DIRS="ipso"
        SUBAGENT_LIBS="../subagents/ecs/ecs.la ../subagents/ipso/ipso.la ../subagents/logwatch/logwatch.la ../subagents/ping/ping.la ../subagents/portCheck/portcheck.la ../subagents/ups/ups.la"
 fi
 
-check_substr "$COMPONENTS" "snmp"
-if test $? = 0; then
-       NEED_ZLIB="yes"
-       MODULES="$MODULES snmp"
-fi
-
-check_substr "$COMPONENTS" "server"
-if test $? = 0; then
-       if test "x$DBDRIVER_SELECTED" != "xyes"; then
-               AC_MSG_ERROR(You must select at least one database driver when building server.)
-       fi
-       BUILD_SERVER="yes"
-       MODULES="$MODULES libnxmap libnxsl libnxlp db server nxscript"
-       TOP_LEVEL_MODULES="$TOP_LEVEL_MODULES sql images"
-       CONTRIB_MODULES="$CONTRIB_MODULES mibs backgrounds"
-       if test "x$XMPP_SUPPORT" = "xyes"; then
-               MODULES="libstrophe $MODULES"
-               AC_DEFINE(XMPP_SUPPORTED, 1, Define to 1 if XMPP is supported)
-       fi
-fi
-
-check_substr "$COMPONENTS" "client"
-if test $? = 0; then
-       BUILD_CLIENT="yes"
-       NEED_ZLIB="yes"
-       MODULES="$MODULES libnxmap libnxcl client"
-       CLIENT_COMPONENTS="$CLIENT_COMPONENTS nxalarm nxevent nxpush nxsms"
-fi
-
-check_substr "$COMPONENTS" "client-proxy"
-if test $? = 0; then
-       MODULES="$MODULES nxcproxy"
-fi
-
 check_substr "$COMPONENTS" "agent"
 if test $? = 0; then
        BUILD_AGENT="yes"
-       MODULES="$MODULES libnxlp db agent"
+       MODULES="$MODULES appagent libnxlp db agent"
 
        case "$PLATFORM" in
                Linux)
-                       SUBAGENT_DIRS="linux"
+                       SUBAGENT_DIRS="linux ds18x20"
                        ;;
                FreeBSD)
                        SUBAGENT_DIRS="freebsd"
@@ -637,6 +713,34 @@ if test $? = 0; then
        esac
 fi
 
+check_substr "$COMPONENTS" "server"
+if test $? = 0; then
+       if test "x$DBDRIVER_SELECTED" != "xyes"; then
+               AC_MSG_ERROR(You must select at least one database driver when building server.)
+       fi
+       BUILD_SERVER="yes"
+       MODULES="$MODULES libnxmap libnxsl libnxcc server nxscript"
+       TOP_LEVEL_MODULES="$TOP_LEVEL_MODULES sql images"
+       CONTRIB_MODULES="$CONTRIB_MODULES mibs backgrounds music"
+       if test "x$XMPP_SUPPORT" = "xyes"; then
+               MODULES="libstrophe $MODULES"
+               AC_DEFINE(XMPP_SUPPORTED, 1, Define to 1 if XMPP is supported)
+       fi
+fi
+
+check_substr "$COMPONENTS" "client"
+if test $? = 0; then
+       BUILD_CLIENT="yes"
+       NEED_ZLIB="yes"
+       MODULES="$MODULES client"
+       CLIENT_COMPONENTS="$CLIENT_COMPONENTS nxalarm nxevent nxpush nxsms"
+fi
+
+check_substr "$COMPONENTS" "client-proxy"
+if test $? = 0; then
+       MODULES="$MODULES nxcproxy"
+fi
+
 check_substr "$COMPONENTS" "mysql"
 if test $? = 0; then
        DB_DRIVERS="$DB_DRIVERS mysql"
@@ -683,12 +787,22 @@ fi
 
 check_substr "$COMPONENTS" "java"
 if test $? = 0; then
-       SUBAGENT_DIRS="$SUBAGENT_DIRS java"
+       SUBAGENT_DIRS="$SUBAGENT_DIRS java ubntlw"
+fi
+
+check_substr "$COMPONENTS" "tuxedo"
+if test $? = 0; then
+       SUBAGENT_DIRS="$SUBAGENT_DIRS tuxedo"
+fi
+
+check_substr "$COMPONENTS" "mongodb"
+if test $? = 0; then
+       SUBAGENT_DIRS="$SUBAGENT_DIRS mongodb"
 fi
 
 check_substr "$COMPONENTS" "sdk"
 if test $? = 0; then
-       MODULES="$MODULES libnxmap libnxcl libnxsl libnxlp db nxscript"
+       MODULES="$MODULES appagent libnxmap client libnxsl libnxmb libnxlp libnxcc db nxscript"
 fi
 
 
@@ -708,6 +822,10 @@ if test "x$PLATFORM" = "xSunOS"; then
        AC_CHECK_PROG([CC], [cc], [cc])
        AC_CHECK_PROG([CCC], [CC], [CC])
 fi
+if test "x$PLATFORM" = "xMinix"; then
+       AC_CHECK_PROG([CC], [clang], [clang])
+       AC_CHECK_PROG([CCC], [clang++], [clang++])
+fi
 AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_CXX
@@ -717,6 +835,9 @@ if test "x$CXX" = "xg++"; then
                AC_MSG_ERROR([*** FATAL: Cannot find any usable C++ compiler])
        fi
 fi
+if test "x$CXX" = "xclang++"; then
+       LIBS="$LIBS -lc++"
+fi
 AM_PROG_AS
 AC_PROG_INSTALL
 AC_PROG_LEX
@@ -750,7 +871,7 @@ case "$PLATFORM" in
       if test "x$CXX" = "xaCC"; then
          CPPFLAGS="$CPPFLAGS -D_HP_ATOMIC_INLINE"
         CFLAGS="$CFLAGS -AC99"
-         CXXFLAGS="-mt $CXXFLAGS +W749 +W829"
+         CXXFLAGS="-mt $CXXFLAGS +W749 +W829 +W4232"
          LDFLAGS="$LDFLAGS -mt"
       fi
       if test `uname -m` != 'ia64'; then
@@ -775,6 +896,11 @@ case "$PLATFORM" in
    Darwin)
       CPPFLAGS="$CPPFLAGS -Wno-deprecated-declarations -O2"
       ;;
+   Minix)
+      CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
+      LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
+      USE_PTH="yes"
+      ;;
    *)
       ;;
 esac
@@ -786,12 +912,23 @@ esac
 #  * Turn on 64bit mode on HP-UX/Itanium
 #  * Turn on 64bit mode on AIX
 #  * Turn on 64bit mode on Solaris
+#  * Disable inconsistent C/C++ linkage warnings for Solaris Studio
 #--------------------------------------------------------------------
 
 if test "x$ac_compiler_gnu" = "xyes" ; then
        SQLFLAGS="-x c -Wundef"
        CPPFLAGS="$CPPFLAGS -Wformat"
 
+       AC_MSG_CHECKING(whether C compiler accepts -Wno-unused-result)
+       OLD_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS -Wno-unused-result"
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
+               [ AC_MSG_RESULT(yes) ], 
+               [ 
+                       CPPFLAGS="$OLD_CPPFLAGS"
+                       AC_MSG_RESULT(no)
+               ])
+
        AC_LANG_PUSH([C++])
 
        AC_MSG_CHECKING(whether C++ compiler accepts -fno-rtti)
@@ -804,21 +941,33 @@ if test "x$ac_compiler_gnu" = "xyes" ; then
                        AC_MSG_RESULT(no)
                ])
 
-       check_substr "$COMPONENTS" "java"
-       if test $? != 0; then
-               AC_MSG_CHECKING(whether C++ compiler accepts -fno-exceptions)
-               OLD_CXXFLAGS="$CXXFLAGS"
-               CXXFLAGS="$CXXFLAGS -fno-exceptions"
-               AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
-                       [ AC_MSG_RESULT(yes) ], 
-                       [ 
-                               CXXFLAGS="$OLD_CXXFLAGS"
-                               AC_MSG_RESULT(no)
-                       ])
-       fi
+       AC_MSG_CHECKING(whether C++ compiler accepts -fno-exceptions)
+       OLD_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -fno-exceptions"
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
+               [ AC_MSG_RESULT(yes) ], 
+               [ 
+                       CXXFLAGS="$OLD_CXXFLAGS"
+                       AC_MSG_RESULT(no)
+               ])
 
        AC_LANG_POP([C++])
 
+       MACHINE=`uname -m`
+       if test "x$MACHINE" = "xi686" -o "x$MACHINE" = "xi586"; then
+                       AC_MSG_CHECKING(whether C compiler accepts -march=$MACHINE)
+                       OLD_CPPFLAGS="$CPPFLAGS"
+                       CPPFLAGS="$CPPFLAGS -march=$MACHINE"
+                       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
+                               [ 
+                                       AC_MSG_RESULT(yes) 
+                               ], 
+                               [ 
+                                       CPPFLAGS="$OLD_CPPFLAGS"
+                                       AC_MSG_RESULT(no)
+                               ])
+       fi
+
        if test "x$PLATFORM" = "xHP-UX"; then
                if test "x$FORCE_32BIT_BUILD" = "xyes"; then
                        AC_MSG_CHECKING(whether C compiler accepts -milp32)
@@ -915,6 +1064,24 @@ if test "x$ac_compiler_gnu" = "xyes" ; then
                fi
        fi
 
+       
+       if test "x$PLATFORM" = "xLinux"; then
+               if test "x$FORCE_32BIT_BUILD" = "xyes"; then
+                       AC_MSG_CHECKING(whether C compiler accepts -m32)
+                       OLD_CPPFLAGS="$CPPFLAGS"
+                       CPPFLAGS="$CPPFLAGS -m32"
+                       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
+                               [ 
+                                       LDFLAGS="-m32 $LDFLAGS"
+                                       AC_MSG_RESULT(yes) 
+                               ], 
+                               [ 
+                                       CPPFLAGS="$OLD_CPPFLAGS"
+                                       AC_MSG_RESULT(no)
+                               ])
+               fi
+       fi
+
        if test "x$ENABLE_DEBUG" = "xyes"; then
                CPPFLAGS="$CPPFLAGS -ggdb3"
        fi
@@ -998,6 +1165,7 @@ fi
 if test "x$CXX" = "xCC" ; then
        SQLFLAGS="-Qn"
        CPPFLAGS="$CPPFLAGS -mt"
+       CXXFLAGS="$CXXFLAGS -erroff=badargtype2w,wbadinit"
 
        if test "x$FORCE_32BIT_BUILD" = "xyes"; then
                AC_MSG_CHECKING(whether C compiler accepts -m32)
@@ -1114,12 +1282,50 @@ if test "x$CXX" != "xaCC"; then
        fi
 fi
 
+
+#--------------------------------------------------------------------
+# Check for additional system libraries
+#--------------------------------------------------------------------
+
+AC_CHECK_LIB(xnet, accept)
+AC_CHECK_LIB(socket, if_nameindex)
+AC_CHECK_LIB(dl, dlopen)
+AC_CHECK_LIB(kstat, kstat_open)
+
+# sockets/resolver
+if test "$BUILD_SERVER-$XMPP_SUPPORT" = "yes-yes"; then
+       AC_CHECK_HEADERS([arpa/nameser_compat.h])
+       AC_CHECK_FUNC(res_query, , [AC_CHECK_LIB(resolv, res_query, [], [AC_CHECK_LIB(resolv, __res_query)])])
+fi
+AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
+AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
+AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
+
+if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
+       AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
+fi
+
+if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
+       AC_MSG_CHECKING([if we can include libnsl + libsocket])
+       LIBS="-lnsl -lsocket $LIBS"
+       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
+       if test "$my_ac_link_result" = "no" ; then
+               AC_MSG_RESULT([failure])
+               AC_MSG_ERROR([unable to use gethostbyname()])
+       else
+               AC_MSG_RESULT([success])
+       fi
+fi
+
+
 #--------------------------------------------------------------------
 # Check for threads library - either POSIX or GNU
 #--------------------------------------------------------------------
 
 if test "x$USE_PTH" = "xyes"; then
        AC_CHECK_HEADER(pth.h,,AC_MSG_ERROR([*** GNU Pth thread support not installed - please install first ***]))
+       CPPFLAGS="$CPPFLAGS -D_USE_GNU_PTH"
+       LIBS="$LIBS -lpth"
 else
        AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
 
@@ -1253,6 +1459,7 @@ AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h poll.h termios.h])
 AC_CHECK_HEADERS([inttypes.h memory.h stdint.h stdlib.h strings.h string.h])
 AC_CHECK_HEADERS([readline/readline.h byteswap.h sys/select.h dlfcn.h locale.h])
 AC_CHECK_HEADERS([sys/sysctl.h sys/param.h sys/user.h vm/vm_param.h syslog.h])
+AC_CHECK_HEADERS([grp.h pwd.h malloc.h])
 AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h],,,
 [[#ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
@@ -1267,21 +1474,42 @@ AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h],,,
 
 
 #--------------------------------------------------------------------
-# Checks for other libs.
+# Checks for IPv6 support
 #--------------------------------------------------------------------
 
-AC_CHECK_LIB(xnet, accept)
-AC_CHECK_LIB(socket, if_nameindex)
-AC_CHECK_LIB(dl, dlopen)
-AC_CHECK_LIB(kstat, kstat_open)
+if test "x$DISABLE_IPV6" != "xyes"; then
+       AC_CHECK_DECL(AF_INET6,,,[
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+       ])
+       if test "x$ac_cv_have_decl_AF_INET6" = "xyes"; then
+               AC_CHECK_TYPE(struct sockaddr_in6, [ 
+                       AC_DEFINE(WITH_IPV6, 1, Define to have IPv6 support) 
+                       IPV6_SUPPORT="yes"
+               ],,[
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+               ])
+       fi
+fi
+
+#--------------------------------------------------------------------
+# Checks for other libs.
+#--------------------------------------------------------------------
 
 if test "x$BUILD_SERVER" = "xyes" ; then
    AC_CHECK_LIB(termcap, tgetstr, [SERVER_LIBS="$SERVER_LIBS -ltermcap"], [AC_CHECK_LIB(ncurses, tgetstr, [SERVER_LIBS="$SERVER_LIBS -lncurses"], AC_CHECK_LIB(curses, tgetstr, [SERVER_LIBS="$SERVER_LIBS -lcurses"]))])
-   AC_CHECK_LIB(readline, readline, [SERVER_LIBS="$SERVER_LIBS -lreadline"], [AC_CHECK_LIB(edit, readline, [SERVER_LIBS="$SERVER_LIBS -ledit"])])
+   if test "x$DISABLE_READLINE" = "xno"; then
+      AC_CHECK_LIB(readline, readline, [SERVER_LIBS="$SERVER_LIBS -lreadline"], [AC_CHECK_LIB(edit, readline, [SERVER_LIBS="$SERVER_LIBS -ledit"])])
+   fi
+   AC_CHECK_LIB(rt, timer_create, [SERVER_LIBS="$SERVER_LIBS -lrt"])
    SAVED_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $SERVER_LIBS"
 
-   AC_CHECK_FUNCS([readline])
+   AC_CHECK_FUNCS([readline timer_create])
+   AC_CHECK_TYPES([timer_t])
 
    # Check if passing rl_insert to rl_bind_key needs cast
    if test "$ac_cv_func_readline" = "yes"; then
@@ -1319,6 +1547,42 @@ if test "x$BUILD_SERVER" = "xyes" ; then
    LDFLAGS="$SAVED_LDFLAGS"
 fi
 
+check_substr "$COMPONENTS" "sqlite"
+if test $? = 0; then
+       if test "x$FORCE_INTERNAL_SQLITE" = "xyes"; then
+               HAVE_SQLITE=no
+       else
+               OLD_LIBS="$LIBS"
+               HAVE_SQLITE=yes
+               AC_CHECK_HEADER(sqlite3.h,,HAVE_SQLITE=no)
+               if test "x$HAVE_SQLITE" = "xyes"; then
+                       AC_CHECK_LIB(sqlite3, sqlite3_initialize, [], [ HAVE_SQLITE=no ])
+               fi
+               if test "x$HAVE_SQLITE" = "xyes"; then
+                       if test "x$cross_compiling" = "xyes"; then
+                               AC_MSG_WARN([Cross-compiling mode is active, assuming libsqlite3 is thread-safe])
+                       else
+                               AC_MSG_CHECKING(if libsqlite3 is thread-safe)
+                               AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <sqlite3.h>
+                                       ]],[[
+                                               return sqlite3_threadsafe() ? 0 : 1;
+                                       ]])
+                               ],[
+                                       AC_MSG_RESULT(yes)
+                               ],[
+                                       AC_MSG_RESULT(no)
+                                       HAVE_SQLITE=no
+                               ])
+                       fi
+               fi
+               LIBS="$OLD_LIBS"
+       fi
+       if test "x$HAVE_SQLITE" = "xno"; then
+               MODULES="sqlite $MODULES"
+       fi
+fi
+
 if test "x$NEED_ZLIB" = "xyes"; then
        if test "x$FORCE_INTERNAL_ZLIB" = "xyes"; then
                HAVE_ZLIB=no
@@ -1404,21 +1668,48 @@ fi
 
 if test "x$HAVE_LIBCURL" = "xyes"; then
   SUBAGENT_DIRS="$SUBAGENT_DIRS netsvc"
-  SMSDRV_DIRS="$SMSDRV_DIRS websms"
+  SMSDRV_DIRS="$SMSDRV_DIRS kannel slack text2reach websms"
   HDLINK_DIRS="$HDLINK_DIRS jira"
+  AC_DEFINE(HAVE_LIBCURL, 1, Define to 1 if libcurl is available)
 fi
 
 if test "x$LDAP_SUPPORT" = "xyes"; then
        AC_CHECK_HEADER(ldap.h,HAVE_LDAP=yes,HAVE_LDAP=no)
        if test "x$HAVE_LDAP" = "xyes"; then
                AC_CHECK_LIB(ldap, ldap_init, [ HAVE_LDAP=yes ], [ HAVE_LDAP=no ])
+               if test "x$HAVE_LDAP" = "xyes"; then
+                       AC_CHECK_LIB(lber, ber_init, [ SERVER_LIBS="-llber $SERVER_LIBS" ])
+               fi
        fi
        if test "x$HAVE_LDAP" = "xyes"; then
                SERVER_LIBS="-lldap $SERVER_LIBS"   
                AC_DEFINE(WITH_LDAP, 1, Define to 1 if you have LDAP libraries and headers)
-               AC_CHECK_LIB(ldap, ldap_initialize, [ 
-                               AC_DEFINE(HAVE_LDAP_INITIALIZE, 1, Define to 1 if you have ldap_initialize function)
-                       ], [ ])
+               AC_CHECK_HEADERS([ldap_ssl.h],,,
+                       [
+#include <ldap.h>
+                       ])
+               AC_CHECK_TYPES([ber_int_t],,,
+                       [
+#include <ldap.h>
+#if HAVE_LDAP_SSL_H
+#include <ldap_ssl.h>
+#endif
+                       ])
+
+               OLD_LIBS="$LIBS"
+               LIBS="$LIBS -lldap"
+               AC_CHECK_FUNCS([ldap_initialize ldapssl_init])
+               AC_CHECK_FUNCS([ldap_control_create ldap_create_control nsldapi_build_control])
+               AC_CHECK_FUNCS([ldap_create_page_control ldap_parse_page_control])
+               LIBS="$OLD_LIBS"
+
+               AC_CHECK_DECLS([nsldapi_build_control],,,
+                       [
+#include <ldap.h>
+#if HAVE_LDAP_SSL_H
+#include <ldap_ssl.h>
+#endif
+                       ])
        fi
        LDAP_SUPPORT="$HAVE_LDAP"
 fi
@@ -1467,9 +1758,15 @@ AC_CHECK_FUNCS([gettimeofday memmove memset bcopy strchr strcspn strdup strerror
 AC_CHECK_FUNCS([strrchr strlwr strtol strtoul strtoll strtoull setlocale])
 AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname poll])
 AC_CHECK_FUNCS([usleep nanosleep gmtime_r localtime_r stat64 fstat64 lstat64])
-AC_CHECK_FUNCS([fopen64 strptime timegm gethostbyname2_r])
+AC_CHECK_FUNCS([fopen64 strptime timegm gethostbyname2_r getaddrinfo])
+AC_CHECK_FUNCS([itoa _itoa isatty getgrnam getpwnam malloc_info malloc_trim])
 
-AC_CHECK_DECLS([nanosleep])
+AC_CHECK_DECLS([nanosleep, daemon, strerror])
+
+# Do not use inet_pton on Solaris as it has binary compatibility problems
+if test "$PLATFORM" != "SunOS"; then
+       AC_CHECK_FUNCS([inet_pton])
+fi
 
 # Check if strerror_r is POSIX-compliant
 if test "$ac_cv_func_strerror_r" = "yes"; then
@@ -1521,34 +1818,10 @@ AC_MSG_RESULT(no)
 AC_CHECK_FUNCS([sysctlbyname sysctlnametomib])
 AC_CHECK_FUNCS([tcgetattr tcsetattr cfsetospeed cfsetispeed])
 
-# sockets/resolver
-if test "$BUILD_SERVER-$XMPP_SUPPORT" = "yes-yes"; then
-       AC_CHECK_HEADERS([arpa/nameser_compat.h])
-       AC_CHECK_FUNC(res_query, , [AC_CHECK_LIB(resolv, res_query, [], [AC_CHECK_LIB(resolv, __res_query)])])
-fi
-AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
-AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
-AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
-
-if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
-       AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
-fi
-
-if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
-       AC_MSG_CHECKING([if we can include libnsl + libsocket])
-       LIBS="-lnsl -lsocket $LIBS"
-       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
-       if test "$my_ac_link_result" = "no" ; then
-               AC_MSG_RESULT([failure])
-               AC_MSG_ERROR([unable to use gethostbyname()])
-       else
-               AC_MSG_RESULT([success])
-       fi
-fi
-
 # asprintf, scprintf, etc.
 AC_CHECK_FUNCS([asprintf aswprintf vasprintf vaswprintf])
 AC_CHECK_FUNCS([scprintf scwprintf vscprintf vscwprintf])
+AC_CHECK_FUNCS([snprintf vsnprintf])
 
 AC_MSG_CHECKING(whether snprintf returns required buffer size)
 AC_RUN_IFELSE(
@@ -1567,7 +1840,6 @@ AC_RUN_IFELSE(
 )
 
 
-
 #--------------------------------------------------------------------
 # Checks for macros and definitions
 #--------------------------------------------------------------------
@@ -1640,6 +1912,15 @@ if test "x$PLATFORM" = "xLinux"; then
 #include <sys/reboot.h>
 #endif
        ])
+
+       AC_CHECK_HEADERS([jemalloc/jemalloc.h],
+               [
+                       AC_CHECK_LIB(jemalloc, malloc,
+                               [ 
+                                       WITH_JEMALLOC="yes"
+                                       AC_DEFINE(WITH_JEMALLOC,1,Define to 1 if libjemalloc is used)
+                               ])
+               ])
 fi
 
 
@@ -1786,10 +2067,19 @@ fi
 
 
 #--------------------------------------------------------------------
+# Minix specific checks
+#--------------------------------------------------------------------
+
+if test "x$PLATFORM" = "xMinix"; then
+       AC_CHECK_HEADERS([minix/minlib.h])
+fi
+
+
+#--------------------------------------------------------------------
 # Check for UNICODE stuff
 #--------------------------------------------------------------------
 
-AC_CHECK_HEADERS([wchar.h wctype.h iconv.h])
+AC_CHECK_HEADERS([wchar.h wctype.h iconv.h widec.h])
 AC_CHECK_TYPES([wchar_t, wint_t],,,[
 #if HAVE_WCHAR_H
 #include <wchar.h>
@@ -1800,10 +2090,12 @@ AC_CHECK_SIZEOF(wchar_t,,[
 #include <wchar.h>
 #endif
 ])
-AC_CHECK_FUNCS([wcslen wcsdup wcsncpy wcstoll wcstoull towupper wcserror wcserror_r])
-AC_CHECK_FUNCS([wfopen wfopen64 fputws putws wopen wstat waccess wgetenv wrename wunlink])
-AC_CHECK_FUNCS([wremove wchdir wmkdir wrmdir wsystem wmkstemp wpopen wctime wchmod])
-AC_CHECK_FUNCS([vwscanf vswscanf vfwscanf wcscasecmp wcsncasecmp wcstombs wcsrtombs])
+AC_CHECK_FUNCS([wcslen wcsdup wcsncpy wcstoll wcstoull towupper towlower])
+AC_CHECK_FUNCS([wcslwr wcserror wcserror_r wfopen wfopen64 fputws putws])
+AC_CHECK_FUNCS([wopen wstat waccess wgetenv wrename wunlink wremove wchdir])
+AC_CHECK_FUNCS([wmkdir wrmdir wsystem wmkstemp wpopen wctime wchmod vwscanf])
+AC_CHECK_FUNCS([vswscanf vfwscanf wcscasecmp wcsncasecmp wcstombs wcsrtombs])
+AC_CHECK_FUNCS([itow _itow])
 
 if test "x$DISABLE_ICONV" != "xyes"; then
        AC_CHECK_LIB(iconv, libiconv_open,
@@ -2086,6 +2378,49 @@ AC_RUN_IFELSE(
   [ AC_MSG_RESULT(no) ]
 )
 
+AC_MSG_CHECKING(whether iconv supports state reset)
+AC_RUN_IFELSE(
+  [AC_LANG_PROGRAM([
+#include <stdio.h>
+#if HAVE_ICONV_H
+#include <iconv.h>
+#endif
+     ], [
+     iconv_t cd = iconv_open("UTF-8","$valid_ucs2_code");
+     if (cd == (iconv_t)(-1)) return 1;
+     return iconv(cd, NULL, NULL, NULL, NULL) != 0;
+     ])
+  ],
+  [ AC_MSG_RESULT(yes)
+    AC_DEFINE(HAVE_ICONV_STATE_RESET, 1, Define to 1 if iconv supports state reset)
+  ],
+  [ AC_MSG_RESULT(no) ],
+  [ AC_MSG_RESULT(no) ]
+)
+
+AC_MSG_CHECKING(whether iconv descriptor cache is needed)
+case $enable_iconv_cache in
+    auto)
+        case $PLATFORM in
+            SunOS|HP-UX|AIX)
+                enable_iconv_cache=yes
+                ;;
+            *)
+                enable_iconv_cache=no
+                ;;
+        esac
+        ;;
+    yes|no)
+        ;;
+    *)
+        AC_MSG_ERROR([Value given to --enable-iconv-cache must be one of yes, no or auto])
+        ;;
+esac
+if test "x$enable_iconv_cache" = "xyes"; then
+    AC_DEFINE(WITH_ICONV_CACHE, 1, Define to 1 to enable iconv descriptor cache)
+fi
+AC_MSG_RESULT($enable_iconv_cache)
+
 # taken from ZSH's configure
 # Check if iconv uses const in prototype declaration
 if test "x$ac_found_iconv" = "xyes"; then
@@ -2133,28 +2468,29 @@ fi
 
 check_substr "$COMPONENTS" "mysql"
 if test $? = 0; then
+       OLD_CPPFLAGS="$CPPFLAGS"
+       OLD_LDFLAGS="$LDFLAGS"
+       OLD_LD_RUN_PATH="$LD_RUN_PATH"
+
+       CPPFLAGS="$CPPFLAGS $MYSQL_CPPFLAGS"
+       LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS"
+       if test "x$MYSQL_LD_RUN_PATH" != "x"; then
+               LD_RUN_PATH="${MYSQL_LD_RUN_PATH}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
+       fi
+
+       AC_CHECK_HEADER(mysql.h,,AC_MSG_ERROR([Cannot find mysql.h - check your MySQL client installation]))
+
        AC_CHECK_LIB(mysqlclient, mysql_init, [MYSQL_LIBS="-lmysqlclient"],
                [AC_MSG_ERROR(libmysqlclient is requred for MySQL support)])
 
        OLD_LIBS="$LIBS"
        LIBS="$LIBS $MYSQL_LIBS"
 
-       AC_MSG_CHECKING(whether mysql clients can run)
-       AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <stdio.h>
-#include <mysql.h>    
-int main(void)
-{
-       MYSQL *a = mysql_init(NULL);
-       return 0;
-}
-               ]])],[],[
-                       AC_MSG_RESULT(no)
-                       AC_MSG_ERROR(Your MySQL client libraries aren't properly installed)
-       ],[])
-       AC_MSG_RESULT(yes)
-
        AC_CHECK_FUNCS(mysql_real_escape_string)
+
+       CPPFLAGS="$OLD_CPPFLAGS"
+       LDFLAGS="$OLD_LDFLAGS"
+       LD_RUN_PATH="$OLD_LD_RUN_PATH"
        LIBS="$OLD_LIBS"
 fi
 
@@ -2165,27 +2501,38 @@ fi
 
 check_substr "$COMPONENTS" "pgsql"
 if test $? = 0; then
+       OLD_CPPFLAGS="$CPPFLAGS"
+       OLD_LDFLAGS="$LDFLAGS"
+       OLD_LD_RUN_PATH="$LD_RUN_PATH"
+
+       CPPFLAGS="$CPPFLAGS $PGSQL_CPPFLAGS"
+       LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
+       if test "x$PGSQL_LD_RUN_PATH" != "x"; then
+               LD_RUN_PATH="${PGSQL_LD_RUN_PATH}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
+       fi
+
+       AC_CHECK_HEADER(libpq-fe.h,,AC_MSG_ERROR([Cannot find libpq-fe.h - check your PostgreSQL client installation]))
+
        AC_CHECK_LIB(m, floor)
-       AC_CHECK_LIB(pq, PQconnectdb, [PGSQL_LIBS="-lpq"],
-               [AC_MSG_ERROR(libpq is required for PostgreSQL support)])        
+       AC_CHECK_LIB(pq, PQconnectdb, [PGSQL_LIBS="-lpq"], [
+               if test "x$PLATFORM" = "xSunOS"; then
+                       PGSQL_LDFLAGS="$PGSQL_LDFLAGS/sparcv9"
+                       LDFLAGS="$OLD_LDFLAGS $PGSQL_LDFLAGS"
+                       if test "x$PGSQL_LD_RUN_PATH" != "x"; then
+                               PGSQL_LD_RUN_PATH="$PGSQL_LD_RUN_PATH/sparcv9"
+                               LD_RUN_PATH="${PGSQL_LD_RUN_PATH}${OLD_LD_RUN_PATH:+:}${OLD_LD_RUN_PATH}"
+                       fi
+                       unset ac_cv_lib_pq_PQconnectdb
+                       AC_CHECK_LIB(pq, PQconnectdb, [PGSQL_LIBS="-lpq"], [
+                               AC_MSG_ERROR(libpq is required for PostgreSQL support)])        
+               else
+                       AC_MSG_ERROR(libpq is required for PostgreSQL support)
+               fi
+       ])
 
-       AC_MSG_CHECKING(whether postgresql clients can run)
-       OLD_LIBS="$LIBS"
-       LIBS="$LIBS $PGSQL_LIBS"
-       AC_RUN_IFELSE([AC_LANG_SOURCE([[
-                       #include <stdio.h>
-                       #include <libpq-fe.h>
-                       int main(void)
-                       {
-                               PGconn *a = PQconnectdb("");
-                               return 0;
-                       }
-               ]])],[AC_MSG_RESULT(yes)],[
-                       AC_MSG_RESULT(no)
-                       AC_MSG_ERROR(Your PostgreSQL client libraries are not properly installed)
-               ],[])    
-       LIBS="$OLD_LIBS"
-       AC_CHECK_LIB(pq, PQfformat, [ AC_DEFINE(HAVE_PQFFORMAT, 1, PQfformat not exist in 7.3) ])
+       CPPFLAGS="$OLD_CPPFLAGS"
+       LDFLAGS="$OLD_LDFLAGS"
+       LD_RUN_PATH="$OLD_LD_RUN_PATH"
 fi
 
 
@@ -2200,7 +2547,7 @@ if test $? = 0; then
        OLD_LD_RUN_PATH="$LD_RUN_PATH"
 
        CPPFLAGS="$CPPFLAGS $ODBC_CPPFLAGS"
-       LDFLAGS="$CPPFLAGS $ODBC_LDFLAGS"
+       LDFLAGS="$LDFLAGS $ODBC_LDFLAGS"
        if test "x$ODBC_LD_RUN_PATH" != "x"; then
                LD_RUN_PATH="${ODBC_LD_RUN_PATH}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
        fi
@@ -2229,15 +2576,18 @@ if test $? = 0; then
        OLD_LD_RUN_PATH="$LD_RUN_PATH"
 
        CPPFLAGS="$CPPFLAGS $ORACLE_CPPFLAGS"
-       LDFLAGS="$CPPFLAGS $ORACLE_LDFLAGS"
+       LDFLAGS="$LDFLAGS $ORACLE_LDFLAGS"
        if test "x$ORACLE_LD_RUN_PATH" != "x"; then
                LD_RUN_PATH="${ORACLE_LD_RUN_PATH}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
        fi
 
        AC_CHECK_HEADER(oci.h,,AC_MSG_ERROR([*** Cannot find oci.h - check your Oracle client installation ***]))
-       AC_CHECK_LIB(nnz11, nzstrcpy, [NNZ_LIB=-lnnz11],
+       AC_CHECK_LIB(nnz12, nzstrcpy, [NNZ_LIB=-lnnz12],
                [
-                       AC_CHECK_LIB(nnz10, nzstrcpy, [NNZ_LIB=-lnnz10], [], [-lclntsh])
+                       AC_CHECK_LIB(nnz11, nzstrcpy, [NNZ_LIB=-lnnz11],
+                               [
+                                       AC_CHECK_LIB(nnz10, nzstrcpy, [NNZ_LIB=-lnnz10], [], [-lclntsh])
+                               ], [-lclntsh])
                ], [-lclntsh])
        AC_CHECK_LIB(clntsh, OCIHandleAlloc, [ORACLE_LIBS="-lclntsh $NNZ_LIB"],
                [AC_MSG_ERROR(libclntsh is required for Oracle support)], [$NNZ_LIB])
 check_substr "$COMPONENTS" "java"
 if test $? = 0; then
        AC_CHECK_HEADER(jni.h,,AC_MSG_ERROR([*** Cannot find jni.h - check your JDK installation ***]))
-#      AC_CHECK_LIB(jvm, SQLAllocHandle, [JAVA_LIBS="-ljvm"],
-#              [AC_MSG_ERROR(libjvm is required for Java support)])
 fi
 
 
 #--------------------------------------------------------------------
+# Tuxedo
+#--------------------------------------------------------------------
+
+check_substr "$COMPONENTS" "tuxedo"
+if test $? = 0; then
+       OLD_CPPFLAGS="$CPPFLAGS"
+       OLD_LDFLAGS="$LDFLAGS"
+       OLD_LIBS="$LIBS"
+
+       if test "x$TUXEDO_BASE" != "x"; then
+               TUXEDO_CPPFLAGS="-I$TUXEDO_BASE/include"
+               TUXEDO_LDFLAGS="-L$TUXEDO_BASE/lib"
+               CPPFLAGS="$CPPFLAGS $TUXEDO_CPPFLAGS"
+               LDFLAGS="$LDFLAGS $TUXEDO_LDFLAGS"
+       fi
+       
+       AC_CHECK_HEADER(atmi.h,,AC_MSG_ERROR([*** Cannot find atmi.h - check your Tuxedo installation ***]))
+
+       # https://community.oracle.com/thread/2346582
+       if test "x$PLATFORM" = "xLinux"; then
+               TUXEDO_LDFLAGS="$TUXEDO_LDFLAGS -Xlinker --no-as-needed"
+               LDFLAGS="$LDFLAGS -Xlinker --no-as-needed"
+       fi
+
+       if test "$PLATFORM" = "SunOS"; then
+               AC_CHECK_LIB(rt, nanosleep, [ TUXEDO_LIBS="$TUXEDO_LIBS -lrt" ])
+       fi
+
+       if test "$PLATFORM" = "AIX"; then
+               AC_MSG_CHECKING(for xa_switchp in libengine)
+               OLD_LIBS_LIBENGINE="$LIBS"
+               LIBS="$LIBS -lengine"
+               AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern char *xa_switchp; ]], [[ *xa_switchp = 0; ]])],
+                       [ 
+                               AC_MSG_RESULT(yes) 
+                               TUXEDO_LIBS="$TUXEDO_LIBS -lengine"
+                       ],
+                       [ AC_MSG_RESULT(no) ])
+               LIBS="$OLD_LIBS_LIBENGINE"
+       fi
+
+       LIBS="$LIBS $TUXEDO_LIBS"
+       AC_CHECK_LIB(tux, tpcall, [], [AC_MSG_ERROR(libtux is required for Tuxedo support)])
+
+       CPPFLAGS="$OLD_CPPFLAGS"
+       LDFLAGS="$OLD_LDFLAGS"
+       LIBS="$OLD_LIBS"
+
+       if test "x$PLATFORM" = "xAIX"; then
+               if test -e $TUXEDO_BASE/lib/tpinit.o; then
+                       TUXEDO_LIBS="$TUXEDO_BASE/lib/tpinit.o $TUXEDO_LIBS"
+               fi
+       fi
+fi
+
+#--------------------------------------------------------------------
+# MongoDB
+#--------------------------------------------------------------------
+
+check_substr "$COMPONENTS" "mongodb"
+if test $? = 0; then
+       OLD_CPPFLAGS="$CPPFLAGS"
+       OLD_LDFLAGS="$LDFLAGS"
+       OLD_LIBS="$LIBS"
+
+       if test "x$MONGODB_BASE" != "x"; then
+               MONGODB_CPPFLAGS="-I$MONGODB_BASE/include/libmongoc-1.0/ -I$MONGODB_BASE/include/libbson-1.0/"
+               MONGODB_LDFLAGS="-L$MONGODB_BASE/lib"
+               CPPFLAGS="$CPPFLAGS $MONGODB_CPPFLAGS"
+               LDFLAGS="$LDFLAGS $MONGODB_LDFLAGS"
+       else
+        MONGODB_CPPFLAGS="-I/usr/local/include/libmongoc-1.0/ -I/usr/local/include/libbson-1.0/"
+               MONGODB_LDFLAGS="-L/usr/local/lib"
+               CPPFLAGS="$CPPFLAGS $MONGODB_CPPFLAGS"
+               LDFLAGS="$LDFLAGS $MONGODB_LDFLAGS"
+    fi
+       
+       AC_CHECK_HEADER(mongoc.h,,AC_MSG_ERROR([*** Cannot find mongoc.h - check your MongoDB installation ***]))
+       AC_CHECK_LIB(mongoc-1.0, nanosleep, [ MONGODB_LIBS="$MONGODB_LIBS -lmongoc-1.0" ])
+       AC_CHECK_LIB(bson-1.0, nanosleep, [ MONGODB_LIBS="$MONGODB_LIBS -lbson-1.0" ])
+
+       LIBS="$LIBS $MONGODB_LIBS"
+
+       CPPFLAGS="$OLD_CPPFLAGS"
+       LDFLAGS="$OLD_LDFLAGS"
+       LIBS="$OLD_LIBS"
+fi
+
+#--------------------------------------------------------------------
 # Other settings
 #--------------------------------------------------------------------
 
 if test "x$RUNTIME_PREFIX" = "x"; then
        if test "x${BUILD_UNICODE}" = "xyes"; then
-               CPPFLAGS="$CPPFLAGS -DPREFIX=L\\\"\${prefix}\\\" -DDATADIR=L\\\"\${pkgdatadir}\\\" -DBINDIR=L\\\"\${bindir}\\\" -DLIBDIR=L\\\"\${libdir}\\\" -DPKGLIBDIR=L\\\"\${pkglibdir}\\\""
+               CPPFLAGS="$CPPFLAGS -DPREFIX=L\\\"\${prefix}\\\" -DDATADIR=L\\\"\${pkgdatadir}\\\" -DBINDIR=L\\\"\${bindir}\\\" -DLIBDIR=L\\\"\${libdir}\\\" -DPKGLIBDIR=L\\\"\${pkglibdir}\\\" -DSTATEDIR=L\\\"\${localstatedir}/lib/netxms\\\""
        else
-               CPPFLAGS="$CPPFLAGS -DPREFIX=\\\"\${prefix}\\\" -DDATADIR=\\\"\${pkgdatadir}\\\" -DBINDIR=\\\"\${bindir}\\\" -DLIBDIR=\\\"\${libdir}\\\" -DPKGLIBDIR=\\\"\${pkglibdir}\\\""
+               CPPFLAGS="$CPPFLAGS -DPREFIX=\\\"\${prefix}\\\" -DDATADIR=\\\"\${pkgdatadir}\\\" -DBINDIR=\\\"\${bindir}\\\" -DLIBDIR=\\\"\${libdir}\\\" -DPKGLIBDIR=\\\"\${pkglibdir}\\\" -DSTATEDIR=\\\"\${localstatedir}/lib/netxms\\\""
        fi
 else
        if test "x${BUILD_UNICODE}" = "xyes"; then
-               CPPFLAGS="$CPPFLAGS -DPREFIX=L\\\"$RUNTIME_PREFIX\\\" -DDATADIR=L\\\"$RUNTIME_PREFIX/share/netxms\\\" -DBINDIR=L\\\"$RUNTIME_PREFIX/bin\\\" -DLIBDIR=L\\\"$RUNTIME_PREFIX/lib\\\" -DPKGLIBDIR=L\\\"$RUNTIME_PREFIX/lib/netxms\\\""
+               CPPFLAGS="$CPPFLAGS -DPREFIX=L\\\"$RUNTIME_PREFIX\\\" -DDATADIR=L\\\"$RUNTIME_PREFIX/share/netxms\\\" -DBINDIR=L\\\"$RUNTIME_PREFIX/bin\\\" -DLIBDIR=L\\\"$RUNTIME_PREFIX/lib\\\" -DPKGLIBDIR=L\\\"$RUNTIME_PREFIX/lib/netxms\\\" -DSTATEDIR=L\\\"$RUNTIME_PREFIX/var/lib/netxms\\\""
        else
-               CPPFLAGS="$CPPFLAGS -DPREFIX=\\\"$RUNTIME_PREFIX\\\" -DDATADIR=\\\"$RUNTIME_PREFIX/share/netxms\\\" -DBINDIR=\\\"$RUNTIME_PREFIX/bin\\\" -DLIBDIR=\\\"$RUNTIME_PREFIX/lib\\\" -DPKGLIBDIR=\\\"$RUNTIME_PREFIX/lib/netxms\\\""
+               CPPFLAGS="$CPPFLAGS -DPREFIX=\\\"$RUNTIME_PREFIX\\\" -DDATADIR=\\\"$RUNTIME_PREFIX/share/netxms\\\" -DBINDIR=\\\"$RUNTIME_PREFIX/bin\\\" -DLIBDIR=\\\"$RUNTIME_PREFIX/lib\\\" -DPKGLIBDIR=\\\"$RUNTIME_PREFIX/lib/netxms\\\" -DSTATEDIR=\\\"$RUNTIME_PREFIX/var/lib/netxms\\\""
        fi
 fi
 LDFLAGS="$LDFLAGS_PREFIX $LDFLAGS $LDFLAGS_SUFFIX"
@@ -2326,9 +2763,18 @@ else
 fi
 AC_DEFINE_UNQUOTED([SHLIB_SUFFIX], _T("$SHLIB_SUFFIX"), [Define to platform's shared library suffix])
 
+if test "x$ENABLE_DEBUG" = "xno"; then
+       CPPFLAGS="$CPPFLAGS -DNDEBUG"
+fi
+
+if test "x$WITH_JEMALLOC" = "xyes"; then
+       LIBS="$LIBS -ljemalloc"
+fi
+
 AM_CONDITIONAL([USE_INTERNAL_EXPAT], [test "x$HAVE_LIBEXPAT" = "xno"])
 AM_CONDITIONAL([USE_INTERNAL_LIBTRE], [test "x$HAVE_LIBTRE" = "xno"])
 AM_CONDITIONAL([USE_INTERNAL_JANSSON], [test "x$HAVE_JANSSON" = "xno"])
+AM_CONDITIONAL([USE_INTERNAL_SQLITE], [test "x$HAVE_SQLITE" = "xno"])
 AM_CONDITIONAL([USE_INTERNAL_ZLIB], [test "$NEED_ZLIB/$HAVE_ZLIB" = "yes/no"])
 AM_CONDITIONAL([STATIC_BUILD], [test "x$STATIC_BUILD" = "xyes"])
 AM_CONDITIONAL([ALL_STATIC], [test "x$ALL_STATIC" = "xyes"])
@@ -2338,6 +2784,18 @@ AM_CONDITIONAL([XMPP_SUPPORT], [test "x$XMPP_SUPPORT" = "xyes"])
 
 
 #--------------------------------------------------------------------
+# Cleanup variables
+#--------------------------------------------------------------------
+
+AS_IF([test "x$with_dist" = "xyes"],
+[
+  SUBAGENT_DIRS=`echo $SUBAGENT_DIRS|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
+  MODULES=`echo $MODULES|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
+  SMSDRV_DIRS=`echo $SMSDRV_DIRS|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
+  HDLINK_DIRS=`echo $HDLINK_DIRS|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
+])
+
+#--------------------------------------------------------------------
 # Substitute variables
 #--------------------------------------------------------------------
 
@@ -2349,6 +2807,7 @@ AC_SUBST(SERVER_LIBS)
 AC_SUBST(SERVER_TOOLS)
 AC_SUBST(SMSDRV_DIRS)
 AC_SUBST(HDLINK_DIRS)
+AC_SUBST(PDSDRV_DIRS)
 AC_SUBST(TOP_LEVEL_MODULES)
 AC_SUBST(CONTRIB_MODULES)
 AC_SUBST(CLIENT_COMPONENTS)
@@ -2377,6 +2836,13 @@ AC_SUBST(INFORMIX_LIBS)
 AC_SUBST(OBJECT_MODE)
 AC_SUBST(SQLFLAGS)
 AC_SUBST(SHLIB_SUFFIX)
+AC_SUBST(TUXEDO_CPPFLAGS)
+AC_SUBST(TUXEDO_LDFLAGS)
+AC_SUBST(TUXEDO_LIBS)
+AC_SUBST(MONGODB_CPPFLAGS)
+AC_SUBST(MONGODB_LDFLAGS)
+AC_SUBST(MONGODB_LIBS)
+AC_SUBST(INSTALL_LIBPATH)
 
 #--------------------------------------------------------------------
 # Shared libs versions
@@ -2407,7 +2873,7 @@ AC_SUBST(SHLIB_SUFFIX)
 #      only the first ever interface is implemented, so age can only be `0'. 
 #--------------------------------------------------------------------
 
-NETXMS_LIBRARY_VERSION=1:0:0
+NETXMS_LIBRARY_VERSION=2:0:0
 AC_SUBST(NETXMS_LIBRARY_VERSION)
 
 #--------------------------------------------------------------------
@@ -2422,6 +2888,7 @@ AC_CONFIG_FILES([
        contrib/integration/HP_EVA/Makefile
        contrib/integration/HP_P2000/Makefile
        contrib/mibs/Makefile
+       contrib/music/Makefile
        contrib/startup/Makefile
        contrib/startup/debian/Makefile
        contrib/startup/gentoo/Makefile
@@ -2430,6 +2897,9 @@ AC_CONFIG_FILES([
        contrib/startup/suse/Makefile
        contrib/startup/ubuntu/Makefile
        contrib/startup/solaris/Makefile
+       debian/Makefile
+       debian/patches/Makefile
+       debian/source/Makefile
        doc/Makefile
        doc/internal/Makefile
        doc/manuals/Makefile
@@ -2439,17 +2909,20 @@ AC_CONFIG_FILES([
        m4/Makefile
        src/Makefile
        src/agent/Makefile
-       src/agent/appagent/Makefile
        src/agent/core/Makefile
        src/agent/install/Makefile
+       src/agent/libnxagent/Makefile
+       src/agent/libnxappc/Makefile
        src/agent/libnxsd/Makefile
        src/agent/subagents/Makefile
        src/agent/subagents/aix/Makefile
        src/agent/subagents/darwin/Makefile
        src/agent/subagents/db2/Makefile
        src/agent/subagents/dbquery/Makefile
-   src/agent/subagents/devemu/Makefile
+       src/agent/subagents/devemu/Makefile
+       src/agent/subagents/ds18x20/Makefile
        src/agent/subagents/ecs/Makefile
+       src/agent/subagents/filemgr/Makefile
        src/agent/subagents/freebsd/Makefile
        src/agent/subagents/hpux/Makefile
        src/agent/subagents/informix/Makefile
@@ -2462,6 +2935,15 @@ AC_CONFIG_FILES([
        src/agent/subagents/java/java/src/main/java/org/Makefile
        src/agent/subagents/java/java/src/main/java/org/netxms/Makefile
        src/agent/subagents/java/java/src/main/java/org/netxms/agent/Makefile
+       src/agent/subagents/java/java/src/main/java/org/netxms/agent/adapters/Makefile
+       src/agent/subagents/java/sample/Makefile
+       src/agent/subagents/java/sample/src/Makefile
+       src/agent/subagents/java/sample/src/main/Makefile
+       src/agent/subagents/java/sample/src/main/java/Makefile
+       src/agent/subagents/java/sample/src/main/java/org/Makefile
+       src/agent/subagents/java/sample/src/main/java/org/netxms/Makefile
+       src/agent/subagents/java/sample/src/main/java/org/netxms/agent/Makefile
+       src/agent/subagents/java/sample/src/main/java/org/netxms/agent/demo/Makefile
        src/agent/subagents/linux/Makefile
        src/agent/subagents/lmsensors/Makefile
        src/agent/subagents/logwatch/Makefile
@@ -2475,6 +2957,9 @@ AC_CONFIG_FILES([
        src/agent/subagents/rpi/Makefile
        src/agent/subagents/sms/Makefile
        src/agent/subagents/sunos/Makefile
+       src/agent/subagents/tuxedo/Makefile
+       src/agent/subagents/mongodb/Makefile
+       src/agent/subagents/ubntlw/Makefile
        src/agent/subagents/ups/Makefile
        src/agent/subagents/winnt/Makefile
        src/agent/subagents/winperf/Makefile
@@ -2482,25 +2967,14 @@ AC_CONFIG_FILES([
        src/agent/tools/Makefile
        src/agent/tools/nxappget/Makefile
        src/agent/tools/nxapush/Makefile
+       src/appagent/Makefile
        src/client/Makefile
        src/client/install/Makefile
+       src/client/libnxclient/Makefile
        src/client/nxalarm/Makefile
        src/client/nxevent/Makefile
-       src/client/nxlexer/Makefile
        src/client/nxpush/Makefile
        src/client/nxsms/Makefile
-       src/client/scilexer/Makefile
-       src/client/windows/Makefile
-       src/client/windows/nxav/Makefile
-       src/client/windows/nxav/res/Makefile
-       src/client/windows/nxcon/Makefile
-       src/client/windows/nxcon/icons/Makefile
-       src/client/windows/nxcon/res/Makefile
-       src/client/windows/nxnotify/Makefile
-       src/client/windows/nxnotify/res/Makefile
-       src/client/windows/nxuilib/Makefile
-       src/client/windows/nxuilib/res/Makefile
-       src/client/windows/nxuilib/sounds/Makefile
        src/db/Makefile
        src/db/dbdrv/Makefile
        src/db/dbdrv/db2/Makefile
@@ -2518,14 +2992,16 @@ AC_CONFIG_FILES([
        src/libexpat/Makefile
        src/libexpat/libexpat/Makefile
        src/libnetxms/Makefile
-       src/libnxcl/Makefile
+       src/libnxcc/Makefile
        src/libnxlp/Makefile
        src/libnxmap/Makefile
+       src/libnxmb/Makefile
        src/libnxsl/Makefile
        src/libstrophe/Makefile
        src/libtre/Makefile
        src/libtre/win32/Makefile
        src/nxcproxy/Makefile
+       src/nxlptest/Makefile
        src/nxscript/Makefile
        src/server/Makefile
        src/server/core/Makefile
@@ -2540,6 +3016,8 @@ AC_CONFIG_FILES([
        src/server/drivers/dell-pwc/Makefile
        src/server/drivers/dlink/Makefile
        src/server/drivers/ers8000/Makefile
+       src/server/drivers/h3c/Makefile
+       src/server/drivers/hpsw/Makefile
        src/server/drivers/lib/Makefile
        src/server/drivers/lib/avaya-ers/Makefile
        src/server/drivers/lib/cisco/Makefile
@@ -2548,18 +3026,25 @@ AC_CONFIG_FILES([
        src/server/drivers/ntws/Makefile
        src/server/drivers/ping3/Makefile
        src/server/drivers/procurve/Makefile
+       src/server/drivers/qtech-olt/Makefile
        src/server/drivers/symbol-ws/Makefile
+       src/server/drivers/tb/Makefile
        src/server/drivers/ubnt/Makefile
        src/server/hdlink/Makefile
        src/server/hdlink/jira/Makefile
        src/server/include/Makefile
        src/server/libnxsrv/Makefile
        src/server/netxmsd/Makefile
+       src/server/pdsdrv/Makefile
+       src/server/pdsdrv/rrdtool/Makefile
        src/server/smsdrv/Makefile
        src/server/smsdrv/dummy/Makefile
        src/server/smsdrv/generic/Makefile
+       src/server/smsdrv/kannel/Makefile
        src/server/smsdrv/nxagent/Makefile
        src/server/smsdrv/portech/Makefile
+       src/server/smsdrv/slack/Makefile
+       src/server/smsdrv/text2reach/Makefile
        src/server/smsdrv/websms/Makefile
        src/server/tools/Makefile
        src/server/tools/nxaction/Makefile
@@ -2580,8 +3065,14 @@ AC_CONFIG_FILES([
        src/tools/Makefile
        src/tools/nxdevcfg/Makefile
        src/tools/nxencpasswd/Makefile
+       src/tools/nxgenguid/Makefile
        src/zlib/Makefile
        sql/Makefile
+       tests/Makefile
+       tests/include/Makefile
+       tests/test-libnetxms/Makefile
+       tests/test-libnxcc/Makefile
+       tests/test-libnxdb/Makefile
        tools/Makefile
 ])
 
@@ -2619,6 +3110,11 @@ echo
        echo "Prefix                  : ${prefix}"
        echo "Platform                : ${PLATFORM}"
        echo "Shared library suffix   : ${SHLIB_SUFFIX}"
+if test "x$IPV6_SUPPORT" = "xyes"; then
+       echo "IPv6 support            : YES"
+else
+       echo "IPv6 support            : NO"
+fi
 if test "x${BUILD_SERVER}" = "xyes"; then
        echo "Build Server            : YES"
        echo "Server libs             : ${SERVER_LIBS}"
@@ -2682,6 +3178,14 @@ if test "x${HAVE_JANSSON}" = "xno"; then
 else
        echo "Use internal libjansson : NO"
 fi
+check_substr "$COMPONENTS" "sqlite"
+if test $? = 0; then
+       if test "x${HAVE_SQLITE}" = "xno"; then
+               echo "Use internal sqlite     : YES"
+       else
+               echo "Use internal sqlite     : NO"
+       fi
+fi
 if test "x${NEED_ZLIB}" = "xyes"; then
        if test "x${HAVE_ZLIB}" = "xno"; then
                echo "Use internal zlib       : YES"
@@ -2763,6 +3267,23 @@ if test "x${INFORMIX_LIBS}" != "x"; then
        echo "Informix LIBS           : ${INFORMIX_LIBS}"
 fi
 
+if test "x${TUXEDO_CPPFLAGS}" != "x"; then
+       echo "Tuxedo CPPFLAGS         : ${TUXEDO_CPPFLAGS}"
+fi
+if test "x${TUXEDO_LDFLAGS}" != "x"; then
+       echo "Tuxedo LDFLAGS          : ${TUXEDO_LDFLAGS}"
+fi
+if test "x${TUXEDO_LIBS}" != "x"; then
+       echo "Tuxedo LIBS             : ${TUXEDO_LIBS}"
+fi
+
+if test "x${MONGODB_CPPFLAGS}" != "x"; then
+       echo "MongoDB CPPFLAGS         : ${MONGODB_CPPFLAGS}"
+fi
+if test "x${MONGODB_LDFLAGS}" != "x"; then
+       echo "MongoDB LDFLAGS          : ${MONGODB_LDFLAGS}"
+fi
+
 FLAGS_CPP="src/tools/nxdevcfg/flags.cpp"
 echo "/* Automatically generated by configure */" > $FLAGS_CPP
 echo "#include <nms_common.h>" >> $FLAGS_CPP
@@ -2775,3 +3296,4 @@ echo "const TCHAR *g_cc = _T(\"${CC}\");" >> $FLAGS_CPP
 echo "const TCHAR *g_cxx = _T(\"${CXX}\");" >> $FLAGS_CPP
 echo "const TCHAR *g_ld = _T(\"${LD}\");" >> $FLAGS_CPP
 echo "const TCHAR *g_perl = _T(\"${PERL}\");" >> $FLAGS_CPP
+echo "const TCHAR *g_serverLibs = _T(\"${SERVER_LIBS}\");" >> $FLAGS_CPP