Package: xmltooling / 1.6.0-4+deb9u2

Discover-xerces-xmlsec-openssl-and-curl-via-pkg-conf.patch Patch series | download
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
From: =?utf-8?q?Ferenc_W=C3=A1gner?= <wferi@niif.hu>
Date: Tue, 5 Jul 2016 12:01:51 +0200
Subject: 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(-)
 create mode 100644 m4/ax_restore_flags.m4
 create mode 100644 m4/ax_save_flags.m4

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@esaurito.net>
+#   Copyright (c) 2011 The Board of Trustees of the Leland Stanford Junior University
+#   Copyright (c) 2011 Russ Allbery <rra@stanford.edu>
+#   Copyright (c) 2013 Bastien ROUCARIES <roucaries.bastien+autoconf@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@esaurito.net>
+#   Copyright (c) 2011 The Board of Trustees of the Leland Stanford Junior University
+#   Copyright (c) 2011 Russ Allbery <rra@stanford.edu>
+#   Copyright (c) 2013 Bastien ROUCARIES <roucaries.bastien+autoconf@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