Index: acinclude.m4
==================================================================
--- acinclude.m4
+++ acinclude.m4
@@ -7,11 +7,11 @@
#
# Add here whatever m4 macros you want to define for your package
#
AC_DEFUN([TCLTLS_SSL_OPENSSL], [
- AC_CHECK_TOOL([PKG_CONFIG], [pkg-config], [false])
+ AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
dnl Disable support for TLS 1.0 protocol
AC_ARG_ENABLE([tls1], AS_HELP_STRING([--disable-tls1], [disable TLS1 protocol]), [
if test "${enableval}" = "no"; then
AC_DEFINE([NO_TLS1], [1], [Disable TLS1 protocol])
@@ -109,18 +109,12 @@
TCLEXT_TLS_STATIC_SSL='no'
])
AC_MSG_CHECKING([for static linking of openSSL libraries])
AC_MSG_RESULT([$TCLEXT_TLS_STATIC_SSL])
- # Static lib
- pkgConfigExtraArgs=''
- if test "${SHARED_BUILD}" == 0 -o "$TCLEXT_TLS_STATIC_SSL" = 'yes'; then
- pkgConfigExtraArgs='--static'
- fi
-
-
- dnl Get SSL paths
+
+ dnl Set SSL files root path
AC_ARG_WITH([openssl-dir],
AS_HELP_STRING([--with-openssl-dir=
],
[path to root directory of OpenSSL or LibreSSL installation]
), [
openssldir="$withval"
@@ -127,11 +121,11 @@
], [
openssldir=''
]
)
- dnl Get SSL include files path
+ dnl Set SSL include files path
AC_ARG_WITH([openssl-includedir],
AS_HELP_STRING([--with-openssl-includedir=],
[path to include directory of OpenSSL or LibreSSL installation]
), [
opensslincludedir="$withval"
@@ -144,20 +138,24 @@
]
)
AC_MSG_CHECKING([for OpenSSL include directory])
AC_MSG_RESULT($opensslincludedir)
- dnl Get SSL lib files path
+ dnl Set SSL include vars
if test -n "$opensslincludedir"; then
if test -f "$opensslincludedir/ssl.h"; then
TCLTLS_SSL_CFLAGS="-I$opensslincludedir"
TCLTLS_SSL_INCLUDES="-I$opensslincludedir"
else
AC_MSG_ERROR([Unable to locate ssl.h])
fi
+ else
+ TCLTLS_SSL_CFLAGS="-I$(includedir)/openssl"
+ TCLTLS_SSL_INCLUDES="-I$(includedir)/openssl"
fi
+ dnl Set SSL lib files path
AC_ARG_WITH([openssl-libdir],
AS_HELP_STRING([--with-openssl-libdir=],
[path to lib directory of OpenSSL or LibreSSL installation]
), [
openssllibdir="$withval"
@@ -174,10 +172,11 @@
]
)
AC_MSG_CHECKING([for OpenSSL lib directory])
AC_MSG_RESULT($openssllibdir)
+ dnl Set SSL lib vars
if test -n "$openssllibdir"; then
if test -f "$openssllibdir/libssl${SHLIB_SUFFIX}"; then
if test "${TCLEXT_TLS_STATIC_SSL}" == 'no'; then
TCLTLS_SSL_LIBS="-L$openssllibdir -lcrypto -lssl"
else
@@ -192,13 +191,19 @@
else
TCLTLS_SSL_LIBS="-lcrypto -lssl"
fi
+ dnl Include config variables in --help list and make available to be substituted via AC_SUBST.
+ AC_ARG_VAR([TCLTLS_SSL_CFLAGS], [C compiler flags for OpenSSL or LibreSSL])
+ AC_ARG_VAR([TCLTLS_SSL_INCLUDES], [C compiler include paths for OpenSSL or LibreSSL])
+ AC_ARG_VAR([TCLTLS_SSL_LIBS], [libraries to pass to the linker for OpenSSL or LibreSSL])
+
+
+ dnl Set location of pkgconfig files
AC_ARG_WITH([openssl-pkgconfig],
- AS_HELP_STRING(
- [--with-openssl-pkgconfig=],
+ AS_HELP_STRING([--with-openssl-pkgconfig=],
[path to root directory of OpenSSL or LibreSSL pkgconfigdir]
), [
opensslpkgconfigdir="$withval"
], [
opensslpkgconfigdir=''
@@ -205,31 +210,36 @@
]
)
AC_MSG_CHECKING([for OpenSSL pkgconfig])
AC_MSG_RESULT($opensslpkgconfigdir)
- 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_INCLUDES], [C compiler include paths for OpenSSL or LibreSSL])
- if test -z "$TCLTLS_SSL_LIBS"; then
- TCLTLS_SSL_LIBS="`"${PKG_CONFIG}" openssl --libs $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
- fi
- if test -z "$TCLTLS_SSL_CFLAGS"; then
- TCLTLS_SSL_CFLAGS="`"${PKG_CONFIG}" openssl --cflags-only-other $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
- fi
- if test -z "$TCLTLS_SSL_INCLUDES"; then
- TCLTLS_SSL_INCLUDES="`"${PKG_CONFIG}" openssl --cflags-only-I $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
- fi
- PKG_CONFIG_PATH="${PKG_CONFIG_PATH_SAVE}"
+
+ # Use Package Config tool to get config
+ pkgConfigExtraArgs=''
+ if test "${SHARED_BUILD}" == 0 -o "$TCLEXT_TLS_STATIC_SSL" = 'yes'; then
+ pkgConfigExtraArgs='--static'
+ fi
+
+ dnl Use pkg-config to find the libraries
+ if test -n "${PKG_CONFIG}"; then
+ 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
+ if test -z "$TCLTLS_SSL_LIBS"; then
+ TCLTLS_SSL_LIBS="`"${PKG_CONFIG}" openssl --libs $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
+ fi
+ if test -z "$TCLTLS_SSL_CFLAGS"; then
+ TCLTLS_SSL_CFLAGS="`"${PKG_CONFIG}" openssl --cflags-only-other $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
+ fi
+ if test -z "$TCLTLS_SSL_INCLUDES"; then
+ TCLTLS_SSL_INCLUDES="`"${PKG_CONFIG}" openssl --cflags-only-I $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
+ fi
+ PKG_CONFIG_PATH="${PKG_CONFIG_PATH_SAVE}"
+ fi
])