-AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
-dnl
-dnl ------ OpenSSL
-AC_SUBST(SSL_CFLAGS)
-openssl=default
-AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
-SSL_CFLAGS=""
-SSL_LIBPATH=""
-if test "$openssl" != "no"; then
- sslver=no
- if test "$openssl" != "yes" -a "$openssl" != "default"; then
- if test -x $openssl/bin/pkg-config; then
- if $openssl/bin/pkg-config --exists openssl; then
- SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
- LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
- sslver=`$openssl/bin/pkg-config --modversion openssl`
+AC_CHECK_FUNC([gethostbyname], ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
+dnl ------ libgcrypt
+AC_SUBST([GCRYPT_LIBS])
+libgcryptpath=NONE
+AC_ARG_WITH(libgcrypt, [ --with-libgcrypt=DIR use libgcrypt-config in DIR],[libgcryptpath=$withval])
+if test "$libgcryptpath" != "no"; then
+ if test "$libgcryptpath" = "NONE"; then
+ AC_PATH_PROG([libgcrypt],[libgcrypt-config],[NONE])
+ elif test -x $libgcryptpath/libgcrypt-config; then
+ libgcrypt=$libgcryptpath/libgcrypt-config
+ else
+ libgcrypt=$libgcryptpath
+ fi
+ AC_MSG_CHECKING([for libgcrypt])
+ if "$libgcrypt" --version >/dev/null 2>&1; then
+ libgcryptversion=`$libgcrypt --version`
+ libgcryptversion2=`echo "$libgcryptversion" | awk 'BEGIN { FS = "."; } { printf "%d", [$]1 * 1000 + [$]2;}'`
+ AC_MSG_RESULT([$libgcryptversion])
+ if test $libgcryptversion2 -ge 1002; then
+ GCRYPT_LIBS="`$libgcrypt --libs`"
+ CFLAGS="$CFLAGS `$libgcrypt --cflags`"
+ AC_DEFINE([HAVE_GCRYPT_H],[1],[Define to 1 if libgcrypt is present])
+ else
+ if test "$libgcryptpath" = "NONE"; then
+ AC_MSG_WARN([Only libgcrypt version 1.2 and later supported])
+ else
+ AC_MSG_ERROR([Only libgcrypt version 1.2 and later supported])