From 4dbd01a0b09f58928f96171da1f47b723f1da4ba Mon Sep 17 00:00:00 2001 From: Cem Keylan To: libtls-bearssl <~mcf/libtls-bearssl@lists.sr.ht> Bcc: Cem Keylan Date: Fri, 25 Sep 2020 13:05:42 +0300 Subject: [PATCH] Add shared library to the Makefile This builds and installs shared libraries from the Makefile, I can modify it to build it optionally (like adding a SHARED=1 option) to the Makefile. --- .gitignore | 1 + Makefile | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 9759343..36cbb30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /libtls.a /libtls.pc +/libtls.so *.o diff --git a/Makefile b/Makefile index 6903d2c..3820277 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ PREFIX?=/usr/local INCDIR?=$(PREFIX)/include LIBDIR?=$(PREFIX)/lib MANDIR?=$(PREFIX)/share/man -CFLAGS+=-Wall -Wpedantic -D _DEFAULT_SOURCE -I . +CFLAGS+=-Wall -Wpedantic -D _DEFAULT_SOURCE -I . -fPIC OBJ=\ tls.o\ @@ -41,7 +41,7 @@ MAN=\ man/tls_ocsp_process_response.3\ man/tls_read.3 -all: libtls.a +all: libtls.a libtls.so $(OBJ): tls.h tls_internal.h compat.h @@ -51,20 +51,24 @@ $(OBJ): tls.h tls_internal.h compat.h libtls.a: $(OBJ) $(AR) cr $@ $(OBJ) +libtls.so: $(OBJ) + $(CC) -shared -Wl,-soname,libtls.so -o $@ $(OBJ) -lc -lbearssl + libtls.pc: libtls.pc.in sed -e "s,@version@,$(VERSION),"\ -e "s,@libdir@,$(LIBDIR),"\ -e "s,@includedir@,$(INCDIR),"\ libtls.pc.in >$@.tmp && mv $@.tmp $@ -install: tls.h libtls.a libtls.pc $(MAN) +install: tls.h libtls.a libtls.pc libtls.so $(MAN) mkdir -p $(DESTDIR)$(INCDIR) cp tls.h $(DESTDIR)$(INCDIR)/ mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig/ cp libtls.a $(DESTDIR)$(LIBDIR)/ + cp libtls.so $(DESTDIR)$(LIBDIR)/ cp libtls.pc $(DESTDIR)$(LIBDIR)/pkgconfig/ mkdir -p $(DESTDIR)$(MANDIR)/man3 cp $(MAN) $(DESTDIR)$(MANDIR)/man3/ clean: - rm -f libtls.a libtls.pc $(OBJ) + rm -f libtls.a libtls.so libtls.pc $(OBJ) -- 2.28.0