Better warnings when pkgconfig not usable.
[shibboleth/cpp-sp.git] / configure.ac
index 65fa7a6..ab07705 100644 (file)
@@ -1,7 +1,7 @@
 AC_PREREQ([2.50])
-AC_INIT([shibboleth], [2.0], [shibboleth-users@internet2.edu], [shibboleth])
+AC_INIT([shibboleth], [2.4], [shibboleth-users@internet2.edu], [shibboleth])
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE([shibboleth],[2.0])
+AM_INIT_AUTOMAKE([shibboleth],[2.4])
 
 sinclude(doxygen.m4)
 sinclude(acx_pthread.m4)
@@ -52,12 +52,16 @@ else
                        if test "$CXX" = "CC" ; then
                                CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
                        fi
-               ;;
+                       ;;
+               *osf*)
+                       CXXFLAGS="$CXXFLAGS -D_POSIX_PII_SOCKET"
+                       ;;
        esac
 fi
 
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
+AC_PATH_PROG(PKG_CONFIG, pkg-config)
 
 AC_LANG(C)
 
@@ -82,36 +86,6 @@ else
     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
 fi
 
-# Thank you Solaris, really.
-AC_MSG_CHECKING(for ctime_r)
- if test -z "$ac_cv_ctime_args"; then
-     AC_TRY_COMPILE(
-     [#include <time.h>],
-     [
-         time_t clock;
-         char buf[26];
-         ctime_r(&clock, buf);
-     ], ac_cv_ctime_args=2)
-
-     AC_TRY_COMPILE(
-     [#include <time.h>],
-     [
-         time_t clock;
-         char buf[26];
-         ctime_r(&clock, buf, 26);
-     ], ac_cv_ctime_args=3)
- fi
- if test -z "$ac_cv_ctime_args"; then
-     AC_MSG_RESULT(no)
- else
-     if test "$ac_cv_ctime_args" = 2; then
-         AC_DEFINE(HAVE_CTIME_R_2)
-     elif test "$ac_cv_ctime_args" = 3; then
-         AC_DEFINE(HAVE_CTIME_R_3)
-     fi
-     AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
- fi 
-
 # OpenSSL settings
 AC_ARG_WITH(openssl,
     AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
@@ -120,12 +94,11 @@ AC_ARG_WITH(openssl,
     fi])
 
 if test "x$SSLFLAGS" = "x" ; then
-    AC_PATH_PROG(PKG_CONFIG, pkg-config)
     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
         if pkg-config openssl ; then
             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
         else
-            AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
+            AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
         fi
     fi
 fi
@@ -143,6 +116,36 @@ AC_LANG(C++)
 AC_CXX_REQUIRE_STL
 AC_CXX_NAMESPACES
 
+# Thank you Solaris, really.
+AC_MSG_CHECKING(for ctime_r)
+ if test -z "$ac_cv_ctime_args"; then
+     AC_TRY_COMPILE(
+     [#include <time.h>],
+     [
+         time_t clock;
+         char buf[26];
+         ctime_r(&clock, buf);
+     ], ac_cv_ctime_args=2)
+
+     AC_TRY_COMPILE(
+     [#include <time.h>],
+     [
+         time_t clock;
+         char buf[26];
+         ctime_r(&clock, buf, 26);
+     ], ac_cv_ctime_args=3)
+ fi
+ if test -z "$ac_cv_ctime_args"; then
+     AC_MSG_RESULT(no)
+ else
+     if test "$ac_cv_ctime_args" = 2; then
+         AC_DEFINE(HAVE_CTIME_R_2,1,[Define if ctime_r is present with 2 parameters.])
+     elif test "$ac_cv_ctime_args" = 3; then
+         AC_DEFINE(HAVE_CTIME_R_3,1,[Define if ctime_r is present with 3 parameters.])
+     fi
+     AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
+ fi 
+
 # log4shib settings (favor this version over the log4cpp code)
 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
 AC_ARG_WITH(log4shib,
@@ -195,11 +198,11 @@ fi
 
 # Xerces settings
 AC_ARG_WITH(xerces, 
-            AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
-            [if test x_$with_xerces != x_/usr; then
-                LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
-                CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
-            fi])
+    AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
+    [if test x_$with_xerces != x_/usr; then
+        LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
+        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]))
@@ -214,46 +217,99 @@ int i = 0;
     [AC_MSG_RESULT(OK)],
     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
 AC_TRY_LINK(
-        [#include <xercesc/util/PlatformUtils.hpp>],
-        [xercesc::XMLPlatformUtils::Initialize()],
-        [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
-        [AC_MSG_ERROR([unable to link with Xerces])])
-
+    [#include <xercesc/util/PlatformUtils.hpp>],
+    [xercesc::XMLPlatformUtils::Initialize()],
+    [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
+    [AC_MSG_ERROR([unable to link with Xerces])])
+
+AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
+AC_TRY_COMPILE([#include <xercesc/util/XMLString.hpp>],
+    [using namespace XERCES_CPP_NAMESPACE;
+      XMLByte* buf=NULL;
+      XMLString::release(&buf);
+    ],
+    [AC_MSG_RESULT([yes])]
+    [AC_DEFINE([SHIBSP_XERCESC_HAS_XMLBYTE_RELEASE], [1], [Define to 1 if Xerces XMLString includes XMLByte release.])],
+    [AC_MSG_RESULT([no])])
+
+AC_MSG_CHECKING([whether Xerces DOMNodeFilter API returns a short])
+AC_TRY_COMPILE([#include <xercesc/dom/DOM.hpp>],
+    [using namespace XERCES_CPP_NAMESPACE;
+      class Blocker : public DOMNodeFilter {
+      public:
+        short acceptNode(const DOMNode* node) const {
+            return FILTER_REJECT;
+        }
+      };
+      static Blocker g_Blocker;
+    ],
+    [AC_MSG_RESULT([yes])]
+    [AC_DEFINE([SHIBSP_XERCESC_SHORT_ACCEPTNODE], [1], [Define to 1 if Xerces DOMNodeFilter API returns a short.])],
+    [AC_MSG_RESULT([no])])
 
 #XML-Tooling settings
 AC_ARG_WITH(xmltooling,
-            AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling-c is installed]),
-            [if test x_$with_xmltooling != x_/usr; then
-                LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
-                CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
-            fi])
+    AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling-c is installed]),
+    [if test x_$with_xmltooling != x_/usr; then
+        LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
+        CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
+        export PKG_CONFIG_PATH="${with_xmltooling}/lib/pkgconfig"
+    fi])
 LITE_LIBS="-lxmltooling-lite"
 XMLSEC_LIBS="-lxmltooling"
 AC_CHECK_HEADER([xmltooling/base.h],,
                 AC_MSG_ERROR([unable to find xmltooling header files]))
+                
+
+# save and append master libs
+save_LIBS="$LIBS"
+LIBS="$XMLSEC_LIBS $LIBS"
+
+AC_TRY_LINK(
+    [#include <xmltooling/io/HTTPResponse.h>],
+    [xmltooling::HTTPResponse::sanitizeURL("http://test")],
+    [AC_DEFINE(HAVE_XMLTOOLING,1,[Define if xmltooling library was found])],
+    [AC_MSG_ERROR([unable to link with XMLTooling, or version was too old])])
+
+# restore master libs
+LIBS="$save_LIBS"
+
+# Determine xmltooling version.
+XMLTOOLINGVER=""
+AC_ARG_WITH(xmltoolingver,
+    AC_HELP_STRING([--with-xmltoolingver=VERSION], [xmltooling version, normally derived via pkg-config]),
+    [XMLTOOLINGVER="-$with_xmltoolingver"],
+    [if test "x$PKG_CONFIG" != "x" && test "x$PKG_CONFIG" != "xno" ; then
+        if pkg-config xmltooling ; then
+            XMLTOOLINGVER="-`$PKG_CONFIG --modversion xmltooling`"
+        fi
+    fi])
+if test "x$XMLTOOLINGVER" = "x" ; then
+    AC_MSG_WARN([pkgconfig not usable, assuming unversioned xmltooling schemas, may need --with-xmltoolingver])
+fi
 
 # Establish location of xmltooling catalog.
 XMLTOOLINGXMLDIR=""
 if test "x$with_xmltooling" = "x" ; then
    with_xmltooling="/usr"
 fi
-if test -f $with_xmltooling/share/xml/xmltooling/catalog.xml ; then
+if test -f $with_xmltooling/share/xml/xmltooling$XMLTOOLINGVER/catalog.xml ; then
     XMLTOOLINGXMLDIR="$with_xmltooling"
-elif test -f $with_xerces/share/xml/xmltooling/catalog.xml ; then
+elif test -f $with_xerces/share/xml/xmltooling$XMLTOOLINGVER/catalog.xml ; then
     XMLTOOLINGXMLDIR="$with_xerces"
-elif test -f $with_log4shib/share/xml/xmltooling/catalog.xml ; then
+elif test -f $with_log4shib/share/xml/xmltooling$XMLTOOLINGVER/catalog.xml ; then
     XMLTOOLINGXMLDIR="$with_log4shib"
 fi
 if test "x$XMLTOOLINGXMLDIR" = "x" ; then
-    AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling option])
+    AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling or --with-xmltoolingver options])
 fi
-XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling"
+XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling$XMLTOOLINGVER"
 AC_SUBST(XMLTOOLINGXMLDIR)
 
 # XML-Security settings
 AC_ARG_WITH(xmlsec,
-            AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
-            [with_xmlsec=/usr])
+    AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
+    [with_xmlsec=/usr])
 
 if test x_$with_xmlsec != x_/usr; then
     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
@@ -277,9 +333,9 @@ int i = 0;
     [AC_MSG_RESULT(OK)],
     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
 AC_TRY_LINK(
-        [#include <xsec/utils/XSECPlatformUtils.hpp>],
-        [XSECPlatformUtils::Initialise()],,
-        [AC_MSG_ERROR([unable to link with XML-Security])])
+    [#include <xsec/utils/XSECPlatformUtils.hpp>],
+    [XSECPlatformUtils::Initialise()],,
+    [AC_MSG_ERROR([unable to link with XML-Security])])
 
 # restore master libs
 LIBS="$save_LIBS"
@@ -302,10 +358,10 @@ AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,
 AC_TRY_LINK(
        [#include <saml/SAMLConfig.h>
 #include <saml/version.h>],
-       [#if _OPENSAML_VERSION >= 20000
+       [#if _OPENSAML_VERSION >= 20200
 opensaml::SAMLConfig::getConfig();
 #else
-#error Need OpenSAML version 2.0 or higher
+#error Need OpenSAML version 2.2 or higher
 #endif],
         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
         [AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])])
@@ -313,29 +369,45 @@ opensaml::SAMLConfig::getConfig();
 # restore master libs
 LIBS="$save_LIBS"
 
+# Determine opensaml version.
+OPENSAMLVER=""
+AC_ARG_WITH(samlver,
+    AC_HELP_STRING([--with-samlver=VERSION], [opensaml version, normally derived via pkg-config]),
+    [OPENSAMLVER="-$with_samlver"],
+    [if test "x$PKG_CONFIG" != "x" && test "x$PKG_CONFIG" != "xno" ; then
+        if pkg-config opensaml ; then
+            OPENSAMLVER="-`$PKG_CONFIG --modversion opensaml`"
+        fi
+    fi])
+if test "x$OPENSAMLVER" = "x" ; then
+    AC_MSG_WARN([pkgconfig not usable, assuming unversioned opensaml schemas, may need --with-samlver])
+fi
+
 # Establish location of opensaml catalogs.
 OPENSAMLXMLDIR=""
 if test "x$with_saml" = "x" ; then
     with_saml="/usr"
 fi
-if test -f $with_saml/share/xml/opensaml/saml20-catalog.xml ; then
+if test -f $with_saml/share/xml/opensaml$OPENSAMLVER/saml20-catalog.xml ; then
     OPENSAMLXMLDIR="$with_saml"
-elif test -f $with_xmltooling/share/xml/opensaml/saml20-catalog.xml ; then
+elif test -f $with_xmltooling/share/xml/opensaml$OPENSAMLVER/saml20-catalog.xml ; then
     OPENSAMLXMLDIR="$with_xmltooling"
-elif test -f $with_xerces/share/xml/opensaml/saml20-catalog.xml ; then
+elif test -f $with_xerces/share/xml/opensaml$OPENSAMLVER/saml20-catalog.xml ; then
     OPENSAMLXMLDIR="$with_xerces"
-elif test -f $with_log4shib/share/xml/opensaml/saml20-catalog.xml ; then
+elif test -f $with_log4shib/share/xml/opensaml$OPENSAMLVER/saml20-catalog.xml ; then
     OPENSAMLXMLDIR="$with_log4shib"
 fi
 if test "x$OPENSAMLXMLDIR" = "x" ; then
-    AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml option])
+    AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml or --with-samlver options])
 fi
-OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml"
+OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml$OPENSAMLVER"
 AC_SUBST(OPENSAMLXMLDIR)
 
 AC_SUBST(LITE_LIBS)
 AC_SUBST(XMLSEC_LIBS)
 
+AC_CONFIG_FILES([shibboleth.spec pkginfo Portfile])
+
 # output the underlying makefiles
 WANT_SUBDIRS="doc schemas configs shibsp shibd util"
 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
@@ -436,6 +508,39 @@ if test ! "$WANT_FASTCGI" = "no" ; then
     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
 fi
 
+#
+# Build Memcached support?
+#
+AC_MSG_CHECKING(for Memcached support)
+AC_ARG_WITH(memcached,
+    AC_HELP_STRING([--with-memcached=DIR], [Build Memcached support]),
+    [WANT_MEMCACHED=$withval],[WANT_MEMCACHED=no])
+AC_MSG_RESULT($WANT_MEMCACHED)
+
+if test "$WANT_MEMCACHED" != "no"; then
+    if test "$WANT_MEMCACHED" != "yes"; then
+        if test x_$WANT_MEMCACHED != x_/usr; then
+            MEMCACHED_INCLUDE="-I$WANT_MEMCACHED/include"
+            MEMCACHED_LDFLAGS="-L$WANT_MEMCACHED/lib"
+        fi
+    fi
+    AC_CHECK_HEADER([libmemcached/memcached.h],,
+        AC_MSG_ERROR([unable to find Memcached header files]))
+    MEMCACHED_LIBS="-lmemcached"
+fi
+
+AC_SUBST(MEMCACHED_INCLUDE)
+AC_SUBST(MEMCACHED_LDFLAGS)
+AC_SUBST(MEMCACHED_LIBS)
+
+# always output the Makefile, even if you don't use it
+AC_CONFIG_FILES([memcache-store/Makefile])
+AM_CONDITIONAL(BUILD_MEMCACHED,test ! "$WANT_MEMCACHED" = "no")
+
+if test ! "$WANT_MEMCACHED" = "no" ; then
+    WANT_SUBDIRS="$WANT_SUBDIRS memcache-store"
+fi
+
 
 #
 # If no --enable-apache-xx specified 
@@ -556,6 +661,7 @@ AC_SUBST(APXS_INCLUDE)
 #   --enable-apache-20
 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
 #      --with-apr        (DSO build, APR development package installed separately)
+#   --with-apu        (DSO build, APR-UTIL development package installed separately)
 
 AC_ARG_ENABLE(apache-20,
        AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
@@ -633,9 +739,30 @@ if test "$WANT_APACHE_20" = "yes" ; then
         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
     fi
 
+    # APU settings
+    AC_ARG_WITH(apu, 
+        AC_HELP_STRING([--with-apu=PATH], [where apu-config is installed]),
+        [
+        AC_MSG_CHECKING(for user-specified apu-config name/location)
+        if test "$withval" != "no" ; then
+            if test "$withval" != "yes"; then
+                APR_CONFIG=$withval
+                AC_MSG_RESULT("$withval")
+            fi
+        fi
+        ],
+        [
+        AC_PATH_PROG(APU_CONFIG, apu-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
+        ])
+    if test -f "${APU_CONFIG}"; then
+        APU_CFLAGS="`${APU_CONFIG} --includes`"
+    else
+        AC_MSG_ERROR([Unable to locate apu-config, may need --with-apu option.])
+    fi
+
     # extract settings we need from APXS2 -q
     APXS2_CC="`$APXS2 -q CC`"
-    APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` $APR_CFLAGS"
+    APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` $APU_CFLAGS"
     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
 fi
 
@@ -647,6 +774,7 @@ AC_SUBST(APXS2_INCLUDE)
 #   --enable-apache-22
 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
 #      --with-apr1       (DSO build, APR development package installed separately)
+#   --with-apu1       (DSO build, APR-UTIL development package installed separately)
 
 AC_ARG_ENABLE(apache-22,
        AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
@@ -724,9 +852,30 @@ if test "$WANT_APACHE_22" = "yes" ; then
         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
     fi
 
+    # APU1 settings
+    AC_ARG_WITH(apu1, 
+        AC_HELP_STRING([--with-apu1=PATH], [where apu-1-config is installed]),
+        [
+        AC_MSG_CHECKING(for user-specified apu-1-config name/location)
+        if test "$withval" != "no" ; then
+            if test "$withval" != "yes"; then
+                APR1_CONFIG=$withval
+                AC_MSG_RESULT("$withval")
+            fi
+        fi
+        ],
+        [
+        AC_PATH_PROG(APU1_CONFIG, apu-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
+        ])
+    if test -f "${APU1_CONFIG}"; then
+        APU1_CFLAGS="`${APU1_CONFIG} --includes`"
+    else
+        AC_MSG_ERROR([Unable to locate apu-1-config, may need --with-apu1 option.])
+    fi
+
     # extract settings we need from APXS22 -q
     APXS22_CC="`$APXS22 -q CC`"
-    APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` $APR1_CFLAGS"
+    APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` $APR1_CFLAGS $APU1_CFLAGS"
     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
 fi
 
@@ -885,4 +1034,3 @@ fi
 LIBTOOL="$LIBTOOL --silent"
 
 AC_OUTPUT
-