1 dnl Autoconf macros for NTBTLS
2 dnl Copyright (C) 2002, 2004, 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 AM_PATH_NTBTLS([MINIMUM-VERSION,
14 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
16 dnl Test for NTBTLS and define NTBTLS_CFLAGS and NTBTLS_LIBS.
17 dnl MINIMUM-VERSION is a string with the version number optionalliy prefixed
18 dnl with the API version to also check the API compatibility. Example:
19 dnl a MINIMUM-VERSION of 1:1.2.5 won't pass the test unless the installed
20 dnl version of ntbtls is at least 1.2.5 *and* the API number is 1. Using
21 dnl this feature prevents building against newer versions of ntbtls
22 dnl with a changed API.
24 AC_DEFUN([AM_PATH_NTBTLS],
25 [ AC_REQUIRE([AC_CANONICAL_HOST])
26 AC_ARG_WITH(ntbtls-prefix,
27 AC_HELP_STRING([--with-ntbtls-prefix=PFX],
28 [prefix where NTBTLS is installed (optional)]),
29 ntbtls_config_prefix="$withval", ntbtls_config_prefix="")
30 if test x"${NTBTLS_CONFIG}" = x ; then
31 if test x"${ntbtls_config_prefix}" != x ; then
32 NTBTLS_CONFIG="${ntbtls_config_prefix}/bin/ntbtls-config"
36 if test -x "${SYSROOT}/bin/ntbtls-config" ; then
37 NTBTLS_CONFIG="${SYSROOT}/bin/ntbtls-config"
43 AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
49 AC_PATH_PROG(NTBTLS_CONFIG, ntbtls-config, no)
50 tmp=ifelse([$1], ,1:1.0.0,$1)
51 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
52 req_ntbtls_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
53 min_ntbtls_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
56 min_ntbtls_version="$tmp"
59 AC_MSG_CHECKING(for NTBTLS - version >= $min_ntbtls_version)
61 if test "$NTBTLS_CONFIG" != "no" ; then
62 req_major=`echo $min_ntbtls_version | \
63 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
64 req_minor=`echo $min_ntbtls_version | \
65 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
66 req_micro=`echo $min_ntbtls_version | \
67 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
68 ntbtls_config_version=`$NTBTLS_CONFIG --version`
69 major=`echo $ntbtls_config_version | \
70 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
71 minor=`echo $ntbtls_config_version | \
72 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
73 micro=`echo $ntbtls_config_version | \
74 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
75 if test "$major" -gt "$req_major"; then
78 if test "$major" -eq "$req_major"; then
79 if test "$minor" -gt "$req_minor"; then
82 if test "$minor" -eq "$req_minor"; then
83 if test "$micro" -ge "$req_micro"; then
91 if test $ok = yes; then
92 AC_MSG_RESULT([yes ($ntbtls_config_version)])
96 if test $ok = yes; then
97 # If we have a recent ntbtls, we should also check that the
99 if test "$req_ntbtls_api" -gt 0 ; then
100 tmp=`$NTBTLS_CONFIG --api-version 2>/dev/null || echo 0`
101 if test "$tmp" -gt 0 ; then
102 AC_MSG_CHECKING([NTBTLS API version])
103 if test "$req_ntbtls_api" -eq "$tmp" ; then
104 AC_MSG_RESULT([okay])
107 AC_MSG_RESULT([does not match. want=$req_ntbtls_api got=$tmp])
112 if test $ok = yes; then
113 NTBTLS_CFLAGS=`$NTBTLS_CONFIG --cflags`
114 NTBTLS_LIBS=`$NTBTLS_CONFIG --libs`
115 ifelse([$2], , :, [$2])
116 ntbtls_config_host=`$NTBTLS_CONFIG --host 2>/dev/null || echo none`
117 if test x"$ntbtls_config_host" != xnone ; then
118 if test x"$ntbtls_config_host" != x"$host" ; then
121 *** The config script $NTBTLS_CONFIG was
122 *** built for $ntbtls_config_host and thus may not match the
124 *** You may want to use the configure option --with-ntbtls-prefix
125 *** to specify a matching config script or use \$SYSROOT.
127 gpg_config_script_warn="$gpg_config_script_warn ntbtls"
133 ifelse([$3], , :, [$3])
135 AC_SUBST(NTBTLS_CFLAGS)
136 AC_SUBST(NTBTLS_LIBS)