Debian Codegraph @

src/modules/tls/Makefile

raw
1 #
2 # TLS module makefile
3 #
4 #
5 # WARNING: do not run this directly, it should be run by the main Makefile
6
7 include ../../Makefile.defs
8 auto_gen=
9 NAME=tls.so
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
18 ifeq ($(CROSS_COMPILE),)
19 SSL_BUILDER=$(shell \
20 if pkg-config --exists libssl; then \
21 echo 'pkg-config libssl'; \
22 fi)
23 CRYPTO_BUILDER=$(shell \
24 if pkg-config --exists libcrypto; then \
25 echo 'pkg-config libcrypto'; \
26 fi)
27 endif
28
29 ifneq ($(SSL_BUILDER),)
30
31 ifneq ($(LIBSSL_STATIC),yes)
32 DEFS += $(shell $(SSL_BUILDER) --cflags)
33 LIBS += $(shell $(SSL_BUILDER) --libs)
34
35 ifneq ($(CRYPTO_BUILDER),)
36 DEFS += $(shell $(CRYPTO_BUILDER) --cflags)
37 LIBS += $(shell $(CRYPTO_BUILDER) --libs)
38 endif # ifneq ($(CRYPTO_BUILDER),)
39
40 else # $(LIBSSL_STATIC),yes)
41
42 DEFS += -DKSR_LIBSSL_STATIC
43
44 ifneq ($(LIBSSL_STATIC_SRCLIB),yes)
45 ## when static libs (*.a) from packages are compiled with -fPIC
46 DEFS += $(shell $(SSL_BUILDER) --cflags)
47 LIBS += $(shell $(SSL_BUILDER) --libs-only-L)
48 # TODO: explore use of LIBS += -Wl,-Bstatic $(shell $(SSL_BUILDER) --libs-only-l)
49 LIBS += -l:libssl.a -l:libcrypto.a -l:libz.a -l:libdl.a
50 else
51 ## when linking against static libs compiled from sources
52 DEFS += -I$(LIBSSL_STATIC_SRCPATH)/include
53 LIBS += $(LIBSSL_STATIC_SRCPATH)/libssl.a $(LIBSSL_STATIC_SRCPATH)/libcrypto.a
54 endif # ifneq ($(LIBSSL_STATIC_SRCLIB),yes)
55
56 endif # ifneq ($(LIBSSL_STATIC),yes)
57
58 else # ifneq ($(SSL_BUILDER),)
59
60 DEFS += -I$(LOCALBASE)/ssl/include
61 LIBS += -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \
62 -L$(LOCALBASE)/lib64 -L$(LOCALBASE)/ssl/lib64 \
63 -lssl -lcrypto
64 # NOTE: depending on the way in which libssl was compiled you might
65 # have to add -lz -lkrb5 (zlib and kerberos5).
66 # E.g.: make TLS_HOOKS=1 TLS_EXTRA_LIBS="-lz -lkrb5"
67
68 endif # ifneq ($(SSL_BUILDER),)
69
70 LIBS+= $(TLS_EXTRA_LIBS) -lpthread
71
72 # dcm: tls.cfg installed via local 'install-cfg' to update paths
73 #MOD_INSTALL_CFGS=tls.cfg
74
75 include ../../Makefile.modules
76
77 install-tls-cert: $(cfg_prefix)/$(cfg_dir)
78 MAIN_NAME=$(MAIN_NAME) ./tls_cert.sh -d $(cfg_prefix)/$(cfg_dir)
79
80 install-cfg:
81 @if ! [ -d $(cfg_prefix)/$(cfg_dir) ]; then \
82 mkdir -p "$(cfg_prefix)/$(cfg_dir)" ; \
83 fi
84 @$(call try_err, $(INSTALL_TOUCH) \
85 "$(cfg_prefix)/$(cfg_dir)tls.cfg.sample" )
86 @sed -e "s#\/usr/local/etc/kamailio/#$(cfg_target)#g" \
87 -e "s#kamailio-selfsigned#$(MAIN_NAME)-selfsigned#g" \
88 < ./tls.cfg > "$(cfg_prefix)/$(cfg_dir)tls.cfg.sample"
89 @if [ -z "${skip_cfg_install}" -a \
90 ! -f "$(cfg_prefix)/$(cfg_dir)tls.cfg" ]; then \
91 mv -f "$(cfg_prefix)/$(cfg_dir)tls.cfg.sample" \
92 "$(cfg_prefix)/$(cfg_dir)tls.cfg" ; \
93 fi
94