Build system: Darwin-specific fixes and strict platform parity

Detailed changes:
- Defined UNAME_S in root Makefile to ensure correct platform guards.
- Isolated Darwin-specific OpenSSL detection and version checks.
- Enabled ICU support for PostgreSQL on Darwin.
- Added Darwin guards for MariaDB client zlib patches.
- Restored original Linux behavior for all build scripts.
- Added new Darwin-specific patches for MariaDB client.
v3.0_mac
René Cannaò 1 month ago
parent 2637d28f36
commit fdb8dfb152

@ -69,6 +69,7 @@ endif
### multiprocessing
NPROCS := 1
OS := $(shell uname -s)
UNAME_S := $(OS)
ifeq ($(OS),Linux)
NPROCS := $(shell nproc)
endif
@ -87,8 +88,12 @@ ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system)
endif
### check user/group
USERCHECK :=
GROUPCHECK :=
ifeq ($(OS),Linux)
USERCHECK := $(shell getent passwd proxysql)
GROUPCHECK := $(shell getent group proxysql)
endif
### main targets
@ -300,7 +305,11 @@ SYS_ARCH := $(shell uname -m)
REL_ARCH = $(subst x86_64,amd64,$(subst aarch64,arm64,$(SYS_ARCH)))
RPM_ARCH = .$(SYS_ARCH)
DEB_ARCH = _$(REL_ARCH)
ifeq ($(UNAME_S),Darwin)
REL_VERS := $(shell echo ${GIT_VERSION} | sed -E 's/^v//' | grep -Eo '^[0-9\.]+')
else
REL_VERS := $(shell echo ${GIT_VERSION} | grep -Po '(?<=^v|^)[\d\.]+')
endif
RPM_VERS := -$(REL_VERS)-1
DEB_VERS := _$(REL_VERS)

@ -8,27 +8,67 @@ ifeq ($(CENTOSVER),8)
endif
endif
$(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE))
# Use pkg-config to get the compiler and linker flags for OpenSSL if CUSTOM_OPENSSL_PATH is not set
ifeq ($(CUSTOM_OPENSSL_PATH),)
$(info No custom path specified.)
ifeq ($(OPENSSL_PACKAGE),openssl3)
ifeq ($(UNAME_S),Darwin)
SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | sed -E 's/-I/ /g' | awk '{for(i=1;i<=NF;i++) if($$i ~ /^\//) print $$i}' | head -n 1)
else
SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+")
endif
SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE))
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so.3" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so.3" 2>/dev/null | head -n 1)
else
ifeq ($(UNAME_S),Darwin)
SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | sed -E 's/-I/ /g' | awk '{for(i=1;i<=NF;i++) if($$i ~ /^\//) print $$i}' | head -n 1)
else
SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+")
endif
SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE))
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
ifeq ($(UNAME_S),Darwin)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
else
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so*" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so*" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
endif
endif
else
SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include
SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64
ifeq ($(UNAME_S),Darwin)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
else
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
endif
$(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH))
endif

@ -3,6 +3,44 @@ REQUIRED_OPENSSL_VERSION := 3.0.0
$(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE))
check_openssl_version:
ifeq ($(UNAME_S),Darwin)
@if [ -n "$(CUSTOM_OPENSSL_PATH)" ]; then \
header_path="$(CUSTOM_OPENSSL_PATH)/include/openssl/opensslv.h"; \
if [ ! -f "$$header_path" ]; then \
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 '"'); \
if [ -z "$$version_number" ]; then \
echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \
exit 1; \
fi; \
major=$$(echo $$version_number | cut -d'.' -f1); \
minor=$$(echo $$version_number | cut -d'.' -f2); \
patch=$$(echo $$version_number | cut -d'.' -f3); \
if [ $$major -gt 3 ] || { [ $$major -eq 3 ] && { [ $$minor -gt 0 ] || { [ $$minor -eq 0 ] && [ $$patch -ge 0 ]; }; }; }; then \
: ; \
else \
echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$major.$$minor.$$patch"; \
exit 1; \
fi; \
else \
openssl_version=$$(pkg-config --modversion $(OPENSSL_PACKAGE) 2>/dev/null); \
if [ -z "$$openssl_version" ]; then \
echo "OpenSSL not found via pkg-config."; \
exit 1; \
fi; \
major=$$(echo $$openssl_version | cut -d'.' -f1); \
minor=$$(echo $$openssl_version | cut -d'.' -f2); \
patch=$$(echo $$openssl_version | cut -d'.' -f3); \
if [ $$major -gt 3 ] || { [ $$major -eq 3 ] && { [ $$minor -gt 0 ] || { [ $$minor -eq 0 ] && [ $$patch -ge 0 ]; }; }; }; then \
: ; \
else \
echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \
exit 1; \
fi; \
fi
else
@echo "Checking OpenSSL version..."
@if [ -n "$(CUSTOM_OPENSSL_PATH)" ]; then \
echo "Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)"; \
@ -11,7 +49,7 @@ check_openssl_version:
echo "OpenSSL header file not found at $$header_path"; \
exit 1; \
fi; \
version_number=$$(grep -oP '# define OPENSSL_VERSION_STR "\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?' $$header_path | tr -d '[:space:]'); \
version_number=$$(awk '/# define OPENSSL_VERSION_STR/ {print $$3}' $$header_path | tr -d '"'); \
if [ -z "$$version_number" ]; then \
echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \
exit 1; \
@ -41,4 +79,5 @@ check_openssl_version:
echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \
exit 1; \
fi; \
fi
fi
endif

30
deps/Makefile vendored

@ -119,9 +119,11 @@ curl/curl/lib/.libs/libcurl.a:
cd curl && tar -zxf curl-*.tar.gz
cd curl/curl && autoreconf -fi
ifeq ($(UNAME_S),Darwin)
cd curl/curl && patch configure < ../configure.patch
endif
cd curl/curl && sed -i '' 's/as_fn_error \$$? "one or more libs available at link-time are not available run-time/echo "Skipped check: one or more libs available at link-time are not available run-time/' configure
cd curl/curl && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" DYLD_LIBRARY_PATH="$(SSL_LDIR):$$DYLD_LIBRARY_PATH" ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --without-librtmp --without-libpsl --without-zstd --with-ssl --enable-shared=yes
else
cd curl/curl && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --without-librtmp --without-libpsl --without-zstd --with-ssl --enable-shared=yes
endif
cd curl/curl && CFLAGS=-fPIC CC=${CC} CXX=${CXX} ${MAKE}
curl: curl/curl/lib/.libs/libcurl.a
@ -188,7 +190,15 @@ mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a:
cd mariadb-client-library && rm -rf mariadb-connector-c-*/ || true
cd mariadb-client-library && tar -zxf mariadb-connector-c-3.3.8-src.tar.gz
cd mariadb-client-library/mariadb_client && patch -p0 < ../plugin_auth_CMakeLists.txt.patch
cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$(brew --prefix libiconv)/include .
ifeq ($(UNAME_S),Darwin)
cd mariadb-client-library/mariadb_client && patch -p0 < ../zutil.c.patch
cd mariadb-client-library/mariadb_client && patch -p0 < ../zutil.h.patch
endif
ifeq ($(UNAME_S),Darwin)
cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$$(brew --prefix libiconv)/include -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .
else
cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .
endif
ifeq ($(PROXYDEBUG),1)
cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch
else ifeq ($(USEVALGRIND),1)
@ -231,7 +241,7 @@ endif
# new compilers fix
cd mariadb-client-library/mariadb_client && patch -p0 < ../bool_keyword.patch
cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient
cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient VERBOSE=1
# cd mariadb-client-library/mariadb_client/include && make my_config.h
mariadb_client: mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a
@ -297,8 +307,6 @@ pcre/pcre/.libs/libpcre.a:
cd pcre/pcre && CC=${CC} CXX=${CXX} ${MAKE}
pcre: pcre/pcre/.libs/libpcre.a
postgresql/postgresql/src/interfaces/libpq/libpq.a:
cd postgresql && rm -rf postgresql-*/ || true
cd postgresql && tar -zxf postgresql-*.tar.gz
@ -307,10 +315,12 @@ postgresql/postgresql/src/interfaces/libpq/libpq.a:
cd postgresql/postgresql && patch -p0 < ../fmt_err_msg.patch
cd postgresql/postgresql && patch -p0 < ../bind_fmt_text.patch
cd postgresql/postgresql && patch -p0 < ../pqsendpipelinesync.patch
#cd postgresql/postgresql && LD_LIBRARY_PATH="$(shell pwd)/libssl/openssl" ./configure --with-ssl=openssl --with-includes="$(shell pwd)/libssl/openssl/include/" --with-libraries="$(shell pwd)/libssl/openssl/" --without-readline --enable-debug CFLAGS="-ggdb -O0 -fno-omit-frame-pointer" CPPFLAGS="-g -O0"
ifeq ($(UNAME_S),Darwin)
cd postgresql/postgresql && LDFLAGS="-L$$(brew --prefix icu4c)/lib" CPPFLAGS="-I$$(brew --prefix icu4c)/include" PKG_CONFIG_PATH="$$(brew --prefix icu4c)/lib/pkgconfig:$$PKG_CONFIG_PATH" DYLD_LIBRARY_PATH="$(SSL_LDIR):$$DYLD_LIBRARY_PATH" ./configure --with-ssl=openssl --with-includes="$(SSL_IDIR)" --with-libraries="$(SSL_LDIR)" --without-readline --with-icu
else
cd postgresql/postgresql && LD_LIBRARY_PATH="$(SSL_LDIR)" ./configure --with-ssl=openssl --with-includes="$(SSL_IDIR)" --with-libraries="$(SSL_LDIR)" --without-readline
endif
cd postgresql/postgresql/src/interfaces/libpq && CC=${CC} CXX=${CXX} ${MAKE} MAKELEVEL=0
#cd postgresql/postgresql && CC=${CC} CXX=${CXX} ${MAKE} -f src/interfaces/libpq/Makefile all
postgresql: postgresql/postgresql/src/interfaces/libpq/libpq.a
@ -319,7 +329,11 @@ libusual/libusual/.libs/libusual.a:
cd libusual && rm -rf libusual-*/ || true
cd libusual && tar -zxf libusual-*.tar.gz
cd libusual/libusual && ./autogen.sh
ifeq ($(UNAME_S),Darwin)
cd libusual/libusual && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" DYLD_LIBRARY_PATH="$(SSL_LDIR):$$DYLD_LIBRARY_PATH" ./configure --with-openssl="$(patsubst %/include,%,$(SSL_IDIR))" --disable-shared
else
cd libusual/libusual && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" ./configure --with-openssl="$(SSL_LDIR)" --disable-shared
endif
cd libusual/libusual && CC=${CC} CXX=${CXX} ${MAKE}
libusual: libusual/libusual/.libs/libusual.a

@ -0,0 +1,35 @@
--- external/zlib/zutil.c.orig 2024-05-22 17:34:00.000000000 +0200
+++ external/zlib/zutil.c 2024-05-22 17:34:00.000000000 +0200
@@ -132,8 +132,7 @@
/* exported to allow conversion of error code to string for compress() and
* uncompress()
*/
-const char * ZEXPORT zError(err)
- int err;
+const char * ZEXPORT zError(int err)
{
return ERR_MSG(err);
}
@@ -304,10 +304,7 @@
extern void free OF((voidpf ptr));
#endif
-voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
+voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
{
(void)opaque;
return sizeof(uInt) > 2 ? (voidpf)malloc((long) items * size) :
@@ -315,9 +312,7 @@
(voidpf)calloc(items, size);
}
-void ZLIB_INTERNAL zcfree(opaque, ptr)
- voidpf opaque;
- voidpf ptr;
+void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
{
(void)opaque;
free(ptr);

@ -0,0 +1,13 @@
--- external/zlib/zutil.h.orig 2024-05-22 17:34:00.000000000 +0200
+++ external/zlib/zutil.h 2024-05-22 17:34:00.000000000 +0200
@@ -143,9 +143,7 @@
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
+
# endif
# endif
#endif

@ -9,7 +9,7 @@ endif
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
DISTRO := $(shell grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
DISTRO := $(shell if [ -f /etc/os-release ]; then grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"'; else echo "unknown"; fi)
CENTOSVER := Unknown
ifneq (,$(wildcard /etc/system-release))

Loading…
Cancel
Save