From 23d2722b1251f1aba9355bba23e17596f93adb65 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 6 Jan 2021 23:12:46 +0100 Subject: [PATCH] build: add ability to specify shared object version Signed-off-by: Jo-Philipp Wich --- Makefile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 715c03e..57b6a09 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ +IWINFO_SOVERSION = $(if $(SOVERSION),$(SOVERSION),0) + IWINFO_BACKENDS = $(BACKENDS) IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -Iinclude IWINFO_LDFLAGS = -luci -lubox -lubus IWINFO_LIB = libiwinfo.so -IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared +IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname -Wl,$(IWINFO_LIB).$(IWINFO_SOVERSION) IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o IWINFO_LUA = iwinfo.so @@ -33,12 +35,19 @@ ifneq ($(filter nl80211,$(IWINFO_BACKENDS)),) endif +compile: clean $(IWINFO_LIB) $(IWINFO_LUA) $(IWINFO_CLI) + %.o: %.c $(CC) $(IWINFO_CFLAGS) $(FPIC) -c -o $@ $< -compile: clean $(IWINFO_LIB_OBJ) $(IWINFO_LUA_OBJ) $(IWINFO_CLI_OBJ) - $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB) $(IWINFO_LIB_OBJ) +$(IWINFO_LIB): $(IWINFO_LIB_OBJ) + $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB).$(IWINFO_SOVERSION) $(IWINFO_LIB_OBJ) && \ + ln -sf $(IWINFO_LIB).$(IWINFO_SOVERSION) $(IWINFO_LIB) + +$(IWINFO_LUA): $(IWINFO_LUA_OBJ) $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LUA_LDFLAGS) -o $(IWINFO_LUA) $(IWINFO_LUA_OBJ) + +$(IWINFO_CLI): $(IWINFO_CLI_OBJ) $(CC) $(IWINFO_LDFLAGS) $(IWINFO_CLI_LDFLAGS) -o $(IWINFO_CLI) $(IWINFO_CLI_OBJ) clean: -- 2.30.2