Blame m4/libgcrypt.m4

Packit 875988
# libgcrypt.m4 - Autoconf macros to detect libgcrypt
Packit 875988
# Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH
Packit 875988
#
Packit 875988
# This file is free software; as a special exception the author gives
Packit 875988
# unlimited permission to copy and/or distribute it, with or without
Packit 875988
# modifications, as long as this notice is preserved.
Packit 875988
#
Packit 875988
# This file is distributed in the hope that it will be useful, but
Packit 875988
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
Packit 875988
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit 875988
#
Packit 875988
# Last-changed: 2014-10-02
Packit 875988
Packit 875988
Packit 875988
dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
Packit 875988
dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
Packit 875988
dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
Packit 875988
dnl MINIMUM-VERSION is a string with the version number optionalliy prefixed
Packit 875988
dnl with the API version to also check the API compatibility. Example:
Packit 875988
dnl a MINIMUM-VERSION of 1:1.2.5 won't pass the test unless the installed
Packit 875988
dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1.  Using
Packit 875988
dnl this feature prevents building against newer versions of libgcrypt
Packit 875988
dnl with a changed API.
Packit 875988
dnl
Packit 875988
dnl If a prefix option is not used, the config script is first
Packit 875988
dnl searched in $SYSROOT/bin and then along $PATH.  If the used
Packit 875988
dnl config script does not match the host specification the script
Packit 875988
dnl is added to the gpg_config_script_warn variable.
Packit 875988
dnl
Packit 875988
AC_DEFUN([AM_PATH_LIBGCRYPT],
Packit 875988
[ AC_REQUIRE([AC_CANONICAL_HOST])
Packit 875988
  AC_ARG_WITH(libgcrypt-prefix,
Packit 875988
            AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
Packit 875988
                           [prefix where LIBGCRYPT is installed (optional)]),
Packit 875988
     libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
Packit 875988
  if test x"${LIBGCRYPT_CONFIG}" = x ; then
Packit 875988
     if test x"${libgcrypt_config_prefix}" != x ; then
Packit 875988
        LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config"
Packit 875988
     else
Packit 875988
       case "${SYSROOT}" in
Packit 875988
         /*)
Packit 875988
           if test -x "${SYSROOT}/bin/libgcrypt-config" ; then
Packit 875988
             LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config"
Packit 875988
           fi
Packit 875988
           ;;
Packit 875988
         '')
Packit 875988
           ;;
Packit 875988
          *)
Packit 875988
           AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
Packit 875988
           ;;
Packit 875988
       esac
Packit 875988
     fi
Packit 875988
  fi
Packit 875988
Packit 875988
  AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
Packit 875988
  tmp=ifelse([$1], ,1:1.2.0,$1)
Packit 875988
  if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
Packit 875988
     req_libgcrypt_api=`echo "$tmp"     | sed 's/\(.*\):\(.*\)/\1/'`
Packit 875988
     min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
Packit 875988
  else
Packit 875988
     req_libgcrypt_api=0
Packit 875988
     min_libgcrypt_version="$tmp"
Packit 875988
  fi
Packit 875988
Packit 875988
  AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
Packit 875988
  ok=no
Packit 875988
  if test "$LIBGCRYPT_CONFIG" != "no" ; then
Packit 875988
    req_major=`echo $min_libgcrypt_version | \
Packit 875988
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
Packit 875988
    req_minor=`echo $min_libgcrypt_version | \
Packit 875988
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
Packit 875988
    req_micro=`echo $min_libgcrypt_version | \
Packit 875988
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
Packit 875988
    libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
Packit 875988
    major=`echo $libgcrypt_config_version | \
Packit 875988
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
Packit 875988
    minor=`echo $libgcrypt_config_version | \
Packit 875988
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
Packit 875988
    micro=`echo $libgcrypt_config_version | \
Packit 875988
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
Packit 875988
    if test "$major" -gt "$req_major"; then
Packit 875988
        ok=yes
Packit 875988
    else
Packit 875988
        if test "$major" -eq "$req_major"; then
Packit 875988
            if test "$minor" -gt "$req_minor"; then
Packit 875988
               ok=yes
Packit 875988
            else
Packit 875988
               if test "$minor" -eq "$req_minor"; then
Packit 875988
                   if test "$micro" -ge "$req_micro"; then
Packit 875988
                     ok=yes
Packit 875988
                   fi
Packit 875988
               fi
Packit 875988
            fi
Packit 875988
        fi
Packit 875988
    fi
Packit 875988
  fi
Packit 875988
  if test $ok = yes; then
Packit 875988
    AC_MSG_RESULT([yes ($libgcrypt_config_version)])
Packit 875988
  else
Packit 875988
    AC_MSG_RESULT(no)
Packit 875988
  fi
Packit 875988
  if test $ok = yes; then
Packit 875988
     # If we have a recent libgcrypt, we should also check that the
Packit 875988
     # API is compatible
Packit 875988
     if test "$req_libgcrypt_api" -gt 0 ; then
Packit 875988
        tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
Packit 875988
        if test "$tmp" -gt 0 ; then
Packit 875988
           AC_MSG_CHECKING([LIBGCRYPT API version])
Packit 875988
           if test "$req_libgcrypt_api" -eq "$tmp" ; then
Packit 875988
             AC_MSG_RESULT([okay])
Packit 875988
           else
Packit 875988
             ok=no
Packit 875988
             AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
Packit 875988
           fi
Packit 875988
        fi
Packit 875988
     fi
Packit 875988
  fi
Packit 875988
  if test $ok = yes; then
Packit 875988
    LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
Packit 875988
    LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
Packit 875988
    ifelse([$2], , :, [$2])
Packit 875988
    libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
Packit 875988
    if test x"$libgcrypt_config_host" != xnone ; then
Packit 875988
      if test x"$libgcrypt_config_host" != x"$host" ; then
Packit 875988
  AC_MSG_WARN([[
Packit 875988
***
Packit 875988
*** The config script $LIBGCRYPT_CONFIG was
Packit 875988
*** built for $libgcrypt_config_host and thus may not match the
Packit 875988
*** used host $host.
Packit 875988
*** You may want to use the configure option --with-libgcrypt-prefix
Packit 875988
*** to specify a matching config script or use \$SYSROOT.
Packit 875988
***]])
Packit 875988
        gpg_config_script_warn="$gpg_config_script_warn libgcrypt"
Packit 875988
      fi
Packit 875988
    fi
Packit 875988
  else
Packit 875988
    LIBGCRYPT_CFLAGS=""
Packit 875988
    LIBGCRYPT_LIBS=""
Packit 875988
    ifelse([$3], , :, [$3])
Packit 875988
  fi
Packit 875988
  AC_SUBST(LIBGCRYPT_CFLAGS)
Packit 875988
  AC_SUBST(LIBGCRYPT_LIBS)
Packit 875988
])