1 # npth.m4 - autoconf macro to detect NPTH.
2 # Copyright (C) 2002, 2003, 2004, 2011 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.
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"
20 AC_PATH_PROG(NPTH_CONFIG, npth-config, no)
22 if test "$NPTH_CONFIG" != "no" ; then
23 npth_version=`$NPTH_CONFIG --version`
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/'`
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.
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/'`
43 min_npth_version="$tmp"
46 AC_MSG_CHECKING(for NPTH - version >= $min_npth_version)
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
56 if test "$npth_version_major" -eq "$req_major"; then
57 if test "$npth_version_minor" -gt "$req_minor"; then
60 if test "$npth_version_minor" -eq "$req_minor"; then
67 if test $ok = yes; then
68 AC_MSG_RESULT([yes ($npth_version)])
72 if test $ok = yes; then
73 # If we have a recent NPTH, we should also check that the
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
83 AC_MSG_RESULT([does not match. want=$req_npth_api got=$tmp])
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
97 *** The config script $NPTH_CONFIG was
98 *** built for $npth_config_host and thus may not match the
100 *** You may want to use the configure option --with-npth-prefix
101 *** to specify a matching config script.
108 ifelse([$3], , :, [$3])
110 AC_SUBST(NPTH_CFLAGS)