Skip to content

Commit

Permalink
Fixed AlmaLinux builid issues for openssl
Browse files Browse the repository at this point in the history
  • Loading branch information
yashwantsahu20 committed Nov 20, 2024
1 parent 793aba0 commit 8cb4f10
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
42 changes: 25 additions & 17 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,36 @@ endif

libinjection: libinjection/libinjection/src/libinjection.a

libssl_path := $(shell find /usr /usr/local /opt -name "libssl.so" 2>/dev/null | head -n 1)

ifneq ($(libssl_path),)
SSL_LDIR := $(dir $(libssl_path))
$(info Found OpenSSL libs at $(SSL_LDIR))
DISTRO := $(shell lsb_release -si 2>/dev/null || grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
OPENSSL_VERSION_3 := 3.0.0

ifeq ($(DISTRO), almalinux)
ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl3/*" 2>/dev/null | head -n 1)
LIB_SSL_PATH := $(shell find /usr /usr/local /opt -name "libssl.so.3" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find /usr /usr/local /opt -name "libcrypto.so.3" 2>/dev/null | head -n 1)
SSL_LDIR := $(dir $(LIB_SSL_PATH))
else
$(error Warning: OpenSSL library not found. exiting, please install openssl.)
ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1)
LIB_SSL_PATH := $(shell find /usr /usr/local /opt -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find /usr /usr/local /opt -name "libcrypto.so" 2>/dev/null | head -n 1)
SSL_LDIR := $(dir $(LIB_SSL_PATH))
endif

ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1)

ifneq ($(ssl_header_path),)
SSL_IDIR := $(shell dirname $(ssl_header_path))
SSL_IDIR := $(shell dirname $(shell dirname $(ssl_header_path)))
$(info Found OpenSSL headers at $(SSL_IDIR))
$(info OpenSSL lib full path is $(LIB_SSL_PATH))
$(info OpenSSL libs directory is $(SSL_LDIR))
else
$(error Warning: OpenSSL headers not found. exiting, please install openssl.)
endif

OPENSSL_VERSION_3 = 3.0.0

check_openssl_version:
@current_version=$$(openssl version | awk '{print $$2}'); \
@if [ "$(DISTRO)" = "almalinux" ]; then \
@current_version=$$(openssl3 version | awk '{print $$2}'); \
else \
@current_version=$$(openssl version | awk '{print $$2}'); \
fi; \
echo "Installed OpenSSL version: $$current_version"; \
compare_result=`printf "%s\n%s" "$(OPENSSL_VERSION_3)" "$$current_version" | sort -V | head -n 1`; \
if [ "$$compare_result" != "$(OPENSSL_VERSION_3)" ]; then \
Expand Down Expand Up @@ -143,8 +151,8 @@ curl/curl/lib/.libs/libcurl.a:
ifeq ($(SYS_KERN),Darwin)
cd curl/curl && patch configure < ../configure.patch
endif
cd curl/curl && ./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
cd curl/curl && LD_LIBRARY_PATH=$(SSL_LDIR) CFLAGS=-fPIC CC=${CC} CXX=${CXX} ${MAKE}
cd curl/curl && CPPFLAGS="-I$(SSL_IDIR)" ./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
cd curl/curl && CFLAGS=-fPIC CC=${CC} CXX=${CXX} ${MAKE}

curl: curl/curl/lib/.libs/libcurl.a

Expand Down Expand Up @@ -213,7 +221,7 @@ 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_LDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$(brew --prefix libiconv)/include .
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 ($(PROXYDEBUG),1)
cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch
else ifeq ($(USEVALGRIND),1)
Expand Down Expand Up @@ -335,14 +343,14 @@ libusual/libusual/.libs/libusual.a:
cd libusual && rm -rf libusual-*/ || true
cd libusual && tar -zxf libusual-*.tar.gz
cd libusual/libusual && ./autogen.sh
cd libusual/libusual && ./configure --with-openssl="$(SSL_LDIR)" --disable-shared
cd libusual/libusual && CPPFLAGS="-I$(SSL_IDIR)" ./configure --with-openssl="$(SSL_LDIR)" --disable-shared
cd libusual/libusual && CC=${CC} CXX=${CXX} ${MAKE}

libusual: libusual/libusual/.libs/libusual.a

libscram/lib/libscram.a:postgresql/postgresql/src/interfaces/libpq/libpq.a
cd libscram && rm -rf lib/* || true
cd libscram && CC=${CC} CXX=${CXX} ${MAKE} LIBOPENSSL_DIR="$(SSL_LDIR)" POSTGRESQL_DIR="$(shell pwd)/postgresql/postgresql/"
cd libscram && CC=${CC} CXX=${CXX} ${MAKE} LIBOPENSSL_DIR="$(SSL_IDIR)" POSTGRESQL_DIR="$(shell pwd)/postgresql/postgresql/"

libscram: libscram/lib/libscram.a

Expand Down
12 changes: 9 additions & 3 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ COREDUMPER_IDIR := $(COREDUMPER_DIR)/include
CURL_DIR := $(DEPS_PATH)/curl/curl
CURL_IDIR := $(CURL_DIR)/include

ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1)
DISTRO := $(shell lsb_release -si 2>/dev/null || grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')

ifeq ($(DISTRO), almalinux)
ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl3/*" 2>/dev/null | head -n 1)
else
ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1)
endif

ifneq ($(ssl_header_path),)
SSL_IDIR := $(shell dirname $(ssl_header_path))
$(info Found OpenSSL headers at $(SSL_IDIR))
SSL_IDIR := $(shell dirname $(shell dirname $(ssl_header_path)))
$(info Found yash OpenSSL headers at $(SSL_IDIR))
else
$(error Warning: OpenSSL headers not found. exiting, please install openssl.)
endif
Expand Down
30 changes: 20 additions & 10 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,27 @@ CURL_PATH := $(DEPS_PATH)/curl/curl
CURL_IDIR := $(CURL_PATH)/include
CURL_LDIR := $(CURL_PATH)/lib/.libs

libssl_path := $(shell find /usr /usr/local /opt -name "libssl.so" 2>/dev/null | head -n 1)
DISTRO := $(shell lsb_release -si 2>/dev/null || grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')

ifneq ($(libssl_path),)
SSL_LDIR := $(dir $(libssl_path))
$(info Found OpenSSL libs at $(SSL_LDIR))
ifeq ($(DISTRO), almalinux)
ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl3/*" 2>/dev/null | head -n 1)
LIB_SSL_PATH := $(shell find /usr /usr/local /opt -name "libssl.so.3" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find /usr /usr/local /opt -name "libcrypto.so.3" 2>/dev/null | head -n 1)
SSL_LDIR := $(dir $(LIB_SSL_PATH))
else
$(error Warning: OpenSSL library not found. exiting, please install openssl.)
ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1)
LIB_SSL_PATH := $(shell find /usr /usr/local /opt -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find /usr /usr/local /opt -name "libcrypto.so" 2>/dev/null | head -n 1)
SSL_LDIR := $(dir $(LIB_SSL_PATH))
endif

ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1)

ifneq ($(ssl_header_path),)
SSL_IDIR := $(shell dirname $(ssl_header_path))
SSL_IDIR := $(shell dirname $(shell dirname $(ssl_header_path)))
$(info Found OpenSSL headers at $(SSL_IDIR))
$(info OpenSSL lib full path is $(LIB_SSL_PATH))
$(info OpenSSL libs directory is $(SSL_LDIR))
else
$(error Warning: OpenSSL headers not found. exiting, please install openssl.)
$(error Warning: OpenSSL headers not found. exiting, please install openssl.)
endif

EV_PATH := $(DEPS_PATH)/libev/libev/
Expand Down Expand Up @@ -196,7 +201,12 @@ ifeq ($(UNAME_S),Linux)
STATICMYLIBS += -lcoredumper
endif

MYLIBS := -Wl,--export-dynamic $(STATICMYLIBS) -Wl,-Bdynamic -lgnutls -lpthread -lssl -lcrypto -lm -lz -lrt -lprometheus-cpp-pull -lprometheus-cpp-core -luuid $(EXTRALINK)
ifeq ($(DISTRO), almalinux)
MYLIBS := -Wl,--export-dynamic $(STATICMYLIBS) -Wl,-Bdynamic -lgnutls -lpthread $(LIB_SSL_PATH) $(LIB_CRYPTO_PATH) -lm -lz -lrt -lprometheus-cpp-pull -lprometheus-cpp-core -luuid $(EXTRALINK)
else
MYLIBS := -Wl,--export-dynamic $(STATICMYLIBS) -Wl,-Bdynamic -lgnutls -lpthread -lssl -lcrypto -lm -lz -lrt -lprometheus-cpp-pull -lprometheus-cpp-core -luuid $(EXTRALINK)
endif

ifeq ($(UNAME_S),Darwin)
MYLIBS :=-lre2 -lmariadbclient -lpq -lpthread -lm -lz -liconv -lgnutls -lprometheus-cpp-pull -lprometheus-cpp-core -luuid
else
Expand Down

0 comments on commit 8cb4f10

Please sign in to comment.