Index: tls/build.sh ================================================================== --- tls/build.sh +++ tls/build.sh @@ -50,46 +50,60 @@ ) || return 1 # We always statically link KC_TLS_LINKSSLSTATIC='1' - SSLDIR="$(pwd)/libressl-${version}/INST" - - PKG_CONFIG_PATH="${SSLDIR}/lib/pkgconfig:${PKG_CONFIG_PATH}" - export PKG_CONFIG_PATH + SSLPKGCONFIGDIR="$(pwd)/libressl-${version}/INST/lib/pkgconfig" return 0 } function preconfigure() { # Determine SSL directory if [ -z "${CPP}" ]; then CPP="${CC:-cc} -E" fi + + SSLPKGCONFIGDIR='' + SSLDIR='' if [ -n "${KC_TLS_SSLDIR}" ]; then - SSLDIR="${KC_TLS_SSLDIR}" + case "${KC_TLS_SSLDIR}" in + */pkgconfig|*/pkgconfig/) + SSLPKGCONFIGDIR="${KC_TLS_SSLDIR}" + ;; + *) + SSLDIR="${KC_TLS_SSLDIR}" + ;; + esac else - SSLDIR='' - + SSLGUESS='0' if [ -z "${KC_TLS_BUILDSSL}" ]; then - SSLDIR="$(echo '#include ' 2>/dev/null | ${CPP} - 2> /dev/null | awk '/# 1 "\/.*\/ssl\.h/{ print $3; exit }' | sed 's@^"@@;s@"$@@;s@/include/openssl/ssl\.h$@@')" + if ! "${PKG_CONFIG:-pkg-config}" --exists openssl >/dev/null 2>/dev/null; then + SSLDIR="$(echo '#include ' 2>/dev/null | ${CPP} - 2> /dev/null | awk '/# 1 "\/.*\/ssl\.h/{ print $3; exit }' | sed 's@^"@@;s@"$@@;s@/include/openssl/ssl\.h$@@')" + else + SSLGUESS='1' + fi + fi + + if [ -z "${SSLDIR}" -a "${SSLGUESS}" = '0' ]; then + buildSSLLibrary || SSLPKGCONFIGDIR='' fi - if [ -z "${SSLDIR}" ]; then - buildSSLLibrary || SSLDIR='' - fi - - if [ -z "${SSLDIR}" ]; then + if [ -z "${SSLPKGCONFIGDIR}" -a -z "${SSLDIR}" -a "${SSLGUESS}" = '0' ]; then echo "Unable to find OpenSSL, aborting." >&2 return 1 fi fi # Add SSL library to configure options - configure_extra=("${configure_extra[@]}" --with-openssl-dir="${SSLDIR}") + if [ -n "${SSLPKGCONFIGDIR}" ]; then + configure_extra=("${configure_extra[@]}" --with-openssl-pkgconfig="${SSLPKGCONFIGDIR}") + elif [ -n "${SSLDIR}" ]; then + configure_extra=("${configure_extra[@]}" --with-openssl-dir="${SSLDIR}") + fi # If we are statically linking to libssl, let tcltls know so it asks for the right # packages if [ "${KC_TLS_LINKSSLSTATIC}" = '1' ]; then configure_extra=("${configure_extra[@]}" --enable-static-ssl)