@@ -20,10 +20,11 @@ ]) AC_DEFUN([TCLTLS_SSL_OPENSSL], [ openssldir='' + opensslpkgconfigdir='' AC_ARG_WITH([ssl-dir], AS_HELP_STRING( [--with-ssl-dir=], [deprecated, use --with-openssl-dir -- currently has the same meaning] ), [ @@ -35,10 +36,18 @@ [--with-openssl-dir=], [path to root directory of OpenSSL or LibreSSL installation] ), [ openssldir="$withval" ] + ) + AC_ARG_WITH([openssl-pkgconfig], + AS_HELP_STRING( + [--with-openssl-pkgconfig=], + [path to root directory of OpenSSL or LibreSSL pkgconfigdir] + ), [ + opensslpkgconfigdir="$withval" + ] ) if test -n "$openssldir"; then if test -e "$openssldir/libssl.$SHOBJEXT"; then TCLTLS_SSL_LIBS="-L$openssldir -lssl -lcrypto" @@ -54,10 +63,21 @@ if test "$TCLEXT_BUILD" = "static" -o "$TCLEXT_TLS_STATIC_SSL" = 'yes'; then pkgConfigExtraArgs='--static' fi dnl Use pkg-config to find the libraries + dnl Temporarily update PKG_CONFIG_PATH + PKG_CONFIG_PATH_SAVE="${PKG_CONFIG_PATH}" + if test -n "${opensslpkgconfigdir}"; then + if ! test -f "${opensslpkgconfigdir}/openssl.pc"; then + AC_MSG_ERROR([Unable to locate ${opensslpkgconfigdir}/openssl.pc]) + fi + + PKG_CONFIG_PATH="${opensslpkgconfigdir}${PATH_SEPARATOR}${PKG_CONFIG_PATH}" + export PKG_CONFIG_PATH + fi + AC_ARG_VAR([TCLTLS_SSL_LIBS], [libraries to pass to the linker for OpenSSL or LibreSSL]) AC_ARG_VAR([TCLTLS_SSL_CFLAGS], [C compiler flags for OpenSSL or LibreSSL]) AC_ARG_VAR([TCLTLS_SSL_CPPFLAGS], [C preprocessor flags for OpenSSL or LibreSSL]) if test -z "$TCLTLS_SSL_LIBS"; then TCLTLS_SSL_LIBS="`"${PKGCONFIG}" openssl --libs $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration]) @@ -66,10 +86,11 @@ TCLTLS_SSL_CFLAGS="`"${PKGCONFIG}" openssl --cflags-only-other $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration]) fi if test -z "$TCLTLS_SSL_CPPFLAGS"; then TCLTLS_SSL_CPPFLAGS="`"${PKGCONFIG}" openssl --cflags-only-I $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration]) fi + PKG_CONFIG_PATH="${PKG_CONFIG_PATH_SAVE}" if test "$TCLEXT_BUILD" = "static"; then dnl If we are doing a static build, save the linker flags for other programs to consume rm -f tcltls.a.linkadd AS_ECHO(["$TCLTLS_SSL_LIBS"]) > tcltls.a.linkadd