]> git.openfabrics.org - ~adrianc/mstflint.git/commitdiff
added --enable-xml2 configure flag to allow libxml2 dependant features
authorAdrian Chiris <adrianc@mellanox.com>
Wed, 7 Sep 2016 12:12:26 +0000 (15:12 +0300)
committerAdrian Chiris <adrianc@mellanox.com>
Wed, 7 Sep 2016 12:12:26 +0000 (15:12 +0300)
configure.ac
mlxconfig/Makefile.am
mlxconfig/mlxcfg_generic_commander.cpp

index 5ec4a74808f0d455070735cc7ad82458b4085797..c7820a15ffd205c4a024330d54d6e39efa0b962f 100644 (file)
@@ -35,15 +35,26 @@ if test "$enable_dc" = "yes"; then
 fi
 
 # XML2
-if test ! -f /usr/include/libxml2/libxml/xpath.h; then
-    AC_MSG_NOTICE([checking for libxml2... no])
-    AC_MSG_ERROR([libxml2: xpath.h is not found in the system PATH. make sure libxml2 headres are installed.])
-else
-    AC_MSG_NOTICE([checking for libxml2... yes])
-    XML2_INC_DIR=/usr/include/libxml2/
+AC_MSG_CHECKING(--enable-xml2 argument)
+AC_ARG_ENABLE(xml2,
+            [  --enable-xml2           Enable mstflint libxml2 dependant features],
+            [enable_xml2="yes"],
+            [enable_xml2="no"])
+AC_MSG_RESULT($enable_xml2)
+if test "x$enable_xml2" = "xyes"; then
+    # XML2 checks
+    if test ! -f /usr/include/libxml2/libxml/xpath.h; then
+        AC_MSG_NOTICE([checking for libxml2... no])
+        AC_MSG_ERROR([libxml2: xpath.h is not found in the system PATH. make sure libxml2 headres are installed.])
+    else
+        AC_MSG_NOTICE([checking for libxml2... yes])
+        XML2_INC_DIR=/usr/include/libxml2/
+    fi
+    AC_CHECK_LIB(xml2, xmlDocDumpFormatMemoryEnc,, AC_MSG_ERROR([cannot find xml2 xmlDocDumpFormatMemoryEnc() function. Try re-installing the library...]))
+    AC_SUBST(XML2_INC_DIR)
 fi
-AC_CHECK_LIB(xml2, xmlDocDumpFormatMemoryEnc,, AC_MSG_ERROR([cannot find xml2 xmlDocDumpFormatMemoryEnc() function. Try re-installing the library...]))
-AC_SUBST(XML2_INC_DIR)
+AM_CONDITIONAL(DISABLE_XML2, [test  "x$enable_xml2" = "xno"])
+AC_SUBST(DISABLE_XML2)
 
 AM_CONDITIONAL(ENABLE_DC, [test  "x$enable_dc" = "xyes"])
 AC_SUBST(ENABLE_DC)
@@ -62,7 +73,7 @@ AM_CONDITIONAL(ENABLE_INBAND, [test  "x$enable_inband" = "xyes"])
 
 AC_MSG_CHECKING(--enable-cs argument)
 AC_ARG_ENABLE(cs,
-            [  --enable-cs          Enable mstflint "checksum" command, dependant of openssl library],
+            [  --enable-cs             Enable mstflint "checksum" command, dependant of openssl library],
             [enable_cs="yes"],
             [enable_cs="no"])
 AC_MSG_RESULT($enable_cs)
index e9143ef9a0dedbc56fe5df7e1ef2482c8d457ed0..c5cc075815652edf48c243652b314349dc1cb3fb 100755 (executable)
@@ -45,15 +45,23 @@ EXT_LIB_DIR = $(USER_DIR)/ext_libs
 SUBDIRS = mlxconfig_dbs
 
 AM_CPPFLAGS = -I. -I$(USER_DIR) -I$(top_srcdir)/include/mtcr_ul -I$(MTCR_DIR) -I$(COMMON_DIR) $(WIN64_INC)\
-           -I $(LAYOUTS_DIR) -I $(UTILS_DIR) -I$(DEV_MGT_DIR) -I$(CMDIF_DIR) -I$(XML2_INC_DIR)
+           -I $(LAYOUTS_DIR) -I $(UTILS_DIR) -I$(DEV_MGT_DIR) -I$(CMDIF_DIR)
+
 
 AM_CXXFLAGS = -Wall -W -g -MP -MD -pipe  -DDATA_PATH=\"$(pkgdatadir)\"
 bin_PROGRAMS = mstconfig
 
-mstconfig_LDADD = $(UTILS_LIB) $(EXT_LIB_DIR)/sqlite/libsqlite3.a $(EXT_LIB_DIR)/muparser/libmuparser.a -lxml2\
+mstconfig_LDADD = $(UTILS_LIB) $(EXT_LIB_DIR)/sqlite/libsqlite3.a $(EXT_LIB_DIR)/muparser/libmuparser.a\
                                                                $(CMDIF_DIR)/libcmdif.a ../reg_access/libreg_access.a $(LAYOUTS_LIB) $(MTCR_DIR)/libmtcr_ul.a\
                                                                $(DEV_MGT_DIR)/libdev_mgt.a $(MLNXOS_PPC_LIBS) $(LIBSTD_CPP) -ldl
 
+if DISABLE_XML2
+AM_CXXFLAGS += -DDISABLE_XML2
+else
+AM_CPPFLAGS += -I$(XML2_INC_DIR)
+mstconfig_LDADD += -lxml2
+endif
+
 mstconfig_SOURCES =  mlxcfg_ui.h mlxcfg_parser.cpp mlxcfg_ui.cpp\
                        mlxcfg_status.h mlxcfg_utils.h mlxcfg_utils.cpp mlxcfg_view.h\
                         mlxcfg_db_manager.h mlxcfg_db_manager.cpp mlxcfg_param.h mlxcfg_param.cpp mlxcfg_tlv.h mlxcfg_tlv.cpp\
index 971b55e4ca4d405c92b406f9d915436f03c24d2d..2c4f4f9fc8c20dd2a0b8eaeefb13bce884e8e8d6 100644 (file)
@@ -48,8 +48,10 @@ using namespace std;
 #include "mlxcfg_tlv.h"
 #include "mlxcfg_status.h"
 
-#include <libxml/parser.h>
-#include <libxml/tree.h>
+#if ! defined(DISABLE_XML2)
+    #include <libxml/parser.h>
+    #include <libxml/tree.h>
+#endif
 
 #define TLVCLASS_OFFSET 24
 #define TLVCLASS_SIZE 8
@@ -723,6 +725,7 @@ void GenericCommander::binTLV2XML(vector<u_int32_t> binTLV, string& xmlTemplate)
 
 void GenericCommander::XML2TLVConf(const string xmlContent, vector<TLVConf*>& tlvs)
 {
+#if ! defined(DISABLE_XML2)
     xmlDocPtr doc;
     xmlNodePtr root, currTlv, currParam;
     xmlChar* portAttr = NULL, *hostAttr = NULL,
@@ -808,6 +811,11 @@ void GenericCommander::XML2TLVConf(const string xmlContent, vector<TLVConf*>& tl
         throw e;
     }
     xmlFreeDoc(doc);
+#else
+    (void) xmlContent;
+    (void) tlvs;
+    throw MlxcfgException("Can not run the command, the tool was not compiled against libxml2");
+#endif
 }
 
 void GenericCommander::XML2Raw(const string xmlContent, string& raw)