For now, apply xmlsec flags to both builds.
[shibboleth/cpp-xmltooling.git] / configure.ac
index ec35c17..fe8c241 100644 (file)
@@ -32,6 +32,7 @@ fi
 
 AC_PROG_CC([gcc gcc3 cc])
 AC_PROG_CXX([g++ g++3 c++ CC])
+AC_CANONICAL_HOST
 
 if test "$GCC" = "yes" ; then
 #    AC_HAVE_GCC_VERSION(4,0,0,0,
@@ -78,43 +79,7 @@ else
     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
 fi
 
-# OpenSSL settings
-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 -lcrypto -lssl"
-        SSLFLAGS="-I${with_openssl}/include"
-    fi])
-
-if test "x$SSLLIBS" = "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
-            SSLLIBS="`$PKG_CONFIG --libs openssl`"
-            SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
-        else
-            AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
-        fi
-    fi
-fi
-
-if test "x$SSLLIBS" = "x" ; then
-    SSLLIBS="-lcrypto -lssl"
-fi
-
-AC_MSG_CHECKING(for OpenSSL libraries)
-AC_MSG_RESULT($SSLLIBS)
-LIBS="$LIBS $SSLLIBS"
-AC_MSG_CHECKING(for OpenSSL cflags)
-AC_MSG_RESULT($SSLFLAGS)
-CPPFLAGS="$SSLFLAGS $CPPFLAGS"
-
-AC_CHECK_HEADER([openssl/pem.h],,
-                AC_MSG_ERROR([unable to find openssl header files]))
-AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
-AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
-             AC_MSG_ERROR([unable to link with openssl libraries]))
-AC_MSG_RESULT(yes)
+AC_CHECK_FUNCS([pthread_rwlock_init])
 
 # libcurl settings
 AC_PATH_PROG(CURL_CONFIG,curl-config)
@@ -210,10 +175,15 @@ AC_ARG_WITH(xmlsec,
 
 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"
+        CPPFLAGS="-I${with_xmlsec}/include"
+        LDFLAGS="-L${with_xmlsec}/lib"
     fi        
-    LIBS="-lxml-security-c $LIBS"
+    XMLSEC_LIBS="-lxml-security-c"
+    
+    # save and append master libs
+    save_LIBS="$LIBS"
+    LIBS="$XMLSEC_LIBS $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(
@@ -229,6 +199,60 @@ int i = 0;
             [#include <xsec/utils/XSECPlatformUtils.hpp>],
             [XSECPlatformUtils::Initialise()],,
             [AC_MSG_ERROR([unable to link with XML-Sec])])
+
+       # restore master libs
+       LIBS="$save_LIBS"
+
+       AC_LANG(C)
+
+       # OpenSSL settings
+       AC_ARG_WITH(openssl,
+           AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
+           [if test x_$with_openssl != x_/usr; then
+               SSLFLAGS="-I${with_openssl}/include"
+               SSLLIBS="-L${with_openssl}/lib -lcrypto -lssl"
+           fi])
+       
+       if test "x$SSLLIBS" = "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
+                   SSLLIBS="`$PKG_CONFIG --libs openssl`"
+                   SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
+               else
+                   AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
+               fi
+           fi
+       fi
+       
+       if test "x$SSLLIBS" = "x" ; then
+           SSLLIBS="-lcrypto -lssl"
+       fi
+       
+       AC_MSG_CHECKING(for OpenSSL cflags)
+       AC_MSG_RESULT($SSLFLAGS)
+       CPPFLAGS="$CPPFLAGS $SSLFLAGS"
+       AC_MSG_CHECKING(for OpenSSL libraries)
+       AC_MSG_RESULT($SSLLIBS)
+       XMLSEC_LIBS="$XMLSEC_LIBS $SSLLIBS"
+
+       # save and append master libs
+       save_LIBS="$LIBS"
+       LIBS="$XMLSEC_LIBS $LIBS"
+       
+       AC_CHECK_HEADER([openssl/pem.h],,
+                       AC_MSG_ERROR([unable to find openssl header files]))
+       AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
+       AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
+                    AC_MSG_ERROR([unable to link with openssl libraries]))
+       AC_MSG_RESULT(yes)
+
+       # restore master libs
+       LIBS="$save_LIBS"
+
+       AC_SUBST(XMLSEC_LIBS)
+       
+       AC_LANG(C++)
 else
     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
@@ -264,4 +288,4 @@ AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
 LIBTOOL="$LIBTOOL --silent"
 
 # output makefiles
-AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)
+AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile doc/Makefile)