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.
13 dnl Common code used for libassuan detection [internal]
14 dnl Returns ok set to yes or no.
16 AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON],
17 [ AC_REQUIRE([AC_CANONICAL_HOST])
18 AC_ARG_WITH(libassuan-prefix,
19 AC_HELP_STRING([--with-libassuan-prefix=PFX],
20 [prefix where LIBASSUAN is installed (optional)]),
21 libassuan_config_prefix="$withval", libassuan_config_prefix="")
22 if test x$libassuan_config_prefix != x ; then
23 libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
24 if test x${LIBASSUAN_CONFIG+set} != xset ; then
25 LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
29 AC_PATH_TOOL(LIBASSUAN_CONFIG, libassuan-config, no)
31 tmp=ifelse([$1], ,1:0.9.2,$1)
32 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
33 req_libassuan_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
34 min_libassuan_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
37 min_libassuan_version="$tmp"
40 AC_MSG_CHECKING(for LIBASSUAN - version >= $min_libassuan_version)
42 if test "$LIBASSUAN_CONFIG" != "no" \
43 && test -f "$LIBASSUAN_CONFIG" ; then
44 req_major=`echo $min_libassuan_version | \
45 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
46 req_minor=`echo $min_libassuan_version | \
47 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
48 req_micro=`echo $min_libassuan_version | \
49 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
51 libassuan_config_version=`$LIBASSUAN_CONFIG --version`
52 major=`echo $libassuan_config_version | \
53 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
54 minor=`echo $libassuan_config_version | \
55 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
56 micro=`echo $libassuan_config_version | \
57 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
59 if test "$major" -gt "$req_major"; then
62 if test "$major" -eq "$req_major"; then
63 if test "$minor" -gt "$req_minor"; then
66 if test "$minor" -eq "$req_minor"; then
67 if test "$micro" -ge "$req_micro"; then
76 if test $ok = yes; then
77 AC_MSG_RESULT([yes ($libassuan_config_version)])
82 if test $ok = yes; then
83 if test "$req_libassuan_api" -gt 0 ; then
84 tmp=`$LIBASSUAN_CONFIG --api-version 2>/dev/null || echo 0`
85 if test "$tmp" -gt 0 ; then
86 AC_MSG_CHECKING([LIBASSUAN API version])
87 if test "$req_libassuan_api" -eq "$tmp" ; then
91 AC_MSG_RESULT([does not match. want=$req_libassuan_api got=$tmp.])
97 if test $ok = yes; then
98 if test x"$host" != x ; then
99 libassuan_config_host=`$LIBASSUAN_CONFIG --host 2>/dev/null || echo none`
100 if test x"$libassuan_config_host" != xnone ; then
101 if test x"$libassuan_config_host" != x"$host" ; then
104 *** The config script $LIBASSUAN_CONFIG was
105 *** built for $libassuan_config_host and thus may not match the
107 *** You may want to use the configure option --with-libassuan-prefix
108 *** to specify a matching config script.
116 dnl AM_CHECK_LIBASSUAN([MINIMUM-VERSION,
117 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
118 dnl Test whether libassuan has at least MINIMUM-VERSION. This is
119 dnl used to test for features only available in newer versions.
121 AC_DEFUN([AM_CHECK_LIBASSUAN],
122 [ _AM_PATH_LIBASSUAN_COMMON($1)
123 if test $ok = yes; then
124 ifelse([$2], , :, [$2])
126 ifelse([$3], , :, [$3])
133 dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
134 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
135 dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
137 AC_DEFUN([AM_PATH_LIBASSUAN],
138 [ _AM_PATH_LIBASSUAN_COMMON($1)
139 if test $ok = yes; then
140 LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
141 LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
142 ifelse([$2], , :, [$2])
146 ifelse([$3], , :, [$3])
148 AC_SUBST(LIBASSUAN_CFLAGS)
149 AC_SUBST(LIBASSUAN_LIBS)