1 From e90e293ea5055da1ef4636c22e947e689cffb983 Mon Sep 17 00:00:00 2001
2 From: Chow Loong Jin <hyperair@debian.org>
3 Date: Thu, 15 Dec 2022 11:45:20 +0800
4 Subject: [PATCH] Update bundled gpgme.m4
6 gpgme.m4 taken from current git master version at
7 https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgme.git;a=blob;f=src/gpgme.m4;hb=2ba11f9bfb1f51a481eb1240b8cf2c8ad260c222.
11 build/bundled/gpgme.m4 | 316 +++++++++++++++++++++++++++--------------
12 1 file changed, 211 insertions(+), 105 deletions(-)
14 diff --git a/build/bundled/gpgme.m4 b/build/bundled/gpgme.m4
15 index 44bf43cb9..f2906c161 100644
16 --- a/build/bundled/gpgme.m4
17 +++ b/build/bundled/gpgme.m4
19 # gpgme.m4 - autoconf macro to detect GPGME.
20 -# Copyright (C) 2002, 2003, 2004 g10 Code GmbH
21 +# Copyright (C) 2002, 2003, 2004, 2014, 2018, 2022 g10 Code GmbH
23 # This file is free software; as a special exception the author gives
24 # unlimited permission to copy and/or distribute it, with or without
26 # This file is distributed in the hope that it will be useful, but
27 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
28 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30 +# Last-changed: 2022-11-25
34 +dnl Find gpgrt-config, which uses .pc file
35 +dnl (minimum pkg-config functionality, supporting cross build)
37 +dnl _AM_PATH_GPGRT_CONFIG
38 +AC_DEFUN([_AM_PATH_GPGRT_CONFIG],[dnl
39 + AC_PATH_PROG(GPGRT_CONFIG, gpgrt-config, no, [$prefix/bin:$PATH])
40 + if test "$GPGRT_CONFIG" != "no"; then
41 + # Determine gpgrt_libdir
43 + # Get the prefix of gpgrt-config assuming it's something like:
44 + # <PREFIX>/bin/gpgrt-config
45 + gpgrt_prefix=${GPGRT_CONFIG%/*/*}
46 + possible_libdir1=${gpgrt_prefix}/lib
47 + # Determine by using system libdir-format with CC, it's like:
48 + # Normal style: /usr/lib
49 + # GNU cross style: /usr/<triplet>/lib
50 + # Debian style: /usr/lib/<multiarch-name>
51 + # Fedora/openSUSE style: /usr/lib, /usr/lib32 or /usr/lib64
52 + # It is assumed that CC is specified to the one of host on cross build.
53 + if libdir_candidates=$(${CC:-cc} -print-search-dirs | \
54 + sed -n -e "/^libraries/{s/libraries: =//;s/:/\\
56 + # From the output of -print-search-dirs, select valid pkgconfig dirs.
57 + libdir_candidates=$(for dir in $libdir_candidates; do
58 + if p=$(cd $dir 2>/dev/null && pwd); then
59 + test -d "$p/pkgconfig" && echo $p;
63 + for possible_libdir0 in $libdir_candidates; do
65 + # Fallback candidate, the one of system-installed (by $CC)
66 + # (/usr/<triplet>/lib, /usr/lib/<multiarch-name> or /usr/lib32)
68 + # Another candidate, user-locally-installed
69 + # (<gpgrt_prefix>/lib)
72 + # (<gpgrt_prefix>/<triplet>/lib,
73 + # <gpgrt_prefix>/lib/<multiarch-name> or <gpgrt_prefix>/lib32)
74 + if test "${possible_libdir0##*/}" = "lib"; then
75 + possible_prefix0=${possible_libdir0%/lib}
76 + possible_prefix0_triplet=${possible_prefix0##*/}
77 + if test -z "$possible_prefix0_triplet"; then
80 + possible_libdir2=${gpgrt_prefix}/$possible_prefix0_triplet/lib
82 + possible_prefix0=${possible_libdir0%%/lib*}
83 + possible_libdir2=${gpgrt_prefix}${possible_libdir0#$possible_prefix0}
85 + if test -f ${possible_libdir2}/pkgconfig/gpg-error.pc; then
86 + gpgrt_libdir=${possible_libdir2}
87 + elif test -f ${possible_libdir1}/pkgconfig/gpg-error.pc; then
88 + gpgrt_libdir=${possible_libdir1}
89 + elif test -f ${possible_libdir0}/pkgconfig/gpg-error.pc; then
90 + gpgrt_libdir=${possible_libdir0}
92 + if test -n "$gpgrt_libdir"; then break; fi
94 + if test -z "$libdir_candidates"; then
95 + # No valid pkgconfig dir in any of the system directories, fallback
96 + gpgrt_libdir=${possible_libdir1}
99 + # When we cannot determine system libdir-format, use this:
100 + gpgrt_libdir=${possible_libdir1}
106 -AC_DEFUN([_AM_PATH_GPGME_CONFIG],
107 -[ AC_ARG_WITH(gpgme-prefix,
108 - AC_HELP_STRING([--with-gpgme-prefix=PFX],
109 - [prefix where GPGME is installed (optional)]),
110 + if test -n "$gpgrt_libdir"; then
111 + GPGRT_CONFIG="$GPGRT_CONFIG --libdir=$gpgrt_libdir"
112 + if $GPGRT_CONFIG gpg-error >/dev/null 2>&1; then
113 + GPG_ERROR_CONFIG="$GPGRT_CONFIG gpg-error"
114 + AC_MSG_NOTICE([Use gpgrt-config with $gpgrt_libdir as gpg-error-config])
115 + gpg_error_config_version=`$GPG_ERROR_CONFIG --modversion`
119 + elif test "$GPG_ERROR_CONFIG" != "no"; then
120 + gpg_error_config_version=`$GPG_ERROR_CONFIG --version`
125 +AC_DEFUN([_AM_PATH_GPGME_CONFIG],[dnl
126 +AC_REQUIRE([_AM_PATH_GPGRT_CONFIG])dnl
127 + AC_ARG_WITH(gpgme-prefix,
128 + AS_HELP_STRING([--with-gpgme-prefix=PFX],
129 + [prefix where GPGME is installed (optional)]),
130 gpgme_config_prefix="$withval", gpgme_config_prefix="")
131 - if test "x$gpgme_config_prefix" != x ; then
132 - GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
133 + if test x"${GPGME_CONFIG}" = x ; then
134 + if test x"${gpgme_config_prefix}" != x ; then
135 + GPGME_CONFIG="${gpgme_config_prefix}/bin/gpgme-config"
137 + case "${SYSROOT}" in
139 + if test -x "${SYSROOT}/bin/gpgme-config" ; then
140 + GPGME_CONFIG="${SYSROOT}/bin/gpgme-config"
146 + AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
152 + use_gpgrt_config=""
153 + if test x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then
154 + if $GPGRT_CONFIG gpgme --exists; then
155 + GPGME_CONFIG="$GPGRT_CONFIG gpgme"
156 + AC_MSG_NOTICE([Use gpgrt-config as gpgme-config])
157 + use_gpgrt_config=yes
160 + if test -z "$use_gpgrt_config"; then
161 + AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
163 - AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
165 if test "$GPGME_CONFIG" != "no" ; then
166 - gpgme_version=`$GPGME_CONFIG --version`
167 + if test -z "$use_gpgrt_config"; then
168 + gpgme_version=`$GPGME_CONFIG --version`
170 + gpgme_version=`$GPGME_CONFIG --modversion`
173 gpgme_version_major=`echo $gpgme_version | \
174 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
175 @@ -31,10 +152,39 @@ AC_DEFUN([_AM_PATH_GPGME_CONFIG],
176 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
180 +AC_DEFUN([_AM_PATH_GPGME_CONFIG_HOST_CHECK],
182 + if test -z "$use_gpgrt_config"; then
183 + gpgme_config_host=`$GPGME_CONFIG --host 2>/dev/null || echo none`
185 + gpgme_config_host=`$GPGME_CONFIG --variable=host 2>/dev/null || echo none`
187 + if test x"$gpgme_config_host" != xnone ; then
188 + if test x"$gpgme_config_host" != x"$host" ; then
191 +*** The config script "$GPGME_CONFIG" was
192 +*** built for $gpgme_config_host and thus may not match the
193 +*** used host $host.
194 +*** You may want to use the configure option --with-gpgme-prefix
195 +*** to specify a matching config script or use \$SYSROOT.
197 + gpg_config_script_warn="$gpg_config_script_warn gpgme"
203 dnl AM_PATH_GPGME([MINIMUM-VERSION,
204 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
205 dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
207 +dnl If a prefix option is not used, the config script is first
208 +dnl searched in $SYSROOT/bin and then along $PATH. If the used
209 +dnl config script does not match the host specification the script
210 +dnl is added to the gpg_config_script_warn variable.
212 AC_DEFUN([AM_PATH_GPGME],
213 [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
214 tmp=ifelse([$1], ,1:0.4.2,$1)
215 @@ -57,7 +207,7 @@ AC_DEFUN([AM_PATH_GPGME],
216 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
217 if test "$gpgme_version_major" -gt "$req_major"; then
221 if test "$gpgme_version_major" -eq "$req_major"; then
222 if test "$gpgme_version_minor" -gt "$req_minor"; then
224 @@ -75,7 +225,11 @@ AC_DEFUN([AM_PATH_GPGME],
225 # If we have a recent GPGME, we should also check that the
227 if test "$req_gpgme_api" -gt 0 ; then
228 - tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
229 + if test -z "$use_gpgrt_config"; then
230 + tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
232 + tmp=`$GPGME_CONFIG --variable=api_version 2>/dev/null || echo 0`
234 if test "$tmp" -gt 0 ; then
235 if test "$req_gpgme_api" -ne "$tmp" ; then
237 @@ -88,6 +242,7 @@ AC_DEFUN([AM_PATH_GPGME],
238 GPGME_LIBS=`$GPGME_CONFIG --libs`
240 ifelse([$2], , :, [$2])
241 + _AM_PATH_GPGME_CONFIG_HOST_CHECK
245 @@ -98,82 +253,14 @@ AC_DEFUN([AM_PATH_GPGME],
249 -dnl AM_PATH_GPGME_PTH([MINIMUM-VERSION,
250 -dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
251 -dnl Test for libgpgme and define GPGME_PTH_CFLAGS and GPGME_PTH_LIBS.
253 -AC_DEFUN([AM_PATH_GPGME_PTH],
254 -[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
255 - tmp=ifelse([$1], ,1:0.4.2,$1)
256 - if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
257 - req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
258 - min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
261 - min_gpgme_version="$tmp"
264 - AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version)
266 - if test "$GPGME_CONFIG" != "no" ; then
267 - if `$GPGME_CONFIG --thread=pth 2> /dev/null` ; then
268 - req_major=`echo $min_gpgme_version | \
269 - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
270 - req_minor=`echo $min_gpgme_version | \
271 - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
272 - req_micro=`echo $min_gpgme_version | \
273 - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
274 - if test "$gpgme_version_major" -gt "$req_major"; then
277 - if test "$gpgme_version_major" -eq "$req_major"; then
278 - if test "$gpgme_version_minor" -gt "$req_minor"; then
281 - if test "$gpgme_version_minor" -eq "$req_minor"; then
282 - if test "$gpgme_version_micro" -ge "$req_micro"; then
291 - if test $ok = yes; then
292 - # If we have a recent GPGME, we should also check that the
293 - # API is compatible.
294 - if test "$req_gpgme_api" -gt 0 ; then
295 - tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
296 - if test "$tmp" -gt 0 ; then
297 - if test "$req_gpgme_api" -ne "$tmp" ; then
303 - if test $ok = yes; then
304 - GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags`
305 - GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs`
307 - ifelse([$2], , :, [$2])
309 - GPGME_PTH_CFLAGS=""
312 - ifelse([$3], , :, [$3])
314 - AC_SUBST(GPGME_PTH_CFLAGS)
315 - AC_SUBST(GPGME_PTH_LIBS)
318 dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
319 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
320 dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
321 dnl and GPGME_PTHREAD_LIBS.
323 -AC_DEFUN([AM_PATH_GPGME_PTHREAD],
324 -[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
325 +AC_DEFUN([AM_PATH_GPGME_PTHREAD],[
326 + AC_OBSOLETE([$0], [; use AM_PATH_GPGME instead to use GPGME_CFLAGS and GPGME_LIBS])dnl
327 + AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
328 tmp=ifelse([$1], ,1:0.4.2,$1)
329 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
330 req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
331 @@ -186,35 +273,37 @@ AC_DEFUN([AM_PATH_GPGME_PTHREAD],
332 AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
334 if test "$GPGME_CONFIG" != "no" ; then
335 - if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
336 - req_major=`echo $min_gpgme_version | \
337 + req_major=`echo $min_gpgme_version | \
338 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
339 - req_minor=`echo $min_gpgme_version | \
340 + req_minor=`echo $min_gpgme_version | \
341 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
342 - req_micro=`echo $min_gpgme_version | \
343 + req_micro=`echo $min_gpgme_version | \
344 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
345 - if test "$gpgme_version_major" -gt "$req_major"; then
346 + if test "$gpgme_version_major" -gt "$req_major"; then
350 if test "$gpgme_version_major" -eq "$req_major"; then
351 - if test "$gpgme_version_minor" -gt "$req_minor"; then
354 - if test "$gpgme_version_minor" -eq "$req_minor"; then
355 - if test "$gpgme_version_micro" -ge "$req_micro"; then
358 + if test "$gpgme_version_minor" -gt "$req_minor"; then
361 + if test "$gpgme_version_minor" -eq "$req_minor"; then
362 + if test "$gpgme_version_micro" -ge "$req_micro"; then
372 if test $ok = yes; then
373 # If we have a recent GPGME, we should also check that the
375 if test "$req_gpgme_api" -gt 0 ; then
376 - tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
377 + if test -z "$use_gpgrt_config"; then
378 + tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
380 + tmp=`$GPGME_CONFIG --variable=api_version 2>/dev/null || echo 0`
382 if test "$tmp" -gt 0 ; then
383 if test "$req_gpgme_api" -ne "$tmp" ; then
385 @@ -223,10 +312,11 @@ AC_DEFUN([AM_PATH_GPGME_PTHREAD],
388 if test $ok = yes; then
389 - GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
390 - GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
391 + GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --cflags`
392 + GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --libs`
394 ifelse([$2], , :, [$2])
395 + _AM_PATH_GPGME_CONFIG_HOST_CHECK
397 GPGME_PTHREAD_CFLAGS=""
398 GPGME_PTHREAD_LIBS=""
399 @@ -264,7 +354,7 @@ AC_DEFUN([AM_PATH_GPGME_GLIB],
400 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
401 if test "$gpgme_version_major" -gt "$req_major"; then
405 if test "$gpgme_version_major" -eq "$req_major"; then
406 if test "$gpgme_version_minor" -gt "$req_minor"; then
408 @@ -282,7 +372,11 @@ AC_DEFUN([AM_PATH_GPGME_GLIB],
409 # If we have a recent GPGME, we should also check that the
411 if test "$req_gpgme_api" -gt 0 ; then
412 - tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
413 + if test -z "$use_gpgrt_config"; then
414 + tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
416 + tmp=`$GPGME_CONFIG --variable=api_version 2>/dev/null || echo 0`
418 if test "$tmp" -gt 0 ; then
419 if test "$req_gpgme_api" -ne "$tmp" ; then
421 @@ -291,10 +385,23 @@ AC_DEFUN([AM_PATH_GPGME_GLIB],
424 if test $ok = yes; then
425 - GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
426 - GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
427 + if test -z "$use_gpgrt_config"; then
428 + GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
429 + GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
431 + if $GPGRT_CONFIG gpgme-glib --exists; then
432 + GPGME_CONFIG="$GPGRT_CONFIG gpgme-glib"
433 + GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --cflags`
434 + GPGME_GLIB_LIBS=`$GPGME_CONFIG --libs`
440 + if test $ok = yes; then
442 ifelse([$2], , :, [$2])
443 + _AM_PATH_GPGME_CONFIG_HOST_CHECK
447 @@ -304,4 +411,3 @@ AC_DEFUN([AM_PATH_GPGME_GLIB],
448 AC_SUBST(GPGME_GLIB_CFLAGS)
449 AC_SUBST(GPGME_GLIB_LIBS)