From 8d8ad8efd9b66de6d53026b5c4d691ae0b532e29 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Fri, 26 Jan 2024 15:08:12 +0100 Subject: [PATCH] Set library SONAME with version --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 95ccdc3..021f285 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ default: build/debug/mujs build/debug/mujs-pp +SOVERSION = 1 + CFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter OPTIM = -O3 @@ -84,7 +86,8 @@ build/sanitize/mujs: main.c one.c $(SRCS) $(HDRS) build/debug/libmujs.$(SO): one.c $(SRCS) $(HDRS) @mkdir -p $(@D) - $(CC) $(CFLAGS) -g -fPIC -shared -o $@ one.c -lm + $(CC) $(CFLAGS) -g -fPIC -shared -Wl,-soname,libmujs.so.$(SOVERSION) -o $@.$(SOVERSION) one.c -lm + ln -sf libmujs.so.$(SOVERSION) $@ build/debug/libmujs.o: one.c $(SRCS) $(HDRS) @mkdir -p $(@D) $(CC) $(CFLAGS) -g -c -o $@ one.c @@ -97,7 +100,8 @@ build/debug/mujs-pp: pp.c build/debug/libmujs.o build/release/libmujs.$(SO): one.c $(SRCS) $(HDRS) @mkdir -p $(@D) - $(CC) $(CFLAGS) $(OPTIM) -fPIC -shared -o $@ one.c -lm + $(CC) $(CFLAGS) $(OPTIM) -fPIC -shared -Wl,-soname,libmujs.so.$(SOVERSION) -o $@.$(SOVERSION) one.c -lm + ln -sf libmujs.so.$(SOVERSION) $@ build/release/libmujs.o: one.c $(SRCS) $(HDRS) @mkdir -p $(@D) $(CC) $(CFLAGS) $(OPTIM) -c -o $@ one.c @@ -132,6 +136,7 @@ install-static: install-common build/release/libmujs.a install-shared: install-common build/release/libmujs.$(SO) install -m 755 build/release/libmujs.$(SO) $(DESTDIR)$(libdir) + install -m 755 build/release/libmujs.$(SO).$(SOVERSION) $(DESTDIR)$(libdir) install: install-static @@ -142,6 +147,7 @@ uninstall: rm -f $(DESTDIR)$(libdir)/pkgconfig/mujs.pc rm -f $(DESTDIR)$(libdir)/libmujs.a rm -f $(DESTDIR)$(libdir)/libmujs.$(SO) + rm -f $(DESTDIR)$(libdir)/libmujs.$(SO).$(SOVERSION) tarball: git archive --format=zip --prefix=mujs-$(VERSION)/ HEAD > mujs-$(VERSION).zip