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..
This commit is contained in:
Mark Pizzolato 2021-10-24 18:41:08 -07:00
parent d0c7276dd7
commit db401a4dbe

View file

@ -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)) </dev/null
@ -378,7 +378,8 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
LIBPATH := $(sort $(foreach lib,$(shell /sbin/ldconfig -p | grep ' => /' | 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