1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
From: =?utf-8?q?Ferenc_W=C3=A1gner?= <wferi@niif.hu>
Date: Mon, 4 Jul 2016 17:18:01 +0200
Subject: 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(-)
create mode 100644 m4/ax_pkg_check_modules.m4
create mode 100644 xml-security-c.pc.in
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@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@
|