shared_lib: Update shared lib build and install
Updates build and install of shared lib to conform with standard naming conventions for shared libraries, including the setting of the lib's soname. Change-Id: Ib46d298ab5f77fd8c32b7c04022b546446189428 Signed-off-by: Lance Hartmann <lance.hartmann@oracle.com> Reviewed-on: https://review.gerrithub.io/421936 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
aec9c3cded
commit
3f6f569854
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@
|
||||
*.o
|
||||
*.pyc
|
||||
*.so
|
||||
*.so.*
|
||||
*.swp
|
||||
*.DS_Store
|
||||
ut_coverage/
|
||||
|
@ -227,6 +227,25 @@ LINK_CXX=\
|
||||
$(Q)echo " LINK $S/$@"; \
|
||||
$(CXX) -o $@ $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) $(SYS_LIBS)
|
||||
|
||||
#
|
||||
# Variables to use for versioning shared libs
|
||||
#
|
||||
SO_VER := 1
|
||||
SO_MINOR := 0
|
||||
SO_SUFFIX_ALL := $(SO_VER).$(SO_MINOR)
|
||||
|
||||
# Provide function to ease build of a shared lib
|
||||
define spdk_build_realname_shared_lib
|
||||
$(CC) -o $@ -shared $(CPPFLAGS) $(LDFLAGS) \
|
||||
-Wl,--soname,$(patsubst %.so.$(SO_SUFFIX_ALL),%.so.$(SO_VER),$(notdir $@)) \
|
||||
-Wl,--whole-archive $(1) -Wl,--no-whole-archive \
|
||||
-Wl,--version-script=$(2) \
|
||||
$(3)
|
||||
endef
|
||||
|
||||
BUILD_LINKERNAME_LIB=\
|
||||
ln -sf $(notdir $<) $@
|
||||
|
||||
# Archive $(OBJS) into $@ (.a)
|
||||
LIB_C=\
|
||||
$(Q)echo " LIB $(notdir $@)"; \
|
||||
@ -243,11 +262,27 @@ INSTALL_LIB=\
|
||||
install -d -m 755 "$(DESTDIR)$(libdir)"; \
|
||||
install -m 644 "$(LIB)" "$(DESTDIR)$(libdir)/"
|
||||
|
||||
# Install a shared library
|
||||
INSTALL_SHARED_LIB=\
|
||||
$(Q)echo " INSTALL $(DESTDIR)$(libdir)/$(notdir $(SHARED_LIB))"; \
|
||||
install -d -m 755 "$(DESTDIR)$(libdir)"; \
|
||||
install -m 644 "$(SHARED_LIB)" "$(DESTDIR)$(libdir)/"
|
||||
ifeq ($(OS),FreeBSD)
|
||||
INSTALL_REL_SYMLINK := install -l rs
|
||||
else
|
||||
INSTALL_REL_SYMLINK := ln -sf -r
|
||||
endif
|
||||
|
||||
define spdk_install_lib_symlink
|
||||
$(INSTALL_REL_SYMLINK) $(DESTDIR)$(libdir)/$(1).$(SO_SUFFIX_ALL) $(DESTDIR)$(libdir)/$(1)
|
||||
endef
|
||||
|
||||
# Install shared library(s)
|
||||
define spdk_install_shared_libs
|
||||
$(Q)echo " INSTALL $(DESTDIR)$(libdir)/$(notdir $(1))"
|
||||
install -d -m 755 $(DESTDIR)$(libdir)
|
||||
@for l in $(1); do \
|
||||
bln=$${l##*/}; \
|
||||
rn=$$l.$(SO_SUFFIX_ALL); \
|
||||
install -m 755 $$rn $(DESTDIR)$(libdir)/; \
|
||||
$(call spdk_install_lib_symlink,$$bln); \
|
||||
done
|
||||
endef
|
||||
|
||||
# Install an app binary
|
||||
INSTALL_APP=\
|
||||
|
@ -37,7 +37,8 @@ include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
|
||||
|
||||
# Build combined libspdk.so shared library
|
||||
SHARED_LIB = $(SPDK_ROOT_DIR)/build/lib/libspdk.so
|
||||
COMBINED_LINKERNAME_LIB = $(SPDK_ROOT_DIR)/build/lib/libspdk.so
|
||||
COMBINED_SHARED_LIB = $(COMBINED_LINKERNAME_LIB).$(SO_SUFFIX_ALL)
|
||||
|
||||
SPDK_LIB_LIST += app_rpc
|
||||
SPDK_LIB_LIST += bdev
|
||||
@ -85,24 +86,22 @@ LIBS += $(ENV_LINKER_ARGS)
|
||||
|
||||
comma := ,
|
||||
|
||||
$(SHARED_LIB): $(SPDK_LIB_FILES) $(SPDK_WHOLE_LIBS) $(BLOCKDEV_MODULES_FILES) $(COPY_MODULES_FILES) $(SOCK_MODULES_FILES) $(LINKER_MODULES) $(ENV_LIBS) $(MAKEFILE_LIST) spdk.map
|
||||
$(COMBINED_SHARED_LIB): $(SPDK_LIB_FILES) $(SPDK_WHOLE_LIBS) $(BLOCKDEV_MODULES_FILES) $(COPY_MODULES_FILES) $(SOCK_MODULES_FILES) $(LINKER_MODULES) $(ENV_LIBS) $(MAKEFILE_LIST) spdk.map
|
||||
$(Q)echo " SO $(notdir $@)"; \
|
||||
rm -f $@; \
|
||||
$(CC) -o $@ -shared $(CPPFLAGS) $(LDFLAGS) \
|
||||
-Wl,--whole-archive \
|
||||
$(filter-out -Wl$(comma)--no-whole-archive,$(LIBS)) \
|
||||
-Wl,--no-whole-archive \
|
||||
-Wl,--version-script=spdk.map \
|
||||
$(SYS_LIBS)
|
||||
$(call spdk_build_realname_shared_lib,$(filter-out -Wl$(comma)--no-whole-archive,$(LIBS)),spdk.map,$(SYS_LIBS))
|
||||
|
||||
$(COMBINED_LINKERNAME_LIB) : %.so : %.so.$(SO_SUFFIX_ALL)
|
||||
$(BUILD_LINKERNAME_LIB)
|
||||
|
||||
.PHONY: all clean $(DIRS-y)
|
||||
|
||||
all: $(SHARED_LIB)
|
||||
all: $(COMBINED_SHARED_LIB) $(COMBINED_LINKERNAME_LIB)
|
||||
|
||||
clean:
|
||||
$(CLEAN_C) $(SHARED_LIB)
|
||||
$(CLEAN_C) $(COMBINED_SHARED_LIB) $(COMBINED_LINKERNAME_LIB)
|
||||
|
||||
install:
|
||||
$(INSTALL_SHARED_LIB)
|
||||
$(call spdk_install_shared_libs, $(COMBINED_LINKERNAME_LIB))
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk
|
||||
|
Loading…
Reference in New Issue
Block a user