build: replace grep -oP with sed -E for macOS compatibility

The -P flag (Perl regex) is not available on macOS by default.
Replaced with sed -E which is POSIX-compliant and universally
available on both Linux and macOS.

- Makefile: CURVER extraction and validation now use sed -nE and grep -cE
- openssl_flags.mk: Removed Darwin-specific branching, using unified
  sed -E + awk approach for all platforms
pull/5351/head
René Cannaò 2 months ago
parent 8655f398e1
commit acdd4c91b1

@ -25,10 +25,10 @@ endif
export GIT_VERSION
# Extract CURVER from GIT_VERSION (first 3 numbers, e.g., 3.0.6 from 3.0.6-388-ga94b7d6)
CURVER := $(shell echo "$(GIT_VERSION)" | grep -oP '^\d+\.\d+\.\d+' | head -1)
CURVER := $(shell echo "$(GIT_VERSION)" | sed -nE 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' | head -1)
# Validate CURVER has 3 numbers separated by dots
CURVER_CHECK := $(shell echo "$(CURVER)" | grep -cP '^\d+\.\d+\.\d+$$')
CURVER_CHECK := $(shell echo "$(CURVER)" | grep -cE '^[0-9]+\.[0-9]+\.[0-9]+$$')
ifeq ($(CURVER_CHECK),0)
$(error CURVER "$(CURVER)" derived from GIT_VERSION "$(GIT_VERSION)" does not have 3 numbers separated by dots (expected format: X.Y.Z)

@ -20,20 +20,12 @@ endif
ifeq ($(CUSTOM_OPENSSL_PATH),)
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))
ifeq ($(UNAME_S),Darwin)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.dylib" 2>/dev/null | head -n 1)

Loading…
Cancel
Save