Merge pull request #20 from bradbishop/version
Add shared library versioning
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..85c8dc9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*.o
+*.sw*
+*.so
+*.so.*
+phosphor-read-eeprom
diff --git a/Makefile b/Makefile
index dc66a77..937b393 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,9 @@
-LIBS += libwritefrudata.so
-HOST_LIBS += libstrgfnhandler.so
+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
@@ -26,8 +28,8 @@
__EXTRA_LIB_RESOLV = $(if $1,$1)
define __BUILD_EXE
-$1 : $$($1_OBJS) | $$(LIBS) $$(HOST_LIBS)
- $$(LINK.cpp) -o $$@ $$^ $(call __EXTRA_LIB_RESOLV,$(addprefix -l,$($1_EXTRA_LIBS))) -L. $(call __PKG_CONFIG,$($1_NEEDED),--libs)
+$1 : $$($1_OBJS) | $$(LIBS) $$(HOST_LIBS)
+ $$(LINK.cpp) -o $$@ $$^ $(call __EXTRA_LIB_RESOLV,$(addprefix -l,$($1_EXTRA_LIBS))) -L. $(call __PKG_CONFIG,$($1_NEEDED),--libs)
$(eval CXXFLAGS += $(call __PKG_CONFIG,$($1_NEEDED),--cflags))
@@ -38,7 +40,8 @@
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 @@
.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 @@
)
$(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