1 dnl Autoconf macros for libassuan
2 dnl Copyright (C) 2002, 2003, 2011 Free Software Foundation, Inc.
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.
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
14 dnl Common code used for libassuan detection [internal]
15 dnl Returns ok set to yes or no.
17 AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON],
18 [ AC_REQUIRE([AC_CANONICAL_HOST])
19 AC_ARG_WITH(libassuan-prefix,
20 AC_HELP_STRING([--with-libassuan-prefix=PFX],
21 [prefix where LIBASSUAN is installed (optional)]),
22 libassuan_config_prefix="$withval", libassuan_config_prefix="")
23 if test x$libassuan_config_prefix != x ; then
24 libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
25 if test x${LIBASSUAN_CONFIG+set} != xset ; then
26 LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
30 AC_PATH_TOOL(LIBASSUAN_CONFIG, libassuan-config, no)
32 tmp=ifelse([$1], ,1:0.9.2,$1)
33 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
34 req_libassuan_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
35 min_libassuan_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
38 min_libassuan_version="$tmp"
41 AC_MSG_CHECKING(for LIBASSUAN - version >= $min_libassuan_version)
43 if test "$LIBASSUAN_CONFIG" != "no" \
44 && test -f "$LIBASSUAN_CONFIG" ; then
45 req_major=`echo $min_libassuan_version | \
46 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
47 req_minor=`echo $min_libassuan_version | \
48 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
49 req_micro=`echo $min_libassuan_version | \
50 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
52 libassuan_config_version=`$LIBASSUAN_CONFIG --version`
53 major=`echo $libassuan_config_version | \
54 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
55 minor=`echo $libassuan_config_version | \
56 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
57 micro=`echo $libassuan_config_version | \
58 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
60 if test "$major" -gt "$req_major"; then
63 if test "$major" -eq "$req_major"; then
64 if test "$minor" -gt "$req_minor"; then
67 if test "$minor" -eq "$req_minor"; then
68 if test "$micro" -ge "$req_micro"; then
77 if test $ok = yes; then
78 AC_MSG_RESULT([yes ($libassuan_config_version)])
83 if test $ok = yes; then
84 if test "$req_libassuan_api" -gt 0 ; then
85 tmp=`$LIBASSUAN_CONFIG --api-version 2>/dev/null || echo 0`
86 if test "$tmp" -gt 0 ; then
87 AC_MSG_CHECKING([LIBASSUAN API version])
88 if test "$req_libassuan_api" -eq "$tmp" ; then
92 AC_MSG_RESULT([does not match. want=$req_libassuan_api got=$tmp.])
98 if test $ok = yes; then
99 if test x"$host" != x ; then
100 libassuan_config_host=`$LIBASSUAN_CONFIG --host 2>/dev/null || echo none`
101 if test x"$libassuan_config_host" != xnone ; then
102 if test x"$libassuan_config_host" != x"$host" ; then
105 *** The config script $LIBASSUAN_CONFIG was
106 *** built for $libassuan_config_host and thus may not match the
108 *** You may want to use the configure option --with-libassuan-prefix
109 *** to specify a matching config script.
117 dnl AM_CHECK_LIBASSUAN([MINIMUM-VERSION,
118 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
119 dnl Test whether libassuan has at least MINIMUM-VERSION. This is
120 dnl used to test for features only available in newer versions.
122 AC_DEFUN([AM_CHECK_LIBASSUAN],
123 [ _AM_PATH_LIBASSUAN_COMMON($1)
124 if test $ok = yes; then
125 ifelse([$2], , :, [$2])
127 ifelse([$3], , :, [$3])
134 dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
135 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
136 dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
138 AC_DEFUN([AM_PATH_LIBASSUAN],
139 [ _AM_PATH_LIBASSUAN_COMMON($1)
140 if test $ok = yes; then
141 LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
142 LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
143 ifelse([$2], , :, [$2])
147 ifelse([$3], , :, [$3])
149 AC_SUBST(LIBASSUAN_CFLAGS)
150 AC_SUBST(LIBASSUAN_LIBS)