From 488ed1bac9b90b6157910d8e163268cf01e86253 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Mon, 9 Nov 2020 21:10:16 +0100 Subject: [PATCH] mk: add .so name versioning, resolves #32 --- Makefile | 14 +++++++++++--- mk/re.mk | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 05d8223fc..85f6312b8 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ VER_MAJOR := 1 VER_MINOR := 1 VER_PATCH := 0 +VER_ABI := $(VER_MAJOR)$(VER_MINOR) PROJECT := re VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) @@ -47,9 +48,10 @@ INCDIR := $(PREFIX)/include/re MKDIR := $(PREFIX)/share/re CFLAGS += -Iinclude -MODMKS := $(patsubst %,src/%/mod.mk,$(MODULES)) -SHARED := libre$(LIB_SUFFIX) -STATIC := libre.a +MODMKS := $(patsubst %,src/%/mod.mk,$(MODULES)) +SHARED := libre$(LIB_SUFFIX) +SHARED_SONAME := libre$(LIB_SUFFIX).$(VER_ABI) +STATIC := libre.a include $(MODMKS) @@ -109,7 +111,12 @@ install: $(SHARED) $(STATIC) libre.pc $(DESTDIR)$(INCDIR) $(DESTDIR)$(MKDIR) $(INSTALL) -m 0644 $(shell find include -name "*.h") \ $(DESTDIR)$(INCDIR) +ifeq ($(OS),linux) + $(INSTALL) -m 0755 $(SHARED) $(DESTDIR)$(LIBDIR)/$(SHARED_SONAME) + cd $(DESTDIR)$(LIBDIR) && ln -sf $(SHARED_SONAME) $(SHARED) +else $(INSTALL) -m 0755 $(SHARED) $(DESTDIR)$(LIBDIR) +endif $(INSTALL) -m 0755 $(STATIC) $(DESTDIR)$(LIBDIR) $(INSTALL) -m 0644 libre.pc $(DESTDIR)$(LIBDIR)/pkgconfig $(INSTALL) -m 0644 $(MK) $(DESTDIR)$(MKDIR) @@ -118,6 +125,7 @@ uninstall: @rm -rf $(DESTDIR)$(INCDIR) @rm -rf $(DESTDIR)$(MKDIR) @rm -f $(DESTDIR)$(LIBDIR)/$(SHARED) + @rm -f $(DESTDIR)$(LIBDIR)/$(SHARED_SONAME) @rm -f $(DESTDIR)$(LIBDIR)/$(STATIC) @rm -f $(DESTDIR)$(LIBDIR)/pkgconfig/libre.pc diff --git a/mk/re.mk b/mk/re.mk index 5f30810e3..bedf8387a 100644 --- a/mk/re.mk +++ b/mk/re.mk @@ -233,7 +233,7 @@ ifeq ($(OS),linux) CFLAGS += -fPIC -DLINUX LIBS += -ldl LFLAGS += -fPIC - SH_LFLAGS += -shared + SH_LFLAGS += -shared -Wl,-soname,libre.so.$(VER_ABI) MOD_LFLAGS += APP_LFLAGS += -rdynamic AR := ar