Blame npth.m4

Packit 5e354d
# npth.m4 - autoconf macro to detect NPTH.
Packit 5e354d
# Copyright (C) 2002, 2003, 2004, 2011 g10 Code GmbH
Packit 5e354d
#
Packit 5e354d
# This file is free software; as a special exception the author gives
Packit 5e354d
# unlimited permission to copy and/or distribute it, with or without
Packit 5e354d
# modifications, as long as this notice is preserved.
Packit 5e354d
#
Packit 5e354d
# This file is distributed in the hope that it will be useful, but
Packit 5e354d
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
Packit 5e354d
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit 5e354d
Packit 5e354d
AC_DEFUN([_AM_PATH_NPTH_CONFIG],
Packit 5e354d
[ AC_ARG_WITH(npth-prefix,
Packit 5e354d
            AC_HELP_STRING([--with-npth-prefix=PFX],
Packit 5e354d
                           [prefix where NPTH is installed (optional)]),
Packit 5e354d
     npth_config_prefix="$withval", npth_config_prefix="")
Packit 5e354d
  if test "x$npth_config_prefix" != x ; then
Packit 5e354d
      NPTH_CONFIG="$npth_config_prefix/bin/npth-config"
Packit 5e354d
  fi
Packit 5e354d
  AC_PATH_PROG(NPTH_CONFIG, npth-config, no)
Packit 5e354d
Packit 5e354d
  if test "$NPTH_CONFIG" != "no" ; then
Packit 5e354d
    npth_version=`$NPTH_CONFIG --version`
Packit 5e354d
  fi
Packit 5e354d
  npth_version_major=`echo $npth_version | \
Packit 5e354d
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
Packit 5e354d
  npth_version_minor=`echo $npth_version | \
Packit 5e354d
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
Packit 5e354d
])
Packit 5e354d
Packit 5e354d
dnl AM_PATH_NPTH([MINIMUM-VERSION,
Packit 5e354d
dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
Packit 5e354d
dnl Test for libnpth and define NPTH_CFLAGS and NPTH_LIBS.
Packit 5e354d
dnl
Packit 5e354d
AC_DEFUN([AM_PATH_NPTH],
Packit 5e354d
[ AC_REQUIRE([_AM_PATH_NPTH_CONFIG])dnl
Packit 5e354d
  tmp=ifelse([$1], ,1:0.91,$1)
Packit 5e354d
  if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
Packit 5e354d
     req_npth_api=`echo "$tmp"     | sed 's/\(.*\):\(.*\)/\1/'`
Packit 5e354d
     min_npth_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
Packit 5e354d
  else
Packit 5e354d
     req_npth_api=1
Packit 5e354d
     min_npth_version="$tmp"
Packit 5e354d
  fi
Packit 5e354d
Packit 5e354d
  AC_MSG_CHECKING(for NPTH - version >= $min_npth_version)
Packit 5e354d
  ok=no
Packit 5e354d
  if test "$NPTH_CONFIG" != "no" ; then
Packit 5e354d
    req_major=`echo $min_npth_version | \
Packit 5e354d
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
Packit 5e354d
    req_minor=`echo $min_npth_version | \
Packit 5e354d
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
Packit 5e354d
    if test "$npth_version_major" -gt "$req_major"; then
Packit 5e354d
        ok=yes
Packit 5e354d
    else
Packit 5e354d
        if test "$npth_version_major" -eq "$req_major"; then
Packit 5e354d
            if test "$npth_version_minor" -gt "$req_minor"; then
Packit 5e354d
               ok=yes
Packit 5e354d
            else
Packit 5e354d
               if test "$npth_version_minor" -eq "$req_minor"; then
Packit 5e354d
                  ok=yes
Packit 5e354d
               fi
Packit 5e354d
            fi
Packit 5e354d
        fi
Packit 5e354d
    fi
Packit 5e354d
  fi
Packit 5e354d
  if test $ok = yes; then
Packit 5e354d
    AC_MSG_RESULT([yes ($npth_version)])
Packit 5e354d
  else
Packit 5e354d
    AC_MSG_RESULT(no)
Packit 5e354d
  fi
Packit 5e354d
  if test $ok = yes; then
Packit 5e354d
     # If we have a recent NPTH, we should also check that the
Packit 5e354d
     # API is compatible.
Packit 5e354d
     if test "$req_npth_api" -gt 0 ; then
Packit 5e354d
        tmp=`$NPTH_CONFIG --api-version 2>/dev/null || echo 0`
Packit 5e354d
        if test "$tmp" -gt 0 ; then
Packit 5e354d
           AC_MSG_CHECKING([NPTH API version])
Packit 5e354d
           if test "$req_npth_api" -eq "$tmp" ; then
Packit 5e354d
             AC_MSG_RESULT([okay])
Packit 5e354d
           else
Packit 5e354d
             ok=no
Packit 5e354d
             AC_MSG_RESULT([does not match. want=$req_npth_api got=$tmp])
Packit 5e354d
           fi
Packit 5e354d
        fi
Packit 5e354d
     fi
Packit 5e354d
  fi
Packit 5e354d
  if test $ok = yes; then
Packit 5e354d
    NPTH_CFLAGS=`$NPTH_CONFIG --cflags`
Packit 5e354d
    NPTH_LIBS=`$NPTH_CONFIG --libs`
Packit 5e354d
    ifelse([$2], , :, [$2])
Packit 5e354d
    npth_config_host=`$NPTH_CONFIG --host 2>/dev/null || echo none`
Packit 5e354d
    if test x"$npth_config_host" != xnone ; then
Packit 5e354d
      if test x"$npth_config_host" != x"$host" ; then
Packit 5e354d
        AC_MSG_WARN([[
Packit 5e354d
***
Packit 5e354d
*** The config script $NPTH_CONFIG was
Packit 5e354d
*** built for $npth_config_host and thus may not match the
Packit 5e354d
*** used host $host.
Packit 5e354d
*** You may want to use the configure option --with-npth-prefix
Packit 5e354d
*** to specify a matching config script.
Packit 5e354d
***]])
Packit 5e354d
      fi
Packit 5e354d
    fi
Packit 5e354d
  else
Packit 5e354d
    NPTH_CFLAGS=""
Packit 5e354d
    NPTH_LIBS=""
Packit 5e354d
    ifelse([$3], , :, [$3])
Packit 5e354d
  fi
Packit 5e354d
  AC_SUBST(NPTH_CFLAGS)
Packit 5e354d
  AC_SUBST(NPTH_LIBS)
Packit 5e354d
])