[AC 21.5] Check TLS headers as well as libraries

Jerry James <[email protected]> Thu, 9 Oct 2014 15:44:35 -0600
Newsgroups gmane.emacs.xemacs.patches
Message-ID <CAHCOHQ=6SZuGB1zmOwQMgVqVtOXdaLy_=4yfOqULDkRjHEiNcA@mail.gmail.com>
AC 21.5

This patch adds checks for headers to the existing TLS library checks.
This should fix the first failure Vin reported recently.  The second
failure (missing openssl symbols at link time) needs a more extensive
fix.

diff -r d59bfb050ca8 ChangeLog
--- a/ChangeLog Wed Oct 08 12:58:20 2014 -0600
+++ b/ChangeLog Thu Oct 09 15:43:06 2014 -0600
@@ -1,3 +1,7 @@
+2014-10-09  Jerry James  <[email protected]>
+
+ * configure.ac: Check for TLS headers as well as libraries.
+
 2014-10-07  Jerry James  <[email protected]>

  * configure.ac: Add TLS support.

diff -r d59bfb050ca8 configure.ac
--- a/configure.ac Wed Oct 08 12:58:20 2014 -0600
+++ b/configure.ac Thu Oct 09 15:43:06 2014 -0600
@@ -5332,20 +5332,35 @@
 fi

 dnl TLS support
-if test "$with_tls" = "yes"; then
-  AC_CHECK_LIB(gnutls, gnutls_global_init, [with_tls=gnutls],
-    AC_CHECK_LIB(nss3, NSS_InitContext, [with_tls=nss],
-      AC_CHECK_LIB(ssl, SSL_library_init, [with_tls=openssl], [with_tls=no])))
-elif test "$with_tls" = "gnutls"; then
-  AC_CHECK_LIB(gnutls, gnutls_global_init, [with_tls=gnutls],
+if test "$with_tls" = "gnutls"; then
+  AC_CHECK_HEADER([gnutls/gnutls.h],
+    [AC_CHECK_LIB(gnutls, gnutls_global_init, [with_tls=gnutls],
+      [XE_DIE("Required gnutls support cannot be provided.")])],
     [XE_DIE("Required gnutls support cannot be provided.")])
 elif test "$with_tls" = "nss"; then
-  AC_CHECK_LIB(nss3, NSS_InitContext, [with_tls=nss],
+  AC_CHECK_HEADER([nss.h],
+    [AC_CHECK_LIB(nss3, NSS_InitContext, [with_tls=nss],
+      [XE_DIE("Required NSS support cannot be provided.")])],
     [XE_DIE("Required NSS support cannot be provided.")])
 elif test "$with_tls" = "openssl"; then
-  AC_CHECK_LIB(ssl, SSL_library_init, [with_tls=openssl],
+  AC_CHECK_HEADER([openssl/ssl.h],
+    [AC_CHECK_LIB(ssl, SSL_library_init, [with_tls=openssl],
+      [XE_DIE("Required openssl support cannot be provided.")])],
     [XE_DIE("Required openssl support cannot be provided.")])
 fi
+dnl Autodetection
+if test "$with_tls" = "yes"; then
+  AC_CHECK_HEADER([gnutls/gnutls.h],
+    [AC_CHECK_LIB(gnutls, gnutls_global_init, [with_tls=gnutls])])
+fi
+if test "$with_tls" = "yes"; then
+  AC_CHECK_HEADER([nss.h],
+    [AC_CHECK_LIB(nss3, NSS_InitContext, [with_tls=nss])])
+fi
+if test "$with_tls" = "yes"; then
+  AC_CHECK_HEADER([openssl/ssl.h],
+    [AC_CHECK_LIB(ssl, SSL_library_init, [with_tls=openssl], [with_tls=no])])
+fi
 if test "$with_tls" != "no"; then
   AC_DEFINE(WITH_TLS)
   if test "$with_tls" = "gnutls"; then

I will push this patch momentarily.
-- 
Jerry James
http://www.jamezone.org/