working Linux build with libjansson
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 15 Apr 2014 17:26:17 +0000 (20:26 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 15 Apr 2014 17:26:17 +0000 (20:26 +0300)
configure.ac
packages/linux/debian/6/netxms-server.control
packages/linux/debian/6/populate.sh
packages/linux/debian/7/netxms-server.control
packages/linux/debian/7/populate.sh
packages/linux/debian/README
src/jansson/Makefile.am
src/server/core/hdlink.cpp
src/server/hdlink/jira/Makefile.am
src/server/libnxsrv/messages.mc

index af4bbf0..38c7fc9 100644 (file)
@@ -70,7 +70,7 @@ ODBC_LIBS=""
 FORCE_INTERNAL_EXPAT="no"
 USE_INTERNAL_LIBTRE="no"
 FORCE_INTERNAL_LIBTRE="no"
-USE_INTERNAL_ZLIB="no"
+FORCE_INTERNAL_JANSSON="no"
 FORCE_INTERNAL_ZLIB="no"
 FORCE_32BIT_BUILD="no"
 FORCE_INTERNAL_GETOPT="no"
@@ -186,6 +186,12 @@ AC_ARG_WITH(internal-libtre,
        FORCE_INTERNAL_LIBTRE="yes"
 ])
 
+AC_ARG_WITH(internal-libjansson,
+[AS_HELP_STRING(--with-internal-libjansson,force use of bundled libjansson)],
+[
+        FORCE_INTERNAL_JANSSON="yes"
+])
+
 AC_ARG_WITH(internal-zlib,
 [AS_HELP_STRING(--with-internal-zlib,force use of bundled zlib)],
 [
@@ -413,7 +419,7 @@ 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="libexpat libstrophe libtre zlib libnetxms install sqlite snmp libnxsl libnxlp db server agent libnxmap libnxcl client nxscript nxcproxy tools"
+       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"
    HDLINK_DIRS="jira"
@@ -1361,6 +1367,17 @@ if test "x$HAVE_LIBTRE" = "xno"; then
        AC_DEFINE(TRE_APPROX, 1, [ Define if you want to enable approximate matching functionality. ])
 fi
 
+if test "x$FORCE_INTERNAL_JANSSON" = "xyes"; then
+       HAVE_JANSSON=no
+else
+       HAVE_JANSSON=yes
+       AC_CHECK_HEADER(jansson.h,,HAVE_JANSSON=no)
+       AC_CHECK_LIB(jansson, json_object, [ HAVE_JANSSON=yes ], [ HAVE_JANSSON=no ])
+fi
+if test "x$HAVE_JANSSON" = "xno"; then
+       MODULES="jansson $MODULES"
+fi
+
 if test "x$DISABLE_LMSENSORS" = "xno"; then
        HAVE_LMSENSORS=yes
        AC_CHECK_HEADER(sensors/sensors.h,,HAVE_LMSENSORS=no)
@@ -2291,6 +2308,7 @@ AC_DEFINE_UNQUOTED([SHLIB_SUFFIX], _T("$SHLIB_SUFFIX"), [Define to platform's sh
 
 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_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"])
@@ -2463,6 +2481,7 @@ AC_CONFIG_FILES([
        src/db/libnxdb/Makefile
        src/install/Makefile
        src/install/windows/Makefile
+       src/jansson/Makefile
        src/libexpat/Makefile
        src/libexpat/libexpat/Makefile
        src/libnetxms/Makefile
@@ -2617,6 +2636,11 @@ if test "x${HAVE_LIBTRE}" = "xno"; then
 else
        echo "Use internal libtre     : NO"
 fi
+if test "x${HAVE_JANSSON}" = "xno"; then
+       echo "Use internal libjansson : YES"
+else
+       echo "Use internal libjansson : NO"
+fi
 if test "x${NEED_ZLIB}" = "xyes"; then
        if test "x${HAVE_ZLIB}" = "xno"; then
                echo "Use internal zlib       : YES"
index 3f7aaf8..7e14e90 100644 (file)
@@ -4,6 +4,6 @@ Section: net
 Priority: optional
 Architecture: @arch@
 Essential: no
-Depends: netxms-agent (= @version@), libreadline6, libcurl3
+Depends: netxms-agent (= @version@), libreadline6, libcurl3, libjansson4
 Maintainer: Victor Kirhenshtein <victor@netxms.org>
 Description: NetXMS server
index 6e11997..dc42807 100755 (executable)
@@ -94,6 +94,7 @@ cp /usr/bin/nxsnmpget netxms-server/usr/bin/
 cp /usr/bin/nxsnmpset netxms-server/usr/bin/
 cp /usr/bin/nxsnmpwalk netxms-server/usr/bin/
 cp /usr/bin/nxupload netxms-server/usr/bin/
+cp /usr/lib/netxms/*.hdlink netxms-server/usr/lib/netxms/
 cp /usr/lib/netxms/ndd/*.ndd netxms-server/usr/lib/netxms/ndd/
 cp -P /usr/lib/libavaya-ers.so* netxms-server/usr/lib/
 cp -P /usr/lib/libcisco.so* netxms-server/usr/lib/
index 3f7aaf8..7e14e90 100644 (file)
@@ -4,6 +4,6 @@ Section: net
 Priority: optional
 Architecture: @arch@
 Essential: no
-Depends: netxms-agent (= @version@), libreadline6, libcurl3
+Depends: netxms-agent (= @version@), libreadline6, libcurl3, libjansson4
 Maintainer: Victor Kirhenshtein <victor@netxms.org>
 Description: NetXMS server
index 6e11997..dc42807 100755 (executable)
@@ -94,6 +94,7 @@ cp /usr/bin/nxsnmpget netxms-server/usr/bin/
 cp /usr/bin/nxsnmpset netxms-server/usr/bin/
 cp /usr/bin/nxsnmpwalk netxms-server/usr/bin/
 cp /usr/bin/nxupload netxms-server/usr/bin/
+cp /usr/lib/netxms/*.hdlink netxms-server/usr/lib/netxms/
 cp /usr/lib/netxms/ndd/*.ndd netxms-server/usr/lib/netxms/ndd/
 cp -P /usr/lib/libavaya-ers.so* netxms-server/usr/lib/
 cp -P /usr/lib/libcisco.so* netxms-server/usr/lib/
index 885b963..631219f 100644 (file)
@@ -1,7 +1,7 @@
 Building binary packages for Debian:
 
 0. Prerequisites:
-       Packages: libssl-dev libexpat1-dev libreadline6-dev libsensors4-dev libcurl4-openssl-dev unixodbc-dev libpq-dev libmysqlclient-dev libaio1
+       Packages: libssl-dev libexpat1-dev libreadline6-dev libsensors4-dev libcurl4-openssl-dev libjansson-dev unixodbc-dev libpq-dev libmysqlclient-dev libaio1
        Oracle Instant Client 11.2 unpacked into /opt/instantclient_11_2
 
 1. Configure and build NetXMS as following:
index 489a957..95488c5 100644 (file)
@@ -1,26 +1,27 @@
-EXTRA_DIST = jansson.def
-
-include_HEADERS = jansson.h jansson_config.h
-
-lib_LTLIBRARIES = libjansson.la
-libjansson_la_SOURCES = \
+lib_LTLIBRARIES = libnxjansson.la
+libnxjansson_la_SOURCES = \
        dump.c \
        error.c \
        hashtable.c \
-       hashtable.h \
        hashtable_seed.c \
-       jansson_private.h \
        load.c \
-       lookup3.h \
        memory.c \
        pack_unpack.c \
        strbuffer.c \
-       strbuffer.h \
        strconv.c \
        utf.c \
-       utf.h \
        value.c
-libjansson_la_LDFLAGS = \
+libnxjansson_la_CPPFLAGS=-I@top_srcdir@/include
+libnxjansson_la_LDFLAGS = \
        -no-undefined \
        -export-symbols-regex '^json_' \
        -version-info 10:0:6
+
+EXTRA_DIST = \
+       hashtable.h \
+       jansson.def \
+       jansson.vcproj \
+       jansson_private.h \
+       lookup3.h \
+       strbuffer.h \
+       utf.h
index 2dd8b2d..987ec39 100644 (file)
@@ -33,31 +33,56 @@ static HelpDeskLink *s_link = NULL;
  */
 void LoadHelpDeskLink()
 {
-   TCHAR file[MAX_PATH], errorText[256];
+   TCHAR name[MAX_PATH], errorText[256];
 
-   ConfigReadStr(_T("HelpDeskLink"), file, MAX_PATH, _T("none"));
-   if ((file[0] == 0) || !_tcsicmp(file, _T("none")))
+   ConfigReadStr(_T("HelpDeskLink"), name, MAX_PATH, _T("none"));
+   if ((name[0] == 0) || !_tcsicmp(name, _T("none")))
    {
       DbgPrintf(2, _T("Helpdesk link disabled"));
       return;
    }
 
-   HMODULE hModule = DLOpen(file, errorText);
+#if !defined(_WIN32) && !defined(_NETWARE)
+   TCHAR fullName[MAX_PATH];
+
+   if (_tcschr(name, _T('/')) == NULL)
+   {
+      // Assume that module name without path given
+      // Try to load it from pkglibdir
+      const TCHAR *homeDir = _tgetenv(_T("NETXMS_HOME"));
+      if (homeDir != NULL)
+      {
+         _sntprintf(fullName, MAX_PATH, _T("%s/lib/netxms/%s"), homeDir, name);
+      }
+      else
+      {
+         _sntprintf(fullName, MAX_PATH, _T("%s/%s"), PKGLIBDIR, name);
+      }
+   }
+   else
+   {
+      nx_strncpy(fullName, name, MAX_PATH);
+   }
+   HMODULE hModule = DLOpen(fullName, errorText);
+#else
+   HMODULE hModule = DLOpen(name, errorText);
+#endif
+
    if (hModule != NULL)
    {
-               int *apiVersion = (int *)DLGetSymbolAddr(hModule, "hdlinkAPIVersion", errorText);
+      int *apiVersion = (int *)DLGetSymbolAddr(hModule, "hdlinkAPIVersion", errorText);
       HelpDeskLink *(* CreateInstance)() = (HelpDeskLink *(*)())DLGetSymbolAddr(hModule, "hdlinkCreateInstance", errorText);
 
       if ((apiVersion != NULL) && (CreateInstance != NULL))
       {
          if (*apiVersion == HDLINK_API_VERSION)
          {
-                               s_link = CreateInstance();
+            s_link = CreateInstance();
                                if (s_link != NULL)
                                {
                if (s_link->init())
                {
-                                          nxlog_write(MSG_HDLINK_LOADED, EVENTLOG_INFORMATION_TYPE, "s", s_link->getName());
+                                          nxlog_write(MSG_HDLINK_LOADED, EVENTLOG_INFORMATION_TYPE, "ss", s_link->getName(), s_link->getVersion());
                   g_dwFlags |= AF_HELPDESK_LINK_ACTIVE;
                }
                                   else
@@ -69,25 +94,25 @@ void LoadHelpDeskLink()
                                }
                                else
                                {
-                                       nxlog_write(MSG_HDLINK_INIT_FAILED, EVENTLOG_ERROR_TYPE, "s", file);
+                                       nxlog_write(MSG_HDLINK_INIT_FAILED, EVENTLOG_ERROR_TYPE, "s", name);
                                        DLClose(hModule);
                                }
          }
          else
          {
-            nxlog_write(MSG_HDLINK_API_VERSION_MISMATCH, EVENTLOG_ERROR_TYPE, "sdd", file, NDDRV_API_VERSION, *apiVersion);
+            nxlog_write(MSG_HDLINK_API_VERSION_MISMATCH, EVENTLOG_ERROR_TYPE, "sdd", name, NDDRV_API_VERSION, *apiVersion);
             DLClose(hModule);
          }
       }
       else
       {
-         nxlog_write(MSG_NO_HDLINK_ENTRY_POINT, EVENTLOG_ERROR_TYPE, "s", file);
+         nxlog_write(MSG_NO_HDLINK_ENTRY_POINT, EVENTLOG_ERROR_TYPE, "s", name);
          DLClose(hModule);
       }
    }
    else
    {
-      nxlog_write(MSG_DLOPEN_FAILED, EVENTLOG_ERROR_TYPE, "ss", file, errorText);
+      nxlog_write(MSG_DLOPEN_FAILED, EVENTLOG_ERROR_TYPE, "ss", name, errorText);
    }
 }
 
index df3550a..47314e3 100644 (file)
@@ -4,7 +4,12 @@ pkglib_LTLIBRARIES = jira.la
 jira_la_SOURCES = jira.cpp
 jira_la_CPPFLAGS=-I@top_srcdir@/include -I@top_srcdir@/src/server/include
 jira_la_LDFLAGS = -module -avoid-version
-jira_la_LIBADD = ../../../libnetxms/libnetxms.la ../../libnxsrv/libnxsrv.la ../../core/libnxcore.la
+jira_la_LIBADD = ../../../libnetxms/libnetxms.la ../../libnxsrv/libnxsrv.la ../../core/libnxcore.la -lcurl
+if USE_INTERNAL_JANSSON
+jira_la_LIBADD += @top_srcdir@/src/jansson/libnxjansson.la
+else
+jira_la_LIBADD += -ljansson
+endif
 
 EXTRA_DIST = \
        jira.vcproj \
@@ -12,6 +17,5 @@ EXTRA_DIST = \
 
 install-exec-hook:
        if test "x`uname -s`" = "xAIX" ; then OBJECT_MODE=@OBJECT_MODE@ $(AR) x $(DESTDIR)$(pkglibdir)/$(HDLINK).a $(DESTDIR)$(pkglibdir)/$(HDLINK)@SHLIB_SUFFIX@ ; rm -f $(DESTDIR)$(pkglibdir)/$(HDLINK).a ; fi
-       mkdir -p $(DESTDIR)$(pkglibdir)/hdlink
-       mv -f $(DESTDIR)$(pkglibdir)/$(HDLINK)@SHLIB_SUFFIX@ $(DESTDIR)$(pkglibdir)/hdlink/$(HDLINK).hdlink
+       mv -f $(DESTDIR)$(pkglibdir)/$(HDLINK)@SHLIB_SUFFIX@ $(DESTDIR)$(pkglibdir)/$(HDLINK).hdlink
        rm -f $(DESTDIR)$(pkglibdir)/$(HDLINK).la
index f9e2bdd..f6e9553 100644 (file)
@@ -941,7 +941,7 @@ Unable to configure serial port %1
 MessageId=
 SymbolicName=MSG_HDLINK_LOADED
 Language=English
-Helpdesk link module "%1" loaded successfully
+Helpdesk link module %1 (version %2) loaded successfully
 .
 
 MessageId=