Skip to content

Commit d9add71

Browse files
committed
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.
1 parent eddaba7 commit d9add71

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

configure.ac

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,19 +680,26 @@ else
680680
fi
681681
fi
682682

683-
AC_CHECK_LIB([crypto],[RAND_egd],[],[
684-
AC_ARG_WITH([libressl],
685-
[AS_HELP_STRING([--with-libressl],[Build with system LibreSSL (default is no; DANGEROUS; NOT SUPPORTED)])],
686-
[AC_MSG_WARN([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])],
687-
[AC_MSG_ERROR([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])]
688-
)
689-
])
690-
691683
CFLAGS_TEMP="$CFLAGS"
692684
LIBS_TEMP="$LIBS"
693685
CFLAGS="$CFLAGS $SSL_CFLAGS $CRYPTO_CFLAGS"
694686
LIBS="$LIBS $SSL_LIBS $CRYPTO_LIBS"
695687
AC_CHECK_HEADER([openssl/ec.h],, AC_MSG_ERROR(OpenSSL ec header missing),)
688+
689+
AC_MSG_CHECKING(for a supported OpenSSL version)
690+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
691+
#include <openssl/rand.h>
692+
]],
693+
[[RAND_egd(NULL);]])],
694+
[AC_MSG_RESULT(yes)],
695+
[
696+
AC_ARG_WITH([libressl],
697+
[AS_HELP_STRING([--with-libressl],[Build with system LibreSSL (default is no; DANGEROUS; NOT SUPPORTED)])],
698+
[AC_MSG_WARN([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])],
699+
[AC_MSG_ERROR([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])]
700+
)]
701+
)
702+
696703
CFLAGS="$CFLAGS_TEMP"
697704
LIBS="$LIBS_TEMP"
698705

0 commit comments

Comments
 (0)