added module info tool; module entry point names changed
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 25 Oct 2016 09:30:49 +0000 (12:30 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 25 Oct 2016 09:30:49 +0000 (12:30 +0300)
12 files changed:
.gitignore
configure.ac
src/server/core/modules.cpp
src/server/include/nxmodule.h
src/server/netxmsd/netxmsd.cpp
src/server/tools/Makefile.am
src/server/tools/nxminfo/.cproject [new file with mode: 0644]
src/server/tools/nxminfo/.project [new file with mode: 0644]
src/server/tools/nxminfo/.settings/language.settings.xml [new file with mode: 0644]
src/server/tools/nxminfo/Makefile.am [new file with mode: 0644]
src/server/tools/nxminfo/nxminfo.cpp [new file with mode: 0644]
tools/updatetag.sh

index 63491b7..004b21f 100644 (file)
@@ -201,6 +201,7 @@ target
 /src/server/tools/nxdbmgr/tables.cpp
 /src/server/tools/nxencpasswd/nxencpasswd
 /src/server/tools/nxget/nxget
+/src/server/tools/nxminfo/nxminfo
 /src/server/tools/nxupload/nxupload
 /src/snmp/nxmibc/lex.mp.c
 /src/snmp/nxmibc/lex.parser.cpp
index a5d1560..08e415a 100644 (file)
@@ -3051,6 +3051,22 @@ AM_CONDITIONAL([ZEROMQ_SUPPORT], [test "x$ZEROMQ_SUPPORT" = "xyes"])
 
 
 #--------------------------------------------------------------------
+# Get compiler version
+#--------------------------------------------------------------------
+
+COMPILER_VERSION=""
+for opt in --version -v -V -qversion; do
+       v=`$CXX $opt 2>/dev/null | head -1`
+       if test $? = 0; then
+               if test "x$COMPILER_VERSION" = "x"; then
+                       COMPILER_VERSION="$v"
+                       AC_DEFINE_UNQUOTED([CPP_COMPILER_VERSION], "$COMPILER_VERSION", [C++ compiler version information])
+               fi
+       fi
+done
+
+
+#--------------------------------------------------------------------
 # Cleanup variables
 #--------------------------------------------------------------------
 
@@ -3324,6 +3340,7 @@ AC_CONFIG_FILES([
        src/server/tools/nxconfig/res/Makefile
        src/server/tools/nxdbmgr/Makefile
        src/server/tools/nxget/Makefile
+       src/server/tools/nxminfo/Makefile
        src/server/tools/nxupload/Makefile
        src/smsdrv/Makefile
        src/smsdrv/dummy/Makefile
@@ -3492,6 +3509,7 @@ fi
 
 echo "C compiler              : ${CC}"
 echo "C++ compiler            : ${CXX}"
+echo "C++ compiler info       : ${COMPILER_VERSION}"
 echo "CPPFLAGS                : ${CPPFLAGS}"
 echo "CXXFLAGS                : ${CXXFLAGS}"
 echo "CFLAGS                  : ${CFLAGS}"
index 4b4f0ad..b213fdc 100644 (file)
@@ -72,7 +72,7 @@ static bool LoadNetXMSModule(const TCHAR *name)
    {
       bool (* ModuleInit)(NXMODULE *, Config *);
 
-      ModuleInit = (bool (*)(NXMODULE *, Config *))DLGetSymbolAddr(hModule, "NetXMSModuleInit", szErrorText);
+      ModuleInit = (bool (*)(NXMODULE *, Config *))DLGetSymbolAddr(hModule, "NXM_Init", szErrorText);
       if (ModuleInit != NULL)
       {
          NXMODULE module;
index 66e68ee..db47868 100644 (file)
@@ -101,6 +101,22 @@ typedef struct
 } NXMODULE;
 
 /**
+ * Module metadata
+ */
+typedef struct
+{
+   UINT32 size;   // structure size in bytes
+   int unicode;  // unicode flag
+   char name[MAX_OBJECT_NAME];
+   char vendor[128];
+   char coreVersion[16];
+   char coreBuildTag[32];
+   char moduleVersion[16];
+   char moduleBuildTag[32];
+   char compiler[256];
+} NXMODULE_METADATA;
+
+/**
  * Enumerate all modules where given entry point available
  */
 #define ENUMERATE_MODULES(e) if (!(g_flags & AF_SHUTDOWN)) \
index dba66fe..ba3e0d8 100644 (file)
@@ -213,6 +213,7 @@ static BOOL ParseCommandLine(int argc, char *argv[])
                _tprintf(_T("NXCP: %d.%d.%d.%d (%s)\n"), 
                   NXCP_VERSION, CLIENT_PROTOCOL_VERSION_BASE, CLIENT_PROTOCOL_VERSION_MOBILE, CLIENT_PROTOCOL_VERSION_FULL,
                   ciphers.isEmpty() ? _T("NO ENCRYPTION") : ciphers.getBuffer());
+               _tprintf(_T("Built with: %hs\n"), CPP_COMPILER_VERSION);
             }
                                return FALSE;
                        case 'c':
index 65e14b1..26f289c 100644 (file)
@@ -8,5 +8,5 @@
 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-SUBDIRS = nxget nxadm nxaction nxap nxdbmgr nxupload
+SUBDIRS = nxget nxadm nxaction nxap nxdbmgr nxminfo nxupload
 SUBDIRS += @SERVER_TOOLS@
diff --git a/src/server/tools/nxminfo/.cproject b/src/server/tools/nxminfo/.cproject
new file mode 100644 (file)
index 0000000..e743a30
--- /dev/null
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+       <storageModule moduleId="org.eclipse.cdt.core.settings">
+               <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1111194898">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1111194898" moduleId="org.eclipse.cdt.core.settings" name="Default">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.1111194898" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+                                       <folderInfo id="cdt.managedbuild.toolchain.gnu.base.1111194898.831660558" name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.gnu.base.1672274140" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
+                                                       <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.GNU_ELF" id="cdt.managedbuild.target.gnu.platform.base.664376638" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
+                                                       <builder id="cdt.managedbuild.target.gnu.builder.base.559483630" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.archiver.base.881638486" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1607732769" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+                                                               <option id="gnu.cpp.compiler.option.include.paths.1688452984" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/src/server/include&quot;"/>
+                                                               </option>
+                                                               <option id="gnu.cpp.compiler.option.preprocessor.def.58621125" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
+                                                                       <listOptionValue builtIn="false" value="_THREAD_SAFE"/>
+                                                                       <listOptionValue builtIn="false" value="TRE_WCHAR=1"/>
+                                                                       <listOptionValue builtIn="false" value="UNICODE"/>
+                                                                       <listOptionValue builtIn="false" value="_GNU_SOURCE"/>
+                                                               </option>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.50048042" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.515456120" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+                                                               <option id="gnu.c.compiler.option.include.paths.528077636" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/src/server/include&quot;"/>
+                                                               </option>
+                                                               <option id="gnu.c.compiler.option.preprocessor.def.symbols.1550170974" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
+                                                                       <listOptionValue builtIn="false" value="_THREAD_SAFE"/>
+                                                                       <listOptionValue builtIn="false" value="TRE_WCHAR=1"/>
+                                                                       <listOptionValue builtIn="false" value="UNICODE"/>
+                                                                       <listOptionValue builtIn="false" value="_GNU_SOURCE"/>
+                                                               </option>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.473896836" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1074715343" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.879669429" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1832957656" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.assembler.base.771902113" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+                                                               <option id="gnu.both.asm.option.include.paths.817675130" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/src/server/include&quot;"/>
+                                                               </option>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.assembler.input.734691278" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+       </storageModule>
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+               <project id="nxminfo.null.251601391" name="nxminfo"/>
+       </storageModule>
+       <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1111194898;cdt.managedbuild.toolchain.gnu.base.1111194898.831660558;cdt.managedbuild.tool.gnu.c.compiler.base.515456120;cdt.managedbuild.tool.gnu.c.compiler.input.473896836">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1111194898;cdt.managedbuild.toolchain.gnu.base.1111194898.831660558;cdt.managedbuild.tool.gnu.cpp.compiler.base.1607732769;cdt.managedbuild.tool.gnu.cpp.compiler.input.50048042">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               </scannerConfigBuildInfo>
+       </storageModule>
+</cproject>
diff --git a/src/server/tools/nxminfo/.project b/src/server/tools/nxminfo/.project
new file mode 100644 (file)
index 0000000..0e5953e
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>nxminfo</name>
+       <comment></comment>
+       <projects>
+               <project>libnetxms</project>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+                       <triggers>clean,full,incremental,</triggers>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+                       <triggers>full,incremental,</triggers>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.cdt.core.cnature</nature>
+               <nature>org.eclipse.cdt.core.ccnature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+       </natures>
+       <filteredResources>
+               <filter>
+                       <id>1477381907921</id>
+                       <name></name>
+                       <type>6</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.o</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1477381907928</id>
+                       <name></name>
+                       <type>6</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.lo</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1477381907933</id>
+                       <name></name>
+                       <type>6</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.la</arguments>
+                       </matcher>
+               </filter>
+       </filteredResources>
+</projectDescription>
diff --git a/src/server/tools/nxminfo/.settings/language.settings.xml b/src/server/tools/nxminfo/.settings/language.settings.xml
new file mode 100644 (file)
index 0000000..12888ce
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project>
+       <configuration id="cdt.managedbuild.toolchain.gnu.base.1111194898" name="Default">
+               <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+                       <provider class="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsGenericProvider" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" name="CDT User Setting Entries" prefer-non-shared="true"/>
+                       <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
+                       <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
+                       <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1092612425949096371" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+                               <language-scope id="org.eclipse.cdt.core.gcc"/>
+                               <language-scope id="org.eclipse.cdt.core.g++"/>
+                       </provider>
+                       <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+               </extension>
+       </configuration>
+</project>
diff --git a/src/server/tools/nxminfo/Makefile.am b/src/server/tools/nxminfo/Makefile.am
new file mode 100644 (file)
index 0000000..045997a
--- /dev/null
@@ -0,0 +1,6 @@
+bin_PROGRAMS = nxminfo
+nxminfo_SOURCES = nxminfo.cpp
+nxminfo_CPPFLAGS=-I@top_srcdir@/include -I@top_srcdir@/src/server/include
+nxminfo_LDADD = ../../../libnetxms/libnetxms.la ../../libnxsrv/libnxsrv.la @SERVER_LIBS@
+
+EXTRA_DIST = nxminfo.vcproj
diff --git a/src/server/tools/nxminfo/nxminfo.cpp b/src/server/tools/nxminfo/nxminfo.cpp
new file mode 100644 (file)
index 0000000..d5fd7e7
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+** nxminfo - NetXMS module info tool
+** Copyright (C) 2016 Raden Solutions
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+**/
+
+#include <nms_common.h>
+#include <nms_util.h>
+#include <netxms-version.h>
+#include <nms_core.h>
+#include <nxmodule.h>
+
+/**
+ * Check if entry point is present
+ */
+#define CHECK_ENTRY_POINT(p) _tprintf(_T("   %-16hs : %s\n"), p, (DLGetSymbolAddr(handle, p, NULL) != NULL) ? _T("yes") : _T("no"))
+
+/**
+ * Entry point
+ */
+int main(int argc, char *argv[])
+{
+   _tprintf(_T("NetXMS Module Info Tool Version ") NETXMS_VERSION_STRING _T(" Build ") NETXMS_BUILD_TAG IS_UNICODE_BUILD_STRING _T("\n\n"));
+   if (argc != 2)
+   {
+      _tprintf(_T("Usage: nxminfo <module>\n"));
+      return 1;
+   }
+
+#ifdef UNICODE
+   WCHAR *fname = WideStringFromMBStringSysLocale(argv[1]);
+#else
+   char *fname = argv[1];
+#endif
+
+#if !defined(_WIN32)
+   TCHAR modname[MAX_PATH];
+   if (_tcschr(fname, _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(modname, MAX_PATH, _T("%s/lib/netxms/%s"), homeDir, fname);
+      }
+      else
+      {
+         _sntprintf(modname, MAX_PATH, _T("%s/%s"), PKGLIBDIR, fname);
+      }
+   }
+   else
+   {
+      nx_strncpy(modname, fname, MAX_PATH);
+   }
+#else
+#define modname fname
+#endif
+
+   TCHAR errorText[1024];
+   HMODULE handle = DLOpen(modname, errorText);
+   if (handle == NULL)
+   {
+      _tprintf(_T("Cannot load module (%s)\n"), errorText);
+      return 2;
+   }
+
+   NXMODULE_METADATA *metadata = (NXMODULE_METADATA *)DLGetSymbolAddr(handle, "NXM_metadata", errorText);
+   if (metadata == NULL)
+   {
+      _tprintf(_T("Cannot locate module metadata (%s)\n"), errorText);
+      return 3;
+   }
+
+   if (sizeof(NXMODULE_METADATA) != metadata->size)
+   {
+      _tprintf(_T("WARNING: module metadata size is different from what is expected by server (%d/%d)\n\n"), metadata->size, (int)sizeof(NXMODULE_METADATA));
+   }
+
+   NXMODULE_METADATA module;
+   memset(&module, 0, sizeof(NXMODULE_METADATA));
+   memcpy(&module, metadata, min(metadata->size, sizeof(NXMODULE_METADATA)));
+
+   _tprintf(_T("Module:         %s\n"), modname);
+   _tprintf(_T("Name:           %hs\n"), module.name);
+   _tprintf(_T("Vendor:         %hs\n"), module.vendor);
+   _tprintf(_T("Version:        %hs\n"), module.moduleVersion);
+   _tprintf(_T("Build tag:      %hs\n"), module.moduleBuildTag);
+   _tprintf(_T("Core version:   %hs\n"), module.coreVersion);
+   _tprintf(_T("Core build tag: %hs\n"), module.coreBuildTag);
+   _tprintf(_T("Compiler:       %hs\n"), module.compiler);
+   _tprintf(_T("UNICODE build:  %s\n"), module.unicode ? _T("yes") : _T("no"));
+
+   _tprintf(_T("\nEntry points:\n"));
+   CHECK_ENTRY_POINT("NXM_Init");
+   CHECK_ENTRY_POINT("NXM_CheckDB");
+   CHECK_ENTRY_POINT("NXM_UpgradeDB");
+   CHECK_ENTRY_POINT("NXM_GetTables");
+
+   DLClose(handle);
+#ifdef UNICODE
+   free(fname);
+#endif
+   return 0;
+}
index 2797956..7a8c87b 100755 (executable)
@@ -1,17 +1,29 @@
 #!/bin/sh
 
-HEADER="netxms-build-tag.h"
+FILE_PREFIX=$1
+DEFINE_PREFIX=$2
+
+if [ "x$FILE_PREFIX" = "x" ]; then
+       FILE_PREFIX="netxms"
+fi
+
+if [ "x$DEFINE_PREFIX" = "x" ]; then
+       DEFINE_PREFIX="NETXMS"
+fi
+
+HEADER="$FILE_PREFIX-build-tag.h"
 
 [ -f $HEADER ] || touch $HEADER
 
-BUILD_TAG=`git describe 2>/dev/null`
+BUILD_TAG=`git describe --always 2>/dev/null`
 [ -z $BUILD_TAG ] && BUILD_TAG=UNKNOWN
 grep "BUILDTAG:$BUILD_TAG" $HEADER >/dev/null 2>&1
 if [ $? != 0 ]; then
   echo "/* BUILDTAG:$BUILD_TAG */" > $HEADER
-  echo "#ifndef _build_tag_h_" >> $HEADER
-  echo "#define _build_tag_h_" >> $HEADER
-  echo "#define NETXMS_BUILD_TAG _T(\"$BUILD_TAG\")" >> $HEADER
+  echo "#ifndef _${FILE_PREFIX}_build_tag_h_" >> $HEADER
+  echo "#define _${FILE_PREFIX}_build_tag_h_" >> $HEADER
+  echo "#define ${DEFINE_PREFIX}_BUILD_TAG _T(\"$BUILD_TAG\")" >> $HEADER
+  echo "#define ${DEFINE_PREFIX}_BUILD_TAG_A \"$BUILD_TAG\"" >> $HEADER
   echo "#endif" >> $HEADER
   echo "Build tag updated"
 fi