tls: Makefile - option to link against libssl static libs
authorDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 26 May 2020 12:56:47 +0000 (14:56 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 26 May 2020 12:56:47 +0000 (14:56 +0200)
src/modules/tls/Makefile

index 1505bc6..f3c15bb 100644 (file)
@@ -8,6 +8,13 @@ include ../../Makefile.defs
 auto_gen=
 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),)
 SSL_BUILDER=$(shell \
        if pkg-config --exists libssl; then \
@@ -16,9 +23,22 @@ SSL_BUILDER=$(shell \
 endif
 
 ifneq ($(SSL_BUILDER),)
+ifneq ($(LIBSSL_STATIC),yes)
        DEFS += $(shell $(SSL_BUILDER) --cflags)
        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
        DEFS += -I$(LOCALBASE)/ssl/include
        LIBS += -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \
                        -L$(LOCALBASE)/lib64 -L$(LOCALBASE)/ssl/lib64 \