Conditional xmlsec support
[shibboleth/xmltooling.git] / configure.ac
index a08e631..6786afc 100644 (file)
@@ -65,8 +65,8 @@ if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
     AC_ARG_WITH(openssl, 
             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
             [if test x_$with_openssl != x_/usr; then
-           SSLLIBS="-L${with_openssl}/lib"
-           SSLFLAGS="-I${with_openssl}/include"
+                SSLLIBS="-L${with_openssl}/lib"
+                SSLFLAGS="-I${with_openssl}/include"
             fi])
     SSLLIBS="$SSLLIBS -lssl -lcrypto"
 else
@@ -139,18 +139,17 @@ AC_ARG_WITH(xerces,
                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
             fi])
 LIBS="-lxerces-c $LIBS"
-AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
-                AC_MSG_ERROR([unable to find xerces header files]))
+AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
 AC_MSG_CHECKING([Xerces version])
 AC_PREPROC_IFELSE(
-       [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
+    [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
 [#if  _XERCES_VERSION != 20600
 int i = 0;
 #else
 #error cannot use version 2.6.0
 #endif])],
-       [AC_MSG_RESULT(OK)],
-       [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use special 2.6.1 tarball provided by Shibboleth Project])])
+    [AC_MSG_RESULT(OK)],
+    [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use special 2.6.1 tarball provided by Shibboleth Project])])
 AC_TRY_LINK(
         [#include <xercesc/util/PlatformUtils.hpp>],
         [xercesc::XMLPlatformUtils::Initialize()],
@@ -165,13 +164,34 @@ AC_ARG_WITH(xmlsec,
                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
             fi])
-LIBS="-lxml-security-c $LIBS"
-AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xsec header files]))
-AC_TRY_LINK(
-        [#include <xsec/utils/XSECPlatformUtils.hpp>],
-        [XSECPlatformUtils::Initialise()],
-        [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
-        [AC_MSG_ERROR([unable to link with XML-Sec])])
+
+if test x_$with_xmlsec != x_no; then
+    if test x_$with_xmlsec != x_/usr; then
+        LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
+        CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
+    fi        
+    LIBS="-lxml-security-c $LIBS"
+    AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
+    AC_MSG_CHECKING([XML-Security version])
+    AC_PREPROC_IFELSE(
+           [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
+        [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
+int i = 0;
+#else
+#error need version 1.3 or later
+#endif])],
+        [AC_MSG_RESULT(OK)],
+        [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
+    AC_TRY_LINK(
+            [#include <xsec/utils/XSECPlatformUtils.hpp>],
+            [XSECPlatformUtils::Initialise()],,
+            [AC_MSG_ERROR([unable to link with XML-Sec])])
+else
+    AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
+    [AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
+        [Define if you wish to disable XML-Security-dependent features.])]
+fi
+AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
 
 # Does the STL in use help or screw us?
 AC_TRY_LINK(
@@ -186,7 +206,7 @@ CXXTEST="/usr/bin/cxxtestgen.pl"
 CXXTESTFLAGS=""
 AC_ARG_WITH(cxxtest,
             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
-            [if test x_$with_xerces != x_/usr; then
+            [if test x_$with_cxxtest != x_/usr; then
                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
                 CXXTESTFLAGS="-I${with_cxxtest}"
             fi])