| 1 |
dnl Autoconf macros for libassuan |
| 2 |
dnl Copyright (C) 2002, 2003, 2011 Free Software Foundation, Inc. |
| 3 |
dnl |
| 4 |
dnl This file is free software; as a special exception the author gives |
| 5 |
dnl unlimited permission to copy and/or distribute it, with or without |
| 6 |
dnl modifications, as long as this notice is preserved. |
| 7 |
dnl |
| 8 |
dnl This file is distributed in the hope that it will be useful, but |
| 9 |
dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the |
| 10 |
dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 11 |
dnl SPDX-License-Identifier: FSFULLR |
| 12 |
# Last-changed: 2020-11-17 |
| 13 |
|
| 14 |
dnl |
| 15 |
dnl Common code used for libassuan detection [internal] |
| 16 |
dnl Returns ok set to yes or no. |
| 17 |
dnl |
| 18 |
AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON], |
| 19 |
[ AC_REQUIRE([AC_CANONICAL_HOST]) |
| 20 |
AC_ARG_WITH(libassuan-prefix, |
| 21 |
AS_HELP_STRING([--with-libassuan-prefix=PFX], |
| 22 |
[prefix where LIBASSUAN is installed (optional)]), |
| 23 |
libassuan_config_prefix="$withval", libassuan_config_prefix="") |
| 24 |
if test x$libassuan_config_prefix != x ; then |
| 25 |
if test x${LIBASSUAN_CONFIG+set} != xset ; then |
| 26 |
LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config |
| 27 |
fi |
| 28 |
fi |
| 29 |
|
| 30 |
use_gpgrt_config="" |
| 31 |
if test x"${LIBASSUAN_CONFIG}" = x -a x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then |
| 32 |
if $GPGRT_CONFIG libassuan --exists; then |
| 33 |
LIBASSUAN_CONFIG="$GPGRT_CONFIG libassuan" |
| 34 |
AC_MSG_NOTICE([Use gpgrt-config as libassuan-config]) |
| 35 |
use_gpgrt_config=yes |
| 36 |
fi |
| 37 |
fi |
| 38 |
if test -z "$use_gpgrt_config"; then |
| 39 |
AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no) |
| 40 |
fi |
| 41 |
|
| 42 |
tmp=ifelse([$1], ,1:0.9.2,$1) |
| 43 |
if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then |
| 44 |
req_libassuan_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` |
| 45 |
min_libassuan_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` |
| 46 |
else |
| 47 |
req_libassuan_api=0 |
| 48 |
min_libassuan_version="$tmp" |
| 49 |
fi |
| 50 |
|
| 51 |
AC_MSG_CHECKING(for LIBASSUAN - version >= $min_libassuan_version) |
| 52 |
ok=no |
| 53 |
if test "$LIBASSUAN_CONFIG" != "no"; then |
| 54 |
req_major=`echo $min_libassuan_version | \ |
| 55 |
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` |
| 56 |
req_minor=`echo $min_libassuan_version | \ |
| 57 |
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` |
| 58 |
req_micro=`echo $min_libassuan_version | \ |
| 59 |
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` |
| 60 |
|
| 61 |
if test -z "$use_gpgrt_config"; then |
| 62 |
libassuan_config_version=`$LIBASSUAN_CONFIG --version` |
| 63 |
else |
| 64 |
libassuan_config_version=`$LIBASSUAN_CONFIG --modversion` |
| 65 |
fi |
| 66 |
major=`echo $libassuan_config_version | \ |
| 67 |
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` |
| 68 |
minor=`echo $libassuan_config_version | \ |
| 69 |
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` |
| 70 |
micro=`echo $libassuan_config_version | \ |
| 71 |
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` |
| 72 |
|
| 73 |
if test "$major" -gt "$req_major"; then |
| 74 |
ok=yes |
| 75 |
else |
| 76 |
if test "$major" -eq "$req_major"; then |
| 77 |
if test "$minor" -gt "$req_minor"; then |
| 78 |
ok=yes |
| 79 |
else |
| 80 |
if test "$minor" -eq "$req_minor"; then |
| 81 |
if test "$micro" -ge "$req_micro"; then |
| 82 |
ok=yes |
| 83 |
fi |
| 84 |
fi |
| 85 |
fi |
| 86 |
fi |
| 87 |
fi |
| 88 |
fi |
| 89 |
|
| 90 |
if test $ok = yes; then |
| 91 |
AC_MSG_RESULT([yes ($libassuan_config_version)]) |
| 92 |
else |
| 93 |
AC_MSG_RESULT(no) |
| 94 |
fi |
| 95 |
|
| 96 |
if test $ok = yes; then |
| 97 |
if test "$req_libassuan_api" -gt 0 ; then |
| 98 |
if test -z "$use_gpgrt_config"; then |
| 99 |
tmp=`$LIBASSUAN_CONFIG --api-version 2>/dev/null || echo 0` |
| 100 |
else |
| 101 |
tmp=`$LIBASSUAN_CONFIG --variable=api_version 2>/dev/null || echo 0` |
| 102 |
fi |
| 103 |
if test "$tmp" -gt 0 ; then |
| 104 |
AC_MSG_CHECKING([LIBASSUAN API version]) |
| 105 |
if test "$req_libassuan_api" -eq "$tmp" ; then |
| 106 |
AC_MSG_RESULT(okay) |
| 107 |
else |
| 108 |
ok=no |
| 109 |
AC_MSG_RESULT([does not match. want=$req_libassuan_api got=$tmp.]) |
| 110 |
fi |
| 111 |
fi |
| 112 |
fi |
| 113 |
fi |
| 114 |
|
| 115 |
if test $ok = yes; then |
| 116 |
if test x"$host" != x ; then |
| 117 |
if test -z "$use_gpgrt_config"; then |
| 118 |
libassuan_config_host=`$LIBASSUAN_CONFIG --host 2>/dev/null || echo none` |
| 119 |
else |
| 120 |
libassuan_config_host=`$LIBASSUAN_CONFIG --variable=host 2>/dev/null || echo none` |
| 121 |
fi |
| 122 |
if test x"$libassuan_config_host" != xnone ; then |
| 123 |
if test x"$libassuan_config_host" != x"$host" ; then |
| 124 |
AC_MSG_WARN([[ |
| 125 |
*** |
| 126 |
*** The config script "$LIBASSUAN_CONFIG" was |
| 127 |
*** built for $libassuan_config_host and thus may not match the |
| 128 |
*** used host $host. |
| 129 |
*** You may want to use the configure option --with-libassuan-prefix |
| 130 |
*** to specify a matching config script. |
| 131 |
***]]) |
| 132 |
fi |
| 133 |
fi |
| 134 |
fi |
| 135 |
fi |
| 136 |
]) |
| 137 |
|
| 138 |
dnl AM_CHECK_LIBASSUAN([MINIMUM-VERSION, |
| 139 |
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) |
| 140 |
dnl Test whether libassuan has at least MINIMUM-VERSION. This is |
| 141 |
dnl used to test for features only available in newer versions. |
| 142 |
dnl |
| 143 |
AC_DEFUN([AM_CHECK_LIBASSUAN], |
| 144 |
[ _AM_PATH_LIBASSUAN_COMMON($1) |
| 145 |
if test $ok = yes; then |
| 146 |
ifelse([$2], , :, [$2]) |
| 147 |
else |
| 148 |
ifelse([$3], , :, [$3]) |
| 149 |
fi |
| 150 |
]) |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION, |
| 156 |
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) |
| 157 |
dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS |
| 158 |
dnl |
| 159 |
AC_DEFUN([AM_PATH_LIBASSUAN], |
| 160 |
[ _AM_PATH_LIBASSUAN_COMMON($1) |
| 161 |
if test $ok = yes; then |
| 162 |
LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG --cflags` |
| 163 |
LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG --libs` |
| 164 |
ifelse([$2], , :, [$2]) |
| 165 |
else |
| 166 |
LIBASSUAN_CFLAGS="" |
| 167 |
LIBASSUAN_LIBS="" |
| 168 |
ifelse([$3], , :, [$3]) |
| 169 |
fi |
| 170 |
AC_SUBST(LIBASSUAN_CFLAGS) |
| 171 |
AC_SUBST(LIBASSUAN_LIBS) |
| 172 |
]) |