chiark / gitweb /
doc: Document summary values of TOFU_STATS
[gnupg2.git] / m4 / npth.m4
1 # npth.m4 - autoconf macro to detect NPTH.
2 # Copyright (C) 2002, 2003, 2004, 2011 g10 Code GmbH
3 #
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.
7 #
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.
11
12 AC_DEFUN([_AM_PATH_NPTH_CONFIG],
13 [ AC_ARG_WITH(npth-prefix,
14             AC_HELP_STRING([--with-npth-prefix=PFX],
15                            [prefix where NPTH is installed (optional)]),
16      npth_config_prefix="$withval", npth_config_prefix="")
17   if test "x$npth_config_prefix" != x ; then
18       NPTH_CONFIG="$npth_config_prefix/bin/npth-config"
19   fi
20   AC_PATH_PROG(NPTH_CONFIG, npth-config, no)
21
22   if test "$NPTH_CONFIG" != "no" ; then
23     npth_version=`$NPTH_CONFIG --version`
24   fi
25   npth_version_major=`echo $npth_version | \
26                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
27   npth_version_minor=`echo $npth_version | \
28                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
29 ])
30
31 dnl AM_PATH_NPTH([MINIMUM-VERSION,
32 dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
33 dnl Test for libnpth and define NPTH_CFLAGS and NPTH_LIBS.
34 dnl
35 AC_DEFUN([AM_PATH_NPTH],
36 [ AC_REQUIRE([_AM_PATH_NPTH_CONFIG])dnl
37   tmp=ifelse([$1], ,1:0.91,$1)
38   if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
39      req_npth_api=`echo "$tmp"     | sed 's/\(.*\):\(.*\)/\1/'`
40      min_npth_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
41   else
42      req_npth_api=1
43      min_npth_version="$tmp"
44   fi
45
46   AC_MSG_CHECKING(for NPTH - version >= $min_npth_version)
47   ok=no
48   if test "$NPTH_CONFIG" != "no" ; then
49     req_major=`echo $min_npth_version | \
50                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
51     req_minor=`echo $min_npth_version | \
52                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
53     if test "$npth_version_major" -gt "$req_major"; then
54         ok=yes
55     else
56         if test "$npth_version_major" -eq "$req_major"; then
57             if test "$npth_version_minor" -gt "$req_minor"; then
58                ok=yes
59             else
60                if test "$npth_version_minor" -eq "$req_minor"; then
61                   ok=yes
62                fi
63             fi
64         fi
65     fi
66   fi
67   if test $ok = yes; then
68     AC_MSG_RESULT([yes ($npth_version)])
69   else
70     AC_MSG_RESULT(no)
71   fi
72   if test $ok = yes; then
73      # If we have a recent NPTH, we should also check that the
74      # API is compatible.
75      if test "$req_npth_api" -gt 0 ; then
76         tmp=`$NPTH_CONFIG --api-version 2>/dev/null || echo 0`
77         if test "$tmp" -gt 0 ; then
78            AC_MSG_CHECKING([NPTH API version])
79            if test "$req_npth_api" -eq "$tmp" ; then
80              AC_MSG_RESULT([okay])
81            else
82              ok=no
83              AC_MSG_RESULT([does not match. want=$req_npth_api got=$tmp])
84            fi
85         fi
86      fi
87   fi
88   if test $ok = yes; then
89     NPTH_CFLAGS=`$NPTH_CONFIG --cflags`
90     NPTH_LIBS=`$NPTH_CONFIG --libs`
91     ifelse([$2], , :, [$2])
92     npth_config_host=`$NPTH_CONFIG --host 2>/dev/null || echo none`
93     if test x"$npth_config_host" != xnone ; then
94       if test x"$npth_config_host" != x"$host" ; then
95         AC_MSG_WARN([[
96 ***
97 *** The config script $NPTH_CONFIG was
98 *** built for $npth_config_host and thus may not match the
99 *** used host $host.
100 *** You may want to use the configure option --with-npth-prefix
101 *** to specify a matching config script.
102 ***]])
103       fi
104     fi
105   else
106     NPTH_CFLAGS=""
107     NPTH_LIBS=""
108     ifelse([$3], , :, [$3])
109   fi
110   AC_SUBST(NPTH_CFLAGS)
111   AC_SUBST(NPTH_LIBS)
112 ])