1 From 22b08ab1a45eb3773b3c90dc37a31a7574520daa Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Sat, 4 Mar 2017 14:56:53 +0100
4 Subject: [PATCH 2/2] configure.ac: switch to pkg-config to find openssl
6 Using AC_CHECK_LIB() doesn't work properly for static linking, because
7 it doesn't return information on transitive dependencies of
8 libraries. For example, if library A internally uses library B, then
9 with dynamic linking, doing -lA is sufficient. However, with static
10 linking, one must do -lA -lB, and AC_CHECK_LIB() will only give the -lA
11 information. This for example causes a build failure when building
12 sngrep statically with openssl enabled:
14 checking for SSL_new in -lssl... no
15 configure: error: You need to have libssl installed to compile sngrep
17 due to undefined symbols in the OpenSSL library.
19 The proper solution for this is to discover the library using
20 pkg-config, because pkg-config properly returns the list of necessary
21 libraries, as it understands the concept of "list of libraries needed
22 when dynamic linking" and "list of libraries needed for static linking".
24 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
25 Upstream-status: https://github.com/irontec/sngrep/pull/176
27 configure.ac | 9 +--------
28 src/Makefile.am | 4 ++++
29 2 files changed, 5 insertions(+), 8 deletions(-)
31 diff --git a/configure.ac b/configure.ac
32 index 42e00e9..9f8e6d2 100644
35 @@ -129,14 +129,7 @@ AS_IF([test "x$WITH_OPENSSL" == "xyes"], [
36 AS_IF([test "x$WITH_GNUTLS" == "xyes"], [
37 AC_MSG_ERROR([ GnuTLS and OpenSSL can not be enabled at the same time ])
40 - AC_CHECK_LIB([ssl], [SSL_new], [], [
41 - AC_MSG_ERROR([ You need to have libssl installed to compile sngrep])
44 - AC_CHECK_LIB([crypto], [EVP_get_cipherbyname], [], [
45 - AC_MSG_ERROR([ You need to have libcrypto installed to compile sngrep])
47 + PKG_CHECK_MODULES([SSL], [libssl libcrypto])
48 AC_DEFINE([WITH_OPENSSL],[],[Compile With Openssl compatibility])
51 diff --git a/src/Makefile.am b/src/Makefile.am
52 index 961f4a0..3a471b7 100644
56 AUTOMAKE_OPTIONS=subdir-objects
58 sngrep_SOURCES=capture.c
62 sngrep_SOURCES+=capture_eep.c
64 @@ -9,6 +11,8 @@ sngrep_SOURCES+=capture_gnutls.c
67 sngrep_SOURCES+=capture_openssl.c
68 +sngrep_CFLAGS+=$(SSL_CFLAGS)
69 +sngrep_LDADD+=$(SSL_LIBS)
71 sngrep_SOURCES+=address.c packet.c sip.c sip_call.c sip_msg.c sip_attr.c main.c
72 sngrep_SOURCES+=option.c group.c filter.c keybinding.c media.c setting.c rtp.c