@@ -21,7 +21,7 @@ If you have problems, you may need to regenerate the build system entirely.
21
21
To do so, use the procedure documented by the package, typically 'autoreconf'.] )] )
22
22
23
23
# gpgme.m4 - autoconf macro to detect GPGME.
24
- # Copyright (C) 2002, 2003, 2004, 2014, 2018 g10 Code GmbH
24
+ # Copyright (C) 2002, 2003, 2004, 2014, 2018, 2022 g10 Code GmbH
25
25
#
26
26
# This file is free software; as a special exception the author gives
27
27
# unlimited permission to copy and/or distribute it, with or without
@@ -31,13 +31,102 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
31
31
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
32
32
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
33
33
#
34
- # Last-changed: 2020 -11-20
34
+ # Last-changed: 2022 -11-15
35
35
36
36
37
- AC_DEFUN ( [ _AM_PATH_GPGME_CONFIG] ,
38
- [ AC_ARG_WITH ( gpgme-prefix ,
39
- AS_HELP_STRING ( [ --with-gpgme-prefix=PFX] ,
40
- [ prefix where GPGME is installed (optional)] ) ,
37
+ dnl
38
+ dnl Find gpgrt-config, which uses .pc file
39
+ dnl (minimum pkg-config functionality, supporting cross build)
40
+ dnl
41
+ dnl _AM_PATH_GPGRT_CONFIG
42
+ AC_DEFUN ( [ _AM_PATH_GPGRT_CONFIG] ,[ dnl
43
+ AC_PATH_PROG ( GPGRT_CONFIG , gpgrt-config , no , [ $prefix/bin:$PATH] )
44
+ if test "$GPGRT_CONFIG" != "no"; then
45
+ # Determine gpgrt_libdir
46
+ #
47
+ # Get the prefix of gpgrt-config assuming it's something like:
48
+ # <PREFIX>/bin/gpgrt-config
49
+ gpgrt_prefix=${GPGRT_CONFIG%/*/*}
50
+ possible_libdir1=${gpgrt_prefix}/lib
51
+ # Determine by using system libdir-format with CC, it's like:
52
+ # Normal style: /usr/lib
53
+ # GNU cross style: /usr/<triplet>/lib
54
+ # Debian style: /usr/lib/<multiarch-name>
55
+ # Fedora/openSUSE style: /usr/lib, /usr/lib32 or /usr/lib64
56
+ # It is assumed that CC is specified to the one of host on cross build.
57
+ if libdir_candidates=$(${CC:-cc} -print-search-dirs | \
58
+ sed -n -e "/^libraries/{s/libraries: =//;s/:/\\
59
+ /g;p;}"); then
60
+ # From the output of -print-search-dirs, select valid pkgconfig dirs.
61
+ libdir_candidates=$(for dir in $libdir_candidates; do
62
+ if p=$(cd $dir 2>/dev/null && pwd); then
63
+ test -d "$p/pkgconfig" && echo $p;
64
+ fi
65
+ done)
66
+
67
+ for possible_libdir0 in $libdir_candidates; do
68
+ # possible_libdir0:
69
+ # Fallback candidate, the one of system-installed (by $CC)
70
+ # (/usr/<triplet>/lib, /usr/lib/<multiarch-name> or /usr/lib32)
71
+ # possible_libdir1:
72
+ # Another candidate, user-locally-installed
73
+ # (<gpgrt_prefix>/lib)
74
+ # possible_libdir2
75
+ # Most preferred
76
+ # (<gpgrt_prefix>/<triplet>/lib,
77
+ # <gpgrt_prefix>/lib/<multiarch-name> or <gpgrt_prefix>/lib32)
78
+ if test "${possible_libdir0##*/}" = "lib"; then
79
+ possible_prefix0=${possible_libdir0%/lib}
80
+ possible_prefix0_triplet=${possible_prefix0##*/}
81
+ if test -z "$possible_prefix0_triplet"; then
82
+ continue
83
+ fi
84
+ possible_libdir2=${gpgrt_prefix}/$possible_prefix0_triplet/lib
85
+ else
86
+ possible_prefix0=${possible_libdir0%%/lib*}
87
+ possible_libdir2=${gpgrt_prefix}${possible_libdir0#$possible_prefix0}
88
+ fi
89
+ if test -f ${possible_libdir2}/pkgconfig/gpg-error.pc; then
90
+ gpgrt_libdir=${possible_libdir2}
91
+ elif test -f ${possible_libdir1}/pkgconfig/gpg-error.pc; then
92
+ gpgrt_libdir=${possible_libdir1}
93
+ elif test -f ${possible_libdir0}/pkgconfig/gpg-error.pc; then
94
+ gpgrt_libdir=${possible_libdir0}
95
+ fi
96
+ if test -n "$gpgrt_libdir"; then break; fi
97
+ done
98
+ if test -z "$libdir_candidates"; then
99
+ # No valid pkgconfig dir in any of the system directories, fallback
100
+ gpgrt_libdir=${possible_libdir1}
101
+ fi
102
+ else
103
+ # When we cannot determine system libdir-format, use this:
104
+ gpgrt_libdir=${possible_libdir1}
105
+ fi
106
+ else
107
+ unset GPGRT_CONFIG
108
+ fi
109
+
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`
116
+ else
117
+ unset GPGRT_CONFIG
118
+ fi
119
+ elif test "$GPG_ERROR_CONFIG" != "no"; then
120
+ gpg_error_config_version=`$GPG_ERROR_CONFIG --version`
121
+ unset GPGRT_CONFIG
122
+ fi
123
+ ] )
124
+
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)] ) ,
41
130
gpgme_config_prefix="$withval" , gpgme_config_prefix="" )
42
131
if test x"${GPGME_CONFIG}" = x ; then
43
132
if test x"${gpgme_config_prefix}" != x ; then
@@ -59,7 +148,7 @@ AC_DEFUN([_AM_PATH_GPGME_CONFIG],
59
148
fi
60
149
61
150
use_gpgrt_config=""
62
- if test x"${GPGME_CONFIG}" = x -a x"$ GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then
151
+ if test x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then
63
152
if $GPGRT_CONFIG gpgme --exists; then
64
153
GPGME_CONFIG="$GPGRT_CONFIG gpgme"
65
154
AC_MSG_NOTICE ( [ Use gpgrt-config as gpgme-config] )
@@ -633,7 +722,6 @@ AC_MSG_CHECKING([for $2])
633
722
634
723
_PKG_CONFIG([ $1 ] [ _CFLAGS] , [ cflags] , [ $2 ] )
635
724
_PKG_CONFIG([ $1 ] [ _LIBS] , [ libs] , [ $2 ] )
636
- _PKG_CONFIG([ $1 ] [ _VERSION] , [ modversion] , [ $2 ] )
637
725
638
726
m4_define ( [ _PKG_TEXT] , [ Alternatively, you may set the environment variables $1 [ ] _CFLAGS
639
727
and $1 [ ] _LIBS to avoid the need to call pkg-config.
@@ -674,7 +762,6 @@ To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
674
762
else
675
763
$1 [ ] _CFLAGS=$pkg_cv_[ ] $1 [ ] _CFLAGS
676
764
$1 [ ] _LIBS=$pkg_cv_[ ] $1 [ ] _LIBS
677
- $1 [ ] _VERSION=$pkg_cv_[ ] $1 [ ] _VERSION
678
765
AC_MSG_RESULT ( [ yes] )
679
766
$3
680
767
fi[ ] dnl
0 commit comments