From 7f80c0df755c1b1ede8ed2c953fa7b37606f6290 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Mon, 30 Jun 2014 06:28:38 +0000 Subject: [PATCH] Yavor Doganov's patch to avoid unnecessary link to libgcrypt git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37966 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++++ Source/GSTLS.h | 2 ++ Source/GSTLS.m | 4 ++++ configure | 14 +++++++------- configure.ac | 13 +++++++------ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index c20c02d5d..59bad2a0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,10 @@ * Tools/DocMakefile: Flags alterations to build documentation before base/autogsdoc is installed. + * configure.ac: Test whether gnutls needs libgcrypt + * Source/GSTLS.h: Use test + * Source/GSTLS.m: Use test + * configure: regenerate 2014-06-26 Riccardo Mottola diff --git a/Source/GSTLS.h b/Source/GSTLS.h index 30b33327d..77586518b 100644 --- a/Source/GSTLS.h +++ b/Source/GSTLS.h @@ -49,7 +49,9 @@ extern NSString * const GSTLSVerify; #define _GCRYPT_IN_LIBGCRYPT #include #include +#if GNUTLS_VERSION_NUMBER <= 0x020b00 #include +#endif #undef id /* This class is used to ensure that the GNUTLS system is initialised diff --git a/Source/GSTLS.m b/Source/GSTLS.m index 273fe6eeb..8a4c96941 100644 --- a/Source/GSTLS.m +++ b/Source/GSTLS.m @@ -67,6 +67,7 @@ standardizedPath(NSString *path) #if defined(HAVE_GNUTLS) +#if GNUTLS_VERSION_NUMBER <= 0x020b00 /* Set up locking callbacks for gcrypt so that it will be thread-safe. */ static int gcry_mutex_init(void **priv) @@ -98,6 +99,7 @@ static struct gcry_thread_cbs gcry_threads_other = { gcry_mutex_lock, gcry_mutex_unlock }; +#endif static void GSTLSLog(int level, const char *msg) @@ -324,9 +326,11 @@ static NSMutableDictionary *fileMap = nil; name: NSUserDefaultsDidChangeNotification object: nil]; +#if GNUTLS_VERSION_NUMBER <= 0x020b00 /* Make gcrypt thread-safe */ gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_other); +#endif /* Initialise gnutls */ diff --git a/configure b/configure index 247586d12..25b80314b 100755 --- a/configure +++ b/configure @@ -25301,7 +25301,8 @@ $as_echo "no" >&6; } fi fi if test $HAVE_GNUTLS = 1; then - { $as_echo "$as_me:$LINENO: checking for gcry_control in -lgcrypt" >&5 + if ! pkg-config --atleast-version=2.12 gnutls; then + { $as_echo "$as_me:$LINENO: checking for gcry_control in -lgcrypt" >&5 $as_echo_n "checking for gcry_control in -lgcrypt... " >&6; } if test "${ac_cv_lib_gcrypt_gcry_control+set}" = set; then $as_echo_n "(cached) " >&6 @@ -25372,12 +25373,11 @@ else have_gcrypt=no fi - if test "$have_gcrypt" = "no"; then - { $as_echo "$as_me:$LINENO: WARNING: Missing support for thread-safe operation in GNUTLS. Disabling TLS support)." >&5 -$as_echo "$as_me: WARNING: Missing support for thread-safe operation in GNUTLS. Disabling TLS support)." >&2;} - HAVE_GNUTLS=0 - else - TLS_LIBS="$TLS_LIBS -lgcrypt" + if test "$have_gcrypt" = "no"; then + HAVE_GNUTLS=0 + else + TLS_LIBS="$TLS_LIBS -lgcrypt" + fi fi fi if test $HAVE_GNUTLS = 0; then diff --git a/configure.ac b/configure.ac index e89f17c57..3346a87e9 100644 --- a/configure.ac +++ b/configure.ac @@ -3130,12 +3130,13 @@ if test $enable_tls = yes; then fi fi if test $HAVE_GNUTLS = 1; then - AC_CHECK_LIB(gcrypt, gcry_control, have_gcrypt=yes, have_gcrypt=no) - if test "$have_gcrypt" = "no"; then - AC_MSG_WARN([Missing support for thread-safe operation in GNUTLS. Disabling TLS support).]) - HAVE_GNUTLS=0 - else - TLS_LIBS="$TLS_LIBS -lgcrypt" + if ! pkg-config --atleast-version=2.12 gnutls; then + AC_CHECK_LIB(gcrypt, gcry_control, have_gcrypt=yes, have_gcrypt=no) + if test "$have_gcrypt" = "no"; then + HAVE_GNUTLS=0 + else + TLS_LIBS="$TLS_LIBS -lgcrypt" + fi fi fi if test $HAVE_GNUTLS = 0; then