Skip to contentSkip to conversation

configure.ac: fix polarssl autodetection

PATCH In review Steffan Karger 2 participants 2 messages Jan 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure.ac: fix polarssl autodetection

A missing , in the previous configure.ac patch caused the autodetection to fail. While fixing that, I noticed I can simplify the check by using the documented ${ac_cv_search_function} cache variable instead of the nested AC_SEARCH_LIBS.

---
 configure.ac | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
configure.ac +10 -12
index 73dd032..7ff2435 100644
@@ -832,30 +832,28 @@ elif test "${with_crypto_library}" = "polarssl"; then
 	AC_ARG_VAR([POLARSSL_CFLAGS], [C compiler flags for polarssl])
 	AC_ARG_VAR([POLARSSL_LIBS], [linker flags for polarssl])
 
+	saved_CFLAGS="${CFLAGS}"
+	saved_LIBS="${LIBS}"
+
 	if test -z "${POLARSSL_CFLAGS}" -a -z "${POLARSSL_LIBS}"; then
         # if the user did not explicitly specify flags, try to autodetect
 		AC_SEARCH_LIBS(
 			[ssl_init],
-			[mbedtls],
-			[POLARSSL_LIBS=-lmbedtls]
+			[mbedtls polarssl],
 			[
-				AC_SEARCH_LIBS(
-					[ssl_init],
-					[polarssl],
-					[POLARSSL_LIBS=-lpolarssl]
-					[],
-					[${PKCS11_HELPER_LIBS}]
-				)
+				if test "${ac_cv_search_ssl_init}" != "none required"; then
+					POLARSSL_LIBS=${ac_cv_search_ssl_init}
+				fi
 			],
+			[AC_MSG_ERROR([Could not find PolarSSL/mbed TLS.])],
 			[${PKCS11_HELPER_LIBS}]
 		)
 	fi
 
-	AC_MSG_CHECKING([polarssl version])
-	saved_CFLAGS="${CFLAGS}"
-	saved_LIBS="${LIBS}"
 	CFLAGS="${POLARSSL_CFLAGS} ${PKCS11_HELPER_CFLAGS} ${CFLAGS}"
 	LIBS="${POLARSSL_LIBS} ${PKCS11_HELPER_LIBS} ${LIBS}"
+
+	AC_MSG_CHECKING([polarssl version])
 	AC_COMPILE_IFELSE(
 		[AC_LANG_PROGRAM(
 			[[
Signature · 1 line
2.5.0
#1 lore raw

ACK, fixes the problem with polarssl library autodetection for systems that need -lpolarssl. If POLARSSL_CFLAGS= is set, it still need POLARSSL_LIBS= to be set as well - usually, you need both anyway, so that's a particular special case that is now different - hereby documented.

Your patch has been applied to the master branch.

commit 417fe4a72c82accca8d95fb0488427f5b6dc4157

Author: Steffan Karger
Date:   Mon Jan 18 21:49:40 2016 +0100
     configure.ac: fix polarssl autodetection

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/11010
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering