Browse code

tls: Makefile - option to link against libssl static libs

Daniel-Constantin Mierla authored on 26/05/2020 12:56:47
Showing 1 changed files
... ...
@@ -8,6 +8,13 @@ include ../../Makefile.defs
8 8
 auto_gen=
9 9
 NAME=tls.so
10 10
 
11
+# set to yes when wanting to link with static libraries
12
+LIBSSL_STATIC ?= no
13
+# set to yes when wanting to link with static libraries compiled from source
14
+LIBSSL_STATIC_SRCLIB ?= no
15
+# set to the path of the folder with static libraries compiled from source
16
+LIBSSL_STATIC_SRCPATH ?= /usr/local/src/openssl
17
+
11 18
 ifeq ($(CROSS_COMPILE),)
12 19
 SSL_BUILDER=$(shell \
13 20
 	if pkg-config --exists libssl; then \
... ...
@@ -16,8 +23,21 @@ SSL_BUILDER=$(shell \
16 23
 endif
17 24
 
18 25
 ifneq ($(SSL_BUILDER),)
26
+ifneq ($(LIBSSL_STATIC),yes)
19 27
 	DEFS += $(shell $(SSL_BUILDER) --cflags)
20 28
 	LIBS += $(shell $(SSL_BUILDER) --libs)
29
+else
30
+ifneq ($(LIBSSL_STATIC_SRCLIB),yes)
31
+	## when static libs (*.a) from packages are compiled with -fPIC
32
+	DEFS += $(shell $(SSL_BUILDER) --cflags)
33
+	LIBS += $(shell $(SSL_BUILDER) --libs-only-L)
34
+	LIBS += -l:libssl.a -l:libcrypto.a -l:libz.a -l:libdl.a
35
+else
36
+	## when linking against static libs compiled from sources
37
+	DEFS += -I$(LIBSSL_STATIC_SRCPATH)/include
38
+	LIBS += $(LIBSSL_STATIC_SRCPATH)/libssl.a $(LIBSSL_STATIC_SRCPATH)/libcrypto.a
39
+endif # ifneq ($(LIBSSL_STATIC_SRCLIB),yes)
40
+endif # ifneq ($(LIBSSL_STATIC),yes)
21 41
 else
22 42
 	DEFS += -I$(LOCALBASE)/ssl/include
23 43
 	LIBS += -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \