[PATCH ipmi-fru-parser 3/3] Add shared library versioning

OpenBMC Patches openbmc-patches at stwcx.xyz
Tue Jun 14 05:40:15 AEST 2016


From: Brad Bishop <bradleyb at us.ibm.com>

Use -soname and install a library symlink.

Signed-off-by: Brad Bishop <bradleyb at fuzziesquirrel.com>
---
 Makefile | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 958ac16..937b393 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,9 @@
 LIBS += libwritefrudata.so
 HOST_LIBS += libstrgfnhandler.so
 libwritefrudata.so_OBJS  += frup.o writefrudata.o
+libwritefrudata.so_VERSION = 1
 libstrgfnhandler.so_OBJS += strgfnhandler.o
+libstrgfnhandler.so_VERSION = 1
 
 EXES += phosphor-read-eeprom
 
@@ -38,7 +40,8 @@ $(foreach exe,$(EXES),$(eval $(call __BUILD_EXE,$(exe))))
 
 define __BUILD_LIB
 $1 : $$($1_OBJS) | $$(addsuffix .so,$$(addprefix lib,$$($1_EXTRA_LIBS)))
-		$$(LINK.cpp) -fPIC -shared -o $$@ $$^ $(call __EXTRA_LIB_RESOLV,$(addprefix -l,$($1_EXTRA_LIBS))) -L. $(call __PKG_CONFIG,$($1_NEEDED),--libs)
+		$$(LINK.cpp) -fPIC -shared -Wl,-soname,$$@ -o $$(addsuffix .$($1_VERSION), $$@) $$^ $(call __EXTRA_LIB_RESOLV,$(addprefix -l,$($1_EXTRA_LIBS))) -L. $(call __PKG_CONFIG,$($1_NEEDED),--libs)
+		ln -sf $$(addsuffix .$($1_VERSION), $$@) $1
 
 $(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags))
 
@@ -51,8 +54,8 @@ $(foreach lib,$(HOST_LIBS),$(eval $(call __BUILD_LIB,$(lib))))
 .PHONY: clean
 clean:
 		$(RM) $(foreach exe,$(EXES),$(exe) $($(exe)_OBJS)) \
-			  $(foreach lib,$(LIBS),$(lib) $($(lib)_OBJS)) \
-			  $(foreach lib,$(HOST_LIBS),$(lib) $($(lib)_OBJS))
+			  $(foreach lib,$(LIBS),$(addsuffix .$($(lib)_VERSION), $(lib)) $(lib) $($(lib)_OBJS)) \
+			  $(foreach lib,$(HOST_LIBS),$(addsuffix .$($(lib)_VERSION), $(lib)) $(lib) $($(lib)_OBJS))
 
 DESTDIR ?= /
 BINDIR ?= /usr/bin
@@ -66,8 +69,10 @@ install:
 		)
 		$(if $(LIBS),\
 		install -m 0755 -d $(DESTDIR)$(LIBDIR)/host-ipmid && \
-		install -m 0755 $(HOST_LIBS) $(DESTDIR)$(LIBDIR)/host-ipmid && \
-		install -m 0755 $(LIBS) $(DESTDIR)$(LIBDIR) \
+		install -m 0755 $(foreach lib,$(HOST_LIBS),$(addsuffix .$($(lib)_VERSION), $(lib))) $(DESTDIR)$(LIBDIR)/host-ipmid && \
+		install -m 0755 $(foreach lib,$(LIBS),$(addsuffix .$($(lib)_VERSION), $(lib))) $(DESTDIR)$(LIBDIR) \
+		$(foreach lib,$(HOST_LIBS), && ln -sf $(addsuffix .$($(lib)_VERSION), $(lib)) $(DESTDIR)$(LIBDIR)/host-ipmid/$(lib)) \
+		$(foreach lib,$(LIBS), && ln -sf $(addsuffix .$($(lib)_VERSION), $(lib)) $(DESTDIR)$(LIBDIR)/$(lib)) \
 		)
 
 .DEFAULT_GOAL: all
-- 
2.8.4




More information about the openbmc mailing list