Skip to content

Commit a6fdd90

Browse files
committed
Tests: use pkg-config to find OpenSSL
1 parent 6653525 commit a6fdd90

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

tests/openssl-settings.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright © 2024 Mobi - Com Polska Sp. z o.o.
3+
# Copyright © 2024-2026 Mobi - Com Polska Sp. z o.o.
44
# Author: Małgorzata Olszówka <Malgorzata.Olszowka@stunnel.org>
55
#
66
# This is free software; you can redistribute it and/or modify it
@@ -20,16 +20,21 @@
2020
# Save original library path for later restoration
2121
TEMP_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
2222

23-
# OpenSSL settings
24-
if test -n ${PKG_CONFIG_PATH}; then
25-
OPENSSL_PATH="${PKG_CONFIG_PATH}/../.."
26-
if command -v "${OPENSSL_PATH}/bin/openssl" &> /dev/null; then
27-
OPENSSL="${OPENSSL_PATH}/bin/openssl"
28-
export LD_LIBRARY_PATH="../src/.libs:${OPENSSL_PATH}/lib64:${OPENSSL_PATH}/lib"
29-
else
30-
OPENSSL=openssl
31-
fi
23+
# Use the configured OpenSSL library path if found
24+
OPENSSL_LIBDIR=$(pkg-config --variable=libdir --silence-errors openssl)
25+
if test -n "${OPENSSL_LIBDIR}"; then
26+
export LD_LIBRARY_PATH="${OPENSSL_LIBDIR}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
27+
fi
28+
29+
# Use the configured OpenSSL executable path if found
30+
OPENSSL_PREFIX=$(pkg-config --variable=prefix --silence-errors openssl)
31+
if test -n "${OPENSSL_PREFIX}"; then
32+
OPENSSL=$(PATH="${OPENSSL_PREFIX}/bin:${PATH}" command -v openssl 2>/dev/null || echo openssl)
3233
else
3334
OPENSSL=openssl
3435
fi
35-
echo "Compiled with: `${OPENSSL} version`"
36+
37+
# Use the compiled and not the installed libp11.so
38+
export LD_LIBRARY_PATH="$(pwd)/../src/.libs${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
39+
40+
echo "Compiled with: $(${OPENSSL} version)"

0 commit comments

Comments
 (0)