@@ -77,10 +77,11 @@ echo "Running: ${MAKE:-make} V=1 install" ${MAKE:-make} V=1 install || exit 1 ) || return 1 SSLDIR="$(pwd)/libressl-${version}/INST" + addlibs="$(PKG_CONFIG_PATH="$(pwd)/libressl-${version}/INST/lib/pkgconfig" "${PKG_CONFIG:-pkg-config}" libssl libcrypto --libs --static)" } ( cd 'build' || exit 1 @@ -216,12 +217,25 @@ LINKADDFILE="$(find "${INSTDIR}" -name '*.a' | head -n 1)" if [ -n "${LINKADDFILE}" ]; then LINKADDFILE="${LINKADDFILE}.linkadd" ## XXX: TODO: Determine what we actually need to link against - addlibs="-L${SSL_LIB_DIR:-/lib} -lssl -lcrypto ${KC_TLS_LINKADD}" - addlibs_staticOnly="" + if [ -z "${addlibs}" ]; then + if [ "${KC_TLS_LINKSSLSTATIC}" = '1' ]; then + addlibs="$("${PKG_CONFIG:-pkg-config}" libssl libcrypto --libs --static)" + else + addlibs="$("${PKG_CONFIG:-pkg-config}" libssl libcrypto --libs)" + fi + fi + + if [ -z "${addlibs}" ]; then + addlibs="-L${SSL_LIB_DIR:-/lib} -lssl -lcrypto" + addlibs_staticOnly="" + fi + + addlibs="${addlibs} ${KC_TLS_LINKADD}" + if [ "${KC_TLS_LINKSSLSTATIC}" = '1' ]; then echo "-Wl,-Bstatic ${addlibs} ${addlibs_staticOnly} -Wl,-Bdynamic" else echo "${addlibs}" fi > "${LINKADDFILE}"