Blame src/gpg-error.m4

Packit fc043f
# gpg-error.m4 - autoconf macro to detect libgpg-error.
Packit fc043f
# Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH
Packit fc043f
#
Packit fc043f
# This file is free software; as a special exception the author gives
Packit fc043f
# unlimited permission to copy and/or distribute it, with or without
Packit fc043f
# modifications, as long as this notice is preserved.
Packit fc043f
#
Packit fc043f
# This file is distributed in the hope that it will be useful, but
Packit fc043f
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
Packit fc043f
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit fc043f
#
Packit fc043f
# Last-changed: 2014-10-02
Packit fc043f
Packit fc043f
Packit fc043f
dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
Packit fc043f
dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
Packit fc043f
dnl
Packit fc043f
dnl Test for libgpg-error and define GPG_ERROR_CFLAGS, GPG_ERROR_LIBS,
Packit fc043f
dnl GPG_ERROR_MT_CFLAGS, and GPG_ERROR_MT_LIBS.  The _MT_ variants are
Packit fc043f
dnl used for programs requireing real multi thread support.
Packit fc043f
dnl
Packit fc043f
dnl If a prefix option is not used, the config script is first
Packit fc043f
dnl searched in $SYSROOT/bin and then along $PATH.  If the used
Packit fc043f
dnl config script does not match the host specification the script
Packit fc043f
dnl is added to the gpg_config_script_warn variable.
Packit fc043f
dnl
Packit fc043f
AC_DEFUN([AM_PATH_GPG_ERROR],
Packit fc043f
[ AC_REQUIRE([AC_CANONICAL_HOST])
Packit fc043f
  gpg_error_config_prefix=""
Packit fc043f
  dnl --with-libgpg-error-prefix=PFX is the preferred name for this option,
Packit fc043f
  dnl since that is consistent with how our three siblings use the directory/
Packit fc043f
  dnl package name in --with-$dir_name-prefix=PFX.
Packit fc043f
  AC_ARG_WITH(libgpg-error-prefix,
Packit fc043f
              AC_HELP_STRING([--with-libgpg-error-prefix=PFX],
Packit fc043f
                             [prefix where GPG Error is installed (optional)]),
Packit fc043f
              [gpg_error_config_prefix="$withval"])
Packit fc043f
Packit fc043f
  dnl Accept --with-gpg-error-prefix and make it work the same as
Packit fc043f
  dnl --with-libgpg-error-prefix above, for backwards compatibility,
Packit fc043f
  dnl but do not document this old, inconsistently-named option.
Packit fc043f
  AC_ARG_WITH(gpg-error-prefix,,
Packit fc043f
              [gpg_error_config_prefix="$withval"])
Packit fc043f
Packit fc043f
  if test x"${GPG_ERROR_CONFIG}" = x ; then
Packit fc043f
     if test x"${gpg_error_config_prefix}" != x ; then
Packit fc043f
        GPG_ERROR_CONFIG="${gpg_error_config_prefix}/bin/gpg-error-config"
Packit fc043f
     else
Packit fc043f
       case "${SYSROOT}" in
Packit fc043f
         /*)
Packit fc043f
           if test -x "${SYSROOT}/bin/gpg-error-config" ; then
Packit fc043f
             GPG_ERROR_CONFIG="${SYSROOT}/bin/gpg-error-config"
Packit fc043f
           fi
Packit fc043f
           ;;
Packit fc043f
         '')
Packit fc043f
           ;;
Packit fc043f
          *)
Packit fc043f
           AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
Packit fc043f
           ;;
Packit fc043f
       esac
Packit fc043f
     fi
Packit fc043f
  fi
Packit fc043f
Packit fc043f
  AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
Packit fc043f
  min_gpg_error_version=ifelse([$1], ,0.0,$1)
Packit fc043f
  AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
Packit fc043f
  ok=no
Packit fc043f
  if test "$GPG_ERROR_CONFIG" != "no" \
Packit fc043f
     && test -f "$GPG_ERROR_CONFIG" ; then
Packit fc043f
    req_major=`echo $min_gpg_error_version | \
Packit fc043f
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
Packit fc043f
    req_minor=`echo $min_gpg_error_version | \
Packit fc043f
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
Packit fc043f
    gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
Packit fc043f
    major=`echo $gpg_error_config_version | \
Packit fc043f
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
Packit fc043f
    minor=`echo $gpg_error_config_version | \
Packit fc043f
               sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
Packit fc043f
    if test "$major" -gt "$req_major"; then
Packit fc043f
        ok=yes
Packit fc043f
    else
Packit fc043f
        if test "$major" -eq "$req_major"; then
Packit fc043f
            if test "$minor" -ge "$req_minor"; then
Packit fc043f
               ok=yes
Packit fc043f
            fi
Packit fc043f
        fi
Packit fc043f
    fi
Packit fc043f
  fi
Packit fc043f
  if test $ok = yes; then
Packit fc043f
    GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
Packit fc043f
    GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
Packit fc043f
    GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null`
Packit fc043f
    GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null`
Packit fc043f
    AC_MSG_RESULT([yes ($gpg_error_config_version)])
Packit fc043f
    ifelse([$2], , :, [$2])
Packit fc043f
    gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none`
Packit fc043f
    if test x"$gpg_error_config_host" != xnone ; then
Packit fc043f
      if test x"$gpg_error_config_host" != x"$host" ; then
Packit fc043f
  AC_MSG_WARN([[
Packit fc043f
***
Packit fc043f
*** The config script $GPG_ERROR_CONFIG was
Packit fc043f
*** built for $gpg_error_config_host and thus may not match the
Packit fc043f
*** used host $host.
Packit fc043f
*** You may want to use the configure option --with-libgpg-error-prefix
Packit fc043f
*** to specify a matching config script or use \$SYSROOT.
Packit fc043f
***]])
Packit fc043f
        gpg_config_script_warn="$gpg_config_script_warn libgpg-error"
Packit fc043f
      fi
Packit fc043f
    fi
Packit fc043f
  else
Packit fc043f
    GPG_ERROR_CFLAGS=""
Packit fc043f
    GPG_ERROR_LIBS=""
Packit fc043f
    GPG_ERROR_MT_CFLAGS=""
Packit fc043f
    GPG_ERROR_MT_LIBS=""
Packit fc043f
    AC_MSG_RESULT(no)
Packit fc043f
    ifelse([$3], , :, [$3])
Packit fc043f
  fi
Packit fc043f
  AC_SUBST(GPG_ERROR_CFLAGS)
Packit fc043f
  AC_SUBST(GPG_ERROR_LIBS)
Packit fc043f
  AC_SUBST(GPG_ERROR_MT_CFLAGS)
Packit fc043f
  AC_SUBST(GPG_ERROR_MT_LIBS)
Packit fc043f
])