[xmltooling] 04/19: Discover xerces, xmlsec, openssl and curl via pkg-config

Ferenc Wágner wferi-guest at moszumanska.debian.org
Thu Jul 21 18:18:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

wferi-guest pushed a commit to branch patch-queue/debian/experimental
in repository xmltooling.

commit 52eea695b451346e482f5ec36fdbbc6423b8df03
Author: Ferenc Wágner <wferi at niif.hu>
Date:   Tue Jul 5 12:01:51 2016 +0200

    Discover xerces, xmlsec, openssl and curl via pkg-config
---
 configure.ac               | 171 ++++++++-------------------------------------
 m4/ax_restore_flags.m4     |  52 ++++++++++++++
 m4/ax_save_flags.m4        |  71 +++++++++++++++++++
 xmltooling/Makefile.am     |  12 ++--
 xmltoolingtest/Makefile.am |   3 +-
 5 files changed, 160 insertions(+), 149 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1263cdb..78ce864 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,32 +122,11 @@ PKG_CHECK_MODULES([log4shib], [log4shib],
     [PKG_CHECK_MODULES([log4cpp], [log4cpp],
         [AC_DEFINE([XMLTOOLING_LOG4CPP],[1],[Define to 1 if log4cpp library is used.])])])
 
-# Xerces settings
-AC_ARG_WITH(xerces,
-    AS_HELP_STRING([--with-xerces=PATH],[where xerces-c is installed]),,
-    [with_xerces=/usr])
-if test x_$with_xerces != x_/usr; then
-    CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
-    LIBS="-L${with_xerces}/lib -lxerces-c $LIBS"
-else
-    LIBS="-lxerces-c $LIBS"
-fi
-
-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>],
-[#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 a newer version])])
-AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]],
-        [[xercesc::XMLPlatformUtils::Initialize()]])],
-    ,[AC_MSG_ERROR([unable to link with Xerces])])
+# Xerces-C v2.6.0 has bugs that inhibit use with signed XML
+PKG_CHECK_MODULES([xerces],[xerces-c != 2.6.0])
+AX_SAVE_FLAGS
+CPPFLAGS="$xerces_CFLAGS $CPPFLAGS"
+LIBS="$xerces_LIBS $LIBS"
 
 AC_MSG_CHECKING([whether Xerces is 64-bit clean])
 AC_COMPILE_IFELSE(
@@ -186,54 +165,18 @@ AC_COMPILE_IFELSE(
     [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XERCESC_HAS_XMLBYTE_RELEASE],[1],[Define to 1 if Xerces XMLString includes XMLByte release.])],
     [AC_MSG_RESULT([no])])
 
-# XML-Security settings
+AX_RESTORE_FLAGS
+
 AC_ARG_WITH(xmlsec,
-    AS_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
-    [with_xmlsec=/usr])
-
-if test x_$with_xmlsec != x_no; then
-
-    # OpenSSL settings (need to do this first in case it's in a different spot from xmlsec)
-    AC_ARG_WITH(openssl,
-        AS_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"
-        else
-            SSLLIBS="-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_WARN([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)
+    AS_HELP_STRING([--with-xmlsec],
+        [include signature/encryption support via Apache Santuario (XML Security) @<:@default=check@:>@]),,
+    [with_xmlsec=check])
+
+AS_IF([test "x$with_xmlsec" != xno],
+    [PKG_CHECK_MODULES([XMLSEC],[xml-security-c >= 1.4 openssl libcurl],
+        [AX_SAVE_FLAGS
+         CPPFLAGS="$XMLSEC_CFLAGS $CPPFLAGS"
+         LIBS="$XMLSEC_LIBS $LIBS"
 
     AC_CHECK_DECL(EVP_sha512,
         [AC_DEFINE([XMLTOOLING_OPENSSL_HAVE_SHA2],[1],[Define to 1 if OpenSSL supports the SHA-2 hash family.])],
@@ -242,36 +185,6 @@ if test x_$with_xmlsec != x_no; then
         [AC_DEFINE([XMLTOOLING_OPENSSL_HAVE_EC],[1],[Define to 1 if OpenSSL has EC support.])],
         ,[#include <openssl/evp.h>])
 
-    # restore master libs
-    LIBS="$save_LIBS"
-
-    if test x_$with_xmlsec != x_/usr; then
-        CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
-        XMLSEC_LIBS="-L${with_xmlsec}/lib -lxml-security-c $XMLSEC_LIBS"
-    else
-        XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
-    fi
-    
-    # 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(
-	    [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
-        [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
-int i = 0;
-#else
-#error need version 1.4.0 or later
-#endif])],
-        [AC_MSG_RESULT(OK)],
-        [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
-        
-    AC_LINK_IFELSE(
-        [AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]],
-            [[XSECPlatformUtils::Initialise()]])],,
-        [AC_MSG_ERROR([unable to link with XML-Security])])
     AC_CHECK_TYPE([xsecsize_t],[AC_DEFINE([HAVE_XSECSIZE_T],[1],[Define to 1 if you have the 'xsecsize_t' type.])])
 
     AC_MSG_CHECKING([whether XML-Security-C has multiple CRL support])
@@ -309,35 +222,6 @@ int i = 0;
         [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XMLSEC_DEBUGLOGGING],[1],[Define to 1 if XML-Security-C includes debug logging support.])],
         [AC_MSG_RESULT([no])])
 
-    # restore master libs
-    LIBS="$save_LIBS"
-
-    # libcurl settings
-    AC_PATH_PROG(CURL_CONFIG,curl-config)
-    AC_ARG_WITH(curl,
-        AS_HELP_STRING([--with-curl=PATH], [where curl-config is installed]),
-        [
-        CURL_CONFIG="${with_curl}"
-        if ! test -f "${CURL_CONFIG}" ; then
-            CURL_CONFIG="${with_curl}/bin/curl-config"
-        fi
-        ])
-    if test -f "${CURL_CONFIG}" ; then
-        CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
-        XMLSEC_LIBS="`${CURL_CONFIG} --libs` $XMLSEC_LIBS"
-    else
-        AC_MSG_ERROR([curl-config not found, may need to use --with-curl option])
-    fi
-
-    # save and append master libs
-    save_LIBS="$LIBS"
-    LIBS="$XMLSEC_LIBS $LIBS"
-	
-    AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
-    AC_LINK_IFELSE(
-        [AC_LANG_PROGRAM([[#include <curl/curl.h>]],
-            [[curl_global_init(CURL_GLOBAL_ALL)]])],,
-        [AC_MSG_ERROR([unable to link with libcurl])])
     AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
     AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
         [AC_MSG_RESULT(yes)],
@@ -346,16 +230,19 @@ int i = 0;
     AC_MSG_CHECKING([for CURLINFO_TLS_SSL_PTR in curl.h])
     AC_EGREP_HEADER([CURLINFO_TLS_SSL_PTR], [curl/curl.h],
         [AC_DEFINE([HAVE_CURLINFO_TLS_SSL_PTR],[1],[Define to 1 if you have support for the CURLINFO_TLS_SSL_PTR feature.])])
-    
-    # restore master libs
-    LIBS="$save_LIBS"
-    
-    AC_SUBST(XMLSEC_LIBS)
-else
-    AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
-    AC_DEFINE([XMLTOOLING_NO_XMLSEC],[1],[Define to 1 if you wish to disable XML-Security-dependent features.])
-fi
-AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
+
+         AX_RESTORE_FLAGS
+        ],
+        [AS_IF([test "x$with_xmlsec" = xyes],
+               [AC_MSG_FAILURE([--with-xmlsec was given, but the package was not found])],
+               [AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
+                AC_DEFINE([XMLTOOLING_NO_XMLSEC],[1],
+                    [Define to 1 if you wish to disable XML-Security-dependent features.])]
+              )
+        ])
+    ])
+
+AM_CONDITIONAL(BUILD_XMLSEC,test "x$XMLSEC_LIBS" != x)
 
 # Does the STL in use help or screw us?
 AC_LINK_IFELSE(
diff --git a/m4/ax_restore_flags.m4 b/m4/ax_restore_flags.m4
new file mode 100644
index 0000000..aafd363
--- /dev/null
+++ b/m4/ax_restore_flags.m4
@@ -0,0 +1,52 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_restore_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_RESTORE_FLAGS([namespace])
+#
+# DESCRIPTION
+#
+#   Restore common compilation flags from temporary variables.
+#
+#   Compilation flags includes: CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, LIBS,
+#   OBJCFLAGS.
+#
+#   By default these flags are restored to a global (empty) namespace, but
+#   user could restore from specific NAMESPACE by using
+#   AX_RESTORE_FLAGS(NAMESPACE) macro.
+#
+#   Typical usage is like:
+#
+#     AX_SAVE_FLAGS(mypackage)
+#     CPPFLAGS="-Imypackagespath ${CPPFLAGS}"
+#     dnl ... do some detection ...
+#     AX_RESTORE_FLAGS(mypackage)
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Filippo Giunchedi <filippo at esaurito.net>
+#   Copyright (c) 2011 The Board of Trustees of the Leland Stanford Junior University
+#   Copyright (c) 2011 Russ Allbery <rra at stanford.edu>
+#   Copyright (c) 2013 Bastien ROUCARIES <roucaries.bastien+autoconf at gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 6
+
+# save one flag in name space
+AC_DEFUN([_AX_RESTORE_ONE_FLAG],[dnl
+  AS_VAR_PUSHDEF([_ax_restore_flag_var], [$2[]_$1[]_ax_save_flags])
+  AS_VAR_COPY($2[],_ax_restore_flag_var)
+  AS_VAR_POPDEF([_ax_restore_flag_var])
+])
+
+AC_DEFUN([AX_RESTORE_FLAGS], [dnl
+   m4_foreach([FLAG], dnl
+	      [_AX_SAVE_FLAGS_LIST()], dnl
+	      [_AX_RESTORE_ONE_FLAG([$1],FLAG)])
+])
diff --git a/m4/ax_save_flags.m4 b/m4/ax_save_flags.m4
new file mode 100644
index 0000000..39f45be
--- /dev/null
+++ b/m4/ax_save_flags.m4
@@ -0,0 +1,71 @@
+# ===========================================================================
+#       http://www.gnu.org/software/autoconf-archive/ax_save_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_SAVE_FLAGS([NAMESPACE])
+#
+# DESCRIPTION
+#
+#   Save common compilation flags into temporary variables.
+#
+#   Compilation flags includes: CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, LIBS,
+#   OBJCFLAGS.
+#
+#   By default these flags are saved to a global (empty) namespace, but user
+#   could specify a specific NAMESPACE to AX_SAVE_FLAGS macro and latter
+#   restore it by using AX_RESTORE_FLAGS(NAMESPACE).
+#
+#     AX_SAVE_FLAGS(mypackage)
+#     CPPFLAGS="-Imypackagespath ${CPPFLAGS}"
+#     dnl .. do some detection ...
+#     AX_RESTORE_FLAGS(mypackage)
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Filippo Giunchedi <filippo at esaurito.net>
+#   Copyright (c) 2011 The Board of Trustees of the Leland Stanford Junior University
+#   Copyright (c) 2011 Russ Allbery <rra at stanford.edu>
+#   Copyright (c) 2013 Bastien ROUCARIES <roucaries.bastien+autoconf at gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 7
+
+# list of flag to save
+AC_DEFUN([_AX_SAVE_FLAGS_LIST],[dnl
+[CCASFLAGS],dnl
+[CFLAGS],dnl
+[CPPFLAGS],dnl
+[CXXFLAGS],dnl
+[ERLCFLAGS],dnl
+[FCFLAGS],dnl
+[FCLIBS],dnl
+[FFLAGS],dnl
+[FLIBS],dnl
+[GCJFLAGS],dnl
+[JAVACFLAGS],dnl
+[LDFLAGS],dnl
+[LIBS],dnl
+[OBJCFLAGS],dnl
+[OBJCXXFLAGS],dnl
+[UPCFLAGS],dnl
+[VALAFLAGS]dnl
+])
+
+# save one flag in name space
+AC_DEFUN([_AX_SAVE_ONE_FLAG],[
+  AS_VAR_PUSHDEF([_ax_save_flag_var], [$2[]_$1[]_ax_save_flags])
+  AS_VAR_COPY(_ax_save_flag_var, $2[])
+  AS_VAR_POPDEF([_ax_save_flag_var])
+])
+
+AC_DEFUN([AX_SAVE_FLAGS],[dnl
+   m4_foreach([FLAG], dnl
+	      [_AX_SAVE_FLAGS_LIST()], dnl
+	      [_AX_SAVE_ONE_FLAG([$1],FLAG)])
+])
diff --git a/xmltooling/Makefile.am b/xmltooling/Makefile.am
index 701c8fd..321e451 100644
--- a/xmltooling/Makefile.am
+++ b/xmltooling/Makefile.am
@@ -206,17 +206,17 @@ common_sources = \
 libxmltooling_lite_la_SOURCES = \
 	${common_sources}
 libxmltooling_lite_la_CPPFLAGS = -DXMLTOOLING_LITE
-libxmltooling_lite_la_LDFLAGS = -version-info 7:0:0
-libxmltooling_lite_la_CPPFLAGS += $(log4shib_CFLAGS) $(log4cpp_CFLAGS)
-libxmltooling_lite_la_LDFLAGS += $(log4shib_LIBS) $(log4cpp_LIBS)
+libxmltooling_lite_la_LDFLAGS  = -version-info 7:0:0
+libxmltooling_lite_la_CPPFLAGS += $(xerces_CFLAGS) $(log4shib_CFLAGS) $(log4cpp_CFLAGS)
+libxmltooling_lite_la_LDFLAGS  += $(xerces_LIBS)   $(log4shib_LIBS)   $(log4cpp_LIBS)
 
 if BUILD_XMLSEC
 libxmltooling_la_SOURCES = \
 	${common_sources} \
 	${xmlsec_sources}
-libxmltooling_la_LDFLAGS = $(XMLSEC_LIBS) -version-info 7:0:0
-libxmltooling_la_CFLAGS = $(log4shib_CFLAGS) $(log4cpp_CFLAGS)
-libxmltooling_la_LDFLAGS += $(log4shib_LIBS) $(log4cpp_LIBS)
+libxmltooling_la_LDFLAGS = -version-info 7:0:0
+libxmltooling_la_CPPFLAGS = $(XMLSEC_CFLAGS) $(xerces_CFLAGS) $(log4shib_CFLAGS) $(log4cpp_CFLAGS)
+libxmltooling_la_LDFLAGS += $(XMLSEC_LIBS)   $(xerces_LIBS)   $(log4shib_LIBS)   $(log4cpp_LIBS)
 endif
 
 install-exec-hook:
diff --git a/xmltoolingtest/Makefile.am b/xmltoolingtest/Makefile.am
index e96be98..779e808 100644
--- a/xmltoolingtest/Makefile.am
+++ b/xmltoolingtest/Makefile.am
@@ -5,7 +5,8 @@ if BUILD_UNITTEST
 bin_PROGRAMS = xmltoolingtest
 xmltoolingtest_CXXFLAGS = $(CXXTESTFLAGS)
 if BUILD_XMLSEC
-xmltoolingtest_LDFLAGS = $(XMLSEC_LIBS)
+xmltoolingtest_CPPFLAGS = $(xerces_CFLAGS) $(XMLSEC_CFLAGS)
+xmltoolingtest_LDFLAGS  = $(xerces_LIBS)   $(XMLSEC_LIBS)
 xmltoolingtest_LDADD = $(top_builddir)/xmltooling/libxmltooling.la
 else
 xmltoolingtest_LDADD = $(top_builddir)/xmltooling/libxmltooling-lite.la

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/xmltooling.git



More information about the Pkg-shibboleth-devel mailing list