From 513c5c3ce6d8fd3878759398748638a1937f54d4 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 24 Apr 2016 12:52:34 -0400 Subject: build system: added library version support. --- project/defs.mk | 17 ++++++++++++++--- project/version.mk | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 project/version.mk (limited to 'project') diff --git a/project/defs.mk b/project/defs.mk index f182b87..5a5d60b 100644 --- a/project/defs.mk +++ b/project/defs.mk @@ -14,9 +14,16 @@ APP_OBJS = $(APP_SRCS:.c=.o) SHARED_OBJS = $(COMMON_LOBJS) $(ARCH_LOBJS) STATIC_OBJS = $(COMMON_OBJS) $(ARCH_OBJS) -SHARED_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX) -STATIC_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT) +DSO_VER = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)$(VER_XYZ) +DSO_SONAME = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)$(VER_SONAME) +DSO_SOLINK = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX) + +SHARED_LIB = lib/$(DSO_VER) +SHARED_SONAME = lib/$(DSO_SONAME) +SHARED_SOLINK = lib/$(DSO_SOLINK) + SHARED_IMPLIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_IMPLIB_EXT) +STATIC_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT) APP = bin/$(OS_APP_PREFIX)$(NICKNAME)$(OS_APP_SUFFIX) DEFAULT_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-default$(OS_APP_SUFFIX) @@ -25,7 +32,8 @@ STATIC_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-static$(OS_APP_SUFFIX) CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_CONFIG) $(CFLAGS_SYSROOT) \ $(CFLAGS_COMMON) $(CFLAGS_CMDLINE) $(CFLAGS_HOST) \ - $(CFLAGS_PATH) $(CFLAGS_OS) $(CFLAGS_SITE) + $(CFLAGS_PATH) $(CFLAGS_OS) $(CFLAGS_SITE) \ + $(CFLAGS_VERSION) CFLAGS_SHARED = $(CFLAGS) $(CFLAGS_PIC) $(CFLAGS_SHARED_ATTR) CFLAGS_STATIC = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_STATIC_ATTR) @@ -35,6 +43,9 @@ LDFLAGS_SHARED = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ $(LDFLAGS_PATH) $(SHARED_LIB_DEPS) $(LDFLAGS_LAST) +LDFLAGS_SHARED += -Wl,-soname +LDFLAGS_SHARED += -Wl,$(DSO_SONAME) + LDFLAGS_APP = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ $(LDFLAGS_PATH) $(SHARED_APP_DEPS) $(LDFLAGS_LAST) diff --git a/project/version.mk b/project/version.mk new file mode 100644 index 0000000..1d58cf3 --- /dev/null +++ b/project/version.mk @@ -0,0 +1,42 @@ +include $(PROJECT_DIR)/project/tagver.mk + +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MAJOR=$(VER_MAJOR) +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MINOR=$(VER_MINOR) +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_PATCH=$(VER_PATCH) + +VER_XYZ = .$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) +VER_SONAME = .$(VER_MAJOR) + +# libfoo.so (common) +install-solink: install-lib + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(DSO_SOLINK) + +$(SHARED_SOLINK): $(SHARED_LIB) + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $@ + +# libfoo.so.x (symlink) +ifeq ($(OS_SONAME),symlink) +$(SHARED_SONAME): $(SHARED_LIB) + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $@ + +install-soname: install-lib + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(DSO_SONAME) +endif + + +# libfoo.so.x (copy) +ifeq ($(OS_SONAME),copy) +install-soname: install-lib + cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR)/$(DSO_SONAME) + +$(SHARED_SONAME): $(SHARED_LIB) + cp $(SHARED_LIB) $(SHARED_SONAME) +endif -- cgit v1.2.3