aboutsummaryrefslogtreecommitdiff
path: root/m4/libgcrypt.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/libgcrypt.m4')
-rw-r--r--m4/libgcrypt.m489
1 files changed, 67 insertions, 22 deletions
diff --git a/m4/libgcrypt.m4 b/m4/libgcrypt.m4
index 6cf482fcb..19d514fd5 100644
--- a/m4/libgcrypt.m4
+++ b/m4/libgcrypt.m4
@@ -1,38 +1,70 @@
1dnl Autoconf macros for libgcrypt 1# libgcrypt.m4 - Autoconf macros to detect libgcrypt
2dnl Copyright (C) 2002, 2004, 2011 Free Software Foundation, Inc. 2# Copyright (C) 2002, 2003, 2004, 2011, 2014, 2018, 2020 g10 Code GmbH
3dnl 3#
4dnl This file is free software; as a special exception the author gives 4# This file is free software; as a special exception the author gives
5dnl unlimited permission to copy and/or distribute it, with or without 5# unlimited permission to copy and/or distribute it, with or without
6dnl modifications, as long as this notice is preserved. 6# modifications, as long as this notice is preserved.
7dnl 7#
8dnl This file is distributed in the hope that it will be useful, but 8# This file is distributed in the hope that it will be useful, but
9dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 9# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11#
12# Last-changed: 2020-09-27
11 13
12 14
13dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, 15dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
14dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) 16dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
15dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. 17dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
16dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed 18dnl MINIMUM-VERSION is a string with the version number optionally prefixed
17dnl with the API version to also check the API compatibility. Example: 19dnl with the API version to also check the API compatibility. Example:
18dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed 20dnl a MINIMUM-VERSION of 1:1.2.5 won't pass the test unless the installed
19dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using 21dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using
20dnl this features allows to prevent build against newer versions of libgcrypt 22dnl this features allows to prevent build against newer versions of libgcrypt
21dnl with a changed API. 23dnl with a changed API.
22dnl 24dnl
25dnl If a prefix option is not used, the config script is first
26dnl searched in $SYSROOT/bin and then along $PATH. If the used
27dnl config script does not match the host specification the script
28dnl is added to the gpg_config_script_warn variable.
29dnl
23AC_DEFUN([AM_PATH_LIBGCRYPT], 30AC_DEFUN([AM_PATH_LIBGCRYPT],
24[ AC_REQUIRE([AC_CANONICAL_HOST]) 31[ AC_REQUIRE([AC_CANONICAL_HOST])
25 AC_ARG_WITH(libgcrypt-prefix, 32 AC_ARG_WITH(libgcrypt-prefix,
26 AC_HELP_STRING([--with-libgcrypt-prefix=PFX], 33 AS_HELP_STRING([--with-libgcrypt-prefix=PFX],
27 [prefix where LIBGCRYPT is installed (optional)]), 34 [prefix where LIBGCRYPT is installed (optional)]),
28 libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="") 35 libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
29 if test x$libgcrypt_config_prefix != x ; then 36 if test x"${LIBGCRYPT_CONFIG}" = x ; then
30 if test x${LIBGCRYPT_CONFIG+set} != xset ; then 37 if test x"${libgcrypt_config_prefix}" != x ; then
31 LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config 38 LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config"
32 fi 39 fi
33 fi 40 fi
34 41
35 AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no) 42 use_gpgrt_config=""
43 if test x"${LIBGCRYPT_CONFIG}" = x -a x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then
44 if $GPGRT_CONFIG libgcrypt --exists; then
45 LIBGCRYPT_CONFIG="$GPGRT_CONFIG libgcrypt"
46 AC_MSG_NOTICE([Use gpgrt-config as libgcrypt-config])
47 use_gpgrt_config=yes
48 fi
49 fi
50 if test -z "$use_gpgrt_config"; then
51 if test x"${LIBGCRYPT_CONFIG}" = x ; then
52 case "${SYSROOT}" in
53 /*)
54 if test -x "${SYSROOT}/bin/libgcrypt-config" ; then
55 LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config"
56 fi
57 ;;
58 '')
59 ;;
60 *)
61 AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
62 ;;
63 esac
64 fi
65 AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
66 fi
67
36 tmp=ifelse([$1], ,1:1.2.0,$1) 68 tmp=ifelse([$1], ,1:1.2.0,$1)
37 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then 69 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
38 req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` 70 req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
@@ -51,7 +83,11 @@ AC_DEFUN([AM_PATH_LIBGCRYPT],
51 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` 83 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
52 req_micro=`echo $min_libgcrypt_version | \ 84 req_micro=`echo $min_libgcrypt_version | \
53 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` 85 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
54 libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` 86 if test -z "$use_gpgrt_config"; then
87 libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
88 else
89 libgcrypt_config_version=`$LIBGCRYPT_CONFIG --modversion`
90 fi
55 major=`echo $libgcrypt_config_version | \ 91 major=`echo $libgcrypt_config_version | \
56 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` 92 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
57 minor=`echo $libgcrypt_config_version | \ 93 minor=`echo $libgcrypt_config_version | \
@@ -83,7 +119,11 @@ AC_DEFUN([AM_PATH_LIBGCRYPT],
83 # If we have a recent libgcrypt, we should also check that the 119 # If we have a recent libgcrypt, we should also check that the
84 # API is compatible 120 # API is compatible
85 if test "$req_libgcrypt_api" -gt 0 ; then 121 if test "$req_libgcrypt_api" -gt 0 ; then
86 tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` 122 if test -z "$use_gpgrt_config"; then
123 tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
124 else
125 tmp=`$LIBGCRYPT_CONFIG --variable=api_version 2>/dev/null || echo 0`
126 fi
87 if test "$tmp" -gt 0 ; then 127 if test "$tmp" -gt 0 ; then
88 AC_MSG_CHECKING([LIBGCRYPT API version]) 128 AC_MSG_CHECKING([LIBGCRYPT API version])
89 if test "$req_libgcrypt_api" -eq "$tmp" ; then 129 if test "$req_libgcrypt_api" -eq "$tmp" ; then
@@ -99,17 +139,22 @@ AC_DEFUN([AM_PATH_LIBGCRYPT],
99 LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` 139 LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
100 LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` 140 LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
101 ifelse([$2], , :, [$2]) 141 ifelse([$2], , :, [$2])
102 libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` 142 if test -z "$use_gpgrt_config"; then
143 libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
144 else
145 libgcrypt_config_host=`$LIBGCRYPT_CONFIG --variable=host 2>/dev/null || echo none`
146 fi
103 if test x"$libgcrypt_config_host" != xnone ; then 147 if test x"$libgcrypt_config_host" != xnone ; then
104 if test x"$libgcrypt_config_host" != x"$host" ; then 148 if test x"$libgcrypt_config_host" != x"$host" ; then
105 AC_MSG_WARN([[ 149 AC_MSG_WARN([[
106*** 150***
107*** The config script $LIBGCRYPT_CONFIG was 151*** The config script "$LIBGCRYPT_CONFIG" was
108*** built for $libgcrypt_config_host and thus may not match the 152*** built for $libgcrypt_config_host and thus may not match the
109*** used host $host. 153*** used host $host.
110*** You may want to use the configure option --with-libgcrypt-prefix 154*** You may want to use the configure option --with-libgcrypt-prefix
111*** to specify a matching config script. 155*** to specify a matching config script or use \$SYSROOT.
112***]]) 156***]])
157 gpg_config_script_warn="$gpg_config_script_warn libgcrypt"
113 fi 158 fi
114 fi 159 fi
115 else 160 else