2
0
Эх сурвалжийг харах

tls: Makefile - option to link against libssl static libs

Daniel-Constantin Mierla 5 жил өмнө
parent
commit
3e7278f28c

+ 20 - 0
src/modules/tls/Makefile

@@ -8,6 +8,13 @@ include ../../Makefile.defs
 auto_gen=
 auto_gen=
 NAME=tls.so
 NAME=tls.so
 
 
+# set to yes when wanting to link with static libraries
+LIBSSL_STATIC ?= no
+# set to yes when wanting to link with static libraries compiled from source
+LIBSSL_STATIC_SRCLIB ?= no
+# set to the path of the folder with static libraries compiled from source
+LIBSSL_STATIC_SRCPATH ?= /usr/local/src/openssl
+
 ifeq ($(CROSS_COMPILE),)
 ifeq ($(CROSS_COMPILE),)
 SSL_BUILDER=$(shell \
 SSL_BUILDER=$(shell \
 	if pkg-config --exists libssl; then \
 	if pkg-config --exists libssl; then \
@@ -16,8 +23,21 @@ SSL_BUILDER=$(shell \
 endif
 endif
 
 
 ifneq ($(SSL_BUILDER),)
 ifneq ($(SSL_BUILDER),)
+ifneq ($(LIBSSL_STATIC),yes)
 	DEFS += $(shell $(SSL_BUILDER) --cflags)
 	DEFS += $(shell $(SSL_BUILDER) --cflags)
 	LIBS += $(shell $(SSL_BUILDER) --libs)
 	LIBS += $(shell $(SSL_BUILDER) --libs)
+else
+ifneq ($(LIBSSL_STATIC_SRCLIB),yes)
+	## when static libs (*.a) from packages are compiled with -fPIC
+	DEFS += $(shell $(SSL_BUILDER) --cflags)
+	LIBS += $(shell $(SSL_BUILDER) --libs-only-L)
+	LIBS += -l:libssl.a -l:libcrypto.a -l:libz.a -l:libdl.a
+else
+	## when linking against static libs compiled from sources
+	DEFS += -I$(LIBSSL_STATIC_SRCPATH)/include
+	LIBS += $(LIBSSL_STATIC_SRCPATH)/libssl.a $(LIBSSL_STATIC_SRCPATH)/libcrypto.a
+endif # ifneq ($(LIBSSL_STATIC_SRCLIB),yes)
+endif # ifneq ($(LIBSSL_STATIC),yes)
 else
 else
 	DEFS += -I$(LOCALBASE)/ssl/include
 	DEFS += -I$(LOCALBASE)/ssl/include
 	LIBS += -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \
 	LIBS += -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \