Skip to content

Commit

Permalink
fixup! Makefile_{v1,src},OpenSSL_version.{mk,c},README.md: major upda…
Browse files Browse the repository at this point in the history
…te with improved diagnostics
  • Loading branch information
DDvO committed Oct 19, 2024
1 parent 387ce7b commit 9fa7ebd
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 141 deletions.
59 changes: 30 additions & 29 deletions Makefile_src
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/make
# Optional LPATH defines where to find any pre-installed libsecutils and UTA libraries, e.g., /usr/lib
# Optional OPENSSL_DIR defines where to find the OpenSSL installation, defaulting to LPATH/.. if set, else ROOTFS/usr
# Optional OPENSSL_LIB defines where to find the OpenSSL library installation (default: ROOTFS/usr/lib or ".").
# Optional OPENSSL_LIB defines where to find the OpenSSL library installation (default: OPENSSL_DIR/lib or OPENSSL_DIR).
# Optional OUT_DIR defines where libgencmp shall be placed, defaulting to LPATH if set, else '.'
# BIN_DIR defines where the CLI application shall be placed, unless it is empty or unset.
# Optional LIBCMP_INC defines the directory of the libcmp header files, must be non-empty if and only if libcmp is used (USE_LIBCMP).
# All these paths may be absolute or relative to the dir containing this Makefile.
# All paths may be absolute or relative to the directory containing this Makefile.
# With USE_LIBCMP, setting STATIC_LIBCMP leads to static linking with libcmp.a .
# Optional DEBUG_FLAGS may set to prepend to local CFLAGS and LDFLAGS (default see below).
# OSSL_VERSION_QUIRKS maybe be needed to provide for setting OpenSSL compilation version quirks.
Expand Down Expand Up @@ -49,7 +49,7 @@ ifeq ($(LPATH),)
ifeq ($(OUT_DIR),)
override OUT_DIR = .
endif
OPENSSL_DIR ?= $(ROOTFS)/usr
override OPENSSL_DIR ?= $(ROOTFS)/usr
LIBCMP_DIR_=cmpossl
LIBCMP_DIR=$(PREFIX)$(LIBCMP_DIR_)
SECUTILS_DIR_=libsecutils
Expand All @@ -58,23 +58,19 @@ else
ifeq ($(OUT_DIR),)
override OUT_DIR = $(LPATH)
endif
OPENSSL_DIR ?= $(LPATH)/..
override OPENSSL_DIR ?= $(LPATH)/..
SECUTILS_LIB=$(PREFIX)$(LPATH)/libsecutils$(DLL)
endif

ifeq ($(shell echo $(OPENSSL_DIR) | grep "^/"),)
# $(OPENSSL_DIR) is relative path
PREFIX_OPENSSL_DIR=$(PREFIX)$(OPENSSL_DIR)
ifeq ($(OPENSSL_LIB),)
override OPENSSL_LIB = $(PREFIX_OPENSSL_DIR)
endif
override OPENSSL_LIB ?= $(PREFIX_OPENSSL_DIR)
# OPENSSL_RPATH=$(OPENSSL_DIR)
# OPENSSL_RPATH_LIB=$(OPENSSL_DIR)
else # $(OPENSSL_DIR) is absolute path
PREFIX_OPENSSL_DIR=$(OPENSSL_DIR)
ifeq ($(OPENSSL_LIB),)
override OPENSSL_LIB = $(PREFIX_OPENSSL_DIR)/$(LIB)
endif
override OPENSSL_LIB ?= $(PREFIX_OPENSSL_DIR)/$(LIB)
# OPENSSL_RPATH=$(PREFIX_OPENSSL_DIR)
# OPENSSL_RPATH_LIB=$(OPENSSL_LIB)
endif
Expand All @@ -84,10 +80,10 @@ OPENSSL_DLLS = *{crypto,ssl}*.dll

CC ?= gcc
ifdef NDEBUG
DEBUG_FLAGS ?= -O2
override DEBUG_FLAGS ?= -O2
override DEBUG_FLAGS += -DNDEBUG=1 -Werror
else
DEBUG_FLAGS ?= -g -O0 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all # not every compiler(version) supports -Og
override DEBUG_FLAGS ?= -g -O0 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all # not every compiler(version) supports -Og
endif
override CFLAGS += $(DEBUG_FLAGS) -fstack-protector -fno-omit-frame-pointer
# override CFLAGS += -std=gnu90 # TODO maybe clean up code and re-enable flag
Expand Down Expand Up @@ -144,27 +140,32 @@ ifeq ($(LPATH),)
# ifeq ($(PREFIX),)
# TODO maybe better use absolute path here, as done by CMake
override LDFLAGS += -Wl,-rpath,$(OUT_DIR) -Wl,-rpath,$(SECUTILS_DIR)
ifndef NDEBUG
override LDFLAGS += -Wl,-rpath,$(OUT_DIR)/../../../.. -Wl,-rpath,$(OUT_DIR)/../../../../$(SECUTILS_DIR) # for CLI-based tests
endif
ifneq ($(LIBCMP_INC),)
override LDFLAGS += -Wl,-rpath,$(LIBCMP_DIR)
ifndef NDEBUG
override LDFLAGS += -Wl,-rpath,$(OUT_DIR)/../../../../$(LIBCMP_DIR) # for CLI-based tests
endif
ifndef NDEBUG # for CLI-based tests
override LDFLAGS += -Wl,-rpath,$(OUT_DIR)/../../../..
# not needed due to OUT_DIR set also for libsecutils:
# override LDFLAGS += -Wl,-rpath,$(OUT_DIR)/../../../../$(SECUTILS_DIR)
endif
# not needed due to OUT_DIR set also for cmpossl:
# ifneq ($(LIBCMP_INC),)
# override LDFLAGS += -Wl,-rpath,$(LIBCMP_DIR)
# ifndef NDEBUG
# override LDFLAGS += -Wl,-rpath,$(OUT_DIR)/../../../../$(LIBCMP_DIR) # for CLI-based tests
# endif
# endif
# endif
endif
override LDFLAGS += -L $(SECUTILS_DIR)
ifneq ($(LIBCMP_INC),)
override LDFLAGS += -L $(LIBCMP_DIR)
endif
# not needed due to OUT_DIR set also for libsecutils and cmpossl:
# override LDFLAGS += -L $(SECUTILS_DIR)
# ifneq ($(LIBCMP_INC),)
# override LDFLAGS += -L $(LIBCMP_DIR)
# endif
ifeq ($(DEB_TARGET_ARCH),) # not during Debian packaging
ifneq ($(PREFIX),)
override LDFLAGS += -Wl,-rpath,$(SECUTILS_DIR_)
ifneq ($(LIBCMP_INC),)
override LDFLAGS += -Wl,-rpath,$(LIBCMP_DIR_)
endif
# not needed due to OUT_DIR set also for libsecutils and cmpossl:
# override LDFLAGS += -Wl,-rpath,$(SECUTILS_DIR_)
# ifneq ($(LIBCMP_INC),)
# override LDFLAGS += -Wl,-rpath,$(LIBCMP_DIR_)
# endif
endif
endif
override LDFLAGS += -L $(OPENSSL_LIB)# -L $(PREFIX_OPENSSL_DIR)
Expand All @@ -179,7 +180,7 @@ else
override LDFLAGS += -L $(LPATH)
endif

OUTLIB_ ?= libgencmp
override OUTLIB_= libgencmp
OUTLIB=$(OUTLIB_)$(DLL)
ifeq ($(OS),MacOS)
OUTLIBV=$(OUTLIB_).$(VERSION)$(DLL)
Expand Down
Loading

0 comments on commit 9fa7ebd

Please sign in to comment.