From 75033d0735c9ac52d667de1377bf8c7083ce788c Mon Sep 17 00:00:00 2001
From: Terry Wilson <twilson@digium.com>
Date: Fri, 13 Aug 2010 16:08:05 +0000
Subject: [PATCH] Merged revisions 282200-282201 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r282200 | twilson | 2010-08-13 11:00:02 -0500 (Fri, 13 Aug 2010) | 10 lines

  Detect when libsrtp cannot be linked in a shared library

  The libsrtp build system currently does not produce a shared library
  or a static library compiled with -fPIC, so on 64-bit systems it is
  possible that we will get a compile error if libsrtp is installed and
  res_srtp is selected in menuselect.

  This patch attempts to detect this situation and provide the user with
  instructions to work around the problem.
........
  r282201 | twilson | 2010-08-13 11:02:20 -0500 (Fri, 13 Aug 2010) | 2 lines

  Whitespace fix :-/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@282202 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 configure    | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 configure.ac | 32 +++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 7f40f51348..ea3d8623c8 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 279659 .
+# From configure.ac Revision: 279954 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.65 for asterisk trunk.
 #
@@ -26148,6 +26148,61 @@ fi
 
 
 
+if test "$PBX_SRTP" = "1";
+then
+    saved_libs="${LIBS}"
+    saved_ldflags="${LDFLAGS}"
+    LIBS="${LIBS} -lsrtp"
+    LDFLAGS="${LDFLAGS} -shared -fPIC"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the ability of -lsrtp to be linked in a shared object" >&5
+$as_echo_n "checking for the ability of -lsrtp to be linked in a shared object... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+        #include <srtp/srtp.h>
+int
+main ()
+{
+srtp_init();
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: ***" >&5
+$as_echo "$as_me: ***" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: *** libsrtp could not be linked as a shared object" >&5
+$as_echo "$as_me: *** libsrtp could not be linked as a shared object" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: *** try compiling libsrtp manually and configuring with" >&5
+$as_echo "$as_me: *** try compiling libsrtp manually and configuring with" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: *** ./configure CFLAGS=-fPIC --prefix=/usr" >&5
+$as_echo "$as_me: *** ./configure CFLAGS=-fPIC --prefix=/usr" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: *** replacing /usr with the prefix of your choice" >&5
+$as_echo "$as_me: *** replacing /usr with the prefix of your choice" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: ***" >&5
+$as_echo "$as_me: ***" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: *** If you do not need SRTP support re-run configure" >&5
+$as_echo "$as_me: *** If you do not need SRTP support re-run configure" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: *** with the --without-srtp option." >&5
+$as_echo "$as_me: *** with the --without-srtp option." >&6;}
+        exit 1
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="${saved_libs}"
+    LDFLAGS="${saved_ldflags}"
+fi
+
 
     if test "x${PBX_GMIME}" != "x1" -a "${USE_GMIME}" != "no"; then
 	PBX_GMIME=0
diff --git a/configure.ac b/configure.ac
index dfc45a5e83..62e7895c31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1807,6 +1807,38 @@ fi
 
 AST_EXT_LIB_CHECK([SRTP], [srtp], [srtp_init], [srtp/srtp.h])
 
+if test "$PBX_SRTP" = "1";
+then
+    saved_libs="${LIBS}"
+    saved_ldflags="${LDFLAGS}"
+    LIBS="${LIBS} -lsrtp"
+    LDFLAGS="${LDFLAGS} -shared -fPIC"
+    AC_MSG_CHECKING(for the ability of -lsrtp to be linked in a shared object)
+    AC_LINK_IFELSE(
+    [
+        AC_LANG_PROGRAM(
+            [#include <srtp/srtp.h>],
+            [srtp_init();]
+        )
+    ],
+    [ AC_MSG_RESULT(yes) ],
+    [
+        AC_MSG_RESULT(no)
+        AC_MSG_NOTICE(***)
+        AC_MSG_NOTICE(*** libsrtp could not be linked as a shared object)
+        AC_MSG_NOTICE(*** try compiling libsrtp manually and configuring with)
+        AC_MSG_NOTICE(*** ./configure CFLAGS=-fPIC --prefix=/usr)
+        AC_MSG_NOTICE(*** replacing /usr with the prefix of your choice)
+        AC_MSG_NOTICE(***)
+        AC_MSG_NOTICE(*** If you do not need SRTP support re-run configure)
+        AC_MSG_NOTICE(*** with the --without-srtp option.)
+        exit 1
+    ]
+    )
+    LIBS="${saved_libs}"
+    LDFLAGS="${saved_ldflags}"
+fi
+
 AST_EXT_TOOL_CHECK([GMIME], [gmime-config], [], [], [#include <gmime/gmime.h>], [gboolean q = g_mime_check_version(0,0,0);])
 
 AST_EXT_LIB_CHECK([HOARD], [hoard], [malloc], [])
-- 
GitLab