Blame m4/gnupg-pth.m4

Packit 3c2767
dnl GnuPG's check for Pth.
Packit 3c2767
dnl       Copyright (C) 2003 Free Software Foundation, Inc.
Packit 3c2767
dnl
Packit 3c2767
dnl This file is free software; as a special exception the author gives
Packit 3c2767
dnl unlimited permission to copy and/or distribute it, with or without
Packit 3c2767
dnl modifications, as long as this notice is preserved.
Packit 3c2767
dnl
Packit 3c2767
dnl This file is distributed in the hope that it will be useful, but
Packit 3c2767
dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
Packit 3c2767
dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit 3c2767
Packit 3c2767
Packit 3c2767
# GNUPG_PTH_VERSION_CHECK(REQUIRED)
Packit 3c2767
# 
Packit 3c2767
# If the version is sufficient, HAVE_PTH will be set to yes.
Packit 3c2767
#
Packit 3c2767
# Taken and modified from the m4 macros which come with Pth.
Packit 3c2767
AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
Packit 3c2767
  [
Packit 3c2767
    _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
Packit 3c2767
    _req_version="ifelse([$1],,1.2.0,$1)"
Packit 3c2767
Packit 3c2767
    AC_MSG_CHECKING(for PTH - version >= $_req_version)
Packit 3c2767
    for _var in _pth_version _req_version; do
Packit 3c2767
        eval "_val=\"\$${_var}\""
Packit 3c2767
        _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
Packit 3c2767
        _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
Packit 3c2767
        _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
Packit 3c2767
        _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
Packit 3c2767
        case $_rtype in
Packit 3c2767
            "a" ) _rtype=0 ;;
Packit 3c2767
            "b" ) _rtype=1 ;;
Packit 3c2767
            "." ) _rtype=2 ;;
Packit 3c2767
        esac
Packit 3c2767
        _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
Packit 3c2767
              "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
Packit 3c2767
        eval "${_var}_hex=\"\$_hex\""
Packit 3c2767
    done
Packit 3c2767
    have_pth=no
Packit 3c2767
    if test ".$_pth_version_hex" != .; then
Packit 3c2767
        if test ".$_req_version_hex" != .; then
Packit 3c2767
            if test $_pth_version_hex -ge $_req_version_hex; then
Packit 3c2767
                have_pth=yes
Packit 3c2767
            fi
Packit 3c2767
        fi
Packit 3c2767
    fi
Packit 3c2767
    if test $have_pth = yes; then
Packit 3c2767
       AC_MSG_RESULT(yes)
Packit 3c2767
       AC_MSG_CHECKING([whether PTH installation is sane])
Packit 3c2767
       AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
Packit 3c2767
         _gnupg_pth_save_cflags=$CFLAGS
Packit 3c2767
         _gnupg_pth_save_ldflags=$LDFLAGS
Packit 3c2767
         _gnupg_pth_save_libs=$LIBS
Packit 3c2767
         CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
Packit 3c2767
         LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
Packit 3c2767
         LIBS="$LIBS `$PTH_CONFIG --libs --all`"
Packit 3c2767
         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
Packit 3c2767
                                         ],
Packit 3c2767
                                         [[ pth_init ();]])],
Packit 3c2767
                        gnupg_cv_pth_is_sane=yes,
Packit 3c2767
                        gnupg_cv_pth_is_sane=no)
Packit 3c2767
         CFLAGS=$_gnupg_pth_save_cflags
Packit 3c2767
         LDFLAGS=$_gnupg_pth_save_ldflags
Packit 3c2767
         LIBS=$_gnupg_pth_save_libs
Packit 3c2767
       ])
Packit 3c2767
       if test $gnupg_cv_pth_is_sane != yes; then
Packit 3c2767
          have_pth=no
Packit 3c2767
       fi
Packit 3c2767
       AC_MSG_RESULT($gnupg_cv_pth_is_sane)
Packit 3c2767
    else
Packit 3c2767
       AC_MSG_RESULT(no)
Packit 3c2767
    fi    
Packit 3c2767
  ])
Packit 3c2767
Packit 3c2767
Packit 3c2767
Packit 3c2767
# GNUPG_PATH_PTH([MINIMUM_VERSION])
Packit 3c2767
#
Packit 3c2767
# On return $have_pth is set as well as HAVE_PTH is defined and
Packit 3c2767
# PTH_CLFAGS and PTH_LIBS are AS_SUBST.
Packit 3c2767
#
Packit 3c2767
AC_DEFUN([GNUPG_PATH_PTH],
Packit 3c2767
[ AC_ARG_WITH(pth-prefix,
Packit 3c2767
             AC_HELP_STRING([--with-pth-prefix=PFX],
Packit 3c2767
                           [prefix where GNU Pth is installed (optional)]),
Packit 3c2767
     pth_config_prefix="$withval", pth_config_prefix="")
Packit 3c2767
  if test x$pth_config_prefix != x ; then
Packit 3c2767
     PTH_CONFIG="$pth_config_prefix/bin/pth-config"
Packit 3c2767
  fi
Packit 3c2767
  AC_PATH_PROG(PTH_CONFIG, pth-config, no)
Packit 3c2767
  tmp=ifelse([$1], ,1.3.7,$1)
Packit 3c2767
  if test "$PTH_CONFIG" != "no"; then
Packit 3c2767
    GNUPG_PTH_VERSION_CHECK($tmp)
Packit 3c2767
    if test $have_pth = yes; then      
Packit 3c2767
       PTH_CFLAGS=`$PTH_CONFIG --cflags`
Packit 3c2767
       PTH_LIBS=`$PTH_CONFIG --ldflags`
Packit 3c2767
       PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
Packit 3c2767
       AC_DEFINE(HAVE_PTH, 1,
Packit 3c2767
                [Defined if the GNU Pth is available])
Packit 3c2767
    fi
Packit 3c2767
  fi
Packit 3c2767
  AC_SUBST(PTH_CFLAGS)
Packit 3c2767
  AC_SUBST(PTH_LIBS)
Packit 3c2767
])
Packit 3c2767