[xml-security-c] 21/23: Use pkg-config for Xerces, OpenSSL and NSS, and provide a pkg-config file

Ferenc Wágner wferi-guest at moszumanska.debian.org
Thu Jul 21 20:15:44 UTC 2016


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

wferi-guest pushed a commit to branch patch-queue/master
in repository xml-security-c.

commit 8e6000c2ffc59e7805b911a816976daebd4e6529
Author: Ferenc Wágner <wferi at niif.hu>
Date:   Mon Jul 4 17:18:01 2016 +0200

    Use pkg-config for Xerces, OpenSSL and NSS, and provide a pkg-config file
    
    We use only the crypto part of OpenSSL
---
 Makefile.am                |   2 +
 configure.ac               | 149 ++++++++++-----------------------------------
 m4/ax_pkg_check_modules.m4 |  69 +++++++++++++++++++++
 xml-security-c.pc.in       |  12 ++++
 4 files changed, 116 insertions(+), 116 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4a65b87..3737973 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,8 @@ ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = xsec
 
+pkgconfig_DATA = xml-security-c.pc
+
 EXTRA_DIST = \
 	CHANGELOG.txt \
 	INSTALL.txt \
diff --git a/configure.ac b/configure.ac
index 8591297..1457fe1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ AC_CONFIG_AUX_DIR(build-aux)
 AC_CONFIG_MACRO_DIR(m4)
 AM_INIT_AUTOMAKE([subdir-objects])
 AC_PROG_LIBTOOL
+PKG_INSTALLDIR
 
 AC_ARG_ENABLE(debug,
     AS_HELP_STRING([--enable-debug],[Have GCC compile with symbols (Default = no)]),
@@ -39,7 +40,7 @@ fi
 
 # Define the files we wish to generate
 
-AC_CONFIG_FILES([Makefile xsec/Makefile])
+AC_CONFIG_FILES([xml-security-c.pc Makefile xsec/Makefile])
 AC_CONFIG_HEADERS([config.h xsec/framework/XSECConfig.hpp])
 AH_BOTTOM([#include <xsec/framework/XSECVersion.hpp>])
 
@@ -86,28 +87,9 @@ return (cwd != NULL) ? EXIT_SUCCESS : EXIT_FAILURE;])],
 
 AC_LANG(C++)
 
-# Xerces is required
-
-AC_ARG_WITH(xerces,AS_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]))
-AC_MSG_CHECKING([Xerces version])
-AC_PREPROC_IFELSE(
-    [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
-[#if  _XERCES_VERSION >= 20000
-int i = 0;
-#else
-#error cannot use version 1.x
-#endif])],
-    [AC_MSG_RESULT(OK)],
-    [AC_MSG_FAILURE([Xerces-C 2.x or 3.x is required])])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]], [[xercesc::XMLPlatformUtils::Initialize()]])],
-    [],[AC_MSG_ERROR([unable to link with Xerces])])
+AX_PKG_CHECK_MODULES([xerces],,[xerces-c >= 2])
+CPPFLAGS="$xerces_CFLAGS $CPPFLAGS"
+LIBS="$xerces_LIBS $LIBS"
 
 # Get user options
 
@@ -383,47 +365,17 @@ fi
 
 # Crypto provider options (OpenSSL / NSS)
 
-AC_ARG_WITH(openssl,
-    AS_HELP_STRING([--with-openssl],[Use Openssl.  Values = 'yes' or installation directory (Default = yes)]),
-    use_openssl=$withval, use_openssl=yes)
-
-if test x"$use_openssl" != "xno" ; then
-
-    # Check for explicit location or try pkg-config
-    if test x"$use_openssl" = "xyes" ; 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=PATH instead])
-            fi
-        fi
-    else
-        if test x_$use_openssl != x_/usr; then
-            SSLFLAGS="-I${use_openssl}/include"
-            SSLLIBS="-L${use_openssl}/lib -lcrypto -lssl"
-        else
-            SSLLIBS="-lcrypto -lssl"
-        fi
-    fi
-    
-    AC_MSG_CHECKING(for OpenSSL cflags)
-    AC_MSG_RESULT($SSLFLAGS)
-    CPPFLAGS="$CPPFLAGS $SSLFLAGS"
-    
-    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <openssl/opensslv.h>]])],
-        [AC_DEFINE([XSEC_HAVE_OPENSSL],[1],[Define if OpenSSL is in use.])],
-        [AC_MSG_ERROR([Unable to find OpenSSL headers])]);
-    
-    AC_MSG_CHECKING(for OpenSSL libraries)
-    AC_MSG_RESULT($SSLLIBS)
-    LIBS="$LIBS $SSLLIBS"
-    
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/evp.h>]], [[EVP_EncryptInit(NULL, NULL, NULL, NULL) ; return 0; ]])],,
-        [AC_MSG_ERROR(["Unable to find libcrypto"])])
-    
+AC_ARG_WITH([openssl],
+    [AS_HELP_STRING([--with-openssl],[use the OpenSSL crypto provider @<:@default=check@:>@])],,
+    [with_openssl=check])
+
+AS_IF([test x"$with_openssl" != xno],
+    [AX_PKG_CHECK_MODULES([openssl],,[libcrypto],
+        [with_openssl=found
+         AC_DEFINE([XSEC_HAVE_OPENSSL],[1],[Define if OpenSSL is in use])
+         CPPFLAGS="$openssl_CFLAGS $CPPFLAGS"
+         LIBS="$openssl_LIBS $LIBS"
+
     # Now try to find out some things about this version of OpenSSL
     
     AC_MSG_CHECKING([for const input buffers in OpenSSL])
@@ -472,61 +424,26 @@ if test x"$use_openssl" != "xno" ; then
         [AC_MSG_RESULT([yes])
     	AC_DEFINE([XSEC_OPENSSL_D2IX509_CONST_BUFFER],[1],[Define to 1 if OpenSSL X509 API has const input buffer.])],
     	[AC_MSG_RESULT([no])])
-fi
 
-AC_ARG_WITH(nss,
-    AS_HELP_STRING([--with-nss],[Use NSS.  Values = 'yes' or installation directory (Default = no)]),
-    use_nss=$withval, use_nss=no)
-
-if test x"$use_nss" != "xno" ; then
-
-    # Check for explicit location or try pkg-config
-    if test x"$use_nss" = "xyes" ; then
-        AC_PATH_PROG(PKG_CONFIG, pkg-config,)
-        if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
-            if pkg-config nss ; then
-                NSSLIBS="`$PKG_CONFIG --libs nss`"
-                NSSFLAGS="`$PKG_CONFIG --cflags nss`"
-            else
-                AC_MSG_WARN([NSS not supported by pkg-config, try --with-nss=PATH instead])
-            fi
-        else
-            check=`nss-config --version 2>/dev/null`
-            if test -n "$check"; then
-                NSSLIBS=`nss-config --libs`
-                NSSFLAGS=`nss-config --cflags`
-            else
-                AC_MSG_ERROR([Unable to use pkg-config or find nss-config, try --with-nss=PATH])
-            fi
-        fi
-    else
-        if test x_$use_nss != x_/usr; then
-            NSSLIBS="-L${use_nss}/lib"
-        fi
-        # NSS is broken and doesn't use a standard include path.
-        NSSFLAGS="-I${use_nss}/include/nss3 -I${use_nss}/include/nss"
-        NSSLIBS="$NSSLIBS -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4"
-    fi
-    
-    AC_MSG_CHECKING(for NSS cflags)
-    AC_MSG_RESULT($NSSFLAGS)
-    CPPFLAGS="$CPPFLAGS $NSSFLAGS"
-    
-    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <nss.h>]])],
-        [AC_DEFINE([XSEC_HAVE_NSS],[1],[Define if NSS is in use.])],
-        [AC_MSG_ERROR([Unable to find NSS headers])])
-    
-    AC_MSG_CHECKING(for NSS libraries)
-    AC_MSG_RESULT($NSSLIBS)
-    LIBS="$LIBS $NSSLIBS"
-    
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nss.h>]], [[NSS_NoDB_Init(NULL);]])],,
-        [AC_MSG_ERROR([Unable to link with NSS])])
-fi
+        ],[AS_IF([test "x$with_openssl" != xcheck],[AC_MSG_ERROR([Unable to find OpenSSL])])])
+    ])
+
+AC_ARG_WITH([nss],
+    [AS_HELP_STRING([--with-nss],[use the NSS crypto provider @<:@default=check@:>@])],,
+    [with_nss=check])
+
+AS_IF([test x"$with_nss" != xno],
+    [AX_PKG_CHECK_MODULES([nss],,[nss],
+        [with_nss=found
+         AC_DEFINE([XSEC_HAVE_NSS],[1],[Define if NSS is in use])
+         CPPFLAGS="$nss_CFLAGS $CPPFLAGS"
+         LIBS="$nss_LIBS $LIBS"
+        ],[AS_IF([test "x$with_nss" != "xcheck"],[AC_MSG_ERROR([Unable to find NSS])])])
+    ])
 
 # Populate the Makefile conditionals
-AM_CONDITIONAL(XSEC_AM_HAVE_OPENSSL, test x"$use_openssl" != "xno")
-AM_CONDITIONAL(XSEC_AM_HAVE_NSS, test x"$use_nss" != "xno")
+AM_CONDITIONAL([XSEC_AM_HAVE_OPENSSL],[test "x$with_openssl" = xfound])
+AM_CONDITIONAL([XSEC_AM_HAVE_NSS],[test "x$with_nss" = xfound])
 
 # output the Makefiles
 AC_OUTPUT
diff --git a/m4/ax_pkg_check_modules.m4 b/m4/ax_pkg_check_modules.m4
new file mode 100644
index 0000000..f3af0f6
--- /dev/null
+++ b/m4/ax_pkg_check_modules.m4
@@ -0,0 +1,69 @@
+# ===========================================================================
+#   http://www.gnu.org/software/autoconf-archive/ax_pkg_check_modules.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PKG_CHECK_MODULES(PREFIX, PUBLIC-MODULES, PRIVATE-MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [PUBLIC-VARIABLE], [PRIVATE-VARIABLE])
+#
+# DESCRIPTION
+#
+#   A wrapper around PKG_CHECK_MODULES which splits the list of modules into
+#   public and private dependencies, and produces two variables listing the
+#   dependencies across all invocations of AX_PKG_CHECK_MODULES. These two
+#   variables are exposed via AC_SUBST, and should be used in a pkg-config
+#   file as the substituted values for Requires and Requires.private.
+#
+#   The PREFIX, PUBLIC-MODULES and PRIVATE-MODULES arguments should be
+#   specified as for PKG_CHECK_MODULES, with the concatenation of
+#   PUBLIC-MODULES and PRIVATE-MODULES equaling the LIST-OF-MODULES from
+#   PKG_CHECK_MODULES.  The ACTION-IF-FOUND and ACTION-IF-NOT-FOUND
+#   arguments are optional, and should also be specified as for
+#   PKG_CHECK_MODULES.  ACTION-IF-FOUND is evaluated if the full
+#   LIST-OF-MODULES is found; ACTION-IF-NOT-FOUND similarly.
+#
+#   PUBLIC-VARIABLE defaults to AX_PACKAGE_REQUIRES, and PRIVATE-VARIABLE
+#   defaults to AX_PACKAGE_REQUIRES_PRIVATE.  Both variables are AC_SUBST-ed
+#   by this macro.
+#
+#   For example:
+#
+#     AX_PKG_CHECK_MODULES([GLIB],[glib-2.0 gio-2.0],[gthread-2.0])
+#     AX_PKG_CHECK_MODULES([DBUS],[],[dbus-glib-1 >= 0.98 dbus-1])
+#
+#   results in the substitutions:
+#
+#     AX_PACKAGE_REQUIRES="glib-2.0 gio-2.0"
+#     AX_PACKAGE_REQUIRES_PRIVATE="gthread-2.0 dbus-glib-1 >= 0.98 dbus-1"
+#
+#   and can be used with a template pkg-config file (.pc.in) using:
+#
+#     Requires: @AX_PACKAGE_REQUIRES@
+#     Requires.private: @AX_PACKAGE_REQUIRES_PRIVATE@
+#
+# LICENSE
+#
+#   Copyright (c) 2014 Philip Withnall <philip at tecnocode.co.uk>
+#
+#   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 2
+
+AC_DEFUN([AX_PKG_CHECK_MODULES],[
+    m4_define([ax_package_requires],
+              [m4_default_quoted([$6],[AX_PACKAGE_REQUIRES])])
+    m4_define([ax_package_requires_private],
+              [m4_default_quoted([$7],[AX_PACKAGE_REQUIRES_PRIVATE])])
+
+    ax_package_requires="$[]ax_package_requires $2"
+    ax_package_requires_private="$[]ax_package_requires_private $3"
+
+    PKG_CHECK_MODULES([$1],[$2 $3],[$4],[$5])
+
+    # Substitute output.
+    AC_SUBST(ax_package_requires)
+    AC_SUBST(ax_package_requires_private)
+])dnl AX_PKG_CHECK_MODULES
diff --git a/xml-security-c.pc.in b/xml-security-c.pc.in
new file mode 100644
index 0000000..d4557f5
--- /dev/null
+++ b/xml-security-c.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+ 
+Name: @PACKAGE_NAME@
+Description: Apache Santuario (formerly XML security) C++ library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lxml-security-c
+Cflags: -I${includedir}
+Requires: @AX_PACKAGE_REQUIRES@
+Requires.private: @AX_PACKAGE_REQUIRES_PRIVATE@

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



More information about the Pkg-shibboleth-devel mailing list