1 # ksba.m4 - autoconf macro to detect ksba
2 # Copyright (C) 2002 g10 Code GmbH
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
8 # This file is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 dnl AM_PATH_KSBA([MINIMUM-VERSION,
14 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
15 dnl Test for libksba and define KSBA_CFLAGS and KSBA_LIBS
16 dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed
17 dnl with the API version to also check the API compatibility. Example:
18 dnl a MINIMUN-VERSION of 1:1.0.7 won't pass the test unless the installed
19 dnl version of libksba is at least 1.0.7 *and* the API number is 1. Using
20 dnl this features allows to prevent build against newer versions of libksba
21 dnl with a changed API.
23 AC_DEFUN([AM_PATH_KSBA],
24 [ AC_ARG_WITH(ksba-prefix,
25 AC_HELP_STRING([--with-ksba-prefix=PFX],
26 [prefix where KSBA is installed (optional)]),
27 ksba_config_prefix="$withval", ksba_config_prefix="")
28 if test x$ksba_config_prefix != x ; then
29 ksba_config_args="$ksba_config_args --prefix=$ksba_config_prefix"
30 if test x${KSBA_CONFIG+set} != xset ; then
31 KSBA_CONFIG=$ksba_config_prefix/bin/ksba-config
35 AC_PATH_PROG(KSBA_CONFIG, ksba-config, no)
36 tmp=ifelse([$1], ,1:1.0.0,$1)
37 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
38 req_ksba_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
39 min_ksba_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
42 min_ksba_version="$tmp"
45 AC_MSG_CHECKING(for KSBA - version >= $min_ksba_version)
47 if test "$KSBA_CONFIG" != "no" ; then
48 req_major=`echo $min_ksba_version | \
49 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
50 req_minor=`echo $min_ksba_version | \
51 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
52 req_micro=`echo $min_ksba_version | \
53 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
54 ksba_config_version=`$KSBA_CONFIG $ksba_config_args --version`
55 major=`echo $ksba_config_version | \
56 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
57 minor=`echo $ksba_config_version | \
58 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
59 micro=`echo $ksba_config_version | \
60 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
61 if test "$major" -gt "$req_major"; then
64 if test "$major" -eq "$req_major"; then
65 if test "$minor" -gt "$req_minor"; then
68 if test "$minor" -eq "$req_minor"; then
69 if test "$micro" -ge "$req_micro"; then
77 if test $ok = yes; then
78 AC_MSG_RESULT([yes ($ksba_config_version)])
82 if test $ok = yes; then
83 # Even if we have a recent libksba, we should check that the
85 if test "$req_ksba_api" -gt 0 ; then
86 tmp=`$KSBA_CONFIG --api-version 2>/dev/null || echo 0`
87 if test "$tmp" -gt 0 ; then
88 AC_MSG_CHECKING([KSBA API version])
89 if test "$req_ksba_api" -eq "$tmp" ; then
93 AC_MSG_RESULT([does not match. want=$req_ksba_api got=$tmp.])
98 if test $ok = yes; then
99 KSBA_CFLAGS=`$KSBA_CONFIG $ksba_config_args --cflags`
100 KSBA_LIBS=`$KSBA_CONFIG $ksba_config_args --libs`
101 ifelse([$2], , :, [$2])
105 ifelse([$3], , :, [$3])
107 AC_SUBST(KSBA_CFLAGS)