[CRIU] [PATCH] Makefile: add soname to libcriu.so

Adrian Reber adrian at lisas.de
Wed Feb 5 06:28:17 PST 2014


Using a soname makes it easy for applications to
detect if the ABI of libcriu.so has changed.
It still creates libcriu.so as before in lib. During
'make install' additional links are created:

 libcriu.so -> libcriu.so.1.0
 libcriu.so.1 -> libcriu.so.1.0

Signed-off-by: Adrian Reber <adrian at lisas.de>
---
 Makefile     | 15 ++++++++++++---
 lib/Makefile |  4 ++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 985b8c9..9ed45bd 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,11 @@ VERSION_MINOR		:= 1
 VERSION_SUBLEVEL	:=
 VERSION_EXTRA		:=
 VERSION_NAME		:=
+VERSION_SO_MAJOR	:= 1
+VERSION_SO_MINOR	:= 0
 
 export VERSION_MAJOR VERSION_MINOR VERSION_SUBLEVEL VERSION_EXTRA VERSION_NAME
+export VERSION_SO_MAJOR VERSION_SO_MINOR
 
 #
 # FIXME zdtm building procedure requires implicit rules
@@ -103,10 +106,11 @@ endif
 CFLAGS		+= $(WARNINGS) $(DEFINES)
 SYSCALL-LIB	:= arch/$(ARCH)/syscalls.built-in.o
 ARCH-LIB	:= arch/$(ARCH)/crtools.built-in.o
-CRIU-LIB	:= lib/libcriu.so
+CRIU-SO		:= libcriu
+CRIU-LIB	:= lib/$(CRIU-SO).so
 CRIU-INC	:= lib/criu.h include/criu-plugin.h include/criu-log.h protobuf/rpc.proto
 
-export CC MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS
+export CC MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS CRIU-SO
 export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD
 export cflags-y
 
@@ -235,7 +239,12 @@ install: $(PROGRAM) install-man
 	$(Q) mkdir -p $(DESTDIR)$(SBINDIR)
 	$(Q) install -m 755 $(PROGRAM) $(DESTDIR)$(SBINDIR)
 	$(Q) mkdir -p $(DESTDIR)$(LIBDIR)
-	$(Q) install -m 755 $(CRIU-LIB) $(DESTDIR)$(LIBDIR)
+	$(Q) install -m 755 $(CRIU-LIB) \
+		$(DESTDIR)$(LIBDIR)/$(CRIU-SO).so.$(VERSION_SO_MAJOR).$(VERSION_SO_MINOR)
+	$(Q) ln -s $(DESTDIR)$(LIBDIR)/$(CRIU-SO).so.$(VERSION_SO_MAJOR).$(VERSION_SO_MINOR) \
+		$(DESTDIR)$(LIBDIR)/$(CRIU-SO).so.$(VERSION_SO_MAJOR)
+	$(Q) ln -s $(DESTDIR)$(LIBDIR)/$(CRIU-SO).so.$(VERSION_SO_MAJOR).$(VERSION_SO_MINOR) \
+		$(DESTDIR)$(LIBDIR)/$(CRIU-SO).so
 	$(Q) mkdir -p $(DESTDIR)$(INCLUDEDIR)
 	$(Q) install -m 644 $(CRIU-INC) $(DESTDIR)$(INCLUDEDIR)
 	$(Q) mkdir -p $(DESTDIR)$(SYSTEMDUNITDIR)
diff --git a/lib/Makefile b/lib/Makefile
index e9beace..aec6d84 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,10 +1,10 @@
-lib-so			+= libcriu
+lib-so			+= $(CRIU-SO)
 obj-y			+= criu.o
 obj-ext-src-y		+= protobuf/rpc.pb-c.o
 
 includes		+= -iquote $(obj)/../arch/$(ARCH)/include -iquote $(obj)/../include -iquote $(obj)/.. -iquote $(obj)/../protobuf
 cflags-y		+= $(includes) -fPIC -Wa,--noexecstack -fno-stack-protector
-cflags-so		+= -rdynamic
+cflags-so		+= -rdynamic -Wl,-soname,$(lib-so).so.$(VERSION_SO_MAJOR)
 ldflags-so		+= -lprotobuf-c
 
 .SECONDARY:
-- 
1.8.5.3



More information about the CRIU mailing list