From 3b75db28673b16766dce16081598e681b40b341b Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 12 Mar 2019 12:47:49 +0000 Subject: [PATCH] defs-cpp.mk: Some improvements for LIBTYPE=static Still doesn't compile valdi statically against regular glibc Signed-off-by: Jan Lindemann --- make/defs-cpp.mk | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/make/defs-cpp.mk b/make/defs-cpp.mk index 2565c77d..b8509bb3 100644 --- a/make/defs-cpp.mk +++ b/make/defs-cpp.mk @@ -100,7 +100,12 @@ ifneq ($(TARGET_TRIPLET),$(HOST_TRIPLET)) # we're cross-compiling else # we're not cross-compiling TC_SYS_ROOT ?= /usr - LIBFLAGS += -ldl -lpthread + ifeq ($(LIBTYPE),shared) + LIBFLAGS += -ldl + else + LIBFLAGS += -l:libdl.a + endif + LIBFLAGS += -pthread endif @@ -257,12 +262,6 @@ ifeq ($(TARGET),mingw) BUILD_LDFLAGS += -fstack-protector endif -ifeq ($(LIBTYPE),shared) - ifneq ($(TARGET),mingw) - BUILD_LDFLAGS += -rdynamic - endif -endif - # TODO: this shoud be only conditional, but breaks, because not all headers # do a conditional include of timer headers, yet GENERATE_FUNC_TIMERS = $(MODDIR)/YStopWatchThreadList/generate_func_timers.sh @@ -451,7 +450,9 @@ endif ifeq ($(USE_EXCEPTIONS_IN_C),true) BUILD_CFLAGS += -fexceptions - GCC_LDFLAGS += -shared-libgcc + ifeq ($(LIBTYPE),shared) + GCC_LDFLAGS += -shared-libgcc + endif endif ifeq ($(STRIP_SYMBOLS),true) @@ -533,9 +534,18 @@ ifeq ($(TARGET),mingw) endif endif -LIBTYPE ?= shared INSTALL_LIBDIR ?= $(EXE_PREFIX)/lib +LIBTYPE ?= shared +ifeq ($(LIBTYPE),shared) + ifneq ($(TARGET),mingw) + BUILD_LDFLAGS += -rdynamic + endif +else + LIB_SO ?= + BUILD_LDFLAGS += -static +endif + ifeq ($(USE_PROJECT_LIB),true) LIBNAME ?= $(PROJECT) MEMBERS += $(LIB_A)($(OBJ))