Blame m4/gpg-error.m4

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