From d9add719519e2019b1f353d8d6832dcfc88ee850 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Fri, 31 Jul 2015 23:15:56 -0400 Subject: [PATCH] build: fix libressl detection Checking libcrypto for a function after we've already found a (possibly different) libcrypto is not what we want to do here. pkg-config might've found a cross lib while AC_CHECK_LIB may find a different or native one. Run a link-test against the lib that's already been found instead. --- configure.ac | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 7f90b5f39..a524bded6 100644 --- a/configure.ac +++ b/configure.ac @@ -680,19 +680,26 @@ else fi fi -AC_CHECK_LIB([crypto],[RAND_egd],[],[ - AC_ARG_WITH([libressl], - [AS_HELP_STRING([--with-libressl],[Build with system LibreSSL (default is no; DANGEROUS; NOT SUPPORTED)])], - [AC_MSG_WARN([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])], - [AC_MSG_ERROR([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])] - ) -]) - CFLAGS_TEMP="$CFLAGS" LIBS_TEMP="$LIBS" CFLAGS="$CFLAGS $SSL_CFLAGS $CRYPTO_CFLAGS" LIBS="$LIBS $SSL_LIBS $CRYPTO_LIBS" AC_CHECK_HEADER([openssl/ec.h],, AC_MSG_ERROR(OpenSSL ec header missing),) + +AC_MSG_CHECKING(for a supported OpenSSL version) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], + [[RAND_egd(NULL);]])], + [AC_MSG_RESULT(yes)], + [ + AC_ARG_WITH([libressl], + [AS_HELP_STRING([--with-libressl],[Build with system LibreSSL (default is no; DANGEROUS; NOT SUPPORTED)])], + [AC_MSG_WARN([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])], + [AC_MSG_ERROR([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])] + )] +) + CFLAGS="$CFLAGS_TEMP" LIBS="$LIBS_TEMP"