Skip to content

Commit

Permalink
1. Fixed pkg-config cflag, as it was failing with older pkg-config.
Browse files Browse the repository at this point in the history
2. Added a custom path for OpenSSL. Tested with 3.5.0.
  • Loading branch information
yashwantsahu20 committed Dec 25, 2024
1 parent 7444d03 commit 3af2af9
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 29 deletions.
58 changes: 45 additions & 13 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 7 additions & 3 deletions test/tap/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions test/tap/tests_with_deps/common_defs.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions test/tap/tests_with_deps/deprecate_eof_support/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3af2af9

Please sign in to comment.