chiark / gitweb /
dotlock.c: add a lot of debug logging
[gnupg2.git] / m4 / ntbtls.m4
1 dnl Autoconf macros for NTBTLS
2 dnl Copyright (C) 2002, 2004, 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
12
13 dnl AM_PATH_NTBTLS([MINIMUM-VERSION,
14 dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
15 dnl
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.
23 dnl
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"
33      else
34        case "${SYSROOT}" in
35          /*)
36            if test -x "${SYSROOT}/bin/ntbtls-config" ; then
37              NTBTLS_CONFIG="${SYSROOT}/bin/ntbtls-config"
38            fi
39            ;;
40          '')
41            ;;
42           *)
43            AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
44            ;;
45        esac
46      fi
47   fi
48
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/'`
54   else
55      req_ntbtls_api=0
56      min_ntbtls_version="$tmp"
57   fi
58
59   AC_MSG_CHECKING(for NTBTLS - version >= $min_ntbtls_version)
60   ok=no
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
76         ok=yes
77     else
78         if test "$major" -eq "$req_major"; then
79             if test "$minor" -gt "$req_minor"; then
80                ok=yes
81             else
82                if test "$minor" -eq "$req_minor"; then
83                    if test "$micro" -ge "$req_micro"; then
84                      ok=yes
85                    fi
86                fi
87             fi
88         fi
89     fi
90   fi
91   if test $ok = yes; then
92     AC_MSG_RESULT([yes ($ntbtls_config_version)])
93   else
94     AC_MSG_RESULT(no)
95   fi
96   if test $ok = yes; then
97      # If we have a recent ntbtls, we should also check that the
98      # API is compatible
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])
105            else
106              ok=no
107              AC_MSG_RESULT([does not match. want=$req_ntbtls_api got=$tmp])
108            fi
109         fi
110      fi
111   fi
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
119   AC_MSG_WARN([[
120 ***
121 *** The config script $NTBTLS_CONFIG was
122 *** built for $ntbtls_config_host and thus may not match the
123 *** used host $host.
124 *** You may want to use the configure option --with-ntbtls-prefix
125 *** to specify a matching config script or use \$SYSROOT.
126 ***]])
127         gpg_config_script_warn="$gpg_config_script_warn ntbtls"
128       fi
129     fi
130   else
131     NTBTLS_CFLAGS=""
132     NTBTLS_LIBS=""
133     ifelse([$3], , :, [$3])
134   fi
135   AC_SUBST(NTBTLS_CFLAGS)
136   AC_SUBST(NTBTLS_LIBS)
137 ])