aboutsummaryrefslogtreecommitdiff
path: root/core/libtls-bearssl/patches/shared-lib.patch
blob: cebd29fe996a8a8dd9fa4c6138dc897a3ef6a127 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From 4dbd01a0b09f58928f96171da1f47b723f1da4ba Mon Sep 17 00:00:00 2001
From: Cem Keylan <cem@ckyln.com>
To: libtls-bearssl <~mcf/libtls-bearssl@lists.sr.ht>
Bcc: Cem Keylan <cem@ckyln.com>
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