diff --git a/common_mk/openssl_flags.mk b/common_mk/openssl_flags.mk index 886ac4cdd..c6c8b2dc7 100644 --- a/common_mk/openssl_flags.mk +++ b/common_mk/openssl_flags.mk @@ -10,6 +10,14 @@ endif # Use pkg-config to get the compiler and linker flags for OpenSSL if CUSTOM_OPENSSL_PATH is not set +ifeq ($(CUSTOM_OPENSSL_PATH),) + ifeq ($(UNAME_S),Darwin) + ifneq ($(OPENSSL_ROOT_DIR),) + CUSTOM_OPENSSL_PATH := $(OPENSSL_ROOT_DIR) + endif + endif +endif + ifeq ($(CUSTOM_OPENSSL_PATH),) ifeq ($(OPENSSL_PACKAGE),openssl3) ifeq ($(UNAME_S),Darwin) @@ -49,7 +57,11 @@ endif endif else SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include +ifeq ($(UNAME_S),Darwin) + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib +else SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 +endif ifeq ($(UNAME_S),Darwin) LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.dylib" 2>/dev/null | head -n 1) ifeq ($(LIB_SSL_PATH),) diff --git a/common_mk/openssl_version_check.mk b/common_mk/openssl_version_check.mk index 7a1785163..885c0c029 100644 --- a/common_mk/openssl_version_check.mk +++ b/common_mk/openssl_version_check.mk @@ -10,7 +10,7 @@ ifeq ($(UNAME_S),Darwin) echo "OpenSSL header file not found at $$header_path"; \ exit 1; \ fi; \ - version_number=$$(awk '/# define OPENSSL_VERSION_STR/ {print $$3}' $$header_path | tr -d '"'); \ + version_number=$$(grep "# *define OPENSSL_VERSION_STR" $$header_path | sed -E 's/.*"([^"]+)".*/\1/'); \ if [ -z "$$version_number" ]; then \ echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \ exit 1; \ @@ -49,7 +49,7 @@ else echo "OpenSSL header file not found at $$header_path"; \ exit 1; \ fi; \ - version_number=$$(awk '/# define OPENSSL_VERSION_STR/ {print $$3}' $$header_path | tr -d '"'); \ + version_number=$$(grep "# *define OPENSSL_VERSION_STR" $$header_path | sed -E 's/.*"([^"]+)".*/\1/'); \ if [ -z "$$version_number" ]; then \ echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \ exit 1; \ diff --git a/doc/BUILD-MACOS.md b/doc/BUILD-MACOS.md index 3196c57bb..ce8012122 100644 --- a/doc/BUILD-MACOS.md +++ b/doc/BUILD-MACOS.md @@ -47,3 +47,17 @@ If the linker fails to find `libssl` or `libcrypto`, ensure that `OPENSSL_ROOT_D ### Missing ICU Headers The build system is configured to find `icu4c` via Homebrew. If you encounter errors related to ICU, ensure `icu4c` is installed and the Homebrew prefix is correct. + +### Building TAP Tests (Optional) + +If you wish to run the TAP tests, you need to build the test dependencies first: + +```bash +export OPENSSL_ROOT_DIR=$(brew --prefix openssl@3) +make build_tap_test_debug +``` + +This will automatically: +1. Build the main ProxySQL debug binary. +2. Download and build MariaDB and MySQL connectors (patched for macOS compatibility). +3. Build the TAP test framework.