From 06cdb3f75e27aae06c16b10e936ddd908ea4e5c5 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 4 Jul 2016 22:38:04 +0100 Subject: Specify the soname in the library and its name This provides users of this library the guarantee that the ABI will stay stable when MAJOR will reach 1, and will stay backwards compatible for the entire duration of the 1.x.y branch. It does require the maintainers to always update the version in the Makefile at every ABI change. --- Makefile | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0d5ddd6..accc760 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ #!/usr/bin/make -f +MAJOR := 0 +MINOR := 1 +PATCH := 0 +VERSION := $(MAJOR).$(MINOR).$(PATCH) BUILD_DIR := build RELEASE_OPTIMIZE_FLAGS ?= -g -O3 DEBUG_OPTIMIZE_FLAGS ?= -g -O0 @@ -9,8 +13,10 @@ CC = gcc EMCC = emcc AFL_CC = afl-gcc AFL_CXX = afl-g++ -RELEASE_TARGET := $(BUILD_DIR)/libolm.so -DEBUG_TARGET := $(BUILD_DIR)/libolm_debug.so +RELEASE_TARGET := $(BUILD_DIR)/libolm.so.$(VERSION) +RELEASE_SYMLINKS := $(BUILD_DIR)/libolm.so.$(MAJOR) $(BUILD_DIR)/libolm.so +DEBUG_TARGET := $(BUILD_DIR)/libolm_debug.so.$(VERSION) +DEBUG_SYMLINKS := $(BUILD_DIR)/libolm_debug.so.$(MAJOR) $(BUILD_DIR)/libolm_debug.so JS_TARGET := javascript/olm.js JS_EXPORTED_FUNCTIONS := javascript/exported_functions.json @@ -87,22 +93,30 @@ $(JS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS) ### top-level targets -lib: $(RELEASE_TARGET) +lib: $(RELEASE_TARGET) $(RELEASE_SYMLINKS) .PHONY: lib $(RELEASE_TARGET): $(RELEASE_OBJECTS) $(CXX) $(LDFLAGS) --shared -fPIC \ + -Wl,-soname,libolm.so.$(MAJOR) \ -Wl,--version-script,version_script.ver \ $(OUTPUT_OPTION) $(RELEASE_OBJECTS) -debug: $(DEBUG_TARGET) +$(RELEASE_SYMLINKS): + ln -s libolm.so.$(VERSION) $@ + +debug: $(DEBUG_TARGET) $(DEBUG_SYMLINKS) .PHONY: debug $(DEBUG_TARGET): $(DEBUG_OBJECTS) $(CXX) $(LDFLAGS) --shared -fPIC \ + -Wl,-soname,libolm_debug.so.$(MAJOR) \ -Wl,--version-script,version_script.ver \ $(OUTPUT_OPTION) $(DEBUG_OBJECTS) +$(DEBUG_SYMLINKS): + ln -s libolm_debug.so.$(VERSION) $@ + js: $(JS_TARGET) .PHONY: js -- cgit v1.2.3