From db401a4dbe0c559c0a3ef0ca8070392322ad2189 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 24 Oct 2021 18:41:08 -0700 Subject: [PATCH] makefile: Support both .so and .a link libraries on Linux For some strange reason, Ubuntu 21.10 delivers various libraries as either direct link libraries (".a") or shared objects (".so") where historically essentially everything was shared objects.. --- makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/makefile b/makefile index fa48c560..047990c3 100644 --- a/makefile +++ b/makefile @@ -178,7 +178,7 @@ ifneq ($(findstring Windows,${OS}),) endif find_exe = $(abspath $(strip $(firstword $(foreach dir,$(strip $(subst :, ,${PATH})),$(wildcard $(dir)/$(1)))))) -find_lib = $(abspath $(strip $(firstword $(foreach dir,$(strip ${LIBPATH}),$(wildcard $(dir)/lib$(1).${LIBEXT}))))) +find_lib = $(firstword $(abspath $(strip $(firstword $(foreach dir,$(strip ${LIBPATH}),$(foreach ext,$(strip ${LIBEXT}),$(wildcard $(dir)/lib$(1).$(ext)))))))) find_include = $(abspath $(strip $(firstword $(foreach dir,$(strip ${INCPATH}),$(wildcard $(dir)/$(1).h))))) ifneq (0,$(TESTS)) find_test = RegisterSanityCheck $(abspath $(wildcard $(1)/tests/$(2)_test.ini)) /' | sed 's/^.* => //'),$(dir $(lib)))) endif endif - LIBEXT = so + LIBSOEXT = so + LIBEXT = $(LIBSOEXT) a else ifeq (SunOS,$(OSTYPE)) OSNAME = Solaris @@ -482,6 +483,9 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) endif endif endif + ifeq (,$(LIBSOEXT)) + LIBSOEXT = $(LIBEXT) + endif ifeq (,$(filter /lib/,$(LIBPATH))) ifeq (existlib,$(shell if $(TEST) -d /lib/; then echo existlib; fi)) LIBPATH += /lib/ @@ -573,7 +577,7 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) endif ifneq (,$(call find_include,dlfcn)) ifneq (,$(call find_lib,dl)) - OS_CCDEFS += -DHAVE_DLOPEN=${LIBEXT} + OS_CCDEFS += -DHAVE_DLOPEN=$(LIBSOEXT) OS_LDFLAGS += -ldl $(info using libdl: $(call find_lib,dl) $(call find_include,dlfcn)) else @@ -582,7 +586,7 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) $(info using libdl: $(call find_include,dlfcn)) else ifneq (,$(call find_lib,dld)) - OS_CCDEFS += -DHAVE_DLOPEN=${LIBEXT} + OS_CCDEFS += -DHAVE_DLOPEN=$(LIBSOEXT) OS_LDFLAGS += -ldld $(info using libdld: $(call find_lib,dld) $(call find_include,dlfcn)) else