From 2da3e913291c39bca3e1342161be6885ca48e333 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sat, 28 Jun 2025 16:28:54 +0300 Subject: Add options to search custom MbedTLS installations Some Linux distributions (like Gentoo or Arch) allows to install MbedTLS 2.x and 3.x branches simultaneously. This change helps to find custom MbedTLS locations. Signed-off-by: Azamat H. Hackimov --- configure.ac | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 65cd5dc2..ead7080a 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,14 @@ AC_ARG_WITH([jpeg-inc], [AS_HELP_STRING([--with-jpeg-inc=DIR], [Specify where to find libjpeg headers])], LIBJPEG_INCDIR=$withval) +AC_ARG_WITH([mbedtls-lib], + [AS_HELP_STRING([--with-mbedtls-lib=DIR], [Specify where to find MbedTLS libraries])], + [LDFLAGS="$LDFLAGS -L$withval"]) + +AC_ARG_WITH([mbedtls-inc], + [AS_HELP_STRING([--with-mbedtls-inc=DIR], [Specify where to find MbedTLS headers])], + [CFLAGS="$CFLAGS -I$withval" CXXFLAGS="$CXXFLAGS -I$withval"]) + AC_ARG_ENABLE([efence], [AS_HELP_STRING([--enable-efence], [Try to compile and run with Electric Fence])], [enable_efence=$enableval], @@ -489,17 +497,20 @@ if test "x$enable_tls" = "xyes"; then dnl If the headers are found, try to link with mbedTLS if test "x$mbedtls_ok" = "xyes"; then old_libs="$LIBS" - AC_CHECK_LIB(mbedtls, mbedtls_ssl_init, mbedtls_ok=yes, mbedtls_ok=no, -lmbedx509 -lmbedcrypto) + AC_SEARCH_LIBS(mbedtls_ssl_init, [mbedtls-3 mbedtls], mbedtls_ok=yes, mbedtls_ok=no) + AC_SEARCH_LIBS(mbedtls_pk_get_name, [mbedcrypto-3 mbedcrypto], mbedcrypto_ok=yes, mbedcrypto_ok=no) + AC_SEARCH_LIBS(mbedtls_x509_crt_init, [mbedx509-3 mbedx509], mbedx509_ok=yes, mbedx509_ok=no) LIBS="$old_libs" fi dnl If it went good, use it, otherwise disable TLS support - if test "x$mbedtls_ok" = "xyes"; then + if test "x$mbedtls_ok" = "xyes" && test "x$mbedcrypto_ok" = "xyes" && test "x$mbedx509_ok" = "xyes" ; then AC_MSG_NOTICE([Using mbedTLS as TLS library.]) tls_impl="mbedTLS" AC_DEFINE([HAVE_MBEDTLS], [1], [mbedTLS works]) - LIBSSL_LIBS="-lmbedtls -lmbedx509 -lmbedcrypto" + LIBSSL_LIBS="$ac_cv_search_mbedtls_ssl_init $ac_cv_search_mbedtls_pk_get_name $ac_cv_search_mbedtls_x509_crt_init" else + mbedtls_ok=no AC_MSG_NOTICE([Cannot find mbedTLS]) fi fi -- cgit v1.2.3