From e9b57ac6efccdb8f69175db7ba522d46bd5942f6 Mon Sep 17 00:00:00 2001 From: Yashwant Sahu Date: Mon, 23 Dec 2024 14:46:46 +0530 Subject: [PATCH 1/6] Using pkg-config to find out insrtalled pkg-config --- deps/Makefile | 38 +++++++++++++++++++++++++------------- lib/Makefile | 40 +++++++++++++++++++++++++++------------- src/Makefile | 40 +++++++++++++++++++++++++++------------- 3 files changed, 79 insertions(+), 39 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 964fe6f0d..b99f8b44c 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -76,26 +76,38 @@ endif libinjection: libinjection/libinjection/src/libinjection.a -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) +CUSTOM_OPENSSL_PATH ?= + +OPENSSL_PACKAGE := openssl + ifeq ($(DISTRO),almalinux) ifeq ($(CENTOSVER),8) - 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) + OPENSSL_PACKAGE := openssl3 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.) + SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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) else + SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif -SSL_LDIR := $(dir $(LIB_SSL_PATH)) -ifneq ($(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)) +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) + $(info SSL_LDIR: $(SSL_LDIR)) + $(info LIB_SSL_PATH: $(LIB_SSL_PATH)) + $(info LIB_CRYPTO_PATH: $(LIB_CRYPTO_PATH)) else - $(error Warning: OpenSSL headers not found. exiting, please install openssl version 3.) + $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif OPENSSL_VERSION_3 := 3.0.0 diff --git a/lib/Makefile b/lib/Makefile index 5328a23eb..580aaa7c8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -62,25 +62,39 @@ 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) -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) +CUSTOM_OPENSSL_PATH ?= + +OPENSSL_PACKAGE := openssl + ifeq ($(DISTRO),almalinux) ifeq ($(CENTOSVER),8) - 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)endif + OPENSSL_PACKAGE := openssl3 +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.) + SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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) +else + SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif -SSL_LDIR := $(dir $(LIB_SSL_PATH)) -ifneq ($(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)) +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) + $(info SSL_LDIR: $(SSL_LDIR)) + $(info LIB_SSL_PATH: $(LIB_SSL_PATH)) + $(info LIB_CRYPTO_PATH: $(LIB_CRYPTO_PATH)) else - $(error Warning: OpenSSL headers not found. exiting, please install openssl version 3.) + $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif EV_DIR := $(DEPS_PATH)/libev/libev/ diff --git a/src/Makefile b/src/Makefile index dd3e0a3a3..2d2d88042 100644 --- a/src/Makefile +++ b/src/Makefile @@ -89,25 +89,39 @@ CURL_PATH := $(DEPS_PATH)/curl/curl CURL_IDIR := $(CURL_PATH)/include CURL_LDIR := $(CURL_PATH)/lib/.libs -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) +CUSTOM_OPENSSL_PATH ?= + +OPENSSL_PACKAGE := openssl + ifeq ($(DISTRO),almalinux) ifeq ($(CENTOSVER),8) - 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) + OPENSSL_PACKAGE := openssl3 +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.) + SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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) +else + SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif -SSL_LDIR := $(dir $(LIB_SSL_PATH)) -ifneq ($(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)) +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) + $(info SSL_LDIR: $(SSL_LDIR)) + $(info LIB_SSL_PATH: $(LIB_SSL_PATH)) + $(info LIB_CRYPTO_PATH: $(LIB_CRYPTO_PATH)) else - $(error Warning: OpenSSL headers not found. exiting, please install openssl version 3.) + $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif EV_PATH := $(DEPS_PATH)/libev/libev/ From 7444d03e879a1120b316f1c425358af97642353e Mon Sep 17 00:00:00 2001 From: Yashwant Sahu Date: Mon, 23 Dec 2024 20:38:48 +0530 Subject: [PATCH 2/6] make file changes for test based on pkg-config --- test/Makefile | 29 ++++++++++++--- test/tap/tests/Makefile | 34 ++++++++++++------ test/tap/tests_with_deps/common_defs.Makefile | 34 ++++++++++++------ .../deprecate_eof_support/Makefile | 35 +++++++++++++------ 4 files changed, 94 insertions(+), 38 deletions(-) diff --git a/test/Makefile b/test/Makefile index 7b1ece3d9..1ab2a44a8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -43,13 +43,32 @@ MICROHTTPD_IDIR := $(MICROHTTPD_PATH)/src/include CURL_PATH := $(DEPS_PATH)/curl/curl CURL_IDIR := -I$(CURL_PATH)/include -ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1) +CUSTOM_OPENSSL_PATH ?= -ifneq ($(ssl_header_path),) - SSL_IDIR := $(shell dirname $(ssl_header_path)) - $(info Found OpenSSL headers at $(SSL_IDIR)) +OPENSSL_PACKAGE := openssl + +ifeq ($(DISTRO),almalinux) +ifeq ($(CENTOSVER),8) + OPENSSL_PACKAGE := openssl3 +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.) + SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") +else + SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) +endif + +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) else - $(error Warning: OpenSSL headers not found. exiting, please install openssl.) + $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif EV_PATH := $(DEPS_PATH)/libev/libev/ diff --git a/test/tap/tests/Makefile b/test/tap/tests/Makefile index 0fe51d09e..87b4e3d9f 100644 --- a/test/tap/tests/Makefile +++ b/test/tap/tests/Makefile @@ -62,22 +62,34 @@ LIBINJECTION_DIR := $(DEPS_PATH)/libinjection/libinjection LIBINJECTION_IDIR := $(LIBINJECTION_DIR)/src LIBINJECTION_LDIR := $(LIBINJECTION_DIR)/src -libssl_path := $(shell find /usr /usr/local /opt -name "libssl.so" 2>/dev/null | head -n 1) +CUSTOM_OPENSSL_PATH ?= -ifneq ($(libssl_path),) - SSL_LDIR := $(dir $(libssl_path)) - $(info Found OpenSSL libs at $(SSL_LDIR)) -else - $(error Warning: OpenSSL library not found. exiting, please install openssl.) +OPENSSL_PACKAGE := openssl + +ifeq ($(DISTRO),almalinux) +ifeq ($(CENTOSVER),8) + OPENSSL_PACKAGE := openssl3 +endif endif -ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1) +$(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.) + SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE) ) +else + SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) +endif -ifneq ($(ssl_header_path),) - SSL_IDIR := $(shell dirname $(ssl_header_path)) - $(info Found OpenSSL headers at $(SSL_IDIR)) +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) + $(info SSL_LDIR: $(SSL_LDIR)) else - $(error Warning: OpenSSL headers not found. exiting, please install openssl.) + $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif EV_DIR := $(DEPS_PATH)/libev/libev/ diff --git a/test/tap/tests_with_deps/common_defs.Makefile b/test/tap/tests_with_deps/common_defs.Makefile index 0ad21d3d7..e87cd5214 100644 --- a/test/tap/tests_with_deps/common_defs.Makefile +++ b/test/tap/tests_with_deps/common_defs.Makefile @@ -44,22 +44,34 @@ LIBINJECTION_DIR=$(DEPS_PATH)/libinjection/libinjection LIBINJECTION_IDIR=$(LIBINJECTION_DIR)/src LIBINJECTION_LDIR=$(LIBINJECTION_DIR)/src -libssl_path := $(shell find /usr /usr/local /opt -name "libssl.so" 2>/dev/null | head -n 1) +CUSTOM_OPENSSL_PATH ?= -ifneq ($(libssl_path),) - SSL_LDIR := $(dir $(libssl_path)) - $(info Found OpenSSL libs at $(SSL_LDIR)) -else - $(error Warning: OpenSSL library not found. exiting, please install openssl.) +OPENSSL_PACKAGE := openssl + +ifeq ($(DISTRO),almalinux) +ifeq ($(CENTOSVER),8) + OPENSSL_PACKAGE := openssl3 +endif endif -ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1) +$(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.) + SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE) ) +else + SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) +endif -ifneq ($(ssl_header_path),) - SSL_IDIR := $(shell dirname $(ssl_header_path)) - $(info Found OpenSSL headers at $(SSL_IDIR)) +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) + $(info SSL_LDIR: $(SSL_LDIR)) else - $(error Warning: OpenSSL headers not found. exiting, please install openssl.) + $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif EV_DIR=$(DEPS_PATH)/libev/libev/ diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index aefbeeb8b..b2c0dd280 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -50,24 +50,37 @@ MICROHTTPD_DIR := $(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src MICROHTTPD_IDIR := $(MICROHTTPD_DIR)/include MICROHTTPD_LDIR := $(MICROHTTPD_DIR)/microhttpd/.libs -libssl_path := $(shell find /usr /usr/local /opt -name "libssl.so" 2>/dev/null | head -n 1) +CUSTOM_OPENSSL_PATH ?= -ifneq ($(libssl_path),) - SSL_LDIR := $(dir $(libssl_path)) - $(info Found OpenSSL libs at $(SSL_LDIR)) -else - $(error Warning: OpenSSL library not found. exiting, please install openssl.) +OPENSSL_PACKAGE := openssl + +ifeq ($(DISTRO),almalinux) +ifeq ($(CENTOSVER),8) + OPENSSL_PACKAGE := openssl3 +endif endif -ssl_header_path := $(shell find /usr /usr/local /opt -name "ssl.h" -path "*/openssl/*" 2>/dev/null | head -n 1) +$(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.) + SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE) ) +else + SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) +endif -ifneq ($(ssl_header_path),) - SSL_IDIR := $(shell dirname $(ssl_header_path)) - $(info Found OpenSSL headers at $(SSL_IDIR)) +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) + $(info SSL_LDIR: $(SSL_LDIR)) else - $(error Warning: OpenSSL headers not found. exiting, please install openssl.) + $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif + EV_DIR := $(DEPS_PATH)/libev/libev/ EV_IDIR := $(EV_DIR) EV_LDIR := $(EV_DIR)/.libs From 3af2af904a1c9699e337e575ac4fd6667dad7892 Mon Sep 17 00:00:00 2001 From: Yashwant Sahu Date: Wed, 25 Dec 2024 19:27:57 +0530 Subject: [PATCH 3/6] 1. Fixed pkg-config cflag, as it was failing with older pkg-config. 2. Added a custom path for OpenSSL. Tested with 3.5.0. --- deps/Makefile | 58 ++++++++++++++----- lib/Makefile | 8 ++- src/Makefile | 8 ++- test/Makefile | 2 +- test/tap/tests/Makefile | 10 +++- test/tap/tests_with_deps/common_defs.Makefile | 10 +++- .../deprecate_eof_support/Makefile | 10 +++- 7 files changed, 77 insertions(+), 29 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index b99f8b44c..c1e417280 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -90,13 +90,15 @@ $(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.) - SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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)[^ ]+") 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) else - SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 + 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) $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif @@ -110,18 +112,48 @@ else $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) endif -OPENSSL_VERSION_3 := 3.0.0 +REQUIRED_OPENSSL_VERSION := 3.0.0 +PKG_CONFIG := pkg-config + check_openssl_version: - @if [[ "$(DISTRO)" = "almalinux" && "$(CENTOSVER)" = "8" ]]; then \ - @current_version=$$(openssl3 version | awk '{print $$2}'); \ + @echo "Checking OpenSSL version..." + @if [ -n "$(CUSTOM_OPENSSL_PATH)" ]; then \ + echo "Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)"; \ + 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=$$(grep -oP '# define OPENSSL_VERSION_STR "\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?' $$header_path | tr -d '[:space:]'); \ + 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); \ + echo "Detected OpenSSL version from header: $$major.$$minor.$$patch"; \ + required_major=3; \ + required_minor=0; \ + required_patch=0; \ + if [ $$major -gt $$required_major ] || { [ $$major -eq $$required_major ] && { [ $$minor -gt $$required_minor ] || { [ $$minor -eq $$required_minor ] && [ $$patch -ge $$required_patch ]; }; }; }; then \ + echo "OpenSSL version is valid."; \ + else \ + echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$major.$$minor.$$patch"; \ + exit 1; \ + fi; \ 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 \ - echo "Error: Installed OpenSSL version must be $(OPENSSL_VERSION_3) or higher, Please upgrade OpenSSL."; \ - exit 1; \ + echo "Using pkg-config to detect OpenSSL"; \ + openssl_version=$$(pkg-config --modversion openssl 2>/dev/null); \ + if [ -z "$$openssl_version" ]; then \ + echo "OpenSSL not found via pkg-config."; \ + exit 1; \ + fi; \ + echo "Detected OpenSSL version from pkg-config: $$openssl_version"; \ + if [ "$$(printf '%s\n' "$(REQUIRED_OPENSSL_VERSION)" "$$openssl_version" | sort -V | head -n1)" != "$(REQUIRED_OPENSSL_VERSION)" ]; then \ + echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \ + exit 1; \ + fi; \ fi libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a: libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/libmicrohttpd.a re2/re2/obj/libre2.a diff --git a/lib/Makefile b/lib/Makefile index 580aaa7c8..8fa750413 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -77,13 +77,15 @@ $(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.) - SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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)[^ ]+") 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) else - SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 + 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) $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif diff --git a/src/Makefile b/src/Makefile index 2d2d88042..5b19ad64e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -104,13 +104,15 @@ $(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.) - SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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)[^ ]+") 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) else - SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 + 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) $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif diff --git a/test/Makefile b/test/Makefile index 1ab2a44a8..4b15a5995 100644 --- a/test/Makefile +++ b/test/Makefile @@ -58,7 +58,7 @@ $(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.) - SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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)[^ ]+") else SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) diff --git a/test/tap/tests/Makefile b/test/tap/tests/Makefile index 87b4e3d9f..0c377247a 100644 --- a/test/tap/tests/Makefile +++ b/test/tap/tests/Makefile @@ -76,11 +76,15 @@ $(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.) - SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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)[^ ]+") 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) else - SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 + 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) $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif diff --git a/test/tap/tests_with_deps/common_defs.Makefile b/test/tap/tests_with_deps/common_defs.Makefile index e87cd5214..b2ecd6841 100644 --- a/test/tap/tests_with_deps/common_defs.Makefile +++ b/test/tap/tests_with_deps/common_defs.Makefile @@ -58,11 +58,15 @@ $(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.) - SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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)[^ ]+") 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) else - SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 + 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) $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index b2c0dd280..9670fdf21 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -64,11 +64,15 @@ $(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.) - SSL_IDIR := $(shell pkg-config --cflags --keep-system-cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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)[^ ]+") 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) else - SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := -L$(CUSTOM_OPENSSL_PATH)/lib -lssl -lcrypto + SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 + 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) $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) endif From 004665c6b0c157eb9fa32ff3b6244607297c6f49 Mon Sep 17 00:00:00 2001 From: Yashwant Sahu Date: Thu, 26 Dec 2024 12:51:32 +0530 Subject: [PATCH 4/6] Moved checking of openssl version and finding of openssl library to common place and including common make file. --- common_mk/openssl_flags.mk | 40 +++++++++ common_mk/openssl_version_check.mk | 44 ++++++++++ deps/Makefile | 81 +------------------ lib/Makefile | 37 +-------- src/Makefile | 37 +-------- test/Makefile | 9 +-- test/tap/tests/Makefile | 34 +------- test/tap/tests_with_deps/common_defs.Makefile | 34 +------- .../deprecate_eof_support/Makefile | 35 +------- 9 files changed, 92 insertions(+), 259 deletions(-) create mode 100644 common_mk/openssl_flags.mk create mode 100644 common_mk/openssl_version_check.mk diff --git a/common_mk/openssl_flags.mk b/common_mk/openssl_flags.mk new file mode 100644 index 000000000..eecfb472c --- /dev/null +++ b/common_mk/openssl_flags.mk @@ -0,0 +1,40 @@ +CUSTOM_OPENSSL_PATH ?= + +OPENSSL_PACKAGE := openssl + +ifeq ($(DISTRO),almalinux) +ifeq ($(CENTOSVER),8) + OPENSSL_PACKAGE := openssl3 +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.) + 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)[^ ]+") + 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) +else + SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include + SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 + 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) + $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) +endif + +# Check if required flags are set and provide feedback +ifneq ($(SSL_IDIR),) +ifneq ($(SSL_LDIR),) + $(info SSL_IDIR: $(SSL_IDIR)) + $(info SSL_LDIR: $(SSL_LDIR)) + $(info LIB_SSL_PATH: $(LIB_SSL_PATH)) + $(info LIB_CRYPTO_PATH: $(LIB_CRYPTO_PATH)) +else + $(error Warning: OpenSSL libraries directory (SSL_LDIR) not found. Exiting. Please ensure the correct path is set or install OpenSSL version 3.) +endif +else + $(error Warning: OpenSSL headers (SSL_IDIR) not found. Exiting. Please install OpenSSL version 3.) +endif \ No newline at end of file diff --git a/common_mk/openssl_version_check.mk b/common_mk/openssl_version_check.mk new file mode 100644 index 000000000..fceccbca1 --- /dev/null +++ b/common_mk/openssl_version_check.mk @@ -0,0 +1,44 @@ +REQUIRED_OPENSSL_VERSION := 3.0.0 + +$(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE)) + +check_openssl_version: + @echo "Checking OpenSSL version..." + @if [ -n "$(CUSTOM_OPENSSL_PATH)" ]; then \ + echo "Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)"; \ + 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=$$(grep -oP '# define OPENSSL_VERSION_STR "\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?' $$header_path | tr -d '[:space:]'); \ + 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); \ + echo "Detected OpenSSL version from header: $$major.$$minor.$$patch"; \ + required_major=3; \ + required_minor=0; \ + required_patch=0; \ + if [ $$major -gt $$required_major ] || { [ $$major -eq $$required_major ] && { [ $$minor -gt $$required_minor ] || { [ $$minor -eq $$required_minor ] && [ $$patch -ge $$required_patch ]; }; }; }; then \ + echo "OpenSSL version is valid."; \ + else \ + echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$major.$$minor.$$patch"; \ + exit 1; \ + fi; \ + else \ + echo "Using pkg-config to detect OpenSSL"; \ + 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; \ + echo "Detected OpenSSL version from pkg-config: $$openssl_version"; \ + if [ "$$(printf '%s\n' "$(REQUIRED_OPENSSL_VERSION)" "$$openssl_version" | sort -V | head -n1)" != "$(REQUIRED_OPENSSL_VERSION)" ]; then \ + echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \ + exit 1; \ + fi; \ + fi \ No newline at end of file diff --git a/deps/Makefile b/deps/Makefile index c1e417280..7c8fcc85e 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -76,85 +76,8 @@ endif libinjection: libinjection/libinjection/src/libinjection.a -CUSTOM_OPENSSL_PATH ?= - -OPENSSL_PACKAGE := openssl - -ifeq ($(DISTRO),almalinux) -ifeq ($(CENTOSVER),8) - OPENSSL_PACKAGE := openssl3 -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.) - 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)[^ ]+") - 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) -else - SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 - 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) - $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) -endif - -# Check if required flags are set and provide feedback -ifneq ($(SSL_IDIR),) - $(info SSL_IDIR: $(SSL_IDIR)) - $(info SSL_LDIR: $(SSL_LDIR)) - $(info LIB_SSL_PATH: $(LIB_SSL_PATH)) - $(info LIB_CRYPTO_PATH: $(LIB_CRYPTO_PATH)) -else - $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) -endif - -REQUIRED_OPENSSL_VERSION := 3.0.0 -PKG_CONFIG := pkg-config - -check_openssl_version: - @echo "Checking OpenSSL version..." - @if [ -n "$(CUSTOM_OPENSSL_PATH)" ]; then \ - echo "Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)"; \ - 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=$$(grep -oP '# define OPENSSL_VERSION_STR "\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?' $$header_path | tr -d '[:space:]'); \ - 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); \ - echo "Detected OpenSSL version from header: $$major.$$minor.$$patch"; \ - required_major=3; \ - required_minor=0; \ - required_patch=0; \ - if [ $$major -gt $$required_major ] || { [ $$major -eq $$required_major ] && { [ $$minor -gt $$required_minor ] || { [ $$minor -eq $$required_minor ] && [ $$patch -ge $$required_patch ]; }; }; }; then \ - echo "OpenSSL version is valid."; \ - else \ - echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$major.$$minor.$$patch"; \ - exit 1; \ - fi; \ - else \ - echo "Using pkg-config to detect OpenSSL"; \ - openssl_version=$$(pkg-config --modversion openssl 2>/dev/null); \ - if [ -z "$$openssl_version" ]; then \ - echo "OpenSSL not found via pkg-config."; \ - exit 1; \ - fi; \ - echo "Detected OpenSSL version from pkg-config: $$openssl_version"; \ - if [ "$$(printf '%s\n' "$(REQUIRED_OPENSSL_VERSION)" "$$openssl_version" | sort -V | head -n1)" != "$(REQUIRED_OPENSSL_VERSION)" ]; then \ - echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \ - exit 1; \ - fi; \ - fi +include ../common_mk/openssl_flags.mk +include ../common_mk/openssl_version_check.mk libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a: libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/libmicrohttpd.a re2/re2/obj/libre2.a cd libhttpserver && rm -rf libhttpserver-*/ || true diff --git a/lib/Makefile b/lib/Makefile index 8fa750413..82f385e0c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -62,42 +62,7 @@ COREDUMPER_IDIR := $(COREDUMPER_DIR)/include CURL_DIR := $(DEPS_PATH)/curl/curl CURL_IDIR := $(CURL_DIR)/include -CUSTOM_OPENSSL_PATH ?= - -OPENSSL_PACKAGE := openssl - -ifeq ($(DISTRO),almalinux) -ifeq ($(CENTOSVER),8) - OPENSSL_PACKAGE := openssl3 -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.) - 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)[^ ]+") - 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) -else - SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 - 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) - $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) -endif - -# Check if required flags are set and provide feedback -ifneq ($(SSL_IDIR),) - $(info SSL_IDIR: $(SSL_IDIR)) - $(info SSL_LDIR: $(SSL_LDIR)) - $(info LIB_SSL_PATH: $(LIB_SSL_PATH)) - $(info LIB_CRYPTO_PATH: $(LIB_CRYPTO_PATH)) -else - $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) -endif +include ../common_mk/openssl_flags.mk EV_DIR := $(DEPS_PATH)/libev/libev/ EV_IDIR := $(EV_DIR) diff --git a/src/Makefile b/src/Makefile index 5b19ad64e..53d0d9b00 100644 --- a/src/Makefile +++ b/src/Makefile @@ -89,42 +89,7 @@ CURL_PATH := $(DEPS_PATH)/curl/curl CURL_IDIR := $(CURL_PATH)/include CURL_LDIR := $(CURL_PATH)/lib/.libs -CUSTOM_OPENSSL_PATH ?= - -OPENSSL_PACKAGE := openssl - -ifeq ($(DISTRO),almalinux) -ifeq ($(CENTOSVER),8) - OPENSSL_PACKAGE := openssl3 -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.) - 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)[^ ]+") - 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) -else - SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 - 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) - $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) -endif - -# Check if required flags are set and provide feedback -ifneq ($(SSL_IDIR),) - $(info SSL_IDIR: $(SSL_IDIR)) - $(info SSL_LDIR: $(SSL_LDIR)) - $(info LIB_SSL_PATH: $(LIB_SSL_PATH)) - $(info LIB_CRYPTO_PATH: $(LIB_CRYPTO_PATH)) -else - $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) -endif +include ../common_mk/openssl_flags.mk EV_PATH := $(DEPS_PATH)/libev/libev/ EV_IDIR := $(EV_PATH) diff --git a/test/Makefile b/test/Makefile index 4b15a5995..fada4a6c0 100644 --- a/test/Makefile +++ b/test/Makefile @@ -55,14 +55,7 @@ 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.) - 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)[^ ]+") -else - SSL_IDIR := -I$(CUSTOM_OPENSSL_PATH)/include - $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) -endif +include ../common_mk/openssl_flags.mk # Check if required flags are set and provide feedback ifneq ($(SSL_IDIR),) diff --git a/test/tap/tests/Makefile b/test/tap/tests/Makefile index 0c377247a..b351d229b 100644 --- a/test/tap/tests/Makefile +++ b/test/tap/tests/Makefile @@ -62,39 +62,7 @@ LIBINJECTION_DIR := $(DEPS_PATH)/libinjection/libinjection LIBINJECTION_IDIR := $(LIBINJECTION_DIR)/src LIBINJECTION_LDIR := $(LIBINJECTION_DIR)/src -CUSTOM_OPENSSL_PATH ?= - -OPENSSL_PACKAGE := openssl - -ifeq ($(DISTRO),almalinux) -ifeq ($(CENTOSVER),8) - OPENSSL_PACKAGE := openssl3 -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.) - 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)[^ ]+") - 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) -else - SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 - 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) - $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) -endif - -# Check if required flags are set and provide feedback -ifneq ($(SSL_IDIR),) - $(info SSL_IDIR: $(SSL_IDIR)) - $(info SSL_LDIR: $(SSL_LDIR)) -else - $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) -endif +include ../../../common_mk/openssl_flags.mk EV_DIR := $(DEPS_PATH)/libev/libev/ EV_IDIR := $(EV_DIR) diff --git a/test/tap/tests_with_deps/common_defs.Makefile b/test/tap/tests_with_deps/common_defs.Makefile index b2ecd6841..937bebd19 100644 --- a/test/tap/tests_with_deps/common_defs.Makefile +++ b/test/tap/tests_with_deps/common_defs.Makefile @@ -44,39 +44,7 @@ LIBINJECTION_DIR=$(DEPS_PATH)/libinjection/libinjection LIBINJECTION_IDIR=$(LIBINJECTION_DIR)/src LIBINJECTION_LDIR=$(LIBINJECTION_DIR)/src -CUSTOM_OPENSSL_PATH ?= - -OPENSSL_PACKAGE := openssl - -ifeq ($(DISTRO),almalinux) -ifeq ($(CENTOSVER),8) - OPENSSL_PACKAGE := openssl3 -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.) - 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)[^ ]+") - 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) -else - SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 - 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) - $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) -endif - -# Check if required flags are set and provide feedback -ifneq ($(SSL_IDIR),) - $(info SSL_IDIR: $(SSL_IDIR)) - $(info SSL_LDIR: $(SSL_LDIR)) -else - $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) -endif +include ../../../common_mk/openssl_flags.mk EV_DIR=$(DEPS_PATH)/libev/libev/ EV_IDIR=$(EV_DIR) diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index 9670fdf21..672bcef56 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -50,40 +50,7 @@ MICROHTTPD_DIR := $(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src MICROHTTPD_IDIR := $(MICROHTTPD_DIR)/include MICROHTTPD_LDIR := $(MICROHTTPD_DIR)/microhttpd/.libs -CUSTOM_OPENSSL_PATH ?= - -OPENSSL_PACKAGE := openssl - -ifeq ($(DISTRO),almalinux) -ifeq ($(CENTOSVER),8) - OPENSSL_PACKAGE := openssl3 -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.) - 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)[^ ]+") - 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) -else - SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include - SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 - 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) - $(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)) -endif - -# Check if required flags are set and provide feedback -ifneq ($(SSL_IDIR),) - $(info SSL_IDIR: $(SSL_IDIR)) - $(info SSL_LDIR: $(SSL_LDIR)) -else - $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) -endif - +include ../../../../common_mk/openssl_flags.mk EV_DIR := $(DEPS_PATH)/libev/libev/ EV_IDIR := $(EV_DIR) From 62ee5a59ac3a3dd42d08c9a105b9433c33db8ec7 Mon Sep 17 00:00:00 2001 From: Yashwant Sahu Date: Thu, 26 Dec 2024 20:41:18 +0530 Subject: [PATCH 5/6] Alma Linux 8 special handling in make file --- common_mk/openssl_flags.mk | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common_mk/openssl_flags.mk b/common_mk/openssl_flags.mk index eecfb472c..4b709e7aa 100644 --- a/common_mk/openssl_flags.mk +++ b/common_mk/openssl_flags.mk @@ -13,10 +13,17 @@ $(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.) - 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)[^ ]+") - 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 ($(OPENSSL_PACKAGE),openssl3) + SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + 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 + 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)[^ ]+") + 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) + endif else SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64 From eb98af9b13bed2bce4b56276a88d239eceeebd8f Mon Sep 17 00:00:00 2001 From: Yashwant Sahu Date: Fri, 27 Dec 2024 14:13:17 +0530 Subject: [PATCH 6/6] Small cleanup --- test/Makefile | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/test/Makefile b/test/Makefile index fada4a6c0..7239c1761 100644 --- a/test/Makefile +++ b/test/Makefile @@ -43,27 +43,8 @@ MICROHTTPD_IDIR := $(MICROHTTPD_PATH)/src/include CURL_PATH := $(DEPS_PATH)/curl/curl CURL_IDIR := -I$(CURL_PATH)/include -CUSTOM_OPENSSL_PATH ?= - -OPENSSL_PACKAGE := openssl - -ifeq ($(DISTRO),almalinux) -ifeq ($(CENTOSVER),8) - OPENSSL_PACKAGE := openssl3 -endif -endif - -$(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE)) - include ../common_mk/openssl_flags.mk -# Check if required flags are set and provide feedback -ifneq ($(SSL_IDIR),) - $(info SSL_IDIR: $(SSL_IDIR)) -else - $(error Warning: OpenSSL headers not found. Exiting. Please install OpenSSL version 3.) -endif - EV_PATH := $(DEPS_PATH)/libev/libev/ EV_IDIR := $(EV_PATH)