Skip to content

Commit

Permalink
mk: add .so name versioning, resolves #32
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Nov 9, 2020
1 parent 9b7f03c commit 488ed1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion mk/re.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 488ed1b

Please sign in to comment.