From c07e3c2f4d644155ff72d393987c2679bdd93da6 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Tue, 19 Oct 2021 10:35:26 -0600
Subject: [PATCH] BuildSystem: Check for alternate openssl packages

OpenSSL is one of those packages that often have alternatives
with later versions.  For instance, CentOS/EL 7 has an
openssl package at version 1.0.2 but there's an openssl11
package from the epel repository that has 1.1.1.  This gets
installed to /usr/include/openssl11 and /usr/lib64/openssl11.
Unfortunately, the existing --with-ssl and --with-crypto
./configure options expect to point to a source tree and
don't work in this situation.  Also unfortunately, the
checks in ./configure don't use pkg-config.

In order to make this work with the existing situation, you'd
have to run...
./configure --with-ssl=/usr/lib64/openssl11 \
    --with-crypto=/usr/lib64/openssl11 \
    CFLAGS=-I/usr/include/openssl11

BUT...  those options don't get passed down to bundled pjproject
so when you run make, you have to include the CFLAGS again
which is a big pain.

Oh...  To make matters worse, although you can specify
PJPROJECT_CONFIGURE_OPTS on the ./configure command line,
they don't get saved so if you do a make clean, which will
force a re-configure of bundled pjproject, those options
don't get used.

So...

* In configure.ac... Since pkg-config is installed by install_prereq
  anyway, we now use it to check for the system openssl >= 1.1.0.
  If that works, great.  If not, we check for the openssl11
  package. If that works, great.  If not, we fall back to just
  checking for any openssl.  If pkg-config isn't installed for some
  reason, or --with-ssl=<dir> or --with-crypto=<dir> were specified
  on the ./configure command line, we fall back to the existing
  logic that uses AST_EXT_LIB_CHECK().

* The whole OpenSSL check process has been moved up before
  THIRD_PARTY_CONFIGURE(), which does the initial pjproject
  bundled configure, is run.  This way the results of the above
  checks, which may result in new include or library directories,
  is included.

* Although not strictly needed for openssl, We now save the value of
  PJPROJECT_CONFIGURE_OPTS in the makeopts file so it can be used
  again if a re-configure is triggered.

ASTERISK-29693

Change-Id: I341ab7603e6b156aa15a66f43675ac5029d5fbde
---
 configure                          | 5545 +++++++++++++++-------------
 configure.ac                       |   61 +-
 include/asterisk/autoconfig.h.in   |    2 +-
 makeopts.in                        |    1 +
 menuselect/configure               |   14 +-
 third-party/pjproject/Makefile     |    6 +-
 third-party/pjproject/configure.m4 |    1 +
 7 files changed, 2995 insertions(+), 2635 deletions(-)

diff --git a/configure b/configure
index 0ce03e96ea..f89bac93d0 100755
--- a/configure
+++ b/configure
@@ -711,9 +711,6 @@ UUID_LIB
 UUID_INCLUDE
 LIBEDIT_LIBS
 LIBEDIT_CFLAGS
-PKG_CONFIG_LIBDIR
-PKG_CONFIG_PATH
-PKG_CONFIG
 ALLOCA
 PBX_ZLIB
 ZLIB_DIR
@@ -759,10 +756,6 @@ PBX_RT
 RT_DIR
 RT_INCLUDE
 RT_LIB
-PBX_OPENSSL
-OPENSSL_DIR
-OPENSSL_INCLUDE
-OPENSSL_LIB
 PBX_SRTP_GET_VERSION
 SRTP_GET_VERSION_DIR
 SRTP_GET_VERSION_INCLUDE
@@ -1153,14 +1146,6 @@ PBX_DAHDI
 DAHDI_DIR
 DAHDI_INCLUDE
 DAHDI_LIB
-PBX_OPENSSL_BIO_METHOD
-OPENSSL_BIO_METHOD_DIR
-OPENSSL_BIO_METHOD_INCLUDE
-OPENSSL_BIO_METHOD_LIB
-PBX_CRYPTO
-CRYPTO_DIR
-CRYPTO_INCLUDE
-CRYPTO_LIB
 PBX_CRYPT
 CRYPT_DIR
 CRYPT_INCLUDE
@@ -1208,6 +1193,20 @@ JANSSON_LIB
 PBX_JANSSON
 JANSSON_BUNDLED
 JANSSON_CONFIGURE_OPTS
+OPENSSL_LIBS
+OPENSSL_CFLAGS
+PBX_OPENSSL_BIO_METHOD
+OPENSSL_BIO_METHOD_DIR
+OPENSSL_BIO_METHOD_INCLUDE
+OPENSSL_BIO_METHOD_LIB
+PBX_OPENSSL
+OPENSSL_DIR
+OPENSSL_INCLUDE
+OPENSSL_LIB
+PBX_CRYPTO
+CRYPTO_DIR
+CRYPTO_INCLUDE
+CRYPTO_LIB
 AST_C_COMPILER_FAMILY
 AST_CLANG_BLOCKS
 AST_CLANG_BLOCKS_LIBS
@@ -1230,6 +1229,9 @@ PBX_BASH
 PBX_XMLSTARLET
 PBX_FLEX
 PBX_BISON
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 OPENSSL
 SHA1SUM
 LDCONFIG
@@ -1377,6 +1379,8 @@ with_externals_cache
 enable_coverage
 with_jansson_bundled
 with_pjproject_bundled
+with_crypto
+with_ssl
 with_asound
 with_bfd
 with_execinfo
@@ -1385,7 +1389,6 @@ with_cap
 with_codec2
 with_cpg
 with_crypt
-with_crypto
 with_dahdi
 with_avcodec
 with_gsm
@@ -1442,7 +1445,6 @@ with_speexdsp
 with_sqlite
 with_sqlite3
 with_srtp
-with_ssl
 with_suppserv
 with_tds
 with_timerfd
@@ -1473,12 +1475,14 @@ CXX
 CXXFLAGS
 CCC
 CXXCPP
-JANSSON_CONFIGURE_OPTS
-PJPROJECT_CONFIGURE_OPTS
-LUA_VERSIONS
 PKG_CONFIG
 PKG_CONFIG_PATH
 PKG_CONFIG_LIBDIR
+OPENSSL_CFLAGS
+OPENSSL_LIBS
+JANSSON_CONFIGURE_OPTS
+PJPROJECT_CONFIGURE_OPTS
+LUA_VERSIONS
 LIBEDIT_CFLAGS
 LIBEDIT_LIBS
 JANSSON_CFLAGS
@@ -2148,6 +2152,8 @@ Optional Packages:
   --with-jansson-bundled  Use bundled jansson library
   --with-pjproject-bundled
                           Use bundled pjproject libraries (default)
+  --with-crypto=PATH      use OpenSSL Cryptography files in PATH
+  --with-ssl=PATH         use OpenSSL Secure Sockets Layer files in PATH
   --with-asound=PATH      use Advanced Linux Sound Architecture files in PATH
   --with-bfd=PATH         use Debug symbol decoding files in PATH
   --with-execinfo=PATH    use Stack Backtrace files in PATH
@@ -2156,7 +2162,6 @@ Optional Packages:
   --with-codec2=PATH      use Codec 2 Audio Decoder/Encoder files in PATH
   --with-cpg=PATH         use Corosync files in PATH
   --with-crypt=PATH       use password and data encryption files in PATH
-  --with-crypto=PATH      use OpenSSL Cryptography files in PATH
   --with-dahdi=PATH       use DAHDI files in PATH
   --with-avcodec=PATH     use Ffmpeg and avcodec files in PATH
   --with-gsm=PATH         use External GSM files in PATH, use 'internal' GSM
@@ -2217,7 +2222,6 @@ Optional Packages:
   --with-sqlite=PATH      use SQLite files in PATH
   --with-sqlite3=PATH     use SQLite files in PATH
   --with-srtp=PATH        use Secure RTP files in PATH
-  --with-ssl=PATH         use OpenSSL Secure Sockets Layer files in PATH
   --with-suppserv=PATH    use mISDN Supplemental Services files in PATH
   --with-tds=PATH         use FreeTDS files in PATH
   --with-timerfd=PATH     use timerfd files in PATH
@@ -2241,17 +2245,21 @@ Some influential environment variables:
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
   CXXCPP      C++ preprocessor
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  OPENSSL_CFLAGS
+              C compiler flags for OPENSSL, overriding pkg-config
+  OPENSSL_LIBS
+              linker flags for OPENSSL, overriding pkg-config
   JANSSON_CONFIGURE_OPTS
               Additional configure options to pass to bundled jansson
   PJPROJECT_CONFIGURE_OPTS
               Additional configure options to pass to bundled pjproject
   LUA_VERSIONS
               A space separated list of target lua versions to test.
-  PKG_CONFIG  path to pkg-config utility
-  PKG_CONFIG_PATH
-              directories to add to pkg-config's search path
-  PKG_CONFIG_LIBDIR
-              path overriding pkg-config's built-in search path
   LIBEDIT_CFLAGS
               C compiler flags for LIBEDIT, overriding pkg-config
   LIBEDIT_LIBS
@@ -7870,6 +7878,127 @@ fi
 
 
 
+
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; 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; }
+		PKG_CONFIG=""
+	fi
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bison that supports parse-param" >&5
 $as_echo_n "checking for bison that supports parse-param... " >&6; }
 if ${ac_cv_path_BISON2+:} false; then :
@@ -9084,72 +9213,745 @@ if test "${with_pjproject}" == "no" || test "${with_pjproject}" == "n" ; then
 	PJPROJECT_BUNDLED=no
 fi
 
+#
+# OpenSSL stuff has to be done here because we want to pass
+# any resulting CFLAGS and LDFLAGS to the bundled pjproject
+# configure done in THIRD_PARTY_CONFIGURE()
+#
 
+    CRYPTO_DESCRIP="OpenSSL Cryptography"
+    CRYPTO_OPTION="crypto"
+    PBX_CRYPTO=0
 
-	if test "$JANSSON_BUNDLED" = "yes" ; then
+# Check whether --with-crypto was given.
+if test "${with_crypto+set}" = set; then :
+  withval=$with_crypto;
+	case ${withval} in
+	n|no)
+	USE_CRYPTO=no
+	# -1 is a magic value used by menuselect to know that the package
+	# was disabled, other than 'not found'
+	PBX_CRYPTO=-1
+	;;
+	y|ye|yes)
+	ac_mandatory_list="${ac_mandatory_list} CRYPTO"
+	;;
+	*)
+	CRYPTO_DIR="${withval}"
+	ac_mandatory_list="${ac_mandatory_list} CRYPTO"
+	;;
+	esac
 
-	if test "${ac_mandatory_list#*JANSSON*}" != "$ac_mandatory_list" ; then
-		as_fn_error $? "--with-jansson and --with-jansson-bundled can't both be specified" "$LINENO" 5
-	fi
+fi
 
-	ac_mandatory_list="$ac_mandatory_list JANSSON"
-	JANSSON_DIR="${ac_pwd}/third-party/jansson"
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for embedded jansson (may have to download)" >&5
-$as_echo_n "checking for embedded jansson (may have to download)... " >&6; }
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: configuring" >&5
-$as_echo "configuring" >&6; }
 
-	if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then
-		as_fn_error $? "A download utility (wget, curl, or fetch) is required to download bundled jansson" "$LINENO" 5
-	fi
-	if test "${BZIP2}" = ":" ; then
-		as_fn_error $? "bzip2 is required to extract the jansson tar file" "$LINENO" 5
-	fi
-	if test "${TAR}" = ":" ; then
-		as_fn_error $? "tar is required to extract the jansson tar file" "$LINENO" 5
-	fi
-	if test "${PATCH}" = ":" ; then
-		as_fn_error $? "patch is required to configure bundled jansson" "$LINENO" 5
-	fi
-	if test "${SED}" = ":" ; then
-		as_fn_error $? "sed is required to configure bundled jansson" "$LINENO" 5
-	fi
-	if test "${NM}" = ":" ; then
-		as_fn_error $? "nm is required to build bundled jansson" "$LINENO" 5
-	fi
-	if test "${MD5}" = ":" ; then
-		as_fn_error $? "md5sum is required to build bundled jansson" "$LINENO" 5
-	fi
-	if test "${CAT}" = ":" ; then
-		as_fn_error $? "cat is required to build bundled jansson" "$LINENO" 5
-	fi
-	if test "${CUT}" = ":" ; then
-		as_fn_error $? "cut is required to build bundled jansson" "$LINENO" 5
-	fi
-	if test "${GREP}" = ":" ; then
-		as_fn_error $? "grep is required to build bundled jansson" "$LINENO" 5
-	fi
 
 
-	this_host=$(./config.sub $(./config.guess))
-	if test "$build" != "$this_host" ; then
-		JANSSON_CONFIGURE_OPTS+=" --build=$build_alias"
-	fi
-	if test "$host" != "$this_host" ; then
-		JANSSON_CONFIGURE_OPTS+=" --host=$host_alias"
-	fi
 
-	export TAR PATCH SED NM EXTERNALS_CACHE_DIR AST_DOWNLOAD_CACHE DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT CUT GREP
-	export NOISY_BUILD
-	${GNU_MAKE} --quiet --no-print-directory -C ${JANSSON_DIR} \
-		JANSSON_CONFIGURE_OPTS="$JANSSON_CONFIGURE_OPTS" \
-		EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" \
-		configure
-	if test $? -ne 0 ; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
-$as_echo "failed" >&6; }
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: Unable to configure ${JANSSON_DIR}" >&5
+
+
+    OPENSSL_DESCRIP="OpenSSL Secure Sockets Layer"
+    OPENSSL_OPTION="ssl"
+    PBX_OPENSSL=0
+
+# Check whether --with-ssl was given.
+if test "${with_ssl+set}" = set; then :
+  withval=$with_ssl;
+	case ${withval} in
+	n|no)
+	USE_OPENSSL=no
+	# -1 is a magic value used by menuselect to know that the package
+	# was disabled, other than 'not found'
+	PBX_OPENSSL=-1
+	;;
+	y|ye|yes)
+	ac_mandatory_list="${ac_mandatory_list} OPENSSL"
+	;;
+	*)
+	OPENSSL_DIR="${withval}"
+	ac_mandatory_list="${ac_mandatory_list} OPENSSL"
+	;;
+	esac
+
+fi
+
+
+
+
+
+
+
+
+OPENSSL_BIO_METHOD_DESCRIP="OpenSSL BIO Method Support"
+OPENSSL_BIO_METHOD_OPTION=crypto
+OPENSSL_BIO_METHOD_DIR=${CRYPTO_DIR}
+
+PBX_OPENSSL_BIO_METHOD=0
+
+
+
+
+
+
+
+# If neither --without-ssl (PBX_OPENSSL=-1) nor --without-crypto (PBX_CRYPTO=-1)
+# and there were no directories atdded to --with-ssl and --with-crypto, and
+# pkg-config is installed (which is should be by install_prereq).
+if test "x$PKG_CONFIG" != "x" -a $PBX_OPENSSL -ge 0 -a $PBX_CRYPTO -ge 0 -a "x$OPENSSL_DIR" == "x" ; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking OPENSSL with pkg-config" >&5
+$as_echo "$as_me: checking OPENSSL with pkg-config" >&6;}
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system openssl > 1.1.0" >&5
+$as_echo "$as_me: checking whether system openssl > 1.1.0" >&6;}
+
+   if test "x${PBX_OPENSSL}" != "x1" -a "${USE_OPENSSL}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5
+$as_echo_n "checking for OPENSSL... " >&6; }
+
+if test -n "$OPENSSL_CFLAGS"; then
+    pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl >= 1.1.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "openssl >= 1.1.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl >= 1.1.0" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$OPENSSL_LIBS"; then
+    pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl >= 1.1.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "openssl >= 1.1.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl >= 1.1.0" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl >= 1.1.0" 2>&1`
+        else
+	        OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl >= 1.1.0" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$OPENSSL_PKG_ERRORS" >&5
+
+
+            PBX_OPENSSL=0
+
+
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+            PBX_OPENSSL=0
+
+
+else
+	OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS
+	OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+            PBX_OPENSSL=1
+            OPENSSL_INCLUDE=$(echo ${OPENSSL_CFLAGS} | $SED -e "s|-std=c99||g")
+            OPENSSL_LIB="$OPENSSL_LIBS"
+
+$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h
+
+
+fi
+   fi
+
+	if test $PBX_OPENSSL -eq 0 ; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether alternate openssl11 is installed" >&5
+$as_echo "$as_me: checking whether alternate openssl11 is installed" >&6;}
+
+   if test "x${PBX_OPENSSL}" != "x1" -a "${USE_OPENSSL}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5
+$as_echo_n "checking for OPENSSL... " >&6; }
+
+if test -n "$OPENSSL_CFLAGS"; then
+    pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl11\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "openssl11") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl11" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$OPENSSL_LIBS"; then
+    pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl11\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "openssl11") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl11" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl11" 2>&1`
+        else
+	        OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl11" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$OPENSSL_PKG_ERRORS" >&5
+
+
+            PBX_OPENSSL=0
+
+
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+            PBX_OPENSSL=0
+
+
+else
+	OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS
+	OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+            PBX_OPENSSL=1
+            OPENSSL_INCLUDE=$(echo ${OPENSSL_CFLAGS} | $SED -e "s|-std=c99||g")
+            OPENSSL_LIB="$OPENSSL_LIBS"
+
+$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h
+
+
+fi
+   fi
+
+	fi
+	if test $PBX_OPENSSL -eq 1 ; then
+		$as_echo "#define HAVE_OPENSSL_BIO_METHOD 1" >>confdefs.h
+
+		PBX_OPENSSL_BIO_METHOD=1
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking fallback system openssl" >&5
+$as_echo "$as_me: checking fallback system openssl" >&6;}
+
+   if test "x${PBX_OPENSSL}" != "x1" -a "${USE_OPENSSL}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5
+$as_echo_n "checking for OPENSSL... " >&6; }
+
+if test -n "$OPENSSL_CFLAGS"; then
+    pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "openssl") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$OPENSSL_LIBS"; then
+    pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "openssl") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl" 2>&1`
+        else
+	        OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$OPENSSL_PKG_ERRORS" >&5
+
+
+            PBX_OPENSSL=0
+
+
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+            PBX_OPENSSL=0
+
+
+else
+	OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS
+	OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+            PBX_OPENSSL=1
+            OPENSSL_INCLUDE=$(echo ${OPENSSL_CFLAGS} | $SED -e "s|-std=c99||g")
+            OPENSSL_LIB="$OPENSSL_LIBS"
+
+$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h
+
+
+fi
+   fi
+
+	fi
+
+	if test $PBX_OPENSSL -eq 1; then
+		$as_echo "#define HAVE_CRYPTO 1" >>confdefs.h
+
+		PBX_CRYPTO=1
+	fi
+else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: Checking OPENSSL without pkg-config" >&5
+$as_echo "$as_me: Checking OPENSSL without pkg-config" >&6;}
+
+if test "x${PBX_CRYPTO}" != "x1" -a "${USE_CRYPTO}" != "no"; then
+   pbxlibdir=""
+   # if --with-CRYPTO=DIR has been specified, use it.
+   if test "x${CRYPTO_DIR}" != "x"; then
+      if test -d ${CRYPTO_DIR}/lib; then
+         pbxlibdir="-L${CRYPTO_DIR}/lib"
+      else
+         pbxlibdir="-L${CRYPTO_DIR}"
+      fi
+   fi
+
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AES_encrypt in -lcrypto" >&5
+$as_echo_n "checking for AES_encrypt in -lcrypto... " >&6; }
+if ${ac_cv_lib_crypto_AES_encrypt+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto ${pbxlibdir}  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char AES_encrypt ();
+int
+main ()
+{
+return AES_encrypt ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_crypto_AES_encrypt=yes
+else
+  ac_cv_lib_crypto_AES_encrypt=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_AES_encrypt" >&5
+$as_echo "$ac_cv_lib_crypto_AES_encrypt" >&6; }
+if test "x$ac_cv_lib_crypto_AES_encrypt" = xyes; then :
+  AST_CRYPTO_FOUND=yes
+else
+  AST_CRYPTO_FOUND=no
+fi
+
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+
+
+   # now check for the header.
+   if test "${AST_CRYPTO_FOUND}" = "yes"; then
+      CRYPTO_LIB="${pbxlibdir} -lcrypto "
+      # if --with-CRYPTO=DIR has been specified, use it.
+      if test "x${CRYPTO_DIR}" != "x"; then
+         CRYPTO_INCLUDE="-I${CRYPTO_DIR}/include"
+      fi
+      CRYPTO_INCLUDE="${CRYPTO_INCLUDE} "
+
+         # check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${CRYPTO_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "openssl/aes.h" "ac_cv_header_openssl_aes_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_aes_h" = xyes; then :
+  CRYPTO_HEADER_FOUND=1
+else
+  CRYPTO_HEADER_FOUND=0
+fi
+
+
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+
+      if test "x${CRYPTO_HEADER_FOUND}" = "x0" ; then
+         CRYPTO_LIB=""
+         CRYPTO_INCLUDE=""
+      else
+
+         PBX_CRYPTO=1
+         cat >>confdefs.h <<_ACEOF
+#define HAVE_CRYPTO 1
+_ACEOF
+
+      fi
+   fi
+fi
+
+
+	if test "$PBX_CRYPTO" = "1";
+	then
+
+if test "x${PBX_OPENSSL}" != "x1" -a "${USE_OPENSSL}" != "no"; then
+   pbxlibdir=""
+   # if --with-OPENSSL=DIR has been specified, use it.
+   if test "x${OPENSSL_DIR}" != "x"; then
+      if test -d ${OPENSSL_DIR}/lib; then
+         pbxlibdir="-L${OPENSSL_DIR}/lib"
+      else
+         pbxlibdir="-L${OPENSSL_DIR}"
+      fi
+   fi
+
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_connect in -lssl" >&5
+$as_echo_n "checking for SSL_connect in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_SSL_connect+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lssl ${pbxlibdir} -lcrypto $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char SSL_connect ();
+int
+main ()
+{
+return SSL_connect ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_ssl_SSL_connect=yes
+else
+  ac_cv_lib_ssl_SSL_connect=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_connect" >&5
+$as_echo "$ac_cv_lib_ssl_SSL_connect" >&6; }
+if test "x$ac_cv_lib_ssl_SSL_connect" = xyes; then :
+  AST_OPENSSL_FOUND=yes
+else
+  AST_OPENSSL_FOUND=no
+fi
+
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+
+
+   # now check for the header.
+   if test "${AST_OPENSSL_FOUND}" = "yes"; then
+      OPENSSL_LIB="${pbxlibdir} -lssl -lcrypto"
+      # if --with-OPENSSL=DIR has been specified, use it.
+      if test "x${OPENSSL_DIR}" != "x"; then
+         OPENSSL_INCLUDE="-I${OPENSSL_DIR}/include"
+      fi
+      OPENSSL_INCLUDE="${OPENSSL_INCLUDE} "
+
+         # check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${OPENSSL_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_ssl_h" = xyes; then :
+  OPENSSL_HEADER_FOUND=1
+else
+  OPENSSL_HEADER_FOUND=0
+fi
+
+
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+
+      if test "x${OPENSSL_HEADER_FOUND}" = "x0" ; then
+         OPENSSL_LIB=""
+         OPENSSL_INCLUDE=""
+      else
+
+         PBX_OPENSSL=1
+         cat >>confdefs.h <<_ACEOF
+#define HAVE_OPENSSL 1
+_ACEOF
+
+      fi
+   fi
+fi
+
+
+
+if test "x${PBX_OPENSSL_BIO_METHOD}" != "x1" -a "${USE_OPENSSL_BIO_METHOD}" != "no"; then
+   pbxlibdir=""
+   # if --with-OPENSSL_BIO_METHOD=DIR has been specified, use it.
+   if test "x${OPENSSL_BIO_METHOD_DIR}" != "x"; then
+      if test -d ${OPENSSL_BIO_METHOD_DIR}/lib; then
+         pbxlibdir="-L${OPENSSL_BIO_METHOD_DIR}/lib"
+      else
+         pbxlibdir="-L${OPENSSL_BIO_METHOD_DIR}"
+      fi
+   fi
+
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_meth_new in -lssl" >&5
+$as_echo_n "checking for BIO_meth_new in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_BIO_meth_new+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lssl ${pbxlibdir} -lcrypto $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char BIO_meth_new ();
+int
+main ()
+{
+return BIO_meth_new ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_ssl_BIO_meth_new=yes
+else
+  ac_cv_lib_ssl_BIO_meth_new=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_BIO_meth_new" >&5
+$as_echo "$ac_cv_lib_ssl_BIO_meth_new" >&6; }
+if test "x$ac_cv_lib_ssl_BIO_meth_new" = xyes; then :
+  AST_OPENSSL_BIO_METHOD_FOUND=yes
+else
+  AST_OPENSSL_BIO_METHOD_FOUND=no
+fi
+
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+
+
+   # now check for the header.
+   if test "${AST_OPENSSL_BIO_METHOD_FOUND}" = "yes"; then
+      OPENSSL_BIO_METHOD_LIB="${pbxlibdir} -lssl -lcrypto"
+      # if --with-OPENSSL_BIO_METHOD=DIR has been specified, use it.
+      if test "x${OPENSSL_BIO_METHOD_DIR}" != "x"; then
+         OPENSSL_BIO_METHOD_INCLUDE="-I${OPENSSL_BIO_METHOD_DIR}/include"
+      fi
+      OPENSSL_BIO_METHOD_INCLUDE="${OPENSSL_BIO_METHOD_INCLUDE} "
+
+         # check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${OPENSSL_BIO_METHOD_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_ssl_h" = xyes; then :
+  OPENSSL_BIO_METHOD_HEADER_FOUND=1
+else
+  OPENSSL_BIO_METHOD_HEADER_FOUND=0
+fi
+
+
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+
+      if test "x${OPENSSL_BIO_METHOD_HEADER_FOUND}" = "x0" ; then
+         OPENSSL_BIO_METHOD_LIB=""
+         OPENSSL_BIO_METHOD_INCLUDE=""
+      else
+
+         PBX_OPENSSL_BIO_METHOD=1
+         cat >>confdefs.h <<_ACEOF
+#define HAVE_OPENSSL_BIO_METHOD 1
+_ACEOF
+
+      fi
+   fi
+fi
+
+
+	fi
+fi
+if test $PBX_OPENSSL -eq 0 ; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: OpenSSL does not seem to be installed" >&5
+$as_echo "$as_me: WARNING: OpenSSL does not seem to be installed" >&2;}
+fi
+
+
+
+
+	if test "$JANSSON_BUNDLED" = "yes" ; then
+
+	if test "${ac_mandatory_list#*JANSSON*}" != "$ac_mandatory_list" ; then
+		as_fn_error $? "--with-jansson and --with-jansson-bundled can't both be specified" "$LINENO" 5
+	fi
+
+	ac_mandatory_list="$ac_mandatory_list JANSSON"
+	JANSSON_DIR="${ac_pwd}/third-party/jansson"
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for embedded jansson (may have to download)" >&5
+$as_echo_n "checking for embedded jansson (may have to download)... " >&6; }
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: configuring" >&5
+$as_echo "configuring" >&6; }
+
+	if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then
+		as_fn_error $? "A download utility (wget, curl, or fetch) is required to download bundled jansson" "$LINENO" 5
+	fi
+	if test "${BZIP2}" = ":" ; then
+		as_fn_error $? "bzip2 is required to extract the jansson tar file" "$LINENO" 5
+	fi
+	if test "${TAR}" = ":" ; then
+		as_fn_error $? "tar is required to extract the jansson tar file" "$LINENO" 5
+	fi
+	if test "${PATCH}" = ":" ; then
+		as_fn_error $? "patch is required to configure bundled jansson" "$LINENO" 5
+	fi
+	if test "${SED}" = ":" ; then
+		as_fn_error $? "sed is required to configure bundled jansson" "$LINENO" 5
+	fi
+	if test "${NM}" = ":" ; then
+		as_fn_error $? "nm is required to build bundled jansson" "$LINENO" 5
+	fi
+	if test "${MD5}" = ":" ; then
+		as_fn_error $? "md5sum is required to build bundled jansson" "$LINENO" 5
+	fi
+	if test "${CAT}" = ":" ; then
+		as_fn_error $? "cat is required to build bundled jansson" "$LINENO" 5
+	fi
+	if test "${CUT}" = ":" ; then
+		as_fn_error $? "cut is required to build bundled jansson" "$LINENO" 5
+	fi
+	if test "${GREP}" = ":" ; then
+		as_fn_error $? "grep is required to build bundled jansson" "$LINENO" 5
+	fi
+
+
+	this_host=$(./config.sub $(./config.guess))
+	if test "$build" != "$this_host" ; then
+		JANSSON_CONFIGURE_OPTS+=" --build=$build_alias"
+	fi
+	if test "$host" != "$this_host" ; then
+		JANSSON_CONFIGURE_OPTS+=" --host=$host_alias"
+	fi
+
+	export TAR PATCH SED NM EXTERNALS_CACHE_DIR AST_DOWNLOAD_CACHE DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT CUT GREP
+	export NOISY_BUILD
+	${GNU_MAKE} --quiet --no-print-directory -C ${JANSSON_DIR} \
+		JANSSON_CONFIGURE_OPTS="$JANSSON_CONFIGURE_OPTS" \
+		EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" \
+		configure
+	if test $? -ne 0 ; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: Unable to configure ${JANSSON_DIR}" >&5
 $as_echo "$as_me: Unable to configure ${JANSSON_DIR}" >&6;}
 		as_fn_error $? "Re-run the ./configure command with 'NOISY_BUILD=yes' appended to see error details." "$LINENO" 5
 	fi
@@ -9362,6 +10164,7 @@ $as_echo "#define HAVE_PJPROJECT_ON_VALID_ICE_PAIR_CALLBACK 1" >>confdefs.h
 
 
 
+
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
@@ -9653,50 +10456,6 @@ fi
 
 
 
-    CRYPTO_DESCRIP="OpenSSL Cryptography"
-    CRYPTO_OPTION="crypto"
-    PBX_CRYPTO=0
-
-# Check whether --with-crypto was given.
-if test "${with_crypto+set}" = set; then :
-  withval=$with_crypto;
-	case ${withval} in
-	n|no)
-	USE_CRYPTO=no
-	# -1 is a magic value used by menuselect to know that the package
-	# was disabled, other than 'not found'
-	PBX_CRYPTO=-1
-	;;
-	y|ye|yes)
-	ac_mandatory_list="${ac_mandatory_list} CRYPTO"
-	;;
-	*)
-	CRYPTO_DIR="${withval}"
-	ac_mandatory_list="${ac_mandatory_list} CRYPTO"
-	;;
-	esac
-
-fi
-
-
-
-
-
-
-
-
-OPENSSL_BIO_METHOD_DESCRIP="OpenSSL BIO Method Support"
-OPENSSL_BIO_METHOD_OPTION=crypto
-OPENSSL_BIO_METHOD_DIR=${CRYPTO_DIR}
-
-PBX_OPENSSL_BIO_METHOD=0
-
-
-
-
-
-
-
     DAHDI_DESCRIP="DAHDI"
     DAHDI_OPTION="dahdi"
     PBX_DAHDI=0
@@ -12400,38 +13159,6 @@ PBX_SRTP_GET_VERSION=0
 
 
 
-    OPENSSL_DESCRIP="OpenSSL Secure Sockets Layer"
-    OPENSSL_OPTION="ssl"
-    PBX_OPENSSL=0
-
-# Check whether --with-ssl was given.
-if test "${with_ssl+set}" = set; then :
-  withval=$with_ssl;
-	case ${withval} in
-	n|no)
-	USE_OPENSSL=no
-	# -1 is a magic value used by menuselect to know that the package
-	# was disabled, other than 'not found'
-	PBX_OPENSSL=-1
-	;;
-	y|ye|yes)
-	ac_mandatory_list="${ac_mandatory_list} OPENSSL"
-	;;
-	*)
-	OPENSSL_DIR="${withval}"
-	ac_mandatory_list="${ac_mandatory_list} OPENSSL"
-	;;
-	esac
-
-fi
-
-
-
-
-
-
-
-
 RT_DESCRIP="Realtime functions"
 
 RT_DIR=${rt_DIR}
@@ -13187,182 +13914,61 @@ ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE
 #  include <netdb.h>
 #endif
 "
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-if test "$ac_cv_header_resolv_h" != "yes"; then
-  as_fn_error $? "*** resolv.h is required." "$LINENO" 5
-fi
-
-# Check for headers that are unconditionally required on all platforms.  Do not use
-# this to check for headers that are only needed by modules.
-for ac_header in  \
-  arpa/nameser.h assert.h ctype.h dlfcn.h errno.h fcntl.h float.h grp.h \
-  inttypes.h limits.h locale.h math.h pwd.h netinet/in.h regex.h \
-  sched.h stdarg.h stdint.h stdio.h stdlib.h string.h syslog.h \
-  sys/file.h sys/ioctl.h sys/param.h sys/resource.h sys/socket.h sys/stat.h \
-  sys/time.h sys/types.h sys/un.h \
-  termios.h time.h unistd.h \
-
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-else
-
-  as_fn_error $? "*** A required header was not found." "$LINENO" 5
-
-fi
-
-done
-
-
-for ac_header in arpa/inet.h libintl.h malloc.h netdb.h stddef.h strings.h sys/event.h utime.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-
-
-
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-	if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
-set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_PKG_CONFIG+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-if test -n "$PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-$as_echo "$PKG_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_path_PKG_CONFIG"; then
-  ac_pt_PKG_CONFIG=$PKG_CONFIG
-  # Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ac_pt_PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
 
-  ;;
-esac
 fi
-ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
-if test -n "$ac_pt_PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
-$as_echo "$ac_pt_PKG_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+
+done
+
+
+if test "$ac_cv_header_resolv_h" != "yes"; then
+  as_fn_error $? "*** resolv.h is required." "$LINENO" 5
 fi
 
-  if test "x$ac_pt_PKG_CONFIG" = x; then
-    PKG_CONFIG=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    PKG_CONFIG=$ac_pt_PKG_CONFIG
-  fi
+# Check for headers that are unconditionally required on all platforms.  Do not use
+# this to check for headers that are only needed by modules.
+for ac_header in  \
+  arpa/nameser.h assert.h ctype.h dlfcn.h errno.h fcntl.h float.h grp.h \
+  inttypes.h limits.h locale.h math.h pwd.h netinet/in.h regex.h \
+  sched.h stdarg.h stdint.h stdio.h stdlib.h string.h syslog.h \
+  sys/file.h sys/ioctl.h sys/param.h sys/resource.h sys/socket.h sys/stat.h \
+  sys/time.h sys/types.h sys/un.h \
+  termios.h time.h unistd.h \
+
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
 else
-  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
-fi
+
+  as_fn_error $? "*** A required header was not found." "$LINENO" 5
 
 fi
-if test -n "$PKG_CONFIG"; then
-	_pkg_min_version=0.9.0
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
-$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
-	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; 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; }
-		PKG_CONFIG=""
-	fi
+
+done
+
+
+for ac_header in arpa/inet.h libintl.h malloc.h netdb.h stddef.h strings.h sys/event.h utime.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
 fi
 
+done
+
+
 # Find required NetBSD Editline library (libedit).
 
    if test "x${PBX_LIBEDIT}" != "x1" -a "${USE_LIBEDIT}" != "no"; then
@@ -14685,7 +15291,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -14731,7 +15337,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -14755,7 +15361,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -14800,7 +15406,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -14824,7 +15430,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -16124,8 +16730,6 @@ main ()
     if (*(data + i) != *(data3 + i))
       return 14;
   close (fd);
-  free (data);
-  free (data3);
   return 0;
 }
 _ACEOF
@@ -25937,263 +26541,87 @@ if ${ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2+:} false; then :
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lpjsip ${pbxlibdir} $PJPROJECT_LIB $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pjsip_tsx_layer_find_tsx2 ();
-int
-main ()
-{
-return pjsip_tsx_layer_find_tsx2 ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2=yes
-else
-  ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2" >&5
-$as_echo "$ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2" >&6; }
-if test "x$ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2" = xyes; then :
-  AST_PJSIP_TSX_LAYER_FIND_TSX2_FOUND=yes
-else
-  AST_PJSIP_TSX_LAYER_FIND_TSX2_FOUND=no
-fi
-
-      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
-
-
-   # now check for the header.
-   if test "${AST_PJSIP_TSX_LAYER_FIND_TSX2_FOUND}" = "yes"; then
-      PJSIP_TSX_LAYER_FIND_TSX2_LIB="${pbxlibdir} -lpjsip $PJPROJECT_LIB"
-      # if --with-PJSIP_TSX_LAYER_FIND_TSX2=DIR has been specified, use it.
-      if test "x${PJSIP_TSX_LAYER_FIND_TSX2_DIR}" != "x"; then
-         PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE="-I${PJSIP_TSX_LAYER_FIND_TSX2_DIR}/include"
-      fi
-      PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE="${PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE} $PJPROJECT_CFLAGS"
-
-         # check for the header
-         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "pjsip.h" "ac_cv_header_pjsip_h" "$ac_includes_default"
-if test "x$ac_cv_header_pjsip_h" = xyes; then :
-  PJSIP_TSX_LAYER_FIND_TSX2_HEADER_FOUND=1
-else
-  PJSIP_TSX_LAYER_FIND_TSX2_HEADER_FOUND=0
-fi
-
-
-         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
-      if test "x${PJSIP_TSX_LAYER_FIND_TSX2_HEADER_FOUND}" = "x0" ; then
-         PJSIP_TSX_LAYER_FIND_TSX2_LIB=""
-         PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE=""
-      else
-
-         PBX_PJSIP_TSX_LAYER_FIND_TSX2=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_PJSIP_TSX_LAYER_FIND_TSX2 1
-_ACEOF
-
-      fi
-   fi
-fi
-
-
-      fi
-   fi
-
-   if test "x$PBX_PJPROJECT" = "x1" ; then
-      if test "x${AST_DEVMODE}" = "xyes" ; then
-
-
-
-   if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
-$as_echo_n "checking for PYTHONDEV... " >&6; }
-
-if test -n "$PYTHONDEV_CFLAGS"; then
-    pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-2.7\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "python-2.7") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python-2.7" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$PYTHONDEV_LIBS"; then
-    pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-2.7\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "python-2.7") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python-2.7" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python-2.7" 2>&1`
-        else
-	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python-2.7" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$PYTHONDEV_PKG_ERRORS" >&5
-
-
-            PBX_PYTHONDEV=0
-
-
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-            PBX_PYTHONDEV=0
-
-
-else
-	PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
-	PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-            PBX_PYTHONDEV=1
-            PYTHONDEV_INCLUDE=$(echo ${PYTHONDEV_CFLAGS} | $SED -e "s|-std=c99||g")
-            PYTHONDEV_LIB="$PYTHONDEV_LIBS"
-
-$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
-
-
-fi
-   fi
-
-
-   if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
-$as_echo_n "checking for PYTHONDEV... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-if test -n "$PYTHONDEV_CFLAGS"; then
-    pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "python2") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python2" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pjsip_tsx_layer_find_tsx2 ();
+int
+main ()
+{
+return pjsip_tsx_layer_find_tsx2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2=yes
 else
-  pkg_failed=yes
+  ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2=no
 fi
- else
-    pkg_failed=untried
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-if test -n "$PYTHONDEV_LIBS"; then
-    pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "python2") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python2" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2" >&5
+$as_echo "$ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2" >&6; }
+if test "x$ac_cv_lib_pjsip_pjsip_tsx_layer_find_tsx2" = xyes; then :
+  AST_PJSIP_TSX_LAYER_FIND_TSX2_FOUND=yes
 else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
+  AST_PJSIP_TSX_LAYER_FIND_TSX2_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
-if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+   # now check for the header.
+   if test "${AST_PJSIP_TSX_LAYER_FIND_TSX2_FOUND}" = "yes"; then
+      PJSIP_TSX_LAYER_FIND_TSX2_LIB="${pbxlibdir} -lpjsip $PJPROJECT_LIB"
+      # if --with-PJSIP_TSX_LAYER_FIND_TSX2=DIR has been specified, use it.
+      if test "x${PJSIP_TSX_LAYER_FIND_TSX2_DIR}" != "x"; then
+         PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE="-I${PJSIP_TSX_LAYER_FIND_TSX2_DIR}/include"
+      fi
+      PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE="${PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE} $PJPROJECT_CFLAGS"
 
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
+         # check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "pjsip.h" "ac_cv_header_pjsip_h" "$ac_includes_default"
+if test "x$ac_cv_header_pjsip_h" = xyes; then :
+  PJSIP_TSX_LAYER_FIND_TSX2_HEADER_FOUND=1
 else
-        _pkg_short_errors_supported=no
+  PJSIP_TSX_LAYER_FIND_TSX2_HEADER_FOUND=0
 fi
-        if test $_pkg_short_errors_supported = yes; then
-	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python2" 2>&1`
-        else
-	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python2" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$PYTHONDEV_PKG_ERRORS" >&5
-
-
-            PBX_PYTHONDEV=0
 
 
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-            PBX_PYTHONDEV=0
+      if test "x${PJSIP_TSX_LAYER_FIND_TSX2_HEADER_FOUND}" = "x0" ; then
+         PJSIP_TSX_LAYER_FIND_TSX2_LIB=""
+         PJSIP_TSX_LAYER_FIND_TSX2_INCLUDE=""
+      else
 
+         PBX_PJSIP_TSX_LAYER_FIND_TSX2=1
+         cat >>confdefs.h <<_ACEOF
+#define HAVE_PJSIP_TSX_LAYER_FIND_TSX2 1
+_ACEOF
 
-else
-	PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
-	PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+      fi
+   fi
+fi
 
-            PBX_PYTHONDEV=1
-            PYTHONDEV_INCLUDE=$(echo ${PYTHONDEV_CFLAGS} | $SED -e "s|-std=c99||g")
-            PYTHONDEV_LIB="$PYTHONDEV_LIBS"
 
-$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
+      fi
+   fi
 
+   if test "x$PBX_PJPROJECT" = "x1" ; then
+      if test "x${AST_DEVMODE}" = "xyes" ; then
 
-fi
-   fi
 
 
    if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
@@ -26206,12 +26634,12 @@ if test -n "$PYTHONDEV_CFLAGS"; then
     pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "python") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-2.7\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "python-2.7") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python" 2>/dev/null`
+  pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python-2.7" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -26223,12 +26651,12 @@ if test -n "$PYTHONDEV_LIBS"; then
     pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "python") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-2.7\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "python-2.7") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python" 2>/dev/null`
+  pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python-2.7" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -26249,9 +26677,9 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python" 2>&1`
+	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python-2.7" 2>&1`
         else
-	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python" 2>&1`
+	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python-2.7" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$PYTHONDEV_PKG_ERRORS" >&5
@@ -26283,131 +26711,23 @@ $as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
 fi
    fi
 
-         # The PJProject offers a C extension to Python. That wrapper is used by the
-         # Asterisk Test Framework, which requires Asterisk to be in Developer Mode.
-         # However, the used wrapper (called 'PJSUA Python') is deprecated and was not
-         # ported from Python 2.7 to Python 3.x. This is confirmed; it simply does not
-         # build. For more see <http://www.pjsip.org/trac/wiki/Python_SIP_Tutorial>.
-         # Therefore, the C libraries for Python 3 are of no help in Asterisk:
-         #AST_PKG_CONFIG_CHECK([PYTHONDEV], [python3])
-      fi
-   fi
-fi
-
-
-if test "x${PBX_POPT}" != "x1" -a "${USE_POPT}" != "no"; then
-   pbxlibdir=""
-   # if --with-POPT=DIR has been specified, use it.
-   if test "x${POPT_DIR}" != "x"; then
-      if test -d ${POPT_DIR}/lib; then
-         pbxlibdir="-L${POPT_DIR}/lib"
-      else
-         pbxlibdir="-L${POPT_DIR}"
-      fi
-   fi
-
-      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for poptStrerror in -lpopt" >&5
-$as_echo_n "checking for poptStrerror in -lpopt... " >&6; }
-if ${ac_cv_lib_popt_poptStrerror+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpopt ${pbxlibdir}  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char poptStrerror ();
-int
-main ()
-{
-return poptStrerror ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_popt_poptStrerror=yes
-else
-  ac_cv_lib_popt_poptStrerror=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_popt_poptStrerror" >&5
-$as_echo "$ac_cv_lib_popt_poptStrerror" >&6; }
-if test "x$ac_cv_lib_popt_poptStrerror" = xyes; then :
-  AST_POPT_FOUND=yes
-else
-  AST_POPT_FOUND=no
-fi
-
-      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
-
-
-   # now check for the header.
-   if test "${AST_POPT_FOUND}" = "yes"; then
-      POPT_LIB="${pbxlibdir} -lpopt "
-      # if --with-POPT=DIR has been specified, use it.
-      if test "x${POPT_DIR}" != "x"; then
-         POPT_INCLUDE="-I${POPT_DIR}/include"
-      fi
-      POPT_INCLUDE="${POPT_INCLUDE} "
-
-         # check for the header
-         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${POPT_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "popt.h" "ac_cv_header_popt_h" "$ac_includes_default"
-if test "x$ac_cv_header_popt_h" = xyes; then :
-  POPT_HEADER_FOUND=1
-else
-  POPT_HEADER_FOUND=0
-fi
-
-
-         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
-      if test "x${POPT_HEADER_FOUND}" = "x0" ; then
-         POPT_LIB=""
-         POPT_INCLUDE=""
-      else
-
-         PBX_POPT=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_POPT 1
-_ACEOF
-
-      fi
-   fi
-fi
-
-
-
 
-   if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
+   if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
 
 pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PORTAUDIO" >&5
-$as_echo_n "checking for PORTAUDIO... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
+$as_echo_n "checking for PYTHONDEV... " >&6; }
 
-if test -n "$PORTAUDIO_CFLAGS"; then
-    pkg_cv_PORTAUDIO_CFLAGS="$PORTAUDIO_CFLAGS"
+if test -n "$PYTHONDEV_CFLAGS"; then
+    pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "python2") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_PORTAUDIO_CFLAGS=`$PKG_CONFIG --cflags "portaudio-2.0" 2>/dev/null`
+  pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python2" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -26415,16 +26735,16 @@ fi
  else
     pkg_failed=untried
 fi
-if test -n "$PORTAUDIO_LIBS"; then
-    pkg_cv_PORTAUDIO_LIBS="$PORTAUDIO_LIBS"
+if test -n "$PYTHONDEV_LIBS"; then
+    pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "python2") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_PORTAUDIO_LIBS=`$PKG_CONFIG --libs "portaudio-2.0" 2>/dev/null`
+  pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python2" 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -26445,255 +26765,160 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "portaudio-2.0" 2>&1`
+	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python2" 2>&1`
         else
-	        PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "portaudio-2.0" 2>&1`
+	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python2" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$PORTAUDIO_PKG_ERRORS" >&5
+	echo "$PYTHONDEV_PKG_ERRORS" >&5
 
 
-            PBX_PORTAUDIO=0
+            PBX_PYTHONDEV=0
 
 
 elif test $pkg_failed = untried; then
      	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 
-            PBX_PORTAUDIO=0
+            PBX_PYTHONDEV=0
 
 
 else
-	PORTAUDIO_CFLAGS=$pkg_cv_PORTAUDIO_CFLAGS
-	PORTAUDIO_LIBS=$pkg_cv_PORTAUDIO_LIBS
+	PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
+	PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-            PBX_PORTAUDIO=1
-            PORTAUDIO_INCLUDE=$(echo ${PORTAUDIO_CFLAGS} | $SED -e "s|-std=c99||g")
-            PORTAUDIO_LIB="$PORTAUDIO_LIBS"
+            PBX_PYTHONDEV=1
+            PYTHONDEV_INCLUDE=$(echo ${PYTHONDEV_CFLAGS} | $SED -e "s|-std=c99||g")
+            PYTHONDEV_LIB="$PYTHONDEV_LIBS"
 
-$as_echo "#define HAVE_PORTAUDIO 1" >>confdefs.h
+$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
 
 
 fi
    fi
 
 
-if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
-   pbxlibdir=""
-   # if --with-PORTAUDIO=DIR has been specified, use it.
-   if test "x${PORTAUDIO_DIR}" != "x"; then
-      if test -d ${PORTAUDIO_DIR}/lib; then
-         pbxlibdir="-L${PORTAUDIO_DIR}/lib"
-      else
-         pbxlibdir="-L${PORTAUDIO_DIR}"
-      fi
-   fi
+   if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
 
-      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Pa_GetDeviceCount in -lportaudio" >&5
-$as_echo_n "checking for Pa_GetDeviceCount in -lportaudio... " >&6; }
-if ${ac_cv_lib_portaudio_Pa_GetDeviceCount+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lportaudio ${pbxlibdir}  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
+$as_echo_n "checking for PYTHONDEV... " >&6; }
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char Pa_GetDeviceCount ();
-int
-main ()
-{
-return Pa_GetDeviceCount ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_portaudio_Pa_GetDeviceCount=yes
+if test -n "$PYTHONDEV_CFLAGS"; then
+    pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "python") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_portaudio_Pa_GetDeviceCount=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_portaudio_Pa_GetDeviceCount" >&5
-$as_echo "$ac_cv_lib_portaudio_Pa_GetDeviceCount" >&6; }
-if test "x$ac_cv_lib_portaudio_Pa_GetDeviceCount" = xyes; then :
-  AST_PORTAUDIO_FOUND=yes
+if test -n "$PYTHONDEV_LIBS"; then
+    pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "python") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  AST_PORTAUDIO_FOUND=no
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
 fi
 
-      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
-   # now check for the header.
-   if test "${AST_PORTAUDIO_FOUND}" = "yes"; then
-      PORTAUDIO_LIB="${pbxlibdir} -lportaudio "
-      # if --with-PORTAUDIO=DIR has been specified, use it.
-      if test "x${PORTAUDIO_DIR}" != "x"; then
-         PORTAUDIO_INCLUDE="-I${PORTAUDIO_DIR}/include"
-      fi
-      PORTAUDIO_INCLUDE="${PORTAUDIO_INCLUDE} "
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-         # check for the header
-         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PORTAUDIO_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "portaudio.h" "ac_cv_header_portaudio_h" "$ac_includes_default"
-if test "x$ac_cv_header_portaudio_h" = xyes; then :
-  PORTAUDIO_HEADER_FOUND=1
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
 else
-  PORTAUDIO_HEADER_FOUND=0
+        _pkg_short_errors_supported=no
 fi
+        if test $_pkg_short_errors_supported = yes; then
+	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python" 2>&1`
+        else
+	        PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$PYTHONDEV_PKG_ERRORS" >&5
 
 
-         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
-      if test "x${PORTAUDIO_HEADER_FOUND}" = "x0" ; then
-         PORTAUDIO_LIB=""
-         PORTAUDIO_INCLUDE=""
-      else
-
-         PBX_PORTAUDIO=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_PORTAUDIO 1
-_ACEOF
-
-      fi
-   fi
-fi
-
+            PBX_PYTHONDEV=0
 
 
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 
-if test "x${PBX_PRI}" != "x1" -a "${USE_PRI}" != "no"; then
-   pbxlibdir=""
-   # if --with-PRI=DIR has been specified, use it.
-   if test "x${PRI_DIR}" != "x"; then
-      if test -d ${PRI_DIR}/lib; then
-         pbxlibdir="-L${PRI_DIR}/lib"
-      else
-         pbxlibdir="-L${PRI_DIR}"
-      fi
-   fi
+            PBX_PYTHONDEV=0
 
-      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_connected_line_update in -lpri" >&5
-$as_echo_n "checking for pri_connected_line_update in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_connected_line_update+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpri ${pbxlibdir}  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pri_connected_line_update ();
-int
-main ()
-{
-return pri_connected_line_update ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_connected_line_update=yes
-else
-  ac_cv_lib_pri_pri_connected_line_update=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_connected_line_update" >&5
-$as_echo "$ac_cv_lib_pri_pri_connected_line_update" >&6; }
-if test "x$ac_cv_lib_pri_pri_connected_line_update" = xyes; then :
-  AST_PRI_FOUND=yes
 else
-  AST_PRI_FOUND=no
-fi
+	PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
+	PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
 
-      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+            PBX_PYTHONDEV=1
+            PYTHONDEV_INCLUDE=$(echo ${PYTHONDEV_CFLAGS} | $SED -e "s|-std=c99||g")
+            PYTHONDEV_LIB="$PYTHONDEV_LIBS"
 
+$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
 
-   # now check for the header.
-   if test "${AST_PRI_FOUND}" = "yes"; then
-      PRI_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI=DIR has been specified, use it.
-      if test "x${PRI_DIR}" != "x"; then
-         PRI_INCLUDE="-I${PRI_DIR}/include"
-      fi
-      PRI_INCLUDE="${PRI_INCLUDE} "
 
-         # check for the header
-         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
-if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_HEADER_FOUND=1
-else
-  PRI_HEADER_FOUND=0
 fi
+   fi
 
-
-         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
-      if test "x${PRI_HEADER_FOUND}" = "x0" ; then
-         PRI_LIB=""
-         PRI_INCLUDE=""
-      else
-
-         PBX_PRI=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI 1
-_ACEOF
-
+         # The PJProject offers a C extension to Python. That wrapper is used by the
+         # Asterisk Test Framework, which requires Asterisk to be in Developer Mode.
+         # However, the used wrapper (called 'PJSUA Python') is deprecated and was not
+         # ported from Python 2.7 to Python 3.x. This is confirmed; it simply does not
+         # build. For more see <http://www.pjsip.org/trac/wiki/Python_SIP_Tutorial>.
+         # Therefore, the C libraries for Python 3 are of no help in Asterisk:
+         #AST_PKG_CONFIG_CHECK([PYTHONDEV], [python3])
       fi
    fi
 fi
 
 
-if test "x$PBX_PRI" = "x1" ; then
-
-if test "x${PBX_PRI_SETUP_ACK_INBAND}" != "x1" -a "${USE_PRI_SETUP_ACK_INBAND}" != "no"; then
+if test "x${PBX_POPT}" != "x1" -a "${USE_POPT}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_SETUP_ACK_INBAND=DIR has been specified, use it.
-   if test "x${PRI_SETUP_ACK_INBAND_DIR}" != "x"; then
-      if test -d ${PRI_SETUP_ACK_INBAND_DIR}/lib; then
-         pbxlibdir="-L${PRI_SETUP_ACK_INBAND_DIR}/lib"
+   # if --with-POPT=DIR has been specified, use it.
+   if test "x${POPT_DIR}" != "x"; then
+      if test -d ${POPT_DIR}/lib; then
+         pbxlibdir="-L${POPT_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_SETUP_ACK_INBAND_DIR}"
+         pbxlibdir="-L${POPT_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_setup_ack in -lpri" >&5
-$as_echo_n "checking for pri_setup_ack in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_setup_ack+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for poptStrerror in -lpopt" >&5
+$as_echo_n "checking for poptStrerror in -lpopt... " >&6; }
+if ${ac_cv_lib_popt_poptStrerror+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpri ${pbxlibdir}  $LIBS"
+LIBS="-lpopt ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -26703,65 +26928,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_setup_ack ();
+char poptStrerror ();
 int
 main ()
 {
-return pri_setup_ack ();
+return poptStrerror ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_setup_ack=yes
+  ac_cv_lib_popt_poptStrerror=yes
 else
-  ac_cv_lib_pri_pri_setup_ack=no
+  ac_cv_lib_popt_poptStrerror=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_setup_ack" >&5
-$as_echo "$ac_cv_lib_pri_pri_setup_ack" >&6; }
-if test "x$ac_cv_lib_pri_pri_setup_ack" = xyes; then :
-  AST_PRI_SETUP_ACK_INBAND_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_popt_poptStrerror" >&5
+$as_echo "$ac_cv_lib_popt_poptStrerror" >&6; }
+if test "x$ac_cv_lib_popt_poptStrerror" = xyes; then :
+  AST_POPT_FOUND=yes
 else
-  AST_PRI_SETUP_ACK_INBAND_FOUND=no
+  AST_POPT_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_SETUP_ACK_INBAND_FOUND}" = "yes"; then
-      PRI_SETUP_ACK_INBAND_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_SETUP_ACK_INBAND=DIR has been specified, use it.
-      if test "x${PRI_SETUP_ACK_INBAND_DIR}" != "x"; then
-         PRI_SETUP_ACK_INBAND_INCLUDE="-I${PRI_SETUP_ACK_INBAND_DIR}/include"
+   if test "${AST_POPT_FOUND}" = "yes"; then
+      POPT_LIB="${pbxlibdir} -lpopt "
+      # if --with-POPT=DIR has been specified, use it.
+      if test "x${POPT_DIR}" != "x"; then
+         POPT_INCLUDE="-I${POPT_DIR}/include"
       fi
-      PRI_SETUP_ACK_INBAND_INCLUDE="${PRI_SETUP_ACK_INBAND_INCLUDE} "
+      POPT_INCLUDE="${POPT_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_SETUP_ACK_INBAND_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
-if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_SETUP_ACK_INBAND_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${POPT_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "popt.h" "ac_cv_header_popt_h" "$ac_includes_default"
+if test "x$ac_cv_header_popt_h" = xyes; then :
+  POPT_HEADER_FOUND=1
 else
-  PRI_SETUP_ACK_INBAND_HEADER_FOUND=0
+  POPT_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_SETUP_ACK_INBAND_HEADER_FOUND}" = "x0" ; then
-         PRI_SETUP_ACK_INBAND_LIB=""
-         PRI_SETUP_ACK_INBAND_INCLUDE=""
+      if test "x${POPT_HEADER_FOUND}" = "x0" ; then
+         POPT_LIB=""
+         POPT_INCLUDE=""
       else
 
-         PBX_PRI_SETUP_ACK_INBAND=1
+         PBX_POPT=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_SETUP_ACK_INBAND 1
+#define HAVE_POPT 1
 _ACEOF
 
       fi
@@ -26770,26 +26995,115 @@ fi
 
 
 
-if test "x${PBX_PRI_L2_PERSISTENCE}" != "x1" -a "${USE_PRI_L2_PERSISTENCE}" != "no"; then
+
+   if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PORTAUDIO" >&5
+$as_echo_n "checking for PORTAUDIO... " >&6; }
+
+if test -n "$PORTAUDIO_CFLAGS"; then
+    pkg_cv_PORTAUDIO_CFLAGS="$PORTAUDIO_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_PORTAUDIO_CFLAGS=`$PKG_CONFIG --cflags "portaudio-2.0" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$PORTAUDIO_LIBS"; then
+    pkg_cv_PORTAUDIO_LIBS="$PORTAUDIO_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_PORTAUDIO_LIBS=`$PKG_CONFIG --libs "portaudio-2.0" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "portaudio-2.0" 2>&1`
+        else
+	        PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "portaudio-2.0" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$PORTAUDIO_PKG_ERRORS" >&5
+
+
+            PBX_PORTAUDIO=0
+
+
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+            PBX_PORTAUDIO=0
+
+
+else
+	PORTAUDIO_CFLAGS=$pkg_cv_PORTAUDIO_CFLAGS
+	PORTAUDIO_LIBS=$pkg_cv_PORTAUDIO_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+            PBX_PORTAUDIO=1
+            PORTAUDIO_INCLUDE=$(echo ${PORTAUDIO_CFLAGS} | $SED -e "s|-std=c99||g")
+            PORTAUDIO_LIB="$PORTAUDIO_LIBS"
+
+$as_echo "#define HAVE_PORTAUDIO 1" >>confdefs.h
+
+
+fi
+   fi
+
+
+if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_L2_PERSISTENCE=DIR has been specified, use it.
-   if test "x${PRI_L2_PERSISTENCE_DIR}" != "x"; then
-      if test -d ${PRI_L2_PERSISTENCE_DIR}/lib; then
-         pbxlibdir="-L${PRI_L2_PERSISTENCE_DIR}/lib"
+   # if --with-PORTAUDIO=DIR has been specified, use it.
+   if test "x${PORTAUDIO_DIR}" != "x"; then
+      if test -d ${PORTAUDIO_DIR}/lib; then
+         pbxlibdir="-L${PORTAUDIO_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_L2_PERSISTENCE_DIR}"
+         pbxlibdir="-L${PORTAUDIO_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_persistent_layer2_option in -lpri" >&5
-$as_echo_n "checking for pri_persistent_layer2_option in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_persistent_layer2_option+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Pa_GetDeviceCount in -lportaudio" >&5
+$as_echo_n "checking for Pa_GetDeviceCount in -lportaudio... " >&6; }
+if ${ac_cv_lib_portaudio_Pa_GetDeviceCount+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpri ${pbxlibdir}  $LIBS"
+LIBS="-lportaudio ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -26799,65 +27113,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_persistent_layer2_option ();
+char Pa_GetDeviceCount ();
 int
 main ()
 {
-return pri_persistent_layer2_option ();
+return Pa_GetDeviceCount ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_persistent_layer2_option=yes
+  ac_cv_lib_portaudio_Pa_GetDeviceCount=yes
 else
-  ac_cv_lib_pri_pri_persistent_layer2_option=no
+  ac_cv_lib_portaudio_Pa_GetDeviceCount=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_persistent_layer2_option" >&5
-$as_echo "$ac_cv_lib_pri_pri_persistent_layer2_option" >&6; }
-if test "x$ac_cv_lib_pri_pri_persistent_layer2_option" = xyes; then :
-  AST_PRI_L2_PERSISTENCE_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_portaudio_Pa_GetDeviceCount" >&5
+$as_echo "$ac_cv_lib_portaudio_Pa_GetDeviceCount" >&6; }
+if test "x$ac_cv_lib_portaudio_Pa_GetDeviceCount" = xyes; then :
+  AST_PORTAUDIO_FOUND=yes
 else
-  AST_PRI_L2_PERSISTENCE_FOUND=no
+  AST_PORTAUDIO_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_L2_PERSISTENCE_FOUND}" = "yes"; then
-      PRI_L2_PERSISTENCE_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_L2_PERSISTENCE=DIR has been specified, use it.
-      if test "x${PRI_L2_PERSISTENCE_DIR}" != "x"; then
-         PRI_L2_PERSISTENCE_INCLUDE="-I${PRI_L2_PERSISTENCE_DIR}/include"
+   if test "${AST_PORTAUDIO_FOUND}" = "yes"; then
+      PORTAUDIO_LIB="${pbxlibdir} -lportaudio "
+      # if --with-PORTAUDIO=DIR has been specified, use it.
+      if test "x${PORTAUDIO_DIR}" != "x"; then
+         PORTAUDIO_INCLUDE="-I${PORTAUDIO_DIR}/include"
       fi
-      PRI_L2_PERSISTENCE_INCLUDE="${PRI_L2_PERSISTENCE_INCLUDE} "
+      PORTAUDIO_INCLUDE="${PORTAUDIO_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_L2_PERSISTENCE_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
-if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_L2_PERSISTENCE_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${PORTAUDIO_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "portaudio.h" "ac_cv_header_portaudio_h" "$ac_includes_default"
+if test "x$ac_cv_header_portaudio_h" = xyes; then :
+  PORTAUDIO_HEADER_FOUND=1
 else
-  PRI_L2_PERSISTENCE_HEADER_FOUND=0
+  PORTAUDIO_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_L2_PERSISTENCE_HEADER_FOUND}" = "x0" ; then
-         PRI_L2_PERSISTENCE_LIB=""
-         PRI_L2_PERSISTENCE_INCLUDE=""
+      if test "x${PORTAUDIO_HEADER_FOUND}" = "x0" ; then
+         PORTAUDIO_LIB=""
+         PORTAUDIO_INCLUDE=""
       else
 
-         PBX_PRI_L2_PERSISTENCE=1
+         PBX_PORTAUDIO=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_L2_PERSISTENCE 1
+#define HAVE_PORTAUDIO 1
 _ACEOF
 
       fi
@@ -26866,22 +27180,23 @@ fi
 
 
 
-if test "x${PBX_PRI_DATETIME_SEND}" != "x1" -a "${USE_PRI_DATETIME_SEND}" != "no"; then
+
+if test "x${PBX_PRI}" != "x1" -a "${USE_PRI}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_DATETIME_SEND=DIR has been specified, use it.
-   if test "x${PRI_DATETIME_SEND_DIR}" != "x"; then
-      if test -d ${PRI_DATETIME_SEND_DIR}/lib; then
-         pbxlibdir="-L${PRI_DATETIME_SEND_DIR}/lib"
+   # if --with-PRI=DIR has been specified, use it.
+   if test "x${PRI_DIR}" != "x"; then
+      if test -d ${PRI_DIR}/lib; then
+         pbxlibdir="-L${PRI_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_DATETIME_SEND_DIR}"
+         pbxlibdir="-L${PRI_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_date_time_send_option in -lpri" >&5
-$as_echo_n "checking for pri_date_time_send_option in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_date_time_send_option+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_connected_line_update in -lpri" >&5
+$as_echo_n "checking for pri_connected_line_update in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_connected_line_update+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -26895,65 +27210,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_date_time_send_option ();
+char pri_connected_line_update ();
 int
 main ()
 {
-return pri_date_time_send_option ();
+return pri_connected_line_update ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_date_time_send_option=yes
+  ac_cv_lib_pri_pri_connected_line_update=yes
 else
-  ac_cv_lib_pri_pri_date_time_send_option=no
+  ac_cv_lib_pri_pri_connected_line_update=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_date_time_send_option" >&5
-$as_echo "$ac_cv_lib_pri_pri_date_time_send_option" >&6; }
-if test "x$ac_cv_lib_pri_pri_date_time_send_option" = xyes; then :
-  AST_PRI_DATETIME_SEND_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_connected_line_update" >&5
+$as_echo "$ac_cv_lib_pri_pri_connected_line_update" >&6; }
+if test "x$ac_cv_lib_pri_pri_connected_line_update" = xyes; then :
+  AST_PRI_FOUND=yes
 else
-  AST_PRI_DATETIME_SEND_FOUND=no
+  AST_PRI_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_DATETIME_SEND_FOUND}" = "yes"; then
-      PRI_DATETIME_SEND_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_DATETIME_SEND=DIR has been specified, use it.
-      if test "x${PRI_DATETIME_SEND_DIR}" != "x"; then
-         PRI_DATETIME_SEND_INCLUDE="-I${PRI_DATETIME_SEND_DIR}/include"
+   if test "${AST_PRI_FOUND}" = "yes"; then
+      PRI_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI=DIR has been specified, use it.
+      if test "x${PRI_DIR}" != "x"; then
+         PRI_INCLUDE="-I${PRI_DIR}/include"
       fi
-      PRI_DATETIME_SEND_INCLUDE="${PRI_DATETIME_SEND_INCLUDE} "
+      PRI_INCLUDE="${PRI_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_DATETIME_SEND_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_DATETIME_SEND_HEADER_FOUND=1
+  PRI_HEADER_FOUND=1
 else
-  PRI_DATETIME_SEND_HEADER_FOUND=0
+  PRI_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_DATETIME_SEND_HEADER_FOUND}" = "x0" ; then
-         PRI_DATETIME_SEND_LIB=""
-         PRI_DATETIME_SEND_INCLUDE=""
+      if test "x${PRI_HEADER_FOUND}" = "x0" ; then
+         PRI_LIB=""
+         PRI_INCLUDE=""
       else
 
-         PBX_PRI_DATETIME_SEND=1
+         PBX_PRI=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_DATETIME_SEND 1
+#define HAVE_PRI 1
 _ACEOF
 
       fi
@@ -26961,23 +27276,24 @@ _ACEOF
 fi
 
 
+if test "x$PBX_PRI" = "x1" ; then
 
-if test "x${PBX_PRI_MWI_V2}" != "x1" -a "${USE_PRI_MWI_V2}" != "no"; then
+if test "x${PBX_PRI_SETUP_ACK_INBAND}" != "x1" -a "${USE_PRI_SETUP_ACK_INBAND}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_MWI_V2=DIR has been specified, use it.
-   if test "x${PRI_MWI_V2_DIR}" != "x"; then
-      if test -d ${PRI_MWI_V2_DIR}/lib; then
-         pbxlibdir="-L${PRI_MWI_V2_DIR}/lib"
+   # if --with-PRI_SETUP_ACK_INBAND=DIR has been specified, use it.
+   if test "x${PRI_SETUP_ACK_INBAND_DIR}" != "x"; then
+      if test -d ${PRI_SETUP_ACK_INBAND_DIR}/lib; then
+         pbxlibdir="-L${PRI_SETUP_ACK_INBAND_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_MWI_V2_DIR}"
+         pbxlibdir="-L${PRI_SETUP_ACK_INBAND_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_mwi_indicate_v2 in -lpri" >&5
-$as_echo_n "checking for pri_mwi_indicate_v2 in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_mwi_indicate_v2+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_setup_ack in -lpri" >&5
+$as_echo_n "checking for pri_setup_ack in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_setup_ack+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -26991,65 +27307,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_mwi_indicate_v2 ();
+char pri_setup_ack ();
 int
 main ()
 {
-return pri_mwi_indicate_v2 ();
+return pri_setup_ack ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_mwi_indicate_v2=yes
+  ac_cv_lib_pri_pri_setup_ack=yes
 else
-  ac_cv_lib_pri_pri_mwi_indicate_v2=no
+  ac_cv_lib_pri_pri_setup_ack=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_mwi_indicate_v2" >&5
-$as_echo "$ac_cv_lib_pri_pri_mwi_indicate_v2" >&6; }
-if test "x$ac_cv_lib_pri_pri_mwi_indicate_v2" = xyes; then :
-  AST_PRI_MWI_V2_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_setup_ack" >&5
+$as_echo "$ac_cv_lib_pri_pri_setup_ack" >&6; }
+if test "x$ac_cv_lib_pri_pri_setup_ack" = xyes; then :
+  AST_PRI_SETUP_ACK_INBAND_FOUND=yes
 else
-  AST_PRI_MWI_V2_FOUND=no
+  AST_PRI_SETUP_ACK_INBAND_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_MWI_V2_FOUND}" = "yes"; then
-      PRI_MWI_V2_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_MWI_V2=DIR has been specified, use it.
-      if test "x${PRI_MWI_V2_DIR}" != "x"; then
-         PRI_MWI_V2_INCLUDE="-I${PRI_MWI_V2_DIR}/include"
+   if test "${AST_PRI_SETUP_ACK_INBAND_FOUND}" = "yes"; then
+      PRI_SETUP_ACK_INBAND_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_SETUP_ACK_INBAND=DIR has been specified, use it.
+      if test "x${PRI_SETUP_ACK_INBAND_DIR}" != "x"; then
+         PRI_SETUP_ACK_INBAND_INCLUDE="-I${PRI_SETUP_ACK_INBAND_DIR}/include"
       fi
-      PRI_MWI_V2_INCLUDE="${PRI_MWI_V2_INCLUDE} "
+      PRI_SETUP_ACK_INBAND_INCLUDE="${PRI_SETUP_ACK_INBAND_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_MWI_V2_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_SETUP_ACK_INBAND_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_MWI_V2_HEADER_FOUND=1
+  PRI_SETUP_ACK_INBAND_HEADER_FOUND=1
 else
-  PRI_MWI_V2_HEADER_FOUND=0
+  PRI_SETUP_ACK_INBAND_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_MWI_V2_HEADER_FOUND}" = "x0" ; then
-         PRI_MWI_V2_LIB=""
-         PRI_MWI_V2_INCLUDE=""
+      if test "x${PRI_SETUP_ACK_INBAND_HEADER_FOUND}" = "x0" ; then
+         PRI_SETUP_ACK_INBAND_LIB=""
+         PRI_SETUP_ACK_INBAND_INCLUDE=""
       else
 
-         PBX_PRI_MWI_V2=1
+         PBX_PRI_SETUP_ACK_INBAND=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_MWI_V2 1
+#define HAVE_PRI_SETUP_ACK_INBAND 1
 _ACEOF
 
       fi
@@ -27058,22 +27374,22 @@ fi
 
 
 
-if test "x${PBX_PRI_DISPLAY_TEXT}" != "x1" -a "${USE_PRI_DISPLAY_TEXT}" != "no"; then
+if test "x${PBX_PRI_L2_PERSISTENCE}" != "x1" -a "${USE_PRI_L2_PERSISTENCE}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_DISPLAY_TEXT=DIR has been specified, use it.
-   if test "x${PRI_DISPLAY_TEXT_DIR}" != "x"; then
-      if test -d ${PRI_DISPLAY_TEXT_DIR}/lib; then
-         pbxlibdir="-L${PRI_DISPLAY_TEXT_DIR}/lib"
+   # if --with-PRI_L2_PERSISTENCE=DIR has been specified, use it.
+   if test "x${PRI_L2_PERSISTENCE_DIR}" != "x"; then
+      if test -d ${PRI_L2_PERSISTENCE_DIR}/lib; then
+         pbxlibdir="-L${PRI_L2_PERSISTENCE_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_DISPLAY_TEXT_DIR}"
+         pbxlibdir="-L${PRI_L2_PERSISTENCE_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_display_text in -lpri" >&5
-$as_echo_n "checking for pri_display_text in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_display_text+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_persistent_layer2_option in -lpri" >&5
+$as_echo_n "checking for pri_persistent_layer2_option in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_persistent_layer2_option+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27087,65 +27403,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_display_text ();
+char pri_persistent_layer2_option ();
 int
 main ()
 {
-return pri_display_text ();
+return pri_persistent_layer2_option ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_display_text=yes
+  ac_cv_lib_pri_pri_persistent_layer2_option=yes
 else
-  ac_cv_lib_pri_pri_display_text=no
+  ac_cv_lib_pri_pri_persistent_layer2_option=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_display_text" >&5
-$as_echo "$ac_cv_lib_pri_pri_display_text" >&6; }
-if test "x$ac_cv_lib_pri_pri_display_text" = xyes; then :
-  AST_PRI_DISPLAY_TEXT_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_persistent_layer2_option" >&5
+$as_echo "$ac_cv_lib_pri_pri_persistent_layer2_option" >&6; }
+if test "x$ac_cv_lib_pri_pri_persistent_layer2_option" = xyes; then :
+  AST_PRI_L2_PERSISTENCE_FOUND=yes
 else
-  AST_PRI_DISPLAY_TEXT_FOUND=no
+  AST_PRI_L2_PERSISTENCE_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_DISPLAY_TEXT_FOUND}" = "yes"; then
-      PRI_DISPLAY_TEXT_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_DISPLAY_TEXT=DIR has been specified, use it.
-      if test "x${PRI_DISPLAY_TEXT_DIR}" != "x"; then
-         PRI_DISPLAY_TEXT_INCLUDE="-I${PRI_DISPLAY_TEXT_DIR}/include"
+   if test "${AST_PRI_L2_PERSISTENCE_FOUND}" = "yes"; then
+      PRI_L2_PERSISTENCE_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_L2_PERSISTENCE=DIR has been specified, use it.
+      if test "x${PRI_L2_PERSISTENCE_DIR}" != "x"; then
+         PRI_L2_PERSISTENCE_INCLUDE="-I${PRI_L2_PERSISTENCE_DIR}/include"
       fi
-      PRI_DISPLAY_TEXT_INCLUDE="${PRI_DISPLAY_TEXT_INCLUDE} "
+      PRI_L2_PERSISTENCE_INCLUDE="${PRI_L2_PERSISTENCE_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_DISPLAY_TEXT_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_L2_PERSISTENCE_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_DISPLAY_TEXT_HEADER_FOUND=1
+  PRI_L2_PERSISTENCE_HEADER_FOUND=1
 else
-  PRI_DISPLAY_TEXT_HEADER_FOUND=0
+  PRI_L2_PERSISTENCE_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_DISPLAY_TEXT_HEADER_FOUND}" = "x0" ; then
-         PRI_DISPLAY_TEXT_LIB=""
-         PRI_DISPLAY_TEXT_INCLUDE=""
+      if test "x${PRI_L2_PERSISTENCE_HEADER_FOUND}" = "x0" ; then
+         PRI_L2_PERSISTENCE_LIB=""
+         PRI_L2_PERSISTENCE_INCLUDE=""
       else
 
-         PBX_PRI_DISPLAY_TEXT=1
+         PBX_PRI_L2_PERSISTENCE=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_DISPLAY_TEXT 1
+#define HAVE_PRI_L2_PERSISTENCE 1
 _ACEOF
 
       fi
@@ -27154,22 +27470,22 @@ fi
 
 
 
-if test "x${PBX_PRI_MWI}" != "x1" -a "${USE_PRI_MWI}" != "no"; then
+if test "x${PBX_PRI_DATETIME_SEND}" != "x1" -a "${USE_PRI_DATETIME_SEND}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_MWI=DIR has been specified, use it.
-   if test "x${PRI_MWI_DIR}" != "x"; then
-      if test -d ${PRI_MWI_DIR}/lib; then
-         pbxlibdir="-L${PRI_MWI_DIR}/lib"
+   # if --with-PRI_DATETIME_SEND=DIR has been specified, use it.
+   if test "x${PRI_DATETIME_SEND_DIR}" != "x"; then
+      if test -d ${PRI_DATETIME_SEND_DIR}/lib; then
+         pbxlibdir="-L${PRI_DATETIME_SEND_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_MWI_DIR}"
+         pbxlibdir="-L${PRI_DATETIME_SEND_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_mwi_indicate in -lpri" >&5
-$as_echo_n "checking for pri_mwi_indicate in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_mwi_indicate+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_date_time_send_option in -lpri" >&5
+$as_echo_n "checking for pri_date_time_send_option in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_date_time_send_option+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27183,65 +27499,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_mwi_indicate ();
+char pri_date_time_send_option ();
 int
 main ()
 {
-return pri_mwi_indicate ();
+return pri_date_time_send_option ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_mwi_indicate=yes
+  ac_cv_lib_pri_pri_date_time_send_option=yes
 else
-  ac_cv_lib_pri_pri_mwi_indicate=no
+  ac_cv_lib_pri_pri_date_time_send_option=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_mwi_indicate" >&5
-$as_echo "$ac_cv_lib_pri_pri_mwi_indicate" >&6; }
-if test "x$ac_cv_lib_pri_pri_mwi_indicate" = xyes; then :
-  AST_PRI_MWI_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_date_time_send_option" >&5
+$as_echo "$ac_cv_lib_pri_pri_date_time_send_option" >&6; }
+if test "x$ac_cv_lib_pri_pri_date_time_send_option" = xyes; then :
+  AST_PRI_DATETIME_SEND_FOUND=yes
 else
-  AST_PRI_MWI_FOUND=no
+  AST_PRI_DATETIME_SEND_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_MWI_FOUND}" = "yes"; then
-      PRI_MWI_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_MWI=DIR has been specified, use it.
-      if test "x${PRI_MWI_DIR}" != "x"; then
-         PRI_MWI_INCLUDE="-I${PRI_MWI_DIR}/include"
+   if test "${AST_PRI_DATETIME_SEND_FOUND}" = "yes"; then
+      PRI_DATETIME_SEND_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_DATETIME_SEND=DIR has been specified, use it.
+      if test "x${PRI_DATETIME_SEND_DIR}" != "x"; then
+         PRI_DATETIME_SEND_INCLUDE="-I${PRI_DATETIME_SEND_DIR}/include"
       fi
-      PRI_MWI_INCLUDE="${PRI_MWI_INCLUDE} "
+      PRI_DATETIME_SEND_INCLUDE="${PRI_DATETIME_SEND_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_MWI_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_DATETIME_SEND_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_MWI_HEADER_FOUND=1
+  PRI_DATETIME_SEND_HEADER_FOUND=1
 else
-  PRI_MWI_HEADER_FOUND=0
+  PRI_DATETIME_SEND_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_MWI_HEADER_FOUND}" = "x0" ; then
-         PRI_MWI_LIB=""
-         PRI_MWI_INCLUDE=""
+      if test "x${PRI_DATETIME_SEND_HEADER_FOUND}" = "x0" ; then
+         PRI_DATETIME_SEND_LIB=""
+         PRI_DATETIME_SEND_INCLUDE=""
       else
 
-         PBX_PRI_MWI=1
+         PBX_PRI_DATETIME_SEND=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_MWI 1
+#define HAVE_PRI_DATETIME_SEND 1
 _ACEOF
 
       fi
@@ -27250,22 +27566,22 @@ fi
 
 
 
-if test "x${PBX_PRI_MCID}" != "x1" -a "${USE_PRI_MCID}" != "no"; then
+if test "x${PBX_PRI_MWI_V2}" != "x1" -a "${USE_PRI_MWI_V2}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_MCID=DIR has been specified, use it.
-   if test "x${PRI_MCID_DIR}" != "x"; then
-      if test -d ${PRI_MCID_DIR}/lib; then
-         pbxlibdir="-L${PRI_MCID_DIR}/lib"
+   # if --with-PRI_MWI_V2=DIR has been specified, use it.
+   if test "x${PRI_MWI_V2_DIR}" != "x"; then
+      if test -d ${PRI_MWI_V2_DIR}/lib; then
+         pbxlibdir="-L${PRI_MWI_V2_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_MCID_DIR}"
+         pbxlibdir="-L${PRI_MWI_V2_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_mcid_enable in -lpri" >&5
-$as_echo_n "checking for pri_mcid_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_mcid_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_mwi_indicate_v2 in -lpri" >&5
+$as_echo_n "checking for pri_mwi_indicate_v2 in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_mwi_indicate_v2+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27279,65 +27595,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_mcid_enable ();
+char pri_mwi_indicate_v2 ();
 int
 main ()
 {
-return pri_mcid_enable ();
+return pri_mwi_indicate_v2 ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_mcid_enable=yes
+  ac_cv_lib_pri_pri_mwi_indicate_v2=yes
 else
-  ac_cv_lib_pri_pri_mcid_enable=no
+  ac_cv_lib_pri_pri_mwi_indicate_v2=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_mcid_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_mcid_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_mcid_enable" = xyes; then :
-  AST_PRI_MCID_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_mwi_indicate_v2" >&5
+$as_echo "$ac_cv_lib_pri_pri_mwi_indicate_v2" >&6; }
+if test "x$ac_cv_lib_pri_pri_mwi_indicate_v2" = xyes; then :
+  AST_PRI_MWI_V2_FOUND=yes
 else
-  AST_PRI_MCID_FOUND=no
+  AST_PRI_MWI_V2_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_MCID_FOUND}" = "yes"; then
-      PRI_MCID_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_MCID=DIR has been specified, use it.
-      if test "x${PRI_MCID_DIR}" != "x"; then
-         PRI_MCID_INCLUDE="-I${PRI_MCID_DIR}/include"
+   if test "${AST_PRI_MWI_V2_FOUND}" = "yes"; then
+      PRI_MWI_V2_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_MWI_V2=DIR has been specified, use it.
+      if test "x${PRI_MWI_V2_DIR}" != "x"; then
+         PRI_MWI_V2_INCLUDE="-I${PRI_MWI_V2_DIR}/include"
       fi
-      PRI_MCID_INCLUDE="${PRI_MCID_INCLUDE} "
+      PRI_MWI_V2_INCLUDE="${PRI_MWI_V2_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_MCID_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_MWI_V2_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_MCID_HEADER_FOUND=1
+  PRI_MWI_V2_HEADER_FOUND=1
 else
-  PRI_MCID_HEADER_FOUND=0
+  PRI_MWI_V2_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_MCID_HEADER_FOUND}" = "x0" ; then
-         PRI_MCID_LIB=""
-         PRI_MCID_INCLUDE=""
+      if test "x${PRI_MWI_V2_HEADER_FOUND}" = "x0" ; then
+         PRI_MWI_V2_LIB=""
+         PRI_MWI_V2_INCLUDE=""
       else
 
-         PBX_PRI_MCID=1
+         PBX_PRI_MWI_V2=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_MCID 1
+#define HAVE_PRI_MWI_V2 1
 _ACEOF
 
       fi
@@ -27346,22 +27662,22 @@ fi
 
 
 
-if test "x${PBX_PRI_CALL_WAITING}" != "x1" -a "${USE_PRI_CALL_WAITING}" != "no"; then
+if test "x${PBX_PRI_DISPLAY_TEXT}" != "x1" -a "${USE_PRI_DISPLAY_TEXT}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_CALL_WAITING=DIR has been specified, use it.
-   if test "x${PRI_CALL_WAITING_DIR}" != "x"; then
-      if test -d ${PRI_CALL_WAITING_DIR}/lib; then
-         pbxlibdir="-L${PRI_CALL_WAITING_DIR}/lib"
+   # if --with-PRI_DISPLAY_TEXT=DIR has been specified, use it.
+   if test "x${PRI_DISPLAY_TEXT_DIR}" != "x"; then
+      if test -d ${PRI_DISPLAY_TEXT_DIR}/lib; then
+         pbxlibdir="-L${PRI_DISPLAY_TEXT_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_CALL_WAITING_DIR}"
+         pbxlibdir="-L${PRI_DISPLAY_TEXT_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_connect_ack_enable in -lpri" >&5
-$as_echo_n "checking for pri_connect_ack_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_connect_ack_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_display_text in -lpri" >&5
+$as_echo_n "checking for pri_display_text in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_display_text+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27375,65 +27691,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_connect_ack_enable ();
+char pri_display_text ();
 int
 main ()
 {
-return pri_connect_ack_enable ();
+return pri_display_text ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_connect_ack_enable=yes
+  ac_cv_lib_pri_pri_display_text=yes
 else
-  ac_cv_lib_pri_pri_connect_ack_enable=no
+  ac_cv_lib_pri_pri_display_text=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_connect_ack_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_connect_ack_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_connect_ack_enable" = xyes; then :
-  AST_PRI_CALL_WAITING_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_display_text" >&5
+$as_echo "$ac_cv_lib_pri_pri_display_text" >&6; }
+if test "x$ac_cv_lib_pri_pri_display_text" = xyes; then :
+  AST_PRI_DISPLAY_TEXT_FOUND=yes
 else
-  AST_PRI_CALL_WAITING_FOUND=no
+  AST_PRI_DISPLAY_TEXT_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_CALL_WAITING_FOUND}" = "yes"; then
-      PRI_CALL_WAITING_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_CALL_WAITING=DIR has been specified, use it.
-      if test "x${PRI_CALL_WAITING_DIR}" != "x"; then
-         PRI_CALL_WAITING_INCLUDE="-I${PRI_CALL_WAITING_DIR}/include"
+   if test "${AST_PRI_DISPLAY_TEXT_FOUND}" = "yes"; then
+      PRI_DISPLAY_TEXT_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_DISPLAY_TEXT=DIR has been specified, use it.
+      if test "x${PRI_DISPLAY_TEXT_DIR}" != "x"; then
+         PRI_DISPLAY_TEXT_INCLUDE="-I${PRI_DISPLAY_TEXT_DIR}/include"
       fi
-      PRI_CALL_WAITING_INCLUDE="${PRI_CALL_WAITING_INCLUDE} "
+      PRI_DISPLAY_TEXT_INCLUDE="${PRI_DISPLAY_TEXT_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_CALL_WAITING_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_DISPLAY_TEXT_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_CALL_WAITING_HEADER_FOUND=1
+  PRI_DISPLAY_TEXT_HEADER_FOUND=1
 else
-  PRI_CALL_WAITING_HEADER_FOUND=0
+  PRI_DISPLAY_TEXT_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_CALL_WAITING_HEADER_FOUND}" = "x0" ; then
-         PRI_CALL_WAITING_LIB=""
-         PRI_CALL_WAITING_INCLUDE=""
+      if test "x${PRI_DISPLAY_TEXT_HEADER_FOUND}" = "x0" ; then
+         PRI_DISPLAY_TEXT_LIB=""
+         PRI_DISPLAY_TEXT_INCLUDE=""
       else
 
-         PBX_PRI_CALL_WAITING=1
+         PBX_PRI_DISPLAY_TEXT=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_CALL_WAITING 1
+#define HAVE_PRI_DISPLAY_TEXT 1
 _ACEOF
 
       fi
@@ -27442,22 +27758,22 @@ fi
 
 
 
-if test "x${PBX_PRI_AOC_EVENTS}" != "x1" -a "${USE_PRI_AOC_EVENTS}" != "no"; then
+if test "x${PBX_PRI_MWI}" != "x1" -a "${USE_PRI_MWI}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_AOC_EVENTS=DIR has been specified, use it.
-   if test "x${PRI_AOC_EVENTS_DIR}" != "x"; then
-      if test -d ${PRI_AOC_EVENTS_DIR}/lib; then
-         pbxlibdir="-L${PRI_AOC_EVENTS_DIR}/lib"
+   # if --with-PRI_MWI=DIR has been specified, use it.
+   if test "x${PRI_MWI_DIR}" != "x"; then
+      if test -d ${PRI_MWI_DIR}/lib; then
+         pbxlibdir="-L${PRI_MWI_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_AOC_EVENTS_DIR}"
+         pbxlibdir="-L${PRI_MWI_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_aoc_events_enable in -lpri" >&5
-$as_echo_n "checking for pri_aoc_events_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_aoc_events_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_mwi_indicate in -lpri" >&5
+$as_echo_n "checking for pri_mwi_indicate in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_mwi_indicate+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27471,65 +27787,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_aoc_events_enable ();
+char pri_mwi_indicate ();
 int
 main ()
 {
-return pri_aoc_events_enable ();
+return pri_mwi_indicate ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_aoc_events_enable=yes
+  ac_cv_lib_pri_pri_mwi_indicate=yes
 else
-  ac_cv_lib_pri_pri_aoc_events_enable=no
+  ac_cv_lib_pri_pri_mwi_indicate=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_aoc_events_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_aoc_events_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_aoc_events_enable" = xyes; then :
-  AST_PRI_AOC_EVENTS_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_mwi_indicate" >&5
+$as_echo "$ac_cv_lib_pri_pri_mwi_indicate" >&6; }
+if test "x$ac_cv_lib_pri_pri_mwi_indicate" = xyes; then :
+  AST_PRI_MWI_FOUND=yes
 else
-  AST_PRI_AOC_EVENTS_FOUND=no
+  AST_PRI_MWI_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_AOC_EVENTS_FOUND}" = "yes"; then
-      PRI_AOC_EVENTS_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_AOC_EVENTS=DIR has been specified, use it.
-      if test "x${PRI_AOC_EVENTS_DIR}" != "x"; then
-         PRI_AOC_EVENTS_INCLUDE="-I${PRI_AOC_EVENTS_DIR}/include"
+   if test "${AST_PRI_MWI_FOUND}" = "yes"; then
+      PRI_MWI_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_MWI=DIR has been specified, use it.
+      if test "x${PRI_MWI_DIR}" != "x"; then
+         PRI_MWI_INCLUDE="-I${PRI_MWI_DIR}/include"
       fi
-      PRI_AOC_EVENTS_INCLUDE="${PRI_AOC_EVENTS_INCLUDE} "
+      PRI_MWI_INCLUDE="${PRI_MWI_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_AOC_EVENTS_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_MWI_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_AOC_EVENTS_HEADER_FOUND=1
+  PRI_MWI_HEADER_FOUND=1
 else
-  PRI_AOC_EVENTS_HEADER_FOUND=0
+  PRI_MWI_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_AOC_EVENTS_HEADER_FOUND}" = "x0" ; then
-         PRI_AOC_EVENTS_LIB=""
-         PRI_AOC_EVENTS_INCLUDE=""
+      if test "x${PRI_MWI_HEADER_FOUND}" = "x0" ; then
+         PRI_MWI_LIB=""
+         PRI_MWI_INCLUDE=""
       else
 
-         PBX_PRI_AOC_EVENTS=1
+         PBX_PRI_MWI=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_AOC_EVENTS 1
+#define HAVE_PRI_MWI 1
 _ACEOF
 
       fi
@@ -27538,22 +27854,22 @@ fi
 
 
 
-if test "x${PBX_PRI_TRANSFER}" != "x1" -a "${USE_PRI_TRANSFER}" != "no"; then
+if test "x${PBX_PRI_MCID}" != "x1" -a "${USE_PRI_MCID}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_TRANSFER=DIR has been specified, use it.
-   if test "x${PRI_TRANSFER_DIR}" != "x"; then
-      if test -d ${PRI_TRANSFER_DIR}/lib; then
-         pbxlibdir="-L${PRI_TRANSFER_DIR}/lib"
+   # if --with-PRI_MCID=DIR has been specified, use it.
+   if test "x${PRI_MCID_DIR}" != "x"; then
+      if test -d ${PRI_MCID_DIR}/lib; then
+         pbxlibdir="-L${PRI_MCID_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_TRANSFER_DIR}"
+         pbxlibdir="-L${PRI_MCID_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_transfer_enable in -lpri" >&5
-$as_echo_n "checking for pri_transfer_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_transfer_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_mcid_enable in -lpri" >&5
+$as_echo_n "checking for pri_mcid_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_mcid_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27567,65 +27883,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_transfer_enable ();
+char pri_mcid_enable ();
 int
 main ()
 {
-return pri_transfer_enable ();
+return pri_mcid_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_transfer_enable=yes
+  ac_cv_lib_pri_pri_mcid_enable=yes
 else
-  ac_cv_lib_pri_pri_transfer_enable=no
+  ac_cv_lib_pri_pri_mcid_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_transfer_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_transfer_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_transfer_enable" = xyes; then :
-  AST_PRI_TRANSFER_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_mcid_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_mcid_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_mcid_enable" = xyes; then :
+  AST_PRI_MCID_FOUND=yes
 else
-  AST_PRI_TRANSFER_FOUND=no
+  AST_PRI_MCID_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_TRANSFER_FOUND}" = "yes"; then
-      PRI_TRANSFER_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_TRANSFER=DIR has been specified, use it.
-      if test "x${PRI_TRANSFER_DIR}" != "x"; then
-         PRI_TRANSFER_INCLUDE="-I${PRI_TRANSFER_DIR}/include"
+   if test "${AST_PRI_MCID_FOUND}" = "yes"; then
+      PRI_MCID_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_MCID=DIR has been specified, use it.
+      if test "x${PRI_MCID_DIR}" != "x"; then
+         PRI_MCID_INCLUDE="-I${PRI_MCID_DIR}/include"
       fi
-      PRI_TRANSFER_INCLUDE="${PRI_TRANSFER_INCLUDE} "
+      PRI_MCID_INCLUDE="${PRI_MCID_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_TRANSFER_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_MCID_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_TRANSFER_HEADER_FOUND=1
+  PRI_MCID_HEADER_FOUND=1
 else
-  PRI_TRANSFER_HEADER_FOUND=0
+  PRI_MCID_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_TRANSFER_HEADER_FOUND}" = "x0" ; then
-         PRI_TRANSFER_LIB=""
-         PRI_TRANSFER_INCLUDE=""
+      if test "x${PRI_MCID_HEADER_FOUND}" = "x0" ; then
+         PRI_MCID_LIB=""
+         PRI_MCID_INCLUDE=""
       else
 
-         PBX_PRI_TRANSFER=1
+         PBX_PRI_MCID=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_TRANSFER 1
+#define HAVE_PRI_MCID 1
 _ACEOF
 
       fi
@@ -27634,22 +27950,22 @@ fi
 
 
 
-if test "x${PBX_PRI_CCSS}" != "x1" -a "${USE_PRI_CCSS}" != "no"; then
+if test "x${PBX_PRI_CALL_WAITING}" != "x1" -a "${USE_PRI_CALL_WAITING}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_CCSS=DIR has been specified, use it.
-   if test "x${PRI_CCSS_DIR}" != "x"; then
-      if test -d ${PRI_CCSS_DIR}/lib; then
-         pbxlibdir="-L${PRI_CCSS_DIR}/lib"
+   # if --with-PRI_CALL_WAITING=DIR has been specified, use it.
+   if test "x${PRI_CALL_WAITING_DIR}" != "x"; then
+      if test -d ${PRI_CALL_WAITING_DIR}/lib; then
+         pbxlibdir="-L${PRI_CALL_WAITING_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_CCSS_DIR}"
+         pbxlibdir="-L${PRI_CALL_WAITING_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_cc_enable in -lpri" >&5
-$as_echo_n "checking for pri_cc_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_cc_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_connect_ack_enable in -lpri" >&5
+$as_echo_n "checking for pri_connect_ack_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_connect_ack_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27663,65 +27979,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_cc_enable ();
+char pri_connect_ack_enable ();
 int
 main ()
 {
-return pri_cc_enable ();
+return pri_connect_ack_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_cc_enable=yes
+  ac_cv_lib_pri_pri_connect_ack_enable=yes
 else
-  ac_cv_lib_pri_pri_cc_enable=no
+  ac_cv_lib_pri_pri_connect_ack_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_cc_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_cc_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_cc_enable" = xyes; then :
-  AST_PRI_CCSS_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_connect_ack_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_connect_ack_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_connect_ack_enable" = xyes; then :
+  AST_PRI_CALL_WAITING_FOUND=yes
 else
-  AST_PRI_CCSS_FOUND=no
+  AST_PRI_CALL_WAITING_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_CCSS_FOUND}" = "yes"; then
-      PRI_CCSS_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_CCSS=DIR has been specified, use it.
-      if test "x${PRI_CCSS_DIR}" != "x"; then
-         PRI_CCSS_INCLUDE="-I${PRI_CCSS_DIR}/include"
+   if test "${AST_PRI_CALL_WAITING_FOUND}" = "yes"; then
+      PRI_CALL_WAITING_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_CALL_WAITING=DIR has been specified, use it.
+      if test "x${PRI_CALL_WAITING_DIR}" != "x"; then
+         PRI_CALL_WAITING_INCLUDE="-I${PRI_CALL_WAITING_DIR}/include"
       fi
-      PRI_CCSS_INCLUDE="${PRI_CCSS_INCLUDE} "
+      PRI_CALL_WAITING_INCLUDE="${PRI_CALL_WAITING_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_CCSS_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_CALL_WAITING_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_CCSS_HEADER_FOUND=1
+  PRI_CALL_WAITING_HEADER_FOUND=1
 else
-  PRI_CCSS_HEADER_FOUND=0
+  PRI_CALL_WAITING_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_CCSS_HEADER_FOUND}" = "x0" ; then
-         PRI_CCSS_LIB=""
-         PRI_CCSS_INCLUDE=""
+      if test "x${PRI_CALL_WAITING_HEADER_FOUND}" = "x0" ; then
+         PRI_CALL_WAITING_LIB=""
+         PRI_CALL_WAITING_INCLUDE=""
       else
 
-         PBX_PRI_CCSS=1
+         PBX_PRI_CALL_WAITING=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_CCSS 1
+#define HAVE_PRI_CALL_WAITING 1
 _ACEOF
 
       fi
@@ -27730,22 +28046,22 @@ fi
 
 
 
-if test "x${PBX_PRI_HANGUP_FIX}" != "x1" -a "${USE_PRI_HANGUP_FIX}" != "no"; then
+if test "x${PBX_PRI_AOC_EVENTS}" != "x1" -a "${USE_PRI_AOC_EVENTS}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_HANGUP_FIX=DIR has been specified, use it.
-   if test "x${PRI_HANGUP_FIX_DIR}" != "x"; then
-      if test -d ${PRI_HANGUP_FIX_DIR}/lib; then
-         pbxlibdir="-L${PRI_HANGUP_FIX_DIR}/lib"
+   # if --with-PRI_AOC_EVENTS=DIR has been specified, use it.
+   if test "x${PRI_AOC_EVENTS_DIR}" != "x"; then
+      if test -d ${PRI_AOC_EVENTS_DIR}/lib; then
+         pbxlibdir="-L${PRI_AOC_EVENTS_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_HANGUP_FIX_DIR}"
+         pbxlibdir="-L${PRI_AOC_EVENTS_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_hangup_fix_enable in -lpri" >&5
-$as_echo_n "checking for pri_hangup_fix_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_hangup_fix_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_aoc_events_enable in -lpri" >&5
+$as_echo_n "checking for pri_aoc_events_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_aoc_events_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27759,65 +28075,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_hangup_fix_enable ();
+char pri_aoc_events_enable ();
 int
 main ()
 {
-return pri_hangup_fix_enable ();
+return pri_aoc_events_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_hangup_fix_enable=yes
+  ac_cv_lib_pri_pri_aoc_events_enable=yes
 else
-  ac_cv_lib_pri_pri_hangup_fix_enable=no
+  ac_cv_lib_pri_pri_aoc_events_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_hangup_fix_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_hangup_fix_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_hangup_fix_enable" = xyes; then :
-  AST_PRI_HANGUP_FIX_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_aoc_events_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_aoc_events_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_aoc_events_enable" = xyes; then :
+  AST_PRI_AOC_EVENTS_FOUND=yes
 else
-  AST_PRI_HANGUP_FIX_FOUND=no
+  AST_PRI_AOC_EVENTS_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_HANGUP_FIX_FOUND}" = "yes"; then
-      PRI_HANGUP_FIX_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_HANGUP_FIX=DIR has been specified, use it.
-      if test "x${PRI_HANGUP_FIX_DIR}" != "x"; then
-         PRI_HANGUP_FIX_INCLUDE="-I${PRI_HANGUP_FIX_DIR}/include"
+   if test "${AST_PRI_AOC_EVENTS_FOUND}" = "yes"; then
+      PRI_AOC_EVENTS_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_AOC_EVENTS=DIR has been specified, use it.
+      if test "x${PRI_AOC_EVENTS_DIR}" != "x"; then
+         PRI_AOC_EVENTS_INCLUDE="-I${PRI_AOC_EVENTS_DIR}/include"
       fi
-      PRI_HANGUP_FIX_INCLUDE="${PRI_HANGUP_FIX_INCLUDE} "
+      PRI_AOC_EVENTS_INCLUDE="${PRI_AOC_EVENTS_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_HANGUP_FIX_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_AOC_EVENTS_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_HANGUP_FIX_HEADER_FOUND=1
+  PRI_AOC_EVENTS_HEADER_FOUND=1
 else
-  PRI_HANGUP_FIX_HEADER_FOUND=0
+  PRI_AOC_EVENTS_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_HANGUP_FIX_HEADER_FOUND}" = "x0" ; then
-         PRI_HANGUP_FIX_LIB=""
-         PRI_HANGUP_FIX_INCLUDE=""
+      if test "x${PRI_AOC_EVENTS_HEADER_FOUND}" = "x0" ; then
+         PRI_AOC_EVENTS_LIB=""
+         PRI_AOC_EVENTS_INCLUDE=""
       else
 
-         PBX_PRI_HANGUP_FIX=1
+         PBX_PRI_AOC_EVENTS=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_HANGUP_FIX 1
+#define HAVE_PRI_AOC_EVENTS 1
 _ACEOF
 
       fi
@@ -27826,22 +28142,22 @@ fi
 
 
 
-if test "x${PBX_PRI_SUBADDR}" != "x1" -a "${USE_PRI_SUBADDR}" != "no"; then
+if test "x${PBX_PRI_TRANSFER}" != "x1" -a "${USE_PRI_TRANSFER}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_SUBADDR=DIR has been specified, use it.
-   if test "x${PRI_SUBADDR_DIR}" != "x"; then
-      if test -d ${PRI_SUBADDR_DIR}/lib; then
-         pbxlibdir="-L${PRI_SUBADDR_DIR}/lib"
+   # if --with-PRI_TRANSFER=DIR has been specified, use it.
+   if test "x${PRI_TRANSFER_DIR}" != "x"; then
+      if test -d ${PRI_TRANSFER_DIR}/lib; then
+         pbxlibdir="-L${PRI_TRANSFER_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_SUBADDR_DIR}"
+         pbxlibdir="-L${PRI_TRANSFER_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_sr_set_called_subaddress in -lpri" >&5
-$as_echo_n "checking for pri_sr_set_called_subaddress in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_sr_set_called_subaddress+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_transfer_enable in -lpri" >&5
+$as_echo_n "checking for pri_transfer_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_transfer_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27855,65 +28171,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_sr_set_called_subaddress ();
+char pri_transfer_enable ();
 int
 main ()
 {
-return pri_sr_set_called_subaddress ();
+return pri_transfer_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_sr_set_called_subaddress=yes
+  ac_cv_lib_pri_pri_transfer_enable=yes
 else
-  ac_cv_lib_pri_pri_sr_set_called_subaddress=no
+  ac_cv_lib_pri_pri_transfer_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_sr_set_called_subaddress" >&5
-$as_echo "$ac_cv_lib_pri_pri_sr_set_called_subaddress" >&6; }
-if test "x$ac_cv_lib_pri_pri_sr_set_called_subaddress" = xyes; then :
-  AST_PRI_SUBADDR_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_transfer_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_transfer_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_transfer_enable" = xyes; then :
+  AST_PRI_TRANSFER_FOUND=yes
 else
-  AST_PRI_SUBADDR_FOUND=no
+  AST_PRI_TRANSFER_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_SUBADDR_FOUND}" = "yes"; then
-      PRI_SUBADDR_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_SUBADDR=DIR has been specified, use it.
-      if test "x${PRI_SUBADDR_DIR}" != "x"; then
-         PRI_SUBADDR_INCLUDE="-I${PRI_SUBADDR_DIR}/include"
+   if test "${AST_PRI_TRANSFER_FOUND}" = "yes"; then
+      PRI_TRANSFER_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_TRANSFER=DIR has been specified, use it.
+      if test "x${PRI_TRANSFER_DIR}" != "x"; then
+         PRI_TRANSFER_INCLUDE="-I${PRI_TRANSFER_DIR}/include"
       fi
-      PRI_SUBADDR_INCLUDE="${PRI_SUBADDR_INCLUDE} "
+      PRI_TRANSFER_INCLUDE="${PRI_TRANSFER_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_SUBADDR_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_TRANSFER_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_SUBADDR_HEADER_FOUND=1
+  PRI_TRANSFER_HEADER_FOUND=1
 else
-  PRI_SUBADDR_HEADER_FOUND=0
+  PRI_TRANSFER_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_SUBADDR_HEADER_FOUND}" = "x0" ; then
-         PRI_SUBADDR_LIB=""
-         PRI_SUBADDR_INCLUDE=""
+      if test "x${PRI_TRANSFER_HEADER_FOUND}" = "x0" ; then
+         PRI_TRANSFER_LIB=""
+         PRI_TRANSFER_INCLUDE=""
       else
 
-         PBX_PRI_SUBADDR=1
+         PBX_PRI_TRANSFER=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_SUBADDR 1
+#define HAVE_PRI_TRANSFER 1
 _ACEOF
 
       fi
@@ -27922,22 +28238,22 @@ fi
 
 
 
-if test "x${PBX_PRI_CALL_HOLD}" != "x1" -a "${USE_PRI_CALL_HOLD}" != "no"; then
+if test "x${PBX_PRI_CCSS}" != "x1" -a "${USE_PRI_CCSS}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_CALL_HOLD=DIR has been specified, use it.
-   if test "x${PRI_CALL_HOLD_DIR}" != "x"; then
-      if test -d ${PRI_CALL_HOLD_DIR}/lib; then
-         pbxlibdir="-L${PRI_CALL_HOLD_DIR}/lib"
+   # if --with-PRI_CCSS=DIR has been specified, use it.
+   if test "x${PRI_CCSS_DIR}" != "x"; then
+      if test -d ${PRI_CCSS_DIR}/lib; then
+         pbxlibdir="-L${PRI_CCSS_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_CALL_HOLD_DIR}"
+         pbxlibdir="-L${PRI_CCSS_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_hold_enable in -lpri" >&5
-$as_echo_n "checking for pri_hold_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_hold_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_cc_enable in -lpri" >&5
+$as_echo_n "checking for pri_cc_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_cc_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -27951,65 +28267,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_hold_enable ();
+char pri_cc_enable ();
 int
 main ()
 {
-return pri_hold_enable ();
+return pri_cc_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_hold_enable=yes
+  ac_cv_lib_pri_pri_cc_enable=yes
 else
-  ac_cv_lib_pri_pri_hold_enable=no
+  ac_cv_lib_pri_pri_cc_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_hold_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_hold_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_hold_enable" = xyes; then :
-  AST_PRI_CALL_HOLD_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_cc_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_cc_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_cc_enable" = xyes; then :
+  AST_PRI_CCSS_FOUND=yes
 else
-  AST_PRI_CALL_HOLD_FOUND=no
+  AST_PRI_CCSS_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_CALL_HOLD_FOUND}" = "yes"; then
-      PRI_CALL_HOLD_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_CALL_HOLD=DIR has been specified, use it.
-      if test "x${PRI_CALL_HOLD_DIR}" != "x"; then
-         PRI_CALL_HOLD_INCLUDE="-I${PRI_CALL_HOLD_DIR}/include"
+   if test "${AST_PRI_CCSS_FOUND}" = "yes"; then
+      PRI_CCSS_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_CCSS=DIR has been specified, use it.
+      if test "x${PRI_CCSS_DIR}" != "x"; then
+         PRI_CCSS_INCLUDE="-I${PRI_CCSS_DIR}/include"
       fi
-      PRI_CALL_HOLD_INCLUDE="${PRI_CALL_HOLD_INCLUDE} "
+      PRI_CCSS_INCLUDE="${PRI_CCSS_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_CALL_HOLD_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_CCSS_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_CALL_HOLD_HEADER_FOUND=1
+  PRI_CCSS_HEADER_FOUND=1
 else
-  PRI_CALL_HOLD_HEADER_FOUND=0
+  PRI_CCSS_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_CALL_HOLD_HEADER_FOUND}" = "x0" ; then
-         PRI_CALL_HOLD_LIB=""
-         PRI_CALL_HOLD_INCLUDE=""
+      if test "x${PRI_CCSS_HEADER_FOUND}" = "x0" ; then
+         PRI_CCSS_LIB=""
+         PRI_CCSS_INCLUDE=""
       else
 
-         PBX_PRI_CALL_HOLD=1
+         PBX_PRI_CCSS=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_CALL_HOLD 1
+#define HAVE_PRI_CCSS 1
 _ACEOF
 
       fi
@@ -28018,22 +28334,22 @@ fi
 
 
 
-if test "x${PBX_PRI_CALL_REROUTING}" != "x1" -a "${USE_PRI_CALL_REROUTING}" != "no"; then
+if test "x${PBX_PRI_HANGUP_FIX}" != "x1" -a "${USE_PRI_HANGUP_FIX}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_CALL_REROUTING=DIR has been specified, use it.
-   if test "x${PRI_CALL_REROUTING_DIR}" != "x"; then
-      if test -d ${PRI_CALL_REROUTING_DIR}/lib; then
-         pbxlibdir="-L${PRI_CALL_REROUTING_DIR}/lib"
+   # if --with-PRI_HANGUP_FIX=DIR has been specified, use it.
+   if test "x${PRI_HANGUP_FIX_DIR}" != "x"; then
+      if test -d ${PRI_HANGUP_FIX_DIR}/lib; then
+         pbxlibdir="-L${PRI_HANGUP_FIX_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_CALL_REROUTING_DIR}"
+         pbxlibdir="-L${PRI_HANGUP_FIX_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_reroute_enable in -lpri" >&5
-$as_echo_n "checking for pri_reroute_enable in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_reroute_enable+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_hangup_fix_enable in -lpri" >&5
+$as_echo_n "checking for pri_hangup_fix_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_hangup_fix_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -28047,65 +28363,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_reroute_enable ();
+char pri_hangup_fix_enable ();
 int
 main ()
 {
-return pri_reroute_enable ();
+return pri_hangup_fix_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_reroute_enable=yes
+  ac_cv_lib_pri_pri_hangup_fix_enable=yes
 else
-  ac_cv_lib_pri_pri_reroute_enable=no
+  ac_cv_lib_pri_pri_hangup_fix_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_reroute_enable" >&5
-$as_echo "$ac_cv_lib_pri_pri_reroute_enable" >&6; }
-if test "x$ac_cv_lib_pri_pri_reroute_enable" = xyes; then :
-  AST_PRI_CALL_REROUTING_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_hangup_fix_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_hangup_fix_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_hangup_fix_enable" = xyes; then :
+  AST_PRI_HANGUP_FIX_FOUND=yes
 else
-  AST_PRI_CALL_REROUTING_FOUND=no
+  AST_PRI_HANGUP_FIX_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_CALL_REROUTING_FOUND}" = "yes"; then
-      PRI_CALL_REROUTING_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_CALL_REROUTING=DIR has been specified, use it.
-      if test "x${PRI_CALL_REROUTING_DIR}" != "x"; then
-         PRI_CALL_REROUTING_INCLUDE="-I${PRI_CALL_REROUTING_DIR}/include"
+   if test "${AST_PRI_HANGUP_FIX_FOUND}" = "yes"; then
+      PRI_HANGUP_FIX_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_HANGUP_FIX=DIR has been specified, use it.
+      if test "x${PRI_HANGUP_FIX_DIR}" != "x"; then
+         PRI_HANGUP_FIX_INCLUDE="-I${PRI_HANGUP_FIX_DIR}/include"
       fi
-      PRI_CALL_REROUTING_INCLUDE="${PRI_CALL_REROUTING_INCLUDE} "
+      PRI_HANGUP_FIX_INCLUDE="${PRI_HANGUP_FIX_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_CALL_REROUTING_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_HANGUP_FIX_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_CALL_REROUTING_HEADER_FOUND=1
+  PRI_HANGUP_FIX_HEADER_FOUND=1
 else
-  PRI_CALL_REROUTING_HEADER_FOUND=0
+  PRI_HANGUP_FIX_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_CALL_REROUTING_HEADER_FOUND}" = "x0" ; then
-         PRI_CALL_REROUTING_LIB=""
-         PRI_CALL_REROUTING_INCLUDE=""
+      if test "x${PRI_HANGUP_FIX_HEADER_FOUND}" = "x0" ; then
+         PRI_HANGUP_FIX_LIB=""
+         PRI_HANGUP_FIX_INCLUDE=""
       else
 
-         PBX_PRI_CALL_REROUTING=1
+         PBX_PRI_HANGUP_FIX=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_CALL_REROUTING 1
+#define HAVE_PRI_HANGUP_FIX 1
 _ACEOF
 
       fi
@@ -28114,22 +28430,22 @@ fi
 
 
 
-if test "x${PBX_PRI_SETUP_KEYPAD}" != "x1" -a "${USE_PRI_SETUP_KEYPAD}" != "no"; then
+if test "x${PBX_PRI_SUBADDR}" != "x1" -a "${USE_PRI_SUBADDR}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_SETUP_KEYPAD=DIR has been specified, use it.
-   if test "x${PRI_SETUP_KEYPAD_DIR}" != "x"; then
-      if test -d ${PRI_SETUP_KEYPAD_DIR}/lib; then
-         pbxlibdir="-L${PRI_SETUP_KEYPAD_DIR}/lib"
+   # if --with-PRI_SUBADDR=DIR has been specified, use it.
+   if test "x${PRI_SUBADDR_DIR}" != "x"; then
+      if test -d ${PRI_SUBADDR_DIR}/lib; then
+         pbxlibdir="-L${PRI_SUBADDR_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_SETUP_KEYPAD_DIR}"
+         pbxlibdir="-L${PRI_SUBADDR_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_sr_set_keypad_digits in -lpri" >&5
-$as_echo_n "checking for pri_sr_set_keypad_digits in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_sr_set_keypad_digits+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_sr_set_called_subaddress in -lpri" >&5
+$as_echo_n "checking for pri_sr_set_called_subaddress in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_sr_set_called_subaddress+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -28143,65 +28459,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_sr_set_keypad_digits ();
+char pri_sr_set_called_subaddress ();
 int
 main ()
 {
-return pri_sr_set_keypad_digits ();
+return pri_sr_set_called_subaddress ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_sr_set_keypad_digits=yes
+  ac_cv_lib_pri_pri_sr_set_called_subaddress=yes
 else
-  ac_cv_lib_pri_pri_sr_set_keypad_digits=no
+  ac_cv_lib_pri_pri_sr_set_called_subaddress=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_sr_set_keypad_digits" >&5
-$as_echo "$ac_cv_lib_pri_pri_sr_set_keypad_digits" >&6; }
-if test "x$ac_cv_lib_pri_pri_sr_set_keypad_digits" = xyes; then :
-  AST_PRI_SETUP_KEYPAD_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_sr_set_called_subaddress" >&5
+$as_echo "$ac_cv_lib_pri_pri_sr_set_called_subaddress" >&6; }
+if test "x$ac_cv_lib_pri_pri_sr_set_called_subaddress" = xyes; then :
+  AST_PRI_SUBADDR_FOUND=yes
 else
-  AST_PRI_SETUP_KEYPAD_FOUND=no
+  AST_PRI_SUBADDR_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_SETUP_KEYPAD_FOUND}" = "yes"; then
-      PRI_SETUP_KEYPAD_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_SETUP_KEYPAD=DIR has been specified, use it.
-      if test "x${PRI_SETUP_KEYPAD_DIR}" != "x"; then
-         PRI_SETUP_KEYPAD_INCLUDE="-I${PRI_SETUP_KEYPAD_DIR}/include"
+   if test "${AST_PRI_SUBADDR_FOUND}" = "yes"; then
+      PRI_SUBADDR_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_SUBADDR=DIR has been specified, use it.
+      if test "x${PRI_SUBADDR_DIR}" != "x"; then
+         PRI_SUBADDR_INCLUDE="-I${PRI_SUBADDR_DIR}/include"
       fi
-      PRI_SETUP_KEYPAD_INCLUDE="${PRI_SETUP_KEYPAD_INCLUDE} "
+      PRI_SUBADDR_INCLUDE="${PRI_SUBADDR_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_SETUP_KEYPAD_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_SUBADDR_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_SETUP_KEYPAD_HEADER_FOUND=1
+  PRI_SUBADDR_HEADER_FOUND=1
 else
-  PRI_SETUP_KEYPAD_HEADER_FOUND=0
+  PRI_SUBADDR_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_SETUP_KEYPAD_HEADER_FOUND}" = "x0" ; then
-         PRI_SETUP_KEYPAD_LIB=""
-         PRI_SETUP_KEYPAD_INCLUDE=""
+      if test "x${PRI_SUBADDR_HEADER_FOUND}" = "x0" ; then
+         PRI_SUBADDR_LIB=""
+         PRI_SUBADDR_INCLUDE=""
       else
 
-         PBX_PRI_SETUP_KEYPAD=1
+         PBX_PRI_SUBADDR=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_SETUP_KEYPAD 1
+#define HAVE_PRI_SUBADDR 1
 _ACEOF
 
       fi
@@ -28210,26 +28526,22 @@ fi
 
 
 
-   # ------------------------------------v
-   # TODO: The code can be changed to always include these features now.
-   # These features will always be present if pri_connected_line_update is available.
-
-if test "x${PBX_PRI_PROG_W_CAUSE}" != "x1" -a "${USE_PRI_PROG_W_CAUSE}" != "no"; then
+if test "x${PBX_PRI_CALL_HOLD}" != "x1" -a "${USE_PRI_CALL_HOLD}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_PROG_W_CAUSE=DIR has been specified, use it.
-   if test "x${PRI_PROG_W_CAUSE_DIR}" != "x"; then
-      if test -d ${PRI_PROG_W_CAUSE_DIR}/lib; then
-         pbxlibdir="-L${PRI_PROG_W_CAUSE_DIR}/lib"
+   # if --with-PRI_CALL_HOLD=DIR has been specified, use it.
+   if test "x${PRI_CALL_HOLD_DIR}" != "x"; then
+      if test -d ${PRI_CALL_HOLD_DIR}/lib; then
+         pbxlibdir="-L${PRI_CALL_HOLD_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_PROG_W_CAUSE_DIR}"
+         pbxlibdir="-L${PRI_CALL_HOLD_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_progress_with_cause in -lpri" >&5
-$as_echo_n "checking for pri_progress_with_cause in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_progress_with_cause+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_hold_enable in -lpri" >&5
+$as_echo_n "checking for pri_hold_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_hold_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -28243,65 +28555,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_progress_with_cause ();
+char pri_hold_enable ();
 int
 main ()
 {
-return pri_progress_with_cause ();
+return pri_hold_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_progress_with_cause=yes
+  ac_cv_lib_pri_pri_hold_enable=yes
 else
-  ac_cv_lib_pri_pri_progress_with_cause=no
+  ac_cv_lib_pri_pri_hold_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_progress_with_cause" >&5
-$as_echo "$ac_cv_lib_pri_pri_progress_with_cause" >&6; }
-if test "x$ac_cv_lib_pri_pri_progress_with_cause" = xyes; then :
-  AST_PRI_PROG_W_CAUSE_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_hold_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_hold_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_hold_enable" = xyes; then :
+  AST_PRI_CALL_HOLD_FOUND=yes
 else
-  AST_PRI_PROG_W_CAUSE_FOUND=no
+  AST_PRI_CALL_HOLD_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_PROG_W_CAUSE_FOUND}" = "yes"; then
-      PRI_PROG_W_CAUSE_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_PROG_W_CAUSE=DIR has been specified, use it.
-      if test "x${PRI_PROG_W_CAUSE_DIR}" != "x"; then
-         PRI_PROG_W_CAUSE_INCLUDE="-I${PRI_PROG_W_CAUSE_DIR}/include"
+   if test "${AST_PRI_CALL_HOLD_FOUND}" = "yes"; then
+      PRI_CALL_HOLD_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_CALL_HOLD=DIR has been specified, use it.
+      if test "x${PRI_CALL_HOLD_DIR}" != "x"; then
+         PRI_CALL_HOLD_INCLUDE="-I${PRI_CALL_HOLD_DIR}/include"
       fi
-      PRI_PROG_W_CAUSE_INCLUDE="${PRI_PROG_W_CAUSE_INCLUDE} "
+      PRI_CALL_HOLD_INCLUDE="${PRI_CALL_HOLD_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_PROG_W_CAUSE_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_CALL_HOLD_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_PROG_W_CAUSE_HEADER_FOUND=1
+  PRI_CALL_HOLD_HEADER_FOUND=1
 else
-  PRI_PROG_W_CAUSE_HEADER_FOUND=0
+  PRI_CALL_HOLD_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_PROG_W_CAUSE_HEADER_FOUND}" = "x0" ; then
-         PRI_PROG_W_CAUSE_LIB=""
-         PRI_PROG_W_CAUSE_INCLUDE=""
+      if test "x${PRI_CALL_HOLD_HEADER_FOUND}" = "x0" ; then
+         PRI_CALL_HOLD_LIB=""
+         PRI_CALL_HOLD_INCLUDE=""
       else
 
-         PBX_PRI_PROG_W_CAUSE=1
+         PBX_PRI_CALL_HOLD=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_PROG_W_CAUSE 1
+#define HAVE_PRI_CALL_HOLD 1
 _ACEOF
 
       fi
@@ -28310,22 +28622,22 @@ fi
 
 
 
-if test "x${PBX_PRI_INBANDDISCONNECT}" != "x1" -a "${USE_PRI_INBANDDISCONNECT}" != "no"; then
+if test "x${PBX_PRI_CALL_REROUTING}" != "x1" -a "${USE_PRI_CALL_REROUTING}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_INBANDDISCONNECT=DIR has been specified, use it.
-   if test "x${PRI_INBANDDISCONNECT_DIR}" != "x"; then
-      if test -d ${PRI_INBANDDISCONNECT_DIR}/lib; then
-         pbxlibdir="-L${PRI_INBANDDISCONNECT_DIR}/lib"
+   # if --with-PRI_CALL_REROUTING=DIR has been specified, use it.
+   if test "x${PRI_CALL_REROUTING_DIR}" != "x"; then
+      if test -d ${PRI_CALL_REROUTING_DIR}/lib; then
+         pbxlibdir="-L${PRI_CALL_REROUTING_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_INBANDDISCONNECT_DIR}"
+         pbxlibdir="-L${PRI_CALL_REROUTING_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_set_inbanddisconnect in -lpri" >&5
-$as_echo_n "checking for pri_set_inbanddisconnect in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_set_inbanddisconnect+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_reroute_enable in -lpri" >&5
+$as_echo_n "checking for pri_reroute_enable in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_reroute_enable+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -28339,65 +28651,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_set_inbanddisconnect ();
+char pri_reroute_enable ();
 int
 main ()
 {
-return pri_set_inbanddisconnect ();
+return pri_reroute_enable ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_set_inbanddisconnect=yes
+  ac_cv_lib_pri_pri_reroute_enable=yes
 else
-  ac_cv_lib_pri_pri_set_inbanddisconnect=no
+  ac_cv_lib_pri_pri_reroute_enable=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_set_inbanddisconnect" >&5
-$as_echo "$ac_cv_lib_pri_pri_set_inbanddisconnect" >&6; }
-if test "x$ac_cv_lib_pri_pri_set_inbanddisconnect" = xyes; then :
-  AST_PRI_INBANDDISCONNECT_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_reroute_enable" >&5
+$as_echo "$ac_cv_lib_pri_pri_reroute_enable" >&6; }
+if test "x$ac_cv_lib_pri_pri_reroute_enable" = xyes; then :
+  AST_PRI_CALL_REROUTING_FOUND=yes
 else
-  AST_PRI_INBANDDISCONNECT_FOUND=no
+  AST_PRI_CALL_REROUTING_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_INBANDDISCONNECT_FOUND}" = "yes"; then
-      PRI_INBANDDISCONNECT_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_INBANDDISCONNECT=DIR has been specified, use it.
-      if test "x${PRI_INBANDDISCONNECT_DIR}" != "x"; then
-         PRI_INBANDDISCONNECT_INCLUDE="-I${PRI_INBANDDISCONNECT_DIR}/include"
+   if test "${AST_PRI_CALL_REROUTING_FOUND}" = "yes"; then
+      PRI_CALL_REROUTING_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_CALL_REROUTING=DIR has been specified, use it.
+      if test "x${PRI_CALL_REROUTING_DIR}" != "x"; then
+         PRI_CALL_REROUTING_INCLUDE="-I${PRI_CALL_REROUTING_DIR}/include"
       fi
-      PRI_INBANDDISCONNECT_INCLUDE="${PRI_INBANDDISCONNECT_INCLUDE} "
+      PRI_CALL_REROUTING_INCLUDE="${PRI_CALL_REROUTING_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_INBANDDISCONNECT_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_CALL_REROUTING_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_INBANDDISCONNECT_HEADER_FOUND=1
+  PRI_CALL_REROUTING_HEADER_FOUND=1
 else
-  PRI_INBANDDISCONNECT_HEADER_FOUND=0
+  PRI_CALL_REROUTING_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_INBANDDISCONNECT_HEADER_FOUND}" = "x0" ; then
-         PRI_INBANDDISCONNECT_LIB=""
-         PRI_INBANDDISCONNECT_INCLUDE=""
+      if test "x${PRI_CALL_REROUTING_HEADER_FOUND}" = "x0" ; then
+         PRI_CALL_REROUTING_LIB=""
+         PRI_CALL_REROUTING_INCLUDE=""
       else
 
-         PBX_PRI_INBANDDISCONNECT=1
+         PBX_PRI_CALL_REROUTING=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_INBANDDISCONNECT 1
+#define HAVE_PRI_CALL_REROUTING 1
 _ACEOF
 
       fi
@@ -28406,22 +28718,22 @@ fi
 
 
 
-if test "x${PBX_PRI_SERVICE_MESSAGES}" != "x1" -a "${USE_PRI_SERVICE_MESSAGES}" != "no"; then
+if test "x${PBX_PRI_SETUP_KEYPAD}" != "x1" -a "${USE_PRI_SETUP_KEYPAD}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_SERVICE_MESSAGES=DIR has been specified, use it.
-   if test "x${PRI_SERVICE_MESSAGES_DIR}" != "x"; then
-      if test -d ${PRI_SERVICE_MESSAGES_DIR}/lib; then
-         pbxlibdir="-L${PRI_SERVICE_MESSAGES_DIR}/lib"
+   # if --with-PRI_SETUP_KEYPAD=DIR has been specified, use it.
+   if test "x${PRI_SETUP_KEYPAD_DIR}" != "x"; then
+      if test -d ${PRI_SETUP_KEYPAD_DIR}/lib; then
+         pbxlibdir="-L${PRI_SETUP_KEYPAD_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_SERVICE_MESSAGES_DIR}"
+         pbxlibdir="-L${PRI_SETUP_KEYPAD_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_maintenance_service in -lpri" >&5
-$as_echo_n "checking for pri_maintenance_service in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_maintenance_service+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_sr_set_keypad_digits in -lpri" >&5
+$as_echo_n "checking for pri_sr_set_keypad_digits in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_sr_set_keypad_digits+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -28435,65 +28747,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_maintenance_service ();
+char pri_sr_set_keypad_digits ();
 int
 main ()
 {
-return pri_maintenance_service ();
+return pri_sr_set_keypad_digits ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_maintenance_service=yes
+  ac_cv_lib_pri_pri_sr_set_keypad_digits=yes
 else
-  ac_cv_lib_pri_pri_maintenance_service=no
+  ac_cv_lib_pri_pri_sr_set_keypad_digits=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_maintenance_service" >&5
-$as_echo "$ac_cv_lib_pri_pri_maintenance_service" >&6; }
-if test "x$ac_cv_lib_pri_pri_maintenance_service" = xyes; then :
-  AST_PRI_SERVICE_MESSAGES_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_sr_set_keypad_digits" >&5
+$as_echo "$ac_cv_lib_pri_pri_sr_set_keypad_digits" >&6; }
+if test "x$ac_cv_lib_pri_pri_sr_set_keypad_digits" = xyes; then :
+  AST_PRI_SETUP_KEYPAD_FOUND=yes
 else
-  AST_PRI_SERVICE_MESSAGES_FOUND=no
+  AST_PRI_SETUP_KEYPAD_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_SERVICE_MESSAGES_FOUND}" = "yes"; then
-      PRI_SERVICE_MESSAGES_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_SERVICE_MESSAGES=DIR has been specified, use it.
-      if test "x${PRI_SERVICE_MESSAGES_DIR}" != "x"; then
-         PRI_SERVICE_MESSAGES_INCLUDE="-I${PRI_SERVICE_MESSAGES_DIR}/include"
+   if test "${AST_PRI_SETUP_KEYPAD_FOUND}" = "yes"; then
+      PRI_SETUP_KEYPAD_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_SETUP_KEYPAD=DIR has been specified, use it.
+      if test "x${PRI_SETUP_KEYPAD_DIR}" != "x"; then
+         PRI_SETUP_KEYPAD_INCLUDE="-I${PRI_SETUP_KEYPAD_DIR}/include"
       fi
-      PRI_SERVICE_MESSAGES_INCLUDE="${PRI_SERVICE_MESSAGES_INCLUDE} "
+      PRI_SETUP_KEYPAD_INCLUDE="${PRI_SETUP_KEYPAD_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_SERVICE_MESSAGES_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_SETUP_KEYPAD_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_SERVICE_MESSAGES_HEADER_FOUND=1
+  PRI_SETUP_KEYPAD_HEADER_FOUND=1
 else
-  PRI_SERVICE_MESSAGES_HEADER_FOUND=0
+  PRI_SETUP_KEYPAD_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_SERVICE_MESSAGES_HEADER_FOUND}" = "x0" ; then
-         PRI_SERVICE_MESSAGES_LIB=""
-         PRI_SERVICE_MESSAGES_INCLUDE=""
+      if test "x${PRI_SETUP_KEYPAD_HEADER_FOUND}" = "x0" ; then
+         PRI_SETUP_KEYPAD_LIB=""
+         PRI_SETUP_KEYPAD_INCLUDE=""
       else
 
-         PBX_PRI_SERVICE_MESSAGES=1
+         PBX_PRI_SETUP_KEYPAD=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_SERVICE_MESSAGES 1
+#define HAVE_PRI_SETUP_KEYPAD 1
 _ACEOF
 
       fi
@@ -28502,22 +28814,26 @@ fi
 
 
 
-if test "x${PBX_PRI_REVERSE_CHARGE}" != "x1" -a "${USE_PRI_REVERSE_CHARGE}" != "no"; then
+   # ------------------------------------v
+   # TODO: The code can be changed to always include these features now.
+   # These features will always be present if pri_connected_line_update is available.
+
+if test "x${PBX_PRI_PROG_W_CAUSE}" != "x1" -a "${USE_PRI_PROG_W_CAUSE}" != "no"; then
    pbxlibdir=""
-   # if --with-PRI_REVERSE_CHARGE=DIR has been specified, use it.
-   if test "x${PRI_REVERSE_CHARGE_DIR}" != "x"; then
-      if test -d ${PRI_REVERSE_CHARGE_DIR}/lib; then
-         pbxlibdir="-L${PRI_REVERSE_CHARGE_DIR}/lib"
+   # if --with-PRI_PROG_W_CAUSE=DIR has been specified, use it.
+   if test "x${PRI_PROG_W_CAUSE_DIR}" != "x"; then
+      if test -d ${PRI_PROG_W_CAUSE_DIR}/lib; then
+         pbxlibdir="-L${PRI_PROG_W_CAUSE_DIR}/lib"
       else
-         pbxlibdir="-L${PRI_REVERSE_CHARGE_DIR}"
+         pbxlibdir="-L${PRI_PROG_W_CAUSE_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_sr_set_reversecharge in -lpri" >&5
-$as_echo_n "checking for pri_sr_set_reversecharge in -lpri... " >&6; }
-if ${ac_cv_lib_pri_pri_sr_set_reversecharge+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_progress_with_cause in -lpri" >&5
+$as_echo_n "checking for pri_progress_with_cause in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_progress_with_cause+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -28531,65 +28847,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pri_sr_set_reversecharge ();
+char pri_progress_with_cause ();
 int
 main ()
 {
-return pri_sr_set_reversecharge ();
+return pri_progress_with_cause ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pri_pri_sr_set_reversecharge=yes
+  ac_cv_lib_pri_pri_progress_with_cause=yes
 else
-  ac_cv_lib_pri_pri_sr_set_reversecharge=no
+  ac_cv_lib_pri_pri_progress_with_cause=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_sr_set_reversecharge" >&5
-$as_echo "$ac_cv_lib_pri_pri_sr_set_reversecharge" >&6; }
-if test "x$ac_cv_lib_pri_pri_sr_set_reversecharge" = xyes; then :
-  AST_PRI_REVERSE_CHARGE_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_progress_with_cause" >&5
+$as_echo "$ac_cv_lib_pri_pri_progress_with_cause" >&6; }
+if test "x$ac_cv_lib_pri_pri_progress_with_cause" = xyes; then :
+  AST_PRI_PROG_W_CAUSE_FOUND=yes
 else
-  AST_PRI_REVERSE_CHARGE_FOUND=no
+  AST_PRI_PROG_W_CAUSE_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_PRI_REVERSE_CHARGE_FOUND}" = "yes"; then
-      PRI_REVERSE_CHARGE_LIB="${pbxlibdir} -lpri "
-      # if --with-PRI_REVERSE_CHARGE=DIR has been specified, use it.
-      if test "x${PRI_REVERSE_CHARGE_DIR}" != "x"; then
-         PRI_REVERSE_CHARGE_INCLUDE="-I${PRI_REVERSE_CHARGE_DIR}/include"
+   if test "${AST_PRI_PROG_W_CAUSE_FOUND}" = "yes"; then
+      PRI_PROG_W_CAUSE_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_PROG_W_CAUSE=DIR has been specified, use it.
+      if test "x${PRI_PROG_W_CAUSE_DIR}" != "x"; then
+         PRI_PROG_W_CAUSE_INCLUDE="-I${PRI_PROG_W_CAUSE_DIR}/include"
       fi
-      PRI_REVERSE_CHARGE_INCLUDE="${PRI_REVERSE_CHARGE_INCLUDE} "
+      PRI_PROG_W_CAUSE_INCLUDE="${PRI_PROG_W_CAUSE_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${PRI_REVERSE_CHARGE_INCLUDE}"
+         CPPFLAGS="${CPPFLAGS} ${PRI_PROG_W_CAUSE_INCLUDE}"
          ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
 if test "x$ac_cv_header_libpri_h" = xyes; then :
-  PRI_REVERSE_CHARGE_HEADER_FOUND=1
+  PRI_PROG_W_CAUSE_HEADER_FOUND=1
 else
-  PRI_REVERSE_CHARGE_HEADER_FOUND=0
+  PRI_PROG_W_CAUSE_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${PRI_REVERSE_CHARGE_HEADER_FOUND}" = "x0" ; then
-         PRI_REVERSE_CHARGE_LIB=""
-         PRI_REVERSE_CHARGE_INCLUDE=""
+      if test "x${PRI_PROG_W_CAUSE_HEADER_FOUND}" = "x0" ; then
+         PRI_PROG_W_CAUSE_LIB=""
+         PRI_PROG_W_CAUSE_INCLUDE=""
       else
 
-         PBX_PRI_REVERSE_CHARGE=1
+         PBX_PRI_PROG_W_CAUSE=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_PRI_REVERSE_CHARGE 1
+#define HAVE_PRI_PROG_W_CAUSE 1
 _ACEOF
 
       fi
@@ -28597,30 +28913,27 @@ _ACEOF
 fi
 
 
-   # ------------------------------------^
-fi
 
-
-if test "x${PBX_RESAMPLE}" != "x1" -a "${USE_RESAMPLE}" != "no"; then
+if test "x${PBX_PRI_INBANDDISCONNECT}" != "x1" -a "${USE_PRI_INBANDDISCONNECT}" != "no"; then
    pbxlibdir=""
-   # if --with-RESAMPLE=DIR has been specified, use it.
-   if test "x${RESAMPLE_DIR}" != "x"; then
-      if test -d ${RESAMPLE_DIR}/lib; then
-         pbxlibdir="-L${RESAMPLE_DIR}/lib"
+   # if --with-PRI_INBANDDISCONNECT=DIR has been specified, use it.
+   if test "x${PRI_INBANDDISCONNECT_DIR}" != "x"; then
+      if test -d ${PRI_INBANDDISCONNECT_DIR}/lib; then
+         pbxlibdir="-L${PRI_INBANDDISCONNECT_DIR}/lib"
       else
-         pbxlibdir="-L${RESAMPLE_DIR}"
+         pbxlibdir="-L${PRI_INBANDDISCONNECT_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for resample_open in -lresample" >&5
-$as_echo_n "checking for resample_open in -lresample... " >&6; }
-if ${ac_cv_lib_resample_resample_open+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_set_inbanddisconnect in -lpri" >&5
+$as_echo_n "checking for pri_set_inbanddisconnect in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_set_inbanddisconnect+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresample ${pbxlibdir} -lm $LIBS"
+LIBS="-lpri ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -28630,65 +28943,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char resample_open ();
+char pri_set_inbanddisconnect ();
 int
 main ()
 {
-return resample_open ();
+return pri_set_inbanddisconnect ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_resample_resample_open=yes
+  ac_cv_lib_pri_pri_set_inbanddisconnect=yes
 else
-  ac_cv_lib_resample_resample_open=no
+  ac_cv_lib_pri_pri_set_inbanddisconnect=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resample_resample_open" >&5
-$as_echo "$ac_cv_lib_resample_resample_open" >&6; }
-if test "x$ac_cv_lib_resample_resample_open" = xyes; then :
-  AST_RESAMPLE_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_set_inbanddisconnect" >&5
+$as_echo "$ac_cv_lib_pri_pri_set_inbanddisconnect" >&6; }
+if test "x$ac_cv_lib_pri_pri_set_inbanddisconnect" = xyes; then :
+  AST_PRI_INBANDDISCONNECT_FOUND=yes
 else
-  AST_RESAMPLE_FOUND=no
+  AST_PRI_INBANDDISCONNECT_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_RESAMPLE_FOUND}" = "yes"; then
-      RESAMPLE_LIB="${pbxlibdir} -lresample -lm"
-      # if --with-RESAMPLE=DIR has been specified, use it.
-      if test "x${RESAMPLE_DIR}" != "x"; then
-         RESAMPLE_INCLUDE="-I${RESAMPLE_DIR}/include"
+   if test "${AST_PRI_INBANDDISCONNECT_FOUND}" = "yes"; then
+      PRI_INBANDDISCONNECT_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_INBANDDISCONNECT=DIR has been specified, use it.
+      if test "x${PRI_INBANDDISCONNECT_DIR}" != "x"; then
+         PRI_INBANDDISCONNECT_INCLUDE="-I${PRI_INBANDDISCONNECT_DIR}/include"
       fi
-      RESAMPLE_INCLUDE="${RESAMPLE_INCLUDE} "
+      PRI_INBANDDISCONNECT_INCLUDE="${PRI_INBANDDISCONNECT_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${RESAMPLE_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "libresample.h" "ac_cv_header_libresample_h" "$ac_includes_default"
-if test "x$ac_cv_header_libresample_h" = xyes; then :
-  RESAMPLE_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${PRI_INBANDDISCONNECT_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
+if test "x$ac_cv_header_libpri_h" = xyes; then :
+  PRI_INBANDDISCONNECT_HEADER_FOUND=1
 else
-  RESAMPLE_HEADER_FOUND=0
+  PRI_INBANDDISCONNECT_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${RESAMPLE_HEADER_FOUND}" = "x0" ; then
-         RESAMPLE_LIB=""
-         RESAMPLE_INCLUDE=""
+      if test "x${PRI_INBANDDISCONNECT_HEADER_FOUND}" = "x0" ; then
+         PRI_INBANDDISCONNECT_LIB=""
+         PRI_INBANDDISCONNECT_INCLUDE=""
       else
 
-         PBX_RESAMPLE=1
+         PBX_PRI_INBANDDISCONNECT=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_RESAMPLE 1
+#define HAVE_PRI_INBANDDISCONNECT 1
 _ACEOF
 
       fi
@@ -28697,26 +29010,26 @@ fi
 
 
 
-if test "x${PBX_FFTW3}" != "x1" -a "${USE_FFTW3}" != "no"; then
+if test "x${PBX_PRI_SERVICE_MESSAGES}" != "x1" -a "${USE_PRI_SERVICE_MESSAGES}" != "no"; then
    pbxlibdir=""
-   # if --with-FFTW3=DIR has been specified, use it.
-   if test "x${FFTW3_DIR}" != "x"; then
-      if test -d ${FFTW3_DIR}/lib; then
-         pbxlibdir="-L${FFTW3_DIR}/lib"
+   # if --with-PRI_SERVICE_MESSAGES=DIR has been specified, use it.
+   if test "x${PRI_SERVICE_MESSAGES_DIR}" != "x"; then
+      if test -d ${PRI_SERVICE_MESSAGES_DIR}/lib; then
+         pbxlibdir="-L${PRI_SERVICE_MESSAGES_DIR}/lib"
       else
-         pbxlibdir="-L${FFTW3_DIR}"
+         pbxlibdir="-L${PRI_SERVICE_MESSAGES_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fftw_malloc in -lfftw3" >&5
-$as_echo_n "checking for fftw_malloc in -lfftw3... " >&6; }
-if ${ac_cv_lib_fftw3_fftw_malloc+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_maintenance_service in -lpri" >&5
+$as_echo_n "checking for pri_maintenance_service in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_maintenance_service+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lfftw3 ${pbxlibdir}  $LIBS"
+LIBS="-lpri ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -28726,65 +29039,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char fftw_malloc ();
+char pri_maintenance_service ();
 int
 main ()
 {
-return fftw_malloc ();
+return pri_maintenance_service ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_fftw3_fftw_malloc=yes
+  ac_cv_lib_pri_pri_maintenance_service=yes
 else
-  ac_cv_lib_fftw3_fftw_malloc=no
+  ac_cv_lib_pri_pri_maintenance_service=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fftw3_fftw_malloc" >&5
-$as_echo "$ac_cv_lib_fftw3_fftw_malloc" >&6; }
-if test "x$ac_cv_lib_fftw3_fftw_malloc" = xyes; then :
-  AST_FFTW3_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_maintenance_service" >&5
+$as_echo "$ac_cv_lib_pri_pri_maintenance_service" >&6; }
+if test "x$ac_cv_lib_pri_pri_maintenance_service" = xyes; then :
+  AST_PRI_SERVICE_MESSAGES_FOUND=yes
 else
-  AST_FFTW3_FOUND=no
+  AST_PRI_SERVICE_MESSAGES_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_FFTW3_FOUND}" = "yes"; then
-      FFTW3_LIB="${pbxlibdir} -lfftw3 "
-      # if --with-FFTW3=DIR has been specified, use it.
-      if test "x${FFTW3_DIR}" != "x"; then
-         FFTW3_INCLUDE="-I${FFTW3_DIR}/include"
+   if test "${AST_PRI_SERVICE_MESSAGES_FOUND}" = "yes"; then
+      PRI_SERVICE_MESSAGES_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_SERVICE_MESSAGES=DIR has been specified, use it.
+      if test "x${PRI_SERVICE_MESSAGES_DIR}" != "x"; then
+         PRI_SERVICE_MESSAGES_INCLUDE="-I${PRI_SERVICE_MESSAGES_DIR}/include"
       fi
-      FFTW3_INCLUDE="${FFTW3_INCLUDE} "
+      PRI_SERVICE_MESSAGES_INCLUDE="${PRI_SERVICE_MESSAGES_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${FFTW3_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "fftw3.h" "ac_cv_header_fftw3_h" "$ac_includes_default"
-if test "x$ac_cv_header_fftw3_h" = xyes; then :
-  FFTW3_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${PRI_SERVICE_MESSAGES_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
+if test "x$ac_cv_header_libpri_h" = xyes; then :
+  PRI_SERVICE_MESSAGES_HEADER_FOUND=1
 else
-  FFTW3_HEADER_FOUND=0
+  PRI_SERVICE_MESSAGES_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${FFTW3_HEADER_FOUND}" = "x0" ; then
-         FFTW3_LIB=""
-         FFTW3_INCLUDE=""
+      if test "x${PRI_SERVICE_MESSAGES_HEADER_FOUND}" = "x0" ; then
+         PRI_SERVICE_MESSAGES_LIB=""
+         PRI_SERVICE_MESSAGES_INCLUDE=""
       else
 
-         PBX_FFTW3=1
+         PBX_PRI_SERVICE_MESSAGES=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_FFTW3 1
+#define HAVE_PRI_SERVICE_MESSAGES 1
 _ACEOF
 
       fi
@@ -28793,26 +29106,26 @@ fi
 
 
 
-if test "x${PBX_SNDFILE}" != "x1" -a "${USE_SNDFILE}" != "no"; then
+if test "x${PBX_PRI_REVERSE_CHARGE}" != "x1" -a "${USE_PRI_REVERSE_CHARGE}" != "no"; then
    pbxlibdir=""
-   # if --with-SNDFILE=DIR has been specified, use it.
-   if test "x${SNDFILE_DIR}" != "x"; then
-      if test -d ${SNDFILE_DIR}/lib; then
-         pbxlibdir="-L${SNDFILE_DIR}/lib"
+   # if --with-PRI_REVERSE_CHARGE=DIR has been specified, use it.
+   if test "x${PRI_REVERSE_CHARGE_DIR}" != "x"; then
+      if test -d ${PRI_REVERSE_CHARGE_DIR}/lib; then
+         pbxlibdir="-L${PRI_REVERSE_CHARGE_DIR}/lib"
       else
-         pbxlibdir="-L${SNDFILE_DIR}"
+         pbxlibdir="-L${PRI_REVERSE_CHARGE_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sf_open in -lsndfile" >&5
-$as_echo_n "checking for sf_open in -lsndfile... " >&6; }
-if ${ac_cv_lib_sndfile_sf_open+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pri_sr_set_reversecharge in -lpri" >&5
+$as_echo_n "checking for pri_sr_set_reversecharge in -lpri... " >&6; }
+if ${ac_cv_lib_pri_pri_sr_set_reversecharge+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsndfile ${pbxlibdir}  $LIBS"
+LIBS="-lpri ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -28822,65 +29135,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char sf_open ();
+char pri_sr_set_reversecharge ();
 int
 main ()
 {
-return sf_open ();
+return pri_sr_set_reversecharge ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_sndfile_sf_open=yes
+  ac_cv_lib_pri_pri_sr_set_reversecharge=yes
 else
-  ac_cv_lib_sndfile_sf_open=no
+  ac_cv_lib_pri_pri_sr_set_reversecharge=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sndfile_sf_open" >&5
-$as_echo "$ac_cv_lib_sndfile_sf_open" >&6; }
-if test "x$ac_cv_lib_sndfile_sf_open" = xyes; then :
-  AST_SNDFILE_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pri_pri_sr_set_reversecharge" >&5
+$as_echo "$ac_cv_lib_pri_pri_sr_set_reversecharge" >&6; }
+if test "x$ac_cv_lib_pri_pri_sr_set_reversecharge" = xyes; then :
+  AST_PRI_REVERSE_CHARGE_FOUND=yes
 else
-  AST_SNDFILE_FOUND=no
+  AST_PRI_REVERSE_CHARGE_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SNDFILE_FOUND}" = "yes"; then
-      SNDFILE_LIB="${pbxlibdir} -lsndfile "
-      # if --with-SNDFILE=DIR has been specified, use it.
-      if test "x${SNDFILE_DIR}" != "x"; then
-         SNDFILE_INCLUDE="-I${SNDFILE_DIR}/include"
+   if test "${AST_PRI_REVERSE_CHARGE_FOUND}" = "yes"; then
+      PRI_REVERSE_CHARGE_LIB="${pbxlibdir} -lpri "
+      # if --with-PRI_REVERSE_CHARGE=DIR has been specified, use it.
+      if test "x${PRI_REVERSE_CHARGE_DIR}" != "x"; then
+         PRI_REVERSE_CHARGE_INCLUDE="-I${PRI_REVERSE_CHARGE_DIR}/include"
       fi
-      SNDFILE_INCLUDE="${SNDFILE_INCLUDE} "
+      PRI_REVERSE_CHARGE_INCLUDE="${PRI_REVERSE_CHARGE_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SNDFILE_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "sndfile.h" "ac_cv_header_sndfile_h" "$ac_includes_default"
-if test "x$ac_cv_header_sndfile_h" = xyes; then :
-  SNDFILE_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${PRI_REVERSE_CHARGE_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "libpri.h" "ac_cv_header_libpri_h" "$ac_includes_default"
+if test "x$ac_cv_header_libpri_h" = xyes; then :
+  PRI_REVERSE_CHARGE_HEADER_FOUND=1
 else
-  SNDFILE_HEADER_FOUND=0
+  PRI_REVERSE_CHARGE_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SNDFILE_HEADER_FOUND}" = "x0" ; then
-         SNDFILE_LIB=""
-         SNDFILE_INCLUDE=""
+      if test "x${PRI_REVERSE_CHARGE_HEADER_FOUND}" = "x0" ; then
+         PRI_REVERSE_CHARGE_LIB=""
+         PRI_REVERSE_CHARGE_INCLUDE=""
       else
 
-         PBX_SNDFILE=1
+         PBX_PRI_REVERSE_CHARGE=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SNDFILE 1
+#define HAVE_PRI_REVERSE_CHARGE 1
 _ACEOF
 
       fi
@@ -28888,77 +29201,30 @@ _ACEOF
 fi
 
 
-
-
-    if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for minimum version of SpanDSP" >&5
-$as_echo_n "checking for minimum version of SpanDSP... " >&6; }
-	saved_cppflags="${CPPFLAGS}"
-	if test "x${SPANDSP_DIR}" != "x"; then
-	    SPANDSP_INCLUDE="-I${SPANDSP_DIR}/include"
-	fi
-	CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
-
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
- #include <spandsp/version.h>
-int
-main ()
-{
-
-		#if SPANDSP_RELEASE_DATE < 20080516
-		#error "spandsp 0.0.5 or greater is required"
-		#endif
-	;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		PBX_SPANDSP=1
-
-$as_echo "#define HAVE_SPANDSP 1" >>confdefs.h
-
-
-
-else
-         { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
+   # ------------------------------------^
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	CPPFLAGS="${saved_cppflags}"
-    fi
-
 
-if test "x${PBX_SPANDSP}" = "x1" ; then
-	# We found the correct version in the header, now let's make sure it links
-	# properly, and that libtiff is available
-	PBX_SPANDSP=0
 
-if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
+if test "x${PBX_RESAMPLE}" != "x1" -a "${USE_RESAMPLE}" != "no"; then
    pbxlibdir=""
-   # if --with-SPANDSP=DIR has been specified, use it.
-   if test "x${SPANDSP_DIR}" != "x"; then
-      if test -d ${SPANDSP_DIR}/lib; then
-         pbxlibdir="-L${SPANDSP_DIR}/lib"
+   # if --with-RESAMPLE=DIR has been specified, use it.
+   if test "x${RESAMPLE_DIR}" != "x"; then
+      if test -d ${RESAMPLE_DIR}/lib; then
+         pbxlibdir="-L${RESAMPLE_DIR}/lib"
       else
-         pbxlibdir="-L${SPANDSP_DIR}"
+         pbxlibdir="-L${RESAMPLE_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for span_set_message_handler in -lspandsp" >&5
-$as_echo_n "checking for span_set_message_handler in -lspandsp... " >&6; }
-if ${ac_cv_lib_spandsp_span_set_message_handler+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for resample_open in -lresample" >&5
+$as_echo_n "checking for resample_open in -lresample... " >&6; }
+if ${ac_cv_lib_resample_resample_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lspandsp ${pbxlibdir} -ltiff $LIBS"
+LIBS="-lresample ${pbxlibdir} -lm $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -28968,65 +29234,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char span_set_message_handler ();
+char resample_open ();
 int
 main ()
 {
-return span_set_message_handler ();
+return resample_open ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_spandsp_span_set_message_handler=yes
+  ac_cv_lib_resample_resample_open=yes
 else
-  ac_cv_lib_spandsp_span_set_message_handler=no
+  ac_cv_lib_resample_resample_open=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_spandsp_span_set_message_handler" >&5
-$as_echo "$ac_cv_lib_spandsp_span_set_message_handler" >&6; }
-if test "x$ac_cv_lib_spandsp_span_set_message_handler" = xyes; then :
-  AST_SPANDSP_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resample_resample_open" >&5
+$as_echo "$ac_cv_lib_resample_resample_open" >&6; }
+if test "x$ac_cv_lib_resample_resample_open" = xyes; then :
+  AST_RESAMPLE_FOUND=yes
 else
-  AST_SPANDSP_FOUND=no
+  AST_RESAMPLE_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SPANDSP_FOUND}" = "yes"; then
-      SPANDSP_LIB="${pbxlibdir} -lspandsp -ltiff"
-      # if --with-SPANDSP=DIR has been specified, use it.
-      if test "x${SPANDSP_DIR}" != "x"; then
-         SPANDSP_INCLUDE="-I${SPANDSP_DIR}/include"
+   if test "${AST_RESAMPLE_FOUND}" = "yes"; then
+      RESAMPLE_LIB="${pbxlibdir} -lresample -lm"
+      # if --with-RESAMPLE=DIR has been specified, use it.
+      if test "x${RESAMPLE_DIR}" != "x"; then
+         RESAMPLE_INCLUDE="-I${RESAMPLE_DIR}/include"
       fi
-      SPANDSP_INCLUDE="${SPANDSP_INCLUDE} "
+      RESAMPLE_INCLUDE="${RESAMPLE_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "spandsp.h" "ac_cv_header_spandsp_h" "$ac_includes_default"
-if test "x$ac_cv_header_spandsp_h" = xyes; then :
-  SPANDSP_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${RESAMPLE_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "libresample.h" "ac_cv_header_libresample_h" "$ac_includes_default"
+if test "x$ac_cv_header_libresample_h" = xyes; then :
+  RESAMPLE_HEADER_FOUND=1
 else
-  SPANDSP_HEADER_FOUND=0
+  RESAMPLE_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SPANDSP_HEADER_FOUND}" = "x0" ; then
-         SPANDSP_LIB=""
-         SPANDSP_INCLUDE=""
+      if test "x${RESAMPLE_HEADER_FOUND}" = "x0" ; then
+         RESAMPLE_LIB=""
+         RESAMPLE_INCLUDE=""
       else
 
-         PBX_SPANDSP=1
+         PBX_RESAMPLE=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SPANDSP 1
+#define HAVE_RESAMPLE 1
 _ACEOF
 
       fi
@@ -29034,32 +29300,27 @@ _ACEOF
 fi
 
 
-fi
-
-if test "x${PBX_SPANDSP}" = "x1" ; then
-	# We also need t38_terminal_init()
-	PBX_SPANDSP=0
 
-if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
+if test "x${PBX_FFTW3}" != "x1" -a "${USE_FFTW3}" != "no"; then
    pbxlibdir=""
-   # if --with-SPANDSP=DIR has been specified, use it.
-   if test "x${SPANDSP_DIR}" != "x"; then
-      if test -d ${SPANDSP_DIR}/lib; then
-         pbxlibdir="-L${SPANDSP_DIR}/lib"
+   # if --with-FFTW3=DIR has been specified, use it.
+   if test "x${FFTW3_DIR}" != "x"; then
+      if test -d ${FFTW3_DIR}/lib; then
+         pbxlibdir="-L${FFTW3_DIR}/lib"
       else
-         pbxlibdir="-L${SPANDSP_DIR}"
+         pbxlibdir="-L${FFTW3_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for t38_terminal_init in -lspandsp" >&5
-$as_echo_n "checking for t38_terminal_init in -lspandsp... " >&6; }
-if ${ac_cv_lib_spandsp_t38_terminal_init+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fftw_malloc in -lfftw3" >&5
+$as_echo_n "checking for fftw_malloc in -lfftw3... " >&6; }
+if ${ac_cv_lib_fftw3_fftw_malloc+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lspandsp ${pbxlibdir} -ltiff $LIBS"
+LIBS="-lfftw3 ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29069,65 +29330,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char t38_terminal_init ();
+char fftw_malloc ();
 int
 main ()
 {
-return t38_terminal_init ();
+return fftw_malloc ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_spandsp_t38_terminal_init=yes
+  ac_cv_lib_fftw3_fftw_malloc=yes
 else
-  ac_cv_lib_spandsp_t38_terminal_init=no
+  ac_cv_lib_fftw3_fftw_malloc=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_spandsp_t38_terminal_init" >&5
-$as_echo "$ac_cv_lib_spandsp_t38_terminal_init" >&6; }
-if test "x$ac_cv_lib_spandsp_t38_terminal_init" = xyes; then :
-  AST_SPANDSP_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fftw3_fftw_malloc" >&5
+$as_echo "$ac_cv_lib_fftw3_fftw_malloc" >&6; }
+if test "x$ac_cv_lib_fftw3_fftw_malloc" = xyes; then :
+  AST_FFTW3_FOUND=yes
 else
-  AST_SPANDSP_FOUND=no
+  AST_FFTW3_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SPANDSP_FOUND}" = "yes"; then
-      SPANDSP_LIB="${pbxlibdir} -lspandsp -ltiff"
-      # if --with-SPANDSP=DIR has been specified, use it.
-      if test "x${SPANDSP_DIR}" != "x"; then
-         SPANDSP_INCLUDE="-I${SPANDSP_DIR}/include"
+   if test "${AST_FFTW3_FOUND}" = "yes"; then
+      FFTW3_LIB="${pbxlibdir} -lfftw3 "
+      # if --with-FFTW3=DIR has been specified, use it.
+      if test "x${FFTW3_DIR}" != "x"; then
+         FFTW3_INCLUDE="-I${FFTW3_DIR}/include"
       fi
-      SPANDSP_INCLUDE="${SPANDSP_INCLUDE} "
+      FFTW3_INCLUDE="${FFTW3_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "spandsp.h" "ac_cv_header_spandsp_h" "$ac_includes_default"
-if test "x$ac_cv_header_spandsp_h" = xyes; then :
-  SPANDSP_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${FFTW3_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "fftw3.h" "ac_cv_header_fftw3_h" "$ac_includes_default"
+if test "x$ac_cv_header_fftw3_h" = xyes; then :
+  FFTW3_HEADER_FOUND=1
 else
-  SPANDSP_HEADER_FOUND=0
+  FFTW3_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SPANDSP_HEADER_FOUND}" = "x0" ; then
-         SPANDSP_LIB=""
-         SPANDSP_INCLUDE=""
+      if test "x${FFTW3_HEADER_FOUND}" = "x0" ; then
+         FFTW3_LIB=""
+         FFTW3_INCLUDE=""
       else
 
-         PBX_SPANDSP=1
+         PBX_FFTW3=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SPANDSP 1
+#define HAVE_FFTW3 1
 _ACEOF
 
       fi
@@ -29135,30 +29396,27 @@ _ACEOF
 fi
 
 
-fi
-
-# Check for libss7 v2.0 branch compatible version.
 
-if test "x${PBX_SS7}" != "x1" -a "${USE_SS7}" != "no"; then
+if test "x${PBX_SNDFILE}" != "x1" -a "${USE_SNDFILE}" != "no"; then
    pbxlibdir=""
-   # if --with-SS7=DIR has been specified, use it.
-   if test "x${SS7_DIR}" != "x"; then
-      if test -d ${SS7_DIR}/lib; then
-         pbxlibdir="-L${SS7_DIR}/lib"
+   # if --with-SNDFILE=DIR has been specified, use it.
+   if test "x${SNDFILE_DIR}" != "x"; then
+      if test -d ${SNDFILE_DIR}/lib; then
+         pbxlibdir="-L${SNDFILE_DIR}/lib"
       else
-         pbxlibdir="-L${SS7_DIR}"
+         pbxlibdir="-L${SNDFILE_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ss7_set_isup_timer in -lss7" >&5
-$as_echo_n "checking for ss7_set_isup_timer in -lss7... " >&6; }
-if ${ac_cv_lib_ss7_ss7_set_isup_timer+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sf_open in -lsndfile" >&5
+$as_echo_n "checking for sf_open in -lsndfile... " >&6; }
+if ${ac_cv_lib_sndfile_sf_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lss7 ${pbxlibdir}  $LIBS"
+LIBS="-lsndfile ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29168,65 +29426,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char ss7_set_isup_timer ();
+char sf_open ();
 int
 main ()
 {
-return ss7_set_isup_timer ();
+return sf_open ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ss7_ss7_set_isup_timer=yes
+  ac_cv_lib_sndfile_sf_open=yes
 else
-  ac_cv_lib_ss7_ss7_set_isup_timer=no
+  ac_cv_lib_sndfile_sf_open=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ss7_ss7_set_isup_timer" >&5
-$as_echo "$ac_cv_lib_ss7_ss7_set_isup_timer" >&6; }
-if test "x$ac_cv_lib_ss7_ss7_set_isup_timer" = xyes; then :
-  AST_SS7_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sndfile_sf_open" >&5
+$as_echo "$ac_cv_lib_sndfile_sf_open" >&6; }
+if test "x$ac_cv_lib_sndfile_sf_open" = xyes; then :
+  AST_SNDFILE_FOUND=yes
 else
-  AST_SS7_FOUND=no
+  AST_SNDFILE_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SS7_FOUND}" = "yes"; then
-      SS7_LIB="${pbxlibdir} -lss7 "
-      # if --with-SS7=DIR has been specified, use it.
-      if test "x${SS7_DIR}" != "x"; then
-         SS7_INCLUDE="-I${SS7_DIR}/include"
+   if test "${AST_SNDFILE_FOUND}" = "yes"; then
+      SNDFILE_LIB="${pbxlibdir} -lsndfile "
+      # if --with-SNDFILE=DIR has been specified, use it.
+      if test "x${SNDFILE_DIR}" != "x"; then
+         SNDFILE_INCLUDE="-I${SNDFILE_DIR}/include"
       fi
-      SS7_INCLUDE="${SS7_INCLUDE} "
+      SNDFILE_INCLUDE="${SNDFILE_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SS7_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "libss7.h" "ac_cv_header_libss7_h" "$ac_includes_default"
-if test "x$ac_cv_header_libss7_h" = xyes; then :
-  SS7_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SNDFILE_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "sndfile.h" "ac_cv_header_sndfile_h" "$ac_includes_default"
+if test "x$ac_cv_header_sndfile_h" = xyes; then :
+  SNDFILE_HEADER_FOUND=1
 else
-  SS7_HEADER_FOUND=0
+  SNDFILE_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SS7_HEADER_FOUND}" = "x0" ; then
-         SS7_LIB=""
-         SS7_INCLUDE=""
+      if test "x${SNDFILE_HEADER_FOUND}" = "x0" ; then
+         SNDFILE_LIB=""
+         SNDFILE_INCLUDE=""
       else
 
-         PBX_SS7=1
+         PBX_SNDFILE=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SS7 1
+#define HAVE_SNDFILE 1
 _ACEOF
 
       fi
@@ -29236,26 +29494,75 @@ fi
 
 
 
-if test "x${PBX_OPENR2}" != "x1" -a "${USE_OPENR2}" != "no"; then
+    if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for minimum version of SpanDSP" >&5
+$as_echo_n "checking for minimum version of SpanDSP... " >&6; }
+	saved_cppflags="${CPPFLAGS}"
+	if test "x${SPANDSP_DIR}" != "x"; then
+	    SPANDSP_INCLUDE="-I${SPANDSP_DIR}/include"
+	fi
+	CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
+
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+ #include <spandsp/version.h>
+int
+main ()
+{
+
+		#if SPANDSP_RELEASE_DATE < 20080516
+		#error "spandsp 0.0.5 or greater is required"
+		#endif
+	;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		PBX_SPANDSP=1
+
+$as_echo "#define HAVE_SPANDSP 1" >>confdefs.h
+
+
+
+else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CPPFLAGS="${saved_cppflags}"
+    fi
+
+
+if test "x${PBX_SPANDSP}" = "x1" ; then
+	# We found the correct version in the header, now let's make sure it links
+	# properly, and that libtiff is available
+	PBX_SPANDSP=0
+
+if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
    pbxlibdir=""
-   # if --with-OPENR2=DIR has been specified, use it.
-   if test "x${OPENR2_DIR}" != "x"; then
-      if test -d ${OPENR2_DIR}/lib; then
-         pbxlibdir="-L${OPENR2_DIR}/lib"
+   # if --with-SPANDSP=DIR has been specified, use it.
+   if test "x${SPANDSP_DIR}" != "x"; then
+      if test -d ${SPANDSP_DIR}/lib; then
+         pbxlibdir="-L${SPANDSP_DIR}/lib"
       else
-         pbxlibdir="-L${OPENR2_DIR}"
+         pbxlibdir="-L${SPANDSP_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openr2_chan_new in -lopenr2" >&5
-$as_echo_n "checking for openr2_chan_new in -lopenr2... " >&6; }
-if ${ac_cv_lib_openr2_openr2_chan_new+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for span_set_message_handler in -lspandsp" >&5
+$as_echo_n "checking for span_set_message_handler in -lspandsp... " >&6; }
+if ${ac_cv_lib_spandsp_span_set_message_handler+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lopenr2 ${pbxlibdir}  $LIBS"
+LIBS="-lspandsp ${pbxlibdir} -ltiff $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29265,65 +29572,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char openr2_chan_new ();
+char span_set_message_handler ();
 int
 main ()
 {
-return openr2_chan_new ();
+return span_set_message_handler ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_openr2_openr2_chan_new=yes
+  ac_cv_lib_spandsp_span_set_message_handler=yes
 else
-  ac_cv_lib_openr2_openr2_chan_new=no
+  ac_cv_lib_spandsp_span_set_message_handler=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_openr2_openr2_chan_new" >&5
-$as_echo "$ac_cv_lib_openr2_openr2_chan_new" >&6; }
-if test "x$ac_cv_lib_openr2_openr2_chan_new" = xyes; then :
-  AST_OPENR2_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_spandsp_span_set_message_handler" >&5
+$as_echo "$ac_cv_lib_spandsp_span_set_message_handler" >&6; }
+if test "x$ac_cv_lib_spandsp_span_set_message_handler" = xyes; then :
+  AST_SPANDSP_FOUND=yes
 else
-  AST_OPENR2_FOUND=no
+  AST_SPANDSP_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_OPENR2_FOUND}" = "yes"; then
-      OPENR2_LIB="${pbxlibdir} -lopenr2 "
-      # if --with-OPENR2=DIR has been specified, use it.
-      if test "x${OPENR2_DIR}" != "x"; then
-         OPENR2_INCLUDE="-I${OPENR2_DIR}/include"
+   if test "${AST_SPANDSP_FOUND}" = "yes"; then
+      SPANDSP_LIB="${pbxlibdir} -lspandsp -ltiff"
+      # if --with-SPANDSP=DIR has been specified, use it.
+      if test "x${SPANDSP_DIR}" != "x"; then
+         SPANDSP_INCLUDE="-I${SPANDSP_DIR}/include"
       fi
-      OPENR2_INCLUDE="${OPENR2_INCLUDE} "
+      SPANDSP_INCLUDE="${SPANDSP_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${OPENR2_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "openr2.h" "ac_cv_header_openr2_h" "$ac_includes_default"
-if test "x$ac_cv_header_openr2_h" = xyes; then :
-  OPENR2_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "spandsp.h" "ac_cv_header_spandsp_h" "$ac_includes_default"
+if test "x$ac_cv_header_spandsp_h" = xyes; then :
+  SPANDSP_HEADER_FOUND=1
 else
-  OPENR2_HEADER_FOUND=0
+  SPANDSP_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${OPENR2_HEADER_FOUND}" = "x0" ; then
-         OPENR2_LIB=""
-         OPENR2_INCLUDE=""
+      if test "x${SPANDSP_HEADER_FOUND}" = "x0" ; then
+         SPANDSP_LIB=""
+         SPANDSP_INCLUDE=""
       else
 
-         PBX_OPENR2=1
+         PBX_SPANDSP=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_OPENR2 1
+#define HAVE_SPANDSP 1
 _ACEOF
 
       fi
@@ -29331,28 +29638,32 @@ _ACEOF
 fi
 
 
+fi
 
+if test "x${PBX_SPANDSP}" = "x1" ; then
+	# We also need t38_terminal_init()
+	PBX_SPANDSP=0
 
-if test "x${PBX_OPUS}" != "x1" -a "${USE_OPUS}" != "no"; then
+if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
    pbxlibdir=""
-   # if --with-OPUS=DIR has been specified, use it.
-   if test "x${OPUS_DIR}" != "x"; then
-      if test -d ${OPUS_DIR}/lib; then
-         pbxlibdir="-L${OPUS_DIR}/lib"
+   # if --with-SPANDSP=DIR has been specified, use it.
+   if test "x${SPANDSP_DIR}" != "x"; then
+      if test -d ${SPANDSP_DIR}/lib; then
+         pbxlibdir="-L${SPANDSP_DIR}/lib"
       else
-         pbxlibdir="-L${OPUS_DIR}"
+         pbxlibdir="-L${SPANDSP_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for opus_encoder_create in -lopus" >&5
-$as_echo_n "checking for opus_encoder_create in -lopus... " >&6; }
-if ${ac_cv_lib_opus_opus_encoder_create+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for t38_terminal_init in -lspandsp" >&5
+$as_echo_n "checking for t38_terminal_init in -lspandsp... " >&6; }
+if ${ac_cv_lib_spandsp_t38_terminal_init+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lopus ${pbxlibdir}  $LIBS"
+LIBS="-lspandsp ${pbxlibdir} -ltiff $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29362,65 +29673,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char opus_encoder_create ();
+char t38_terminal_init ();
 int
 main ()
 {
-return opus_encoder_create ();
+return t38_terminal_init ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_opus_opus_encoder_create=yes
+  ac_cv_lib_spandsp_t38_terminal_init=yes
 else
-  ac_cv_lib_opus_opus_encoder_create=no
+  ac_cv_lib_spandsp_t38_terminal_init=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opus_opus_encoder_create" >&5
-$as_echo "$ac_cv_lib_opus_opus_encoder_create" >&6; }
-if test "x$ac_cv_lib_opus_opus_encoder_create" = xyes; then :
-  AST_OPUS_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_spandsp_t38_terminal_init" >&5
+$as_echo "$ac_cv_lib_spandsp_t38_terminal_init" >&6; }
+if test "x$ac_cv_lib_spandsp_t38_terminal_init" = xyes; then :
+  AST_SPANDSP_FOUND=yes
 else
-  AST_OPUS_FOUND=no
+  AST_SPANDSP_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
-
-   # now check for the header.
-   if test "${AST_OPUS_FOUND}" = "yes"; then
-      OPUS_LIB="${pbxlibdir} -lopus "
-      # if --with-OPUS=DIR has been specified, use it.
-      if test "x${OPUS_DIR}" != "x"; then
-         OPUS_INCLUDE="-I${OPUS_DIR}/include"
+
+   # now check for the header.
+   if test "${AST_SPANDSP_FOUND}" = "yes"; then
+      SPANDSP_LIB="${pbxlibdir} -lspandsp -ltiff"
+      # if --with-SPANDSP=DIR has been specified, use it.
+      if test "x${SPANDSP_DIR}" != "x"; then
+         SPANDSP_INCLUDE="-I${SPANDSP_DIR}/include"
       fi
-      OPUS_INCLUDE="${OPUS_INCLUDE} "
+      SPANDSP_INCLUDE="${SPANDSP_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${OPUS_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "opus/opus.h" "ac_cv_header_opus_opus_h" "$ac_includes_default"
-if test "x$ac_cv_header_opus_opus_h" = xyes; then :
-  OPUS_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "spandsp.h" "ac_cv_header_spandsp_h" "$ac_includes_default"
+if test "x$ac_cv_header_spandsp_h" = xyes; then :
+  SPANDSP_HEADER_FOUND=1
 else
-  OPUS_HEADER_FOUND=0
+  SPANDSP_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${OPUS_HEADER_FOUND}" = "x0" ; then
-         OPUS_LIB=""
-         OPUS_INCLUDE=""
+      if test "x${SPANDSP_HEADER_FOUND}" = "x0" ; then
+         SPANDSP_LIB=""
+         SPANDSP_INCLUDE=""
       else
 
-         PBX_OPUS=1
+         PBX_SPANDSP=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_OPUS 1
+#define HAVE_SPANDSP 1
 _ACEOF
 
       fi
@@ -29428,33 +29739,30 @@ _ACEOF
 fi
 
 
-# opusfile.h includes <opus_multistream.h> so we need to make sure that
-# either $OPUS_INCLUDE or /usr/include/opus is added to the search path.
-__opus_include=${OPUS_INCLUDE}
-if test -z "$__opus_include" -o x"$__opus_include" = x" " ; then
-	__opus_include=-I/usr/include/opus
 fi
 
-if test "x${PBX_OPUSFILE}" != "x1" -a "${USE_OPUSFILE}" != "no"; then
+# Check for libss7 v2.0 branch compatible version.
+
+if test "x${PBX_SS7}" != "x1" -a "${USE_SS7}" != "no"; then
    pbxlibdir=""
-   # if --with-OPUSFILE=DIR has been specified, use it.
-   if test "x${OPUSFILE_DIR}" != "x"; then
-      if test -d ${OPUSFILE_DIR}/lib; then
-         pbxlibdir="-L${OPUSFILE_DIR}/lib"
+   # if --with-SS7=DIR has been specified, use it.
+   if test "x${SS7_DIR}" != "x"; then
+      if test -d ${SS7_DIR}/lib; then
+         pbxlibdir="-L${SS7_DIR}/lib"
       else
-         pbxlibdir="-L${OPUSFILE_DIR}"
+         pbxlibdir="-L${SS7_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} $__opus_include"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5
-$as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; }
-if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then :
+      CFLAGS="${CFLAGS} "
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ss7_set_isup_timer in -lss7" >&5
+$as_echo_n "checking for ss7_set_isup_timer in -lss7... " >&6; }
+if ${ac_cv_lib_ss7_ss7_set_isup_timer+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lopusfile ${pbxlibdir}  $LIBS"
+LIBS="-lss7 ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29464,65 +29772,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char op_open_callbacks ();
+char ss7_set_isup_timer ();
 int
 main ()
 {
-return op_open_callbacks ();
+return ss7_set_isup_timer ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_opusfile_op_open_callbacks=yes
+  ac_cv_lib_ss7_ss7_set_isup_timer=yes
 else
-  ac_cv_lib_opusfile_op_open_callbacks=no
+  ac_cv_lib_ss7_ss7_set_isup_timer=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5
-$as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; }
-if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then :
-  AST_OPUSFILE_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ss7_ss7_set_isup_timer" >&5
+$as_echo "$ac_cv_lib_ss7_ss7_set_isup_timer" >&6; }
+if test "x$ac_cv_lib_ss7_ss7_set_isup_timer" = xyes; then :
+  AST_SS7_FOUND=yes
 else
-  AST_OPUSFILE_FOUND=no
+  AST_SS7_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_OPUSFILE_FOUND}" = "yes"; then
-      OPUSFILE_LIB="${pbxlibdir} -lopusfile "
-      # if --with-OPUSFILE=DIR has been specified, use it.
-      if test "x${OPUSFILE_DIR}" != "x"; then
-         OPUSFILE_INCLUDE="-I${OPUSFILE_DIR}/include"
+   if test "${AST_SS7_FOUND}" = "yes"; then
+      SS7_LIB="${pbxlibdir} -lss7 "
+      # if --with-SS7=DIR has been specified, use it.
+      if test "x${SS7_DIR}" != "x"; then
+         SS7_INCLUDE="-I${SS7_DIR}/include"
       fi
-      OPUSFILE_INCLUDE="${OPUSFILE_INCLUDE} $__opus_include"
+      SS7_INCLUDE="${SS7_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${OPUSFILE_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default"
-if test "x$ac_cv_header_opus_opusfile_h" = xyes; then :
-  OPUSFILE_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SS7_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "libss7.h" "ac_cv_header_libss7_h" "$ac_includes_default"
+if test "x$ac_cv_header_libss7_h" = xyes; then :
+  SS7_HEADER_FOUND=1
 else
-  OPUSFILE_HEADER_FOUND=0
+  SS7_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${OPUSFILE_HEADER_FOUND}" = "x0" ; then
-         OPUSFILE_LIB=""
-         OPUSFILE_INCLUDE=""
+      if test "x${SS7_HEADER_FOUND}" = "x0" ; then
+         SS7_LIB=""
+         SS7_INCLUDE=""
       else
 
-         PBX_OPUSFILE=1
+         PBX_SS7=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_OPUSFILE 1
+#define HAVE_SS7 1
 _ACEOF
 
       fi
@@ -29531,29 +29839,27 @@ fi
 
 
 
-for ver in ${LUA_VERSIONS:-5.4 5.3 5.2 5.1}; do
 
-if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
+if test "x${PBX_OPENR2}" != "x1" -a "${USE_OPENR2}" != "no"; then
    pbxlibdir=""
-   # if --with-LUA=DIR has been specified, use it.
-   if test "x${LUA_DIR}" != "x"; then
-      if test -d ${LUA_DIR}/lib; then
-         pbxlibdir="-L${LUA_DIR}/lib"
+   # if --with-OPENR2=DIR has been specified, use it.
+   if test "x${OPENR2_DIR}" != "x"; then
+      if test -d ${OPENR2_DIR}/lib; then
+         pbxlibdir="-L${OPENR2_DIR}/lib"
       else
-         pbxlibdir="-L${LUA_DIR}"
+         pbxlibdir="-L${OPENR2_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      as_ac_Lib=`$as_echo "ac_cv_lib_lua${ver}''_luaL_newstate" | $as_tr_sh`
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for luaL_newstate in -llua${ver}" >&5
-$as_echo_n "checking for luaL_newstate in -llua${ver}... " >&6; }
-if eval \${$as_ac_Lib+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openr2_chan_new in -lopenr2" >&5
+$as_echo_n "checking for openr2_chan_new in -lopenr2... " >&6; }
+if ${ac_cv_lib_openr2_openr2_chan_new+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-llua${ver} ${pbxlibdir} -lm $LIBS"
+LIBS="-lopenr2 ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29563,67 +29869,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char luaL_newstate ();
+char openr2_chan_new ();
 int
 main ()
 {
-return luaL_newstate ();
+return openr2_chan_new ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  eval "$as_ac_Lib=yes"
+  ac_cv_lib_openr2_openr2_chan_new=yes
 else
-  eval "$as_ac_Lib=no"
+  ac_cv_lib_openr2_openr2_chan_new=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-eval ac_res=\$$as_ac_Lib
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
-  AST_LUA_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_openr2_openr2_chan_new" >&5
+$as_echo "$ac_cv_lib_openr2_openr2_chan_new" >&6; }
+if test "x$ac_cv_lib_openr2_openr2_chan_new" = xyes; then :
+  AST_OPENR2_FOUND=yes
 else
-  AST_LUA_FOUND=no
+  AST_OPENR2_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_LUA_FOUND}" = "yes"; then
-      LUA_LIB="${pbxlibdir} -llua${ver} -lm"
-      # if --with-LUA=DIR has been specified, use it.
-      if test "x${LUA_DIR}" != "x"; then
-         LUA_INCLUDE="-I${LUA_DIR}/include"
+   if test "${AST_OPENR2_FOUND}" = "yes"; then
+      OPENR2_LIB="${pbxlibdir} -lopenr2 "
+      # if --with-OPENR2=DIR has been specified, use it.
+      if test "x${OPENR2_DIR}" != "x"; then
+         OPENR2_INCLUDE="-I${OPENR2_DIR}/include"
       fi
-      LUA_INCLUDE="${LUA_INCLUDE} "
+      OPENR2_INCLUDE="${OPENR2_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}"
-         as_ac_Header=`$as_echo "ac_cv_header_lua${ver}/lua.h" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "lua${ver}/lua.h" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  LUA_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${OPENR2_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "openr2.h" "ac_cv_header_openr2_h" "$ac_includes_default"
+if test "x$ac_cv_header_openr2_h" = xyes; then :
+  OPENR2_HEADER_FOUND=1
 else
-  LUA_HEADER_FOUND=0
+  OPENR2_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${LUA_HEADER_FOUND}" = "x0" ; then
-         LUA_LIB=""
-         LUA_INCLUDE=""
+      if test "x${OPENR2_HEADER_FOUND}" = "x0" ; then
+         OPENR2_LIB=""
+         OPENR2_INCLUDE=""
       else
 
-         PBX_LUA=1
+         PBX_OPENR2=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_LUA 1
+#define HAVE_OPENR2 1
 _ACEOF
 
       fi
@@ -29631,39 +29935,28 @@ _ACEOF
 fi
 
 
-	if test "x${PBX_LUA}" = "x1" ; then
-		if test x"${LUA_DIR}" = x; then
-			LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua${ver}"
-		else
-			LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua${ver}"
-		fi
-		break;
-	fi
-done
 
-# Some distributions (like openSUSE and NetBSD) remove the 5.x suffix.
-if test "x${LUA_VERSIONS}" = "x"; then
 
-if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
+if test "x${PBX_OPUS}" != "x1" -a "${USE_OPUS}" != "no"; then
    pbxlibdir=""
-   # if --with-LUA=DIR has been specified, use it.
-   if test "x${LUA_DIR}" != "x"; then
-      if test -d ${LUA_DIR}/lib; then
-         pbxlibdir="-L${LUA_DIR}/lib"
+   # if --with-OPUS=DIR has been specified, use it.
+   if test "x${OPUS_DIR}" != "x"; then
+      if test -d ${OPUS_DIR}/lib; then
+         pbxlibdir="-L${OPUS_DIR}/lib"
       else
-         pbxlibdir="-L${LUA_DIR}"
+         pbxlibdir="-L${OPUS_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for luaL_newstate in -llua" >&5
-$as_echo_n "checking for luaL_newstate in -llua... " >&6; }
-if ${ac_cv_lib_lua_luaL_newstate+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for opus_encoder_create in -lopus" >&5
+$as_echo_n "checking for opus_encoder_create in -lopus... " >&6; }
+if ${ac_cv_lib_opus_opus_encoder_create+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-llua ${pbxlibdir} -lm $LIBS"
+LIBS="-lopus ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29673,65 +29966,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char luaL_newstate ();
+char opus_encoder_create ();
 int
 main ()
 {
-return luaL_newstate ();
+return opus_encoder_create ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_lua_luaL_newstate=yes
+  ac_cv_lib_opus_opus_encoder_create=yes
 else
-  ac_cv_lib_lua_luaL_newstate=no
+  ac_cv_lib_opus_opus_encoder_create=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_luaL_newstate" >&5
-$as_echo "$ac_cv_lib_lua_luaL_newstate" >&6; }
-if test "x$ac_cv_lib_lua_luaL_newstate" = xyes; then :
-  AST_LUA_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opus_opus_encoder_create" >&5
+$as_echo "$ac_cv_lib_opus_opus_encoder_create" >&6; }
+if test "x$ac_cv_lib_opus_opus_encoder_create" = xyes; then :
+  AST_OPUS_FOUND=yes
 else
-  AST_LUA_FOUND=no
+  AST_OPUS_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_LUA_FOUND}" = "yes"; then
-      LUA_LIB="${pbxlibdir} -llua -lm"
-      # if --with-LUA=DIR has been specified, use it.
-      if test "x${LUA_DIR}" != "x"; then
-         LUA_INCLUDE="-I${LUA_DIR}/include"
+   if test "${AST_OPUS_FOUND}" = "yes"; then
+      OPUS_LIB="${pbxlibdir} -lopus "
+      # if --with-OPUS=DIR has been specified, use it.
+      if test "x${OPUS_DIR}" != "x"; then
+         OPUS_INCLUDE="-I${OPUS_DIR}/include"
       fi
-      LUA_INCLUDE="${LUA_INCLUDE} "
+      OPUS_INCLUDE="${OPUS_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "lua.h" "ac_cv_header_lua_h" "$ac_includes_default"
-if test "x$ac_cv_header_lua_h" = xyes; then :
-  LUA_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${OPUS_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "opus/opus.h" "ac_cv_header_opus_opus_h" "$ac_includes_default"
+if test "x$ac_cv_header_opus_opus_h" = xyes; then :
+  OPUS_HEADER_FOUND=1
 else
-  LUA_HEADER_FOUND=0
+  OPUS_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${LUA_HEADER_FOUND}" = "x0" ; then
-         LUA_LIB=""
-         LUA_INCLUDE=""
+      if test "x${OPUS_HEADER_FOUND}" = "x0" ; then
+         OPUS_LIB=""
+         OPUS_INCLUDE=""
       else
 
-         PBX_LUA=1
+         PBX_OPUS=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_LUA 1
+#define HAVE_OPUS 1
 _ACEOF
 
       fi
@@ -29739,31 +30032,33 @@ _ACEOF
 fi
 
 
+# opusfile.h includes <opus_multistream.h> so we need to make sure that
+# either $OPUS_INCLUDE or /usr/include/opus is added to the search path.
+__opus_include=${OPUS_INCLUDE}
+if test -z "$__opus_include" -o x"$__opus_include" = x" " ; then
+	__opus_include=-I/usr/include/opus
 fi
 
-# Accept either RADIUS client library, their APIs are fully compatible,
-# just different header filenames and different SONAMEs
-
-if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
+if test "x${PBX_OPUSFILE}" != "x1" -a "${USE_OPUSFILE}" != "no"; then
    pbxlibdir=""
-   # if --with-RADIUS=DIR has been specified, use it.
-   if test "x${RADIUS_DIR}" != "x"; then
-      if test -d ${RADIUS_DIR}/lib; then
-         pbxlibdir="-L${RADIUS_DIR}/lib"
+   # if --with-OPUSFILE=DIR has been specified, use it.
+   if test "x${OPUSFILE_DIR}" != "x"; then
+      if test -d ${OPUSFILE_DIR}/lib; then
+         pbxlibdir="-L${OPUSFILE_DIR}/lib"
       else
-         pbxlibdir="-L${RADIUS_DIR}"
+         pbxlibdir="-L${OPUSFILE_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lfreeradius-client" >&5
-$as_echo_n "checking for rc_read_config in -lfreeradius-client... " >&6; }
-if ${ac_cv_lib_freeradius_client_rc_read_config+:} false; then :
+      CFLAGS="${CFLAGS} $__opus_include"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5
+$as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; }
+if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lfreeradius-client ${pbxlibdir}  $LIBS"
+LIBS="-lopusfile ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29773,65 +30068,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char rc_read_config ();
+char op_open_callbacks ();
 int
 main ()
 {
-return rc_read_config ();
+return op_open_callbacks ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_freeradius_client_rc_read_config=yes
+  ac_cv_lib_opusfile_op_open_callbacks=yes
 else
-  ac_cv_lib_freeradius_client_rc_read_config=no
+  ac_cv_lib_opusfile_op_open_callbacks=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freeradius_client_rc_read_config" >&5
-$as_echo "$ac_cv_lib_freeradius_client_rc_read_config" >&6; }
-if test "x$ac_cv_lib_freeradius_client_rc_read_config" = xyes; then :
-  AST_RADIUS_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5
+$as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; }
+if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then :
+  AST_OPUSFILE_FOUND=yes
 else
-  AST_RADIUS_FOUND=no
+  AST_OPUSFILE_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_RADIUS_FOUND}" = "yes"; then
-      RADIUS_LIB="${pbxlibdir} -lfreeradius-client "
-      # if --with-RADIUS=DIR has been specified, use it.
-      if test "x${RADIUS_DIR}" != "x"; then
-         RADIUS_INCLUDE="-I${RADIUS_DIR}/include"
+   if test "${AST_OPUSFILE_FOUND}" = "yes"; then
+      OPUSFILE_LIB="${pbxlibdir} -lopusfile "
+      # if --with-OPUSFILE=DIR has been specified, use it.
+      if test "x${OPUSFILE_DIR}" != "x"; then
+         OPUSFILE_INCLUDE="-I${OPUSFILE_DIR}/include"
       fi
-      RADIUS_INCLUDE="${RADIUS_INCLUDE} "
+      OPUSFILE_INCLUDE="${OPUSFILE_INCLUDE} $__opus_include"
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "freeradius-client.h" "ac_cv_header_freeradius_client_h" "$ac_includes_default"
-if test "x$ac_cv_header_freeradius_client_h" = xyes; then :
-  RADIUS_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${OPUSFILE_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default"
+if test "x$ac_cv_header_opus_opusfile_h" = xyes; then :
+  OPUSFILE_HEADER_FOUND=1
 else
-  RADIUS_HEADER_FOUND=0
+  OPUSFILE_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then
-         RADIUS_LIB=""
-         RADIUS_INCLUDE=""
+      if test "x${OPUSFILE_HEADER_FOUND}" = "x0" ; then
+         OPUSFILE_LIB=""
+         OPUSFILE_INCLUDE=""
       else
 
-         PBX_RADIUS=1
+         PBX_OPUSFILE=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_RADIUS 1
+#define HAVE_OPUSFILE 1
 _ACEOF
 
       fi
@@ -29839,32 +30134,30 @@ _ACEOF
 fi
 
 
-if test "x${PBX_RADIUS}" = "x1"; then
-
-$as_echo "#define RADIUS_HEADER_STR <freeradius-client.h>" >>confdefs.h
 
-else
+for ver in ${LUA_VERSIONS:-5.4 5.3 5.2 5.1}; do
 
-if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
+if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
    pbxlibdir=""
-   # if --with-RADIUS=DIR has been specified, use it.
-   if test "x${RADIUS_DIR}" != "x"; then
-      if test -d ${RADIUS_DIR}/lib; then
-         pbxlibdir="-L${RADIUS_DIR}/lib"
+   # if --with-LUA=DIR has been specified, use it.
+   if test "x${LUA_DIR}" != "x"; then
+      if test -d ${LUA_DIR}/lib; then
+         pbxlibdir="-L${LUA_DIR}/lib"
       else
-         pbxlibdir="-L${RADIUS_DIR}"
+         pbxlibdir="-L${LUA_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient-ng" >&5
-$as_echo_n "checking for rc_read_config in -lradiusclient-ng... " >&6; }
-if ${ac_cv_lib_radiusclient_ng_rc_read_config+:} false; then :
+      as_ac_Lib=`$as_echo "ac_cv_lib_lua${ver}''_luaL_newstate" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for luaL_newstate in -llua${ver}" >&5
+$as_echo_n "checking for luaL_newstate in -llua${ver}... " >&6; }
+if eval \${$as_ac_Lib+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lradiusclient-ng ${pbxlibdir}  $LIBS"
+LIBS="-llua${ver} ${pbxlibdir} -lm $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29874,65 +30167,67 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char rc_read_config ();
+char luaL_newstate ();
 int
 main ()
 {
-return rc_read_config ();
+return luaL_newstate ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_radiusclient_ng_rc_read_config=yes
+  eval "$as_ac_Lib=yes"
 else
-  ac_cv_lib_radiusclient_ng_rc_read_config=no
+  eval "$as_ac_Lib=no"
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_radiusclient_ng_rc_read_config" >&5
-$as_echo "$ac_cv_lib_radiusclient_ng_rc_read_config" >&6; }
-if test "x$ac_cv_lib_radiusclient_ng_rc_read_config" = xyes; then :
-  AST_RADIUS_FOUND=yes
+eval ac_res=\$$as_ac_Lib
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
+  AST_LUA_FOUND=yes
 else
-  AST_RADIUS_FOUND=no
+  AST_LUA_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_RADIUS_FOUND}" = "yes"; then
-      RADIUS_LIB="${pbxlibdir} -lradiusclient-ng "
-      # if --with-RADIUS=DIR has been specified, use it.
-      if test "x${RADIUS_DIR}" != "x"; then
-         RADIUS_INCLUDE="-I${RADIUS_DIR}/include"
+   if test "${AST_LUA_FOUND}" = "yes"; then
+      LUA_LIB="${pbxlibdir} -llua${ver} -lm"
+      # if --with-LUA=DIR has been specified, use it.
+      if test "x${LUA_DIR}" != "x"; then
+         LUA_INCLUDE="-I${LUA_DIR}/include"
       fi
-      RADIUS_INCLUDE="${RADIUS_INCLUDE} "
+      LUA_INCLUDE="${LUA_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "radiusclient-ng.h" "ac_cv_header_radiusclient_ng_h" "$ac_includes_default"
-if test "x$ac_cv_header_radiusclient_ng_h" = xyes; then :
-  RADIUS_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}"
+         as_ac_Header=`$as_echo "ac_cv_header_lua${ver}/lua.h" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "lua${ver}/lua.h" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  LUA_HEADER_FOUND=1
 else
-  RADIUS_HEADER_FOUND=0
+  LUA_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then
-         RADIUS_LIB=""
-         RADIUS_INCLUDE=""
+      if test "x${LUA_HEADER_FOUND}" = "x0" ; then
+         LUA_LIB=""
+         LUA_INCLUDE=""
       else
 
-         PBX_RADIUS=1
+         PBX_LUA=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_RADIUS 1
+#define HAVE_LUA 1
 _ACEOF
 
       fi
@@ -29940,32 +30235,39 @@ _ACEOF
 fi
 
 
-	if test "x${PBX_RADIUS}" = "x1"; then
-
-$as_echo "#define RADIUS_HEADER_STR <radiusclient-ng.h>" >>confdefs.h
+	if test "x${PBX_LUA}" = "x1" ; then
+		if test x"${LUA_DIR}" = x; then
+			LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua${ver}"
+		else
+			LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua${ver}"
+		fi
+		break;
+	fi
+done
 
-	else
+# Some distributions (like openSUSE and NetBSD) remove the 5.x suffix.
+if test "x${LUA_VERSIONS}" = "x"; then
 
-if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
+if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
    pbxlibdir=""
-   # if --with-RADIUS=DIR has been specified, use it.
-   if test "x${RADIUS_DIR}" != "x"; then
-      if test -d ${RADIUS_DIR}/lib; then
-         pbxlibdir="-L${RADIUS_DIR}/lib"
+   # if --with-LUA=DIR has been specified, use it.
+   if test "x${LUA_DIR}" != "x"; then
+      if test -d ${LUA_DIR}/lib; then
+         pbxlibdir="-L${LUA_DIR}/lib"
       else
-         pbxlibdir="-L${RADIUS_DIR}"
+         pbxlibdir="-L${LUA_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradcli" >&5
-$as_echo_n "checking for rc_read_config in -lradcli... " >&6; }
-if ${ac_cv_lib_radcli_rc_read_config+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for luaL_newstate in -llua" >&5
+$as_echo_n "checking for luaL_newstate in -llua... " >&6; }
+if ${ac_cv_lib_lua_luaL_newstate+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lradcli ${pbxlibdir}  $LIBS"
+LIBS="-llua ${pbxlibdir} -lm $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -29975,65 +30277,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char rc_read_config ();
+char luaL_newstate ();
 int
 main ()
 {
-return rc_read_config ();
+return luaL_newstate ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_radcli_rc_read_config=yes
+  ac_cv_lib_lua_luaL_newstate=yes
 else
-  ac_cv_lib_radcli_rc_read_config=no
+  ac_cv_lib_lua_luaL_newstate=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_radcli_rc_read_config" >&5
-$as_echo "$ac_cv_lib_radcli_rc_read_config" >&6; }
-if test "x$ac_cv_lib_radcli_rc_read_config" = xyes; then :
-  AST_RADIUS_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_luaL_newstate" >&5
+$as_echo "$ac_cv_lib_lua_luaL_newstate" >&6; }
+if test "x$ac_cv_lib_lua_luaL_newstate" = xyes; then :
+  AST_LUA_FOUND=yes
 else
-  AST_RADIUS_FOUND=no
+  AST_LUA_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_RADIUS_FOUND}" = "yes"; then
-      RADIUS_LIB="${pbxlibdir} -lradcli "
-      # if --with-RADIUS=DIR has been specified, use it.
-      if test "x${RADIUS_DIR}" != "x"; then
-         RADIUS_INCLUDE="-I${RADIUS_DIR}/include"
+   if test "${AST_LUA_FOUND}" = "yes"; then
+      LUA_LIB="${pbxlibdir} -llua -lm"
+      # if --with-LUA=DIR has been specified, use it.
+      if test "x${LUA_DIR}" != "x"; then
+         LUA_INCLUDE="-I${LUA_DIR}/include"
       fi
-      RADIUS_INCLUDE="${RADIUS_INCLUDE} "
+      LUA_INCLUDE="${LUA_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "radcli/radcli.h" "ac_cv_header_radcli_radcli_h" "$ac_includes_default"
-if test "x$ac_cv_header_radcli_radcli_h" = xyes; then :
-  RADIUS_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "lua.h" "ac_cv_header_lua_h" "$ac_includes_default"
+if test "x$ac_cv_header_lua_h" = xyes; then :
+  LUA_HEADER_FOUND=1
 else
-  RADIUS_HEADER_FOUND=0
+  LUA_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then
-         RADIUS_LIB=""
-         RADIUS_INCLUDE=""
+      if test "x${LUA_HEADER_FOUND}" = "x0" ; then
+         LUA_LIB=""
+         LUA_INCLUDE=""
       else
 
-         PBX_RADIUS=1
+         PBX_LUA=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_RADIUS 1
+#define HAVE_LUA 1
 _ACEOF
 
       fi
@@ -30041,35 +30343,31 @@ _ACEOF
 fi
 
 
-		if test "x${PBX_RADIUS}" = "x1"; then
-
-$as_echo "#define RADIUS_HEADER_STR <radcli/radcli.h>" >>confdefs.h
-
-		fi
-	fi
 fi
 
+# Accept either RADIUS client library, their APIs are fully compatible,
+# just different header filenames and different SONAMEs
 
-if test "x${PBX_CODEC2}" != "x1" -a "${USE_CODEC2}" != "no"; then
+if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
    pbxlibdir=""
-   # if --with-CODEC2=DIR has been specified, use it.
-   if test "x${CODEC2_DIR}" != "x"; then
-      if test -d ${CODEC2_DIR}/lib; then
-         pbxlibdir="-L${CODEC2_DIR}/lib"
+   # if --with-RADIUS=DIR has been specified, use it.
+   if test "x${RADIUS_DIR}" != "x"; then
+      if test -d ${RADIUS_DIR}/lib; then
+         pbxlibdir="-L${RADIUS_DIR}/lib"
       else
-         pbxlibdir="-L${CODEC2_DIR}"
+         pbxlibdir="-L${RADIUS_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for codec2_create in -lcodec2" >&5
-$as_echo_n "checking for codec2_create in -lcodec2... " >&6; }
-if ${ac_cv_lib_codec2_codec2_create+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lfreeradius-client" >&5
+$as_echo_n "checking for rc_read_config in -lfreeradius-client... " >&6; }
+if ${ac_cv_lib_freeradius_client_rc_read_config+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcodec2 ${pbxlibdir}  $LIBS"
+LIBS="-lfreeradius-client ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30079,65 +30377,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char codec2_create ();
+char rc_read_config ();
 int
 main ()
 {
-return codec2_create ();
+return rc_read_config ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_codec2_codec2_create=yes
+  ac_cv_lib_freeradius_client_rc_read_config=yes
 else
-  ac_cv_lib_codec2_codec2_create=no
+  ac_cv_lib_freeradius_client_rc_read_config=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_codec2_codec2_create" >&5
-$as_echo "$ac_cv_lib_codec2_codec2_create" >&6; }
-if test "x$ac_cv_lib_codec2_codec2_create" = xyes; then :
-  AST_CODEC2_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freeradius_client_rc_read_config" >&5
+$as_echo "$ac_cv_lib_freeradius_client_rc_read_config" >&6; }
+if test "x$ac_cv_lib_freeradius_client_rc_read_config" = xyes; then :
+  AST_RADIUS_FOUND=yes
 else
-  AST_CODEC2_FOUND=no
+  AST_RADIUS_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_CODEC2_FOUND}" = "yes"; then
-      CODEC2_LIB="${pbxlibdir} -lcodec2 "
-      # if --with-CODEC2=DIR has been specified, use it.
-      if test "x${CODEC2_DIR}" != "x"; then
-         CODEC2_INCLUDE="-I${CODEC2_DIR}/include"
+   if test "${AST_RADIUS_FOUND}" = "yes"; then
+      RADIUS_LIB="${pbxlibdir} -lfreeradius-client "
+      # if --with-RADIUS=DIR has been specified, use it.
+      if test "x${RADIUS_DIR}" != "x"; then
+         RADIUS_INCLUDE="-I${RADIUS_DIR}/include"
       fi
-      CODEC2_INCLUDE="${CODEC2_INCLUDE} "
+      RADIUS_INCLUDE="${RADIUS_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${CODEC2_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "codec2/codec2.h" "ac_cv_header_codec2_codec2_h" "$ac_includes_default"
-if test "x$ac_cv_header_codec2_codec2_h" = xyes; then :
-  CODEC2_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "freeradius-client.h" "ac_cv_header_freeradius_client_h" "$ac_includes_default"
+if test "x$ac_cv_header_freeradius_client_h" = xyes; then :
+  RADIUS_HEADER_FOUND=1
 else
-  CODEC2_HEADER_FOUND=0
+  RADIUS_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${CODEC2_HEADER_FOUND}" = "x0" ; then
-         CODEC2_LIB=""
-         CODEC2_INCLUDE=""
+      if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then
+         RADIUS_LIB=""
+         RADIUS_INCLUDE=""
       else
 
-         PBX_CODEC2=1
+         PBX_RADIUS=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_CODEC2 1
+#define HAVE_RADIUS 1
 _ACEOF
 
       fi
@@ -30145,28 +30443,32 @@ _ACEOF
 fi
 
 
+if test "x${PBX_RADIUS}" = "x1"; then
 
+$as_echo "#define RADIUS_HEADER_STR <freeradius-client.h>" >>confdefs.h
 
-if test "x${PBX_COROSYNC}" != "x1" -a "${USE_COROSYNC}" != "no"; then
+else
+
+if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
    pbxlibdir=""
-   # if --with-COROSYNC=DIR has been specified, use it.
-   if test "x${COROSYNC_DIR}" != "x"; then
-      if test -d ${COROSYNC_DIR}/lib; then
-         pbxlibdir="-L${COROSYNC_DIR}/lib"
+   # if --with-RADIUS=DIR has been specified, use it.
+   if test "x${RADIUS_DIR}" != "x"; then
+      if test -d ${RADIUS_DIR}/lib; then
+         pbxlibdir="-L${RADIUS_DIR}/lib"
       else
-         pbxlibdir="-L${COROSYNC_DIR}"
+         pbxlibdir="-L${RADIUS_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cpg_join in -lcpg" >&5
-$as_echo_n "checking for cpg_join in -lcpg... " >&6; }
-if ${ac_cv_lib_cpg_cpg_join+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradiusclient-ng" >&5
+$as_echo_n "checking for rc_read_config in -lradiusclient-ng... " >&6; }
+if ${ac_cv_lib_radiusclient_ng_rc_read_config+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcpg ${pbxlibdir} -lcpg -lcfg $LIBS"
+LIBS="-lradiusclient-ng ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30176,65 +30478,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char cpg_join ();
+char rc_read_config ();
 int
 main ()
 {
-return cpg_join ();
+return rc_read_config ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_cpg_cpg_join=yes
+  ac_cv_lib_radiusclient_ng_rc_read_config=yes
 else
-  ac_cv_lib_cpg_cpg_join=no
+  ac_cv_lib_radiusclient_ng_rc_read_config=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cpg_cpg_join" >&5
-$as_echo "$ac_cv_lib_cpg_cpg_join" >&6; }
-if test "x$ac_cv_lib_cpg_cpg_join" = xyes; then :
-  AST_COROSYNC_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_radiusclient_ng_rc_read_config" >&5
+$as_echo "$ac_cv_lib_radiusclient_ng_rc_read_config" >&6; }
+if test "x$ac_cv_lib_radiusclient_ng_rc_read_config" = xyes; then :
+  AST_RADIUS_FOUND=yes
 else
-  AST_COROSYNC_FOUND=no
+  AST_RADIUS_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_COROSYNC_FOUND}" = "yes"; then
-      COROSYNC_LIB="${pbxlibdir} -lcpg -lcpg -lcfg"
-      # if --with-COROSYNC=DIR has been specified, use it.
-      if test "x${COROSYNC_DIR}" != "x"; then
-         COROSYNC_INCLUDE="-I${COROSYNC_DIR}/include"
+   if test "${AST_RADIUS_FOUND}" = "yes"; then
+      RADIUS_LIB="${pbxlibdir} -lradiusclient-ng "
+      # if --with-RADIUS=DIR has been specified, use it.
+      if test "x${RADIUS_DIR}" != "x"; then
+         RADIUS_INCLUDE="-I${RADIUS_DIR}/include"
       fi
-      COROSYNC_INCLUDE="${COROSYNC_INCLUDE} "
+      RADIUS_INCLUDE="${RADIUS_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${COROSYNC_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "corosync/cpg.h" "ac_cv_header_corosync_cpg_h" "$ac_includes_default"
-if test "x$ac_cv_header_corosync_cpg_h" = xyes; then :
-  COROSYNC_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "radiusclient-ng.h" "ac_cv_header_radiusclient_ng_h" "$ac_includes_default"
+if test "x$ac_cv_header_radiusclient_ng_h" = xyes; then :
+  RADIUS_HEADER_FOUND=1
 else
-  COROSYNC_HEADER_FOUND=0
+  RADIUS_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${COROSYNC_HEADER_FOUND}" = "x0" ; then
-         COROSYNC_LIB=""
-         COROSYNC_INCLUDE=""
+      if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then
+         RADIUS_LIB=""
+         RADIUS_INCLUDE=""
       else
 
-         PBX_COROSYNC=1
+         PBX_RADIUS=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_COROSYNC 1
+#define HAVE_RADIUS 1
 _ACEOF
 
       fi
@@ -30242,27 +30544,32 @@ _ACEOF
 fi
 
 
+	if test "x${PBX_RADIUS}" = "x1"; then
 
-if test "x${PBX_COROSYNC_CFG_STATE_TRACK}" != "x1" -a "${USE_COROSYNC_CFG_STATE_TRACK}" != "no"; then
+$as_echo "#define RADIUS_HEADER_STR <radiusclient-ng.h>" >>confdefs.h
+
+	else
+
+if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
    pbxlibdir=""
-   # if --with-COROSYNC_CFG_STATE_TRACK=DIR has been specified, use it.
-   if test "x${COROSYNC_CFG_STATE_TRACK_DIR}" != "x"; then
-      if test -d ${COROSYNC_CFG_STATE_TRACK_DIR}/lib; then
-         pbxlibdir="-L${COROSYNC_CFG_STATE_TRACK_DIR}/lib"
+   # if --with-RADIUS=DIR has been specified, use it.
+   if test "x${RADIUS_DIR}" != "x"; then
+      if test -d ${RADIUS_DIR}/lib; then
+         pbxlibdir="-L${RADIUS_DIR}/lib"
       else
-         pbxlibdir="-L${COROSYNC_CFG_STATE_TRACK_DIR}"
+         pbxlibdir="-L${RADIUS_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for corosync_cfg_state_track in -lcfg" >&5
-$as_echo_n "checking for corosync_cfg_state_track in -lcfg... " >&6; }
-if ${ac_cv_lib_cfg_corosync_cfg_state_track+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rc_read_config in -lradcli" >&5
+$as_echo_n "checking for rc_read_config in -lradcli... " >&6; }
+if ${ac_cv_lib_radcli_rc_read_config+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcfg ${pbxlibdir} -lcfg $LIBS"
+LIBS="-lradcli ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30272,65 +30579,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char corosync_cfg_state_track ();
+char rc_read_config ();
 int
 main ()
 {
-return corosync_cfg_state_track ();
+return rc_read_config ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_cfg_corosync_cfg_state_track=yes
+  ac_cv_lib_radcli_rc_read_config=yes
 else
-  ac_cv_lib_cfg_corosync_cfg_state_track=no
+  ac_cv_lib_radcli_rc_read_config=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cfg_corosync_cfg_state_track" >&5
-$as_echo "$ac_cv_lib_cfg_corosync_cfg_state_track" >&6; }
-if test "x$ac_cv_lib_cfg_corosync_cfg_state_track" = xyes; then :
-  AST_COROSYNC_CFG_STATE_TRACK_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_radcli_rc_read_config" >&5
+$as_echo "$ac_cv_lib_radcli_rc_read_config" >&6; }
+if test "x$ac_cv_lib_radcli_rc_read_config" = xyes; then :
+  AST_RADIUS_FOUND=yes
 else
-  AST_COROSYNC_CFG_STATE_TRACK_FOUND=no
+  AST_RADIUS_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_COROSYNC_CFG_STATE_TRACK_FOUND}" = "yes"; then
-      COROSYNC_CFG_STATE_TRACK_LIB="${pbxlibdir} -lcfg -lcfg"
-      # if --with-COROSYNC_CFG_STATE_TRACK=DIR has been specified, use it.
-      if test "x${COROSYNC_CFG_STATE_TRACK_DIR}" != "x"; then
-         COROSYNC_CFG_STATE_TRACK_INCLUDE="-I${COROSYNC_CFG_STATE_TRACK_DIR}/include"
+   if test "${AST_RADIUS_FOUND}" = "yes"; then
+      RADIUS_LIB="${pbxlibdir} -lradcli "
+      # if --with-RADIUS=DIR has been specified, use it.
+      if test "x${RADIUS_DIR}" != "x"; then
+         RADIUS_INCLUDE="-I${RADIUS_DIR}/include"
       fi
-      COROSYNC_CFG_STATE_TRACK_INCLUDE="${COROSYNC_CFG_STATE_TRACK_INCLUDE} "
+      RADIUS_INCLUDE="${RADIUS_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${COROSYNC_CFG_STATE_TRACK_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "corosync/cfg.h" "ac_cv_header_corosync_cfg_h" "$ac_includes_default"
-if test "x$ac_cv_header_corosync_cfg_h" = xyes; then :
-  COROSYNC_CFG_STATE_TRACK_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "radcli/radcli.h" "ac_cv_header_radcli_radcli_h" "$ac_includes_default"
+if test "x$ac_cv_header_radcli_radcli_h" = xyes; then :
+  RADIUS_HEADER_FOUND=1
 else
-  COROSYNC_CFG_STATE_TRACK_HEADER_FOUND=0
+  RADIUS_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${COROSYNC_CFG_STATE_TRACK_HEADER_FOUND}" = "x0" ; then
-         COROSYNC_CFG_STATE_TRACK_LIB=""
-         COROSYNC_CFG_STATE_TRACK_INCLUDE=""
+      if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then
+         RADIUS_LIB=""
+         RADIUS_INCLUDE=""
       else
 
-         PBX_COROSYNC_CFG_STATE_TRACK=1
+         PBX_RADIUS=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_COROSYNC_CFG_STATE_TRACK 1
+#define HAVE_RADIUS 1
 _ACEOF
 
       fi
@@ -30338,28 +30645,35 @@ _ACEOF
 fi
 
 
+		if test "x${PBX_RADIUS}" = "x1"; then
 
+$as_echo "#define RADIUS_HEADER_STR <radcli/radcli.h>" >>confdefs.h
 
-if test "x${PBX_SPEEX}" != "x1" -a "${USE_SPEEX}" != "no"; then
+		fi
+	fi
+fi
+
+
+if test "x${PBX_CODEC2}" != "x1" -a "${USE_CODEC2}" != "no"; then
    pbxlibdir=""
-   # if --with-SPEEX=DIR has been specified, use it.
-   if test "x${SPEEX_DIR}" != "x"; then
-      if test -d ${SPEEX_DIR}/lib; then
-         pbxlibdir="-L${SPEEX_DIR}/lib"
+   # if --with-CODEC2=DIR has been specified, use it.
+   if test "x${CODEC2_DIR}" != "x"; then
+      if test -d ${CODEC2_DIR}/lib; then
+         pbxlibdir="-L${CODEC2_DIR}/lib"
       else
-         pbxlibdir="-L${SPEEX_DIR}"
+         pbxlibdir="-L${CODEC2_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for speex_encode in -lspeex" >&5
-$as_echo_n "checking for speex_encode in -lspeex... " >&6; }
-if ${ac_cv_lib_speex_speex_encode+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for codec2_create in -lcodec2" >&5
+$as_echo_n "checking for codec2_create in -lcodec2... " >&6; }
+if ${ac_cv_lib_codec2_codec2_create+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lspeex ${pbxlibdir} -lm $LIBS"
+LIBS="-lcodec2 ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30369,65 +30683,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char speex_encode ();
+char codec2_create ();
 int
 main ()
 {
-return speex_encode ();
+return codec2_create ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_speex_speex_encode=yes
+  ac_cv_lib_codec2_codec2_create=yes
 else
-  ac_cv_lib_speex_speex_encode=no
+  ac_cv_lib_codec2_codec2_create=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_speex_speex_encode" >&5
-$as_echo "$ac_cv_lib_speex_speex_encode" >&6; }
-if test "x$ac_cv_lib_speex_speex_encode" = xyes; then :
-  AST_SPEEX_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_codec2_codec2_create" >&5
+$as_echo "$ac_cv_lib_codec2_codec2_create" >&6; }
+if test "x$ac_cv_lib_codec2_codec2_create" = xyes; then :
+  AST_CODEC2_FOUND=yes
 else
-  AST_SPEEX_FOUND=no
+  AST_CODEC2_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SPEEX_FOUND}" = "yes"; then
-      SPEEX_LIB="${pbxlibdir} -lspeex -lm"
-      # if --with-SPEEX=DIR has been specified, use it.
-      if test "x${SPEEX_DIR}" != "x"; then
-         SPEEX_INCLUDE="-I${SPEEX_DIR}/include"
+   if test "${AST_CODEC2_FOUND}" = "yes"; then
+      CODEC2_LIB="${pbxlibdir} -lcodec2 "
+      # if --with-CODEC2=DIR has been specified, use it.
+      if test "x${CODEC2_DIR}" != "x"; then
+         CODEC2_INCLUDE="-I${CODEC2_DIR}/include"
       fi
-      SPEEX_INCLUDE="${SPEEX_INCLUDE} "
+      CODEC2_INCLUDE="${CODEC2_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SPEEX_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "speex/speex.h" "ac_cv_header_speex_speex_h" "$ac_includes_default"
-if test "x$ac_cv_header_speex_speex_h" = xyes; then :
-  SPEEX_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${CODEC2_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "codec2/codec2.h" "ac_cv_header_codec2_codec2_h" "$ac_includes_default"
+if test "x$ac_cv_header_codec2_codec2_h" = xyes; then :
+  CODEC2_HEADER_FOUND=1
 else
-  SPEEX_HEADER_FOUND=0
+  CODEC2_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SPEEX_HEADER_FOUND}" = "x0" ; then
-         SPEEX_LIB=""
-         SPEEX_INCLUDE=""
+      if test "x${CODEC2_HEADER_FOUND}" = "x0" ; then
+         CODEC2_LIB=""
+         CODEC2_INCLUDE=""
       else
 
-         PBX_SPEEX=1
+         PBX_CODEC2=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SPEEX 1
+#define HAVE_CODEC2 1
 _ACEOF
 
       fi
@@ -30436,28 +30750,27 @@ fi
 
 
 
-# See if the main speex library contains the preprocess functions
 
-if test "x${PBX_SPEEX_PREPROCESS}" != "x1" -a "${USE_SPEEX_PREPROCESS}" != "no"; then
+if test "x${PBX_COROSYNC}" != "x1" -a "${USE_COROSYNC}" != "no"; then
    pbxlibdir=""
-   # if --with-SPEEX_PREPROCESS=DIR has been specified, use it.
-   if test "x${SPEEX_PREPROCESS_DIR}" != "x"; then
-      if test -d ${SPEEX_PREPROCESS_DIR}/lib; then
-         pbxlibdir="-L${SPEEX_PREPROCESS_DIR}/lib"
+   # if --with-COROSYNC=DIR has been specified, use it.
+   if test "x${COROSYNC_DIR}" != "x"; then
+      if test -d ${COROSYNC_DIR}/lib; then
+         pbxlibdir="-L${COROSYNC_DIR}/lib"
       else
-         pbxlibdir="-L${SPEEX_PREPROCESS_DIR}"
+         pbxlibdir="-L${COROSYNC_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for speex_preprocess_ctl in -lspeex" >&5
-$as_echo_n "checking for speex_preprocess_ctl in -lspeex... " >&6; }
-if ${ac_cv_lib_speex_speex_preprocess_ctl+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cpg_join in -lcpg" >&5
+$as_echo_n "checking for cpg_join in -lcpg... " >&6; }
+if ${ac_cv_lib_cpg_cpg_join+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lspeex ${pbxlibdir} -lm $LIBS"
+LIBS="-lcpg ${pbxlibdir} -lcpg -lcfg $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30467,65 +30780,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char speex_preprocess_ctl ();
+char cpg_join ();
 int
 main ()
 {
-return speex_preprocess_ctl ();
+return cpg_join ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_speex_speex_preprocess_ctl=yes
+  ac_cv_lib_cpg_cpg_join=yes
 else
-  ac_cv_lib_speex_speex_preprocess_ctl=no
+  ac_cv_lib_cpg_cpg_join=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_speex_speex_preprocess_ctl" >&5
-$as_echo "$ac_cv_lib_speex_speex_preprocess_ctl" >&6; }
-if test "x$ac_cv_lib_speex_speex_preprocess_ctl" = xyes; then :
-  AST_SPEEX_PREPROCESS_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cpg_cpg_join" >&5
+$as_echo "$ac_cv_lib_cpg_cpg_join" >&6; }
+if test "x$ac_cv_lib_cpg_cpg_join" = xyes; then :
+  AST_COROSYNC_FOUND=yes
 else
-  AST_SPEEX_PREPROCESS_FOUND=no
+  AST_COROSYNC_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SPEEX_PREPROCESS_FOUND}" = "yes"; then
-      SPEEX_PREPROCESS_LIB="${pbxlibdir} -lspeex -lm"
-      # if --with-SPEEX_PREPROCESS=DIR has been specified, use it.
-      if test "x${SPEEX_PREPROCESS_DIR}" != "x"; then
-         SPEEX_PREPROCESS_INCLUDE="-I${SPEEX_PREPROCESS_DIR}/include"
+   if test "${AST_COROSYNC_FOUND}" = "yes"; then
+      COROSYNC_LIB="${pbxlibdir} -lcpg -lcpg -lcfg"
+      # if --with-COROSYNC=DIR has been specified, use it.
+      if test "x${COROSYNC_DIR}" != "x"; then
+         COROSYNC_INCLUDE="-I${COROSYNC_DIR}/include"
       fi
-      SPEEX_PREPROCESS_INCLUDE="${SPEEX_PREPROCESS_INCLUDE} "
+      COROSYNC_INCLUDE="${COROSYNC_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SPEEX_PREPROCESS_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "speex/speex.h" "ac_cv_header_speex_speex_h" "$ac_includes_default"
-if test "x$ac_cv_header_speex_speex_h" = xyes; then :
-  SPEEX_PREPROCESS_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${COROSYNC_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "corosync/cpg.h" "ac_cv_header_corosync_cpg_h" "$ac_includes_default"
+if test "x$ac_cv_header_corosync_cpg_h" = xyes; then :
+  COROSYNC_HEADER_FOUND=1
 else
-  SPEEX_PREPROCESS_HEADER_FOUND=0
+  COROSYNC_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SPEEX_PREPROCESS_HEADER_FOUND}" = "x0" ; then
-         SPEEX_PREPROCESS_LIB=""
-         SPEEX_PREPROCESS_INCLUDE=""
+      if test "x${COROSYNC_HEADER_FOUND}" = "x0" ; then
+         COROSYNC_LIB=""
+         COROSYNC_INCLUDE=""
       else
 
-         PBX_SPEEX_PREPROCESS=1
+         PBX_COROSYNC=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SPEEX_PREPROCESS 1
+#define HAVE_COROSYNC 1
 _ACEOF
 
       fi
@@ -30533,31 +30846,27 @@ _ACEOF
 fi
 
 
-if test "${PBX_SPEEX_PREPROCESS}" = 1; then
-   PBX_SPEEX_PREPROCESS=1
-fi
-
 
-if test "x${PBX_SPEEXDSP}" != "x1" -a "${USE_SPEEXDSP}" != "no"; then
+if test "x${PBX_COROSYNC_CFG_STATE_TRACK}" != "x1" -a "${USE_COROSYNC_CFG_STATE_TRACK}" != "no"; then
    pbxlibdir=""
-   # if --with-SPEEXDSP=DIR has been specified, use it.
-   if test "x${SPEEXDSP_DIR}" != "x"; then
-      if test -d ${SPEEXDSP_DIR}/lib; then
-         pbxlibdir="-L${SPEEXDSP_DIR}/lib"
+   # if --with-COROSYNC_CFG_STATE_TRACK=DIR has been specified, use it.
+   if test "x${COROSYNC_CFG_STATE_TRACK_DIR}" != "x"; then
+      if test -d ${COROSYNC_CFG_STATE_TRACK_DIR}/lib; then
+         pbxlibdir="-L${COROSYNC_CFG_STATE_TRACK_DIR}/lib"
       else
-         pbxlibdir="-L${SPEEXDSP_DIR}"
+         pbxlibdir="-L${COROSYNC_CFG_STATE_TRACK_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for speex_preprocess_ctl in -lspeexdsp" >&5
-$as_echo_n "checking for speex_preprocess_ctl in -lspeexdsp... " >&6; }
-if ${ac_cv_lib_speexdsp_speex_preprocess_ctl+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for corosync_cfg_state_track in -lcfg" >&5
+$as_echo_n "checking for corosync_cfg_state_track in -lcfg... " >&6; }
+if ${ac_cv_lib_cfg_corosync_cfg_state_track+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lspeexdsp ${pbxlibdir} -lm $LIBS"
+LIBS="-lcfg ${pbxlibdir} -lcfg $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30567,65 +30876,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char speex_preprocess_ctl ();
+char corosync_cfg_state_track ();
 int
 main ()
 {
-return speex_preprocess_ctl ();
+return corosync_cfg_state_track ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_speexdsp_speex_preprocess_ctl=yes
+  ac_cv_lib_cfg_corosync_cfg_state_track=yes
 else
-  ac_cv_lib_speexdsp_speex_preprocess_ctl=no
+  ac_cv_lib_cfg_corosync_cfg_state_track=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_speexdsp_speex_preprocess_ctl" >&5
-$as_echo "$ac_cv_lib_speexdsp_speex_preprocess_ctl" >&6; }
-if test "x$ac_cv_lib_speexdsp_speex_preprocess_ctl" = xyes; then :
-  AST_SPEEXDSP_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cfg_corosync_cfg_state_track" >&5
+$as_echo "$ac_cv_lib_cfg_corosync_cfg_state_track" >&6; }
+if test "x$ac_cv_lib_cfg_corosync_cfg_state_track" = xyes; then :
+  AST_COROSYNC_CFG_STATE_TRACK_FOUND=yes
 else
-  AST_SPEEXDSP_FOUND=no
+  AST_COROSYNC_CFG_STATE_TRACK_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SPEEXDSP_FOUND}" = "yes"; then
-      SPEEXDSP_LIB="${pbxlibdir} -lspeexdsp -lm"
-      # if --with-SPEEXDSP=DIR has been specified, use it.
-      if test "x${SPEEXDSP_DIR}" != "x"; then
-         SPEEXDSP_INCLUDE="-I${SPEEXDSP_DIR}/include"
+   if test "${AST_COROSYNC_CFG_STATE_TRACK_FOUND}" = "yes"; then
+      COROSYNC_CFG_STATE_TRACK_LIB="${pbxlibdir} -lcfg -lcfg"
+      # if --with-COROSYNC_CFG_STATE_TRACK=DIR has been specified, use it.
+      if test "x${COROSYNC_CFG_STATE_TRACK_DIR}" != "x"; then
+         COROSYNC_CFG_STATE_TRACK_INCLUDE="-I${COROSYNC_CFG_STATE_TRACK_DIR}/include"
       fi
-      SPEEXDSP_INCLUDE="${SPEEXDSP_INCLUDE} "
+      COROSYNC_CFG_STATE_TRACK_INCLUDE="${COROSYNC_CFG_STATE_TRACK_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SPEEXDSP_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "speex/speex.h" "ac_cv_header_speex_speex_h" "$ac_includes_default"
-if test "x$ac_cv_header_speex_speex_h" = xyes; then :
-  SPEEXDSP_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${COROSYNC_CFG_STATE_TRACK_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "corosync/cfg.h" "ac_cv_header_corosync_cfg_h" "$ac_includes_default"
+if test "x$ac_cv_header_corosync_cfg_h" = xyes; then :
+  COROSYNC_CFG_STATE_TRACK_HEADER_FOUND=1
 else
-  SPEEXDSP_HEADER_FOUND=0
+  COROSYNC_CFG_STATE_TRACK_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SPEEXDSP_HEADER_FOUND}" = "x0" ; then
-         SPEEXDSP_LIB=""
-         SPEEXDSP_INCLUDE=""
+      if test "x${COROSYNC_CFG_STATE_TRACK_HEADER_FOUND}" = "x0" ; then
+         COROSYNC_CFG_STATE_TRACK_LIB=""
+         COROSYNC_CFG_STATE_TRACK_INCLUDE=""
       else
 
-         PBX_SPEEXDSP=1
+         PBX_COROSYNC_CFG_STATE_TRACK=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SPEEXDSP 1
+#define HAVE_COROSYNC_CFG_STATE_TRACK 1
 _ACEOF
 
       fi
@@ -30633,33 +30942,28 @@ _ACEOF
 fi
 
 
-if test "${PBX_SPEEXDSP}" = 1; then
-   PBX_SPEEX_PREPROCESS=1
-fi
-
-
 
 
-if test "x${PBX_SQLITE}" != "x1" -a "${USE_SQLITE}" != "no"; then
+if test "x${PBX_SPEEX}" != "x1" -a "${USE_SPEEX}" != "no"; then
    pbxlibdir=""
-   # if --with-SQLITE=DIR has been specified, use it.
-   if test "x${SQLITE_DIR}" != "x"; then
-      if test -d ${SQLITE_DIR}/lib; then
-         pbxlibdir="-L${SQLITE_DIR}/lib"
+   # if --with-SPEEX=DIR has been specified, use it.
+   if test "x${SPEEX_DIR}" != "x"; then
+      if test -d ${SPEEX_DIR}/lib; then
+         pbxlibdir="-L${SPEEX_DIR}/lib"
       else
-         pbxlibdir="-L${SQLITE_DIR}"
+         pbxlibdir="-L${SPEEX_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite_exec in -lsqlite" >&5
-$as_echo_n "checking for sqlite_exec in -lsqlite... " >&6; }
-if ${ac_cv_lib_sqlite_sqlite_exec+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for speex_encode in -lspeex" >&5
+$as_echo_n "checking for speex_encode in -lspeex... " >&6; }
+if ${ac_cv_lib_speex_speex_encode+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsqlite ${pbxlibdir}  $LIBS"
+LIBS="-lspeex ${pbxlibdir} -lm $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30669,65 +30973,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char sqlite_exec ();
+char speex_encode ();
 int
 main ()
 {
-return sqlite_exec ();
+return speex_encode ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_sqlite_sqlite_exec=yes
+  ac_cv_lib_speex_speex_encode=yes
 else
-  ac_cv_lib_sqlite_sqlite_exec=no
+  ac_cv_lib_speex_speex_encode=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite_sqlite_exec" >&5
-$as_echo "$ac_cv_lib_sqlite_sqlite_exec" >&6; }
-if test "x$ac_cv_lib_sqlite_sqlite_exec" = xyes; then :
-  AST_SQLITE_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_speex_speex_encode" >&5
+$as_echo "$ac_cv_lib_speex_speex_encode" >&6; }
+if test "x$ac_cv_lib_speex_speex_encode" = xyes; then :
+  AST_SPEEX_FOUND=yes
 else
-  AST_SQLITE_FOUND=no
+  AST_SPEEX_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SQLITE_FOUND}" = "yes"; then
-      SQLITE_LIB="${pbxlibdir} -lsqlite "
-      # if --with-SQLITE=DIR has been specified, use it.
-      if test "x${SQLITE_DIR}" != "x"; then
-         SQLITE_INCLUDE="-I${SQLITE_DIR}/include"
+   if test "${AST_SPEEX_FOUND}" = "yes"; then
+      SPEEX_LIB="${pbxlibdir} -lspeex -lm"
+      # if --with-SPEEX=DIR has been specified, use it.
+      if test "x${SPEEX_DIR}" != "x"; then
+         SPEEX_INCLUDE="-I${SPEEX_DIR}/include"
       fi
-      SQLITE_INCLUDE="${SQLITE_INCLUDE} "
+      SPEEX_INCLUDE="${SPEEX_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SQLITE_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "sqlite.h" "ac_cv_header_sqlite_h" "$ac_includes_default"
-if test "x$ac_cv_header_sqlite_h" = xyes; then :
-  SQLITE_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SPEEX_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "speex/speex.h" "ac_cv_header_speex_speex_h" "$ac_includes_default"
+if test "x$ac_cv_header_speex_speex_h" = xyes; then :
+  SPEEX_HEADER_FOUND=1
 else
-  SQLITE_HEADER_FOUND=0
+  SPEEX_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
-      if test "x${SQLITE_HEADER_FOUND}" = "x0" ; then
-         SQLITE_LIB=""
-         SQLITE_INCLUDE=""
+
+      if test "x${SPEEX_HEADER_FOUND}" = "x0" ; then
+         SPEEX_LIB=""
+         SPEEX_INCLUDE=""
       else
 
-         PBX_SQLITE=1
+         PBX_SPEEX=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SQLITE 1
+#define HAVE_SPEEX 1
 _ACEOF
 
       fi
@@ -30736,27 +31040,28 @@ fi
 
 
 
+# See if the main speex library contains the preprocess functions
 
-if test "x${PBX_SQLITE3}" != "x1" -a "${USE_SQLITE3}" != "no"; then
+if test "x${PBX_SPEEX_PREPROCESS}" != "x1" -a "${USE_SPEEX_PREPROCESS}" != "no"; then
    pbxlibdir=""
-   # if --with-SQLITE3=DIR has been specified, use it.
-   if test "x${SQLITE3_DIR}" != "x"; then
-      if test -d ${SQLITE3_DIR}/lib; then
-         pbxlibdir="-L${SQLITE3_DIR}/lib"
+   # if --with-SPEEX_PREPROCESS=DIR has been specified, use it.
+   if test "x${SPEEX_PREPROCESS_DIR}" != "x"; then
+      if test -d ${SPEEX_PREPROCESS_DIR}/lib; then
+         pbxlibdir="-L${SPEEX_PREPROCESS_DIR}/lib"
       else
-         pbxlibdir="-L${SQLITE3_DIR}"
+         pbxlibdir="-L${SPEEX_PREPROCESS_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5
-$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; }
-if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then :
+      CFLAGS="${CFLAGS} "
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for speex_preprocess_ctl in -lspeex" >&5
+$as_echo_n "checking for speex_preprocess_ctl in -lspeex... " >&6; }
+if ${ac_cv_lib_speex_speex_preprocess_ctl+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsqlite3 ${pbxlibdir} ${PTHREAD_LIBS} $LIBS"
+LIBS="-lspeex ${pbxlibdir} -lm $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30766,65 +31071,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char sqlite3_open ();
+char speex_preprocess_ctl ();
 int
 main ()
 {
-return sqlite3_open ();
+return speex_preprocess_ctl ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_sqlite3_sqlite3_open=yes
+  ac_cv_lib_speex_speex_preprocess_ctl=yes
 else
-  ac_cv_lib_sqlite3_sqlite3_open=no
+  ac_cv_lib_speex_speex_preprocess_ctl=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5
-$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; }
-if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then :
-  AST_SQLITE3_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_speex_speex_preprocess_ctl" >&5
+$as_echo "$ac_cv_lib_speex_speex_preprocess_ctl" >&6; }
+if test "x$ac_cv_lib_speex_speex_preprocess_ctl" = xyes; then :
+  AST_SPEEX_PREPROCESS_FOUND=yes
 else
-  AST_SQLITE3_FOUND=no
+  AST_SPEEX_PREPROCESS_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_SQLITE3_FOUND}" = "yes"; then
-      SQLITE3_LIB="${pbxlibdir} -lsqlite3 ${PTHREAD_LIBS}"
-      # if --with-SQLITE3=DIR has been specified, use it.
-      if test "x${SQLITE3_DIR}" != "x"; then
-         SQLITE3_INCLUDE="-I${SQLITE3_DIR}/include"
+   if test "${AST_SPEEX_PREPROCESS_FOUND}" = "yes"; then
+      SPEEX_PREPROCESS_LIB="${pbxlibdir} -lspeex -lm"
+      # if --with-SPEEX_PREPROCESS=DIR has been specified, use it.
+      if test "x${SPEEX_PREPROCESS_DIR}" != "x"; then
+         SPEEX_PREPROCESS_INCLUDE="-I${SPEEX_PREPROCESS_DIR}/include"
       fi
-      SQLITE3_INCLUDE="${SQLITE3_INCLUDE} ${PTHREAD_CFLAGS}"
+      SPEEX_PREPROCESS_INCLUDE="${SPEEX_PREPROCESS_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${SQLITE3_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default"
-if test "x$ac_cv_header_sqlite3_h" = xyes; then :
-  SQLITE3_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SPEEX_PREPROCESS_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "speex/speex.h" "ac_cv_header_speex_speex_h" "$ac_includes_default"
+if test "x$ac_cv_header_speex_speex_h" = xyes; then :
+  SPEEX_PREPROCESS_HEADER_FOUND=1
 else
-  SQLITE3_HEADER_FOUND=0
+  SPEEX_PREPROCESS_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${SQLITE3_HEADER_FOUND}" = "x0" ; then
-         SQLITE3_LIB=""
-         SQLITE3_INCLUDE=""
+      if test "x${SPEEX_PREPROCESS_HEADER_FOUND}" = "x0" ; then
+         SPEEX_PREPROCESS_LIB=""
+         SPEEX_PREPROCESS_INCLUDE=""
       else
 
-         PBX_SQLITE3=1
+         PBX_SPEEX_PREPROCESS=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_SQLITE3 1
+#define HAVE_SPEEX_PREPROCESS 1
 _ACEOF
 
       fi
@@ -30832,37 +31137,31 @@ _ACEOF
 fi
 
 
-
-if test "${PBX_SQLITE3}" != 1; then
-	as_fn_error $? "*** Asterisk now uses SQLite3 for the internal Asterisk database." "$LINENO" 5
-	as_fn_error $? "*** Please install the SQLite3 development package." "$LINENO" 5
-	exit 1
+if test "${PBX_SPEEX_PREPROCESS}" = 1; then
+   PBX_SPEEX_PREPROCESS=1
 fi
 
-# Find crypt support
-# * -lcrypt on *NIX
-# * in libsystem on OS X
 
-if test "x${PBX_LIBCRYPT}" != "x1" -a "${USE_LIBCRYPT}" != "no"; then
+if test "x${PBX_SPEEXDSP}" != "x1" -a "${USE_SPEEXDSP}" != "no"; then
    pbxlibdir=""
-   # if --with-LIBCRYPT=DIR has been specified, use it.
-   if test "x${LIBCRYPT_DIR}" != "x"; then
-      if test -d ${LIBCRYPT_DIR}/lib; then
-         pbxlibdir="-L${LIBCRYPT_DIR}/lib"
+   # if --with-SPEEXDSP=DIR has been specified, use it.
+   if test "x${SPEEXDSP_DIR}" != "x"; then
+      if test -d ${SPEEXDSP_DIR}/lib; then
+         pbxlibdir="-L${SPEEXDSP_DIR}/lib"
       else
-         pbxlibdir="-L${LIBCRYPT_DIR}"
+         pbxlibdir="-L${SPEEXDSP_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5
-$as_echo_n "checking for crypt in -lcrypt... " >&6; }
-if ${ac_cv_lib_crypt_crypt+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for speex_preprocess_ctl in -lspeexdsp" >&5
+$as_echo_n "checking for speex_preprocess_ctl in -lspeexdsp... " >&6; }
+if ${ac_cv_lib_speexdsp_speex_preprocess_ctl+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypt ${pbxlibdir}  $LIBS"
+LIBS="-lspeexdsp ${pbxlibdir} -lm $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30872,65 +31171,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char crypt ();
+char speex_preprocess_ctl ();
 int
 main ()
 {
-return crypt ();
+return speex_preprocess_ctl ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_crypt_crypt=yes
+  ac_cv_lib_speexdsp_speex_preprocess_ctl=yes
 else
-  ac_cv_lib_crypt_crypt=no
+  ac_cv_lib_speexdsp_speex_preprocess_ctl=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5
-$as_echo "$ac_cv_lib_crypt_crypt" >&6; }
-if test "x$ac_cv_lib_crypt_crypt" = xyes; then :
-  AST_LIBCRYPT_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_speexdsp_speex_preprocess_ctl" >&5
+$as_echo "$ac_cv_lib_speexdsp_speex_preprocess_ctl" >&6; }
+if test "x$ac_cv_lib_speexdsp_speex_preprocess_ctl" = xyes; then :
+  AST_SPEEXDSP_FOUND=yes
 else
-  AST_LIBCRYPT_FOUND=no
+  AST_SPEEXDSP_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_LIBCRYPT_FOUND}" = "yes"; then
-      LIBCRYPT_LIB="${pbxlibdir} -lcrypt "
-      # if --with-LIBCRYPT=DIR has been specified, use it.
-      if test "x${LIBCRYPT_DIR}" != "x"; then
-         LIBCRYPT_INCLUDE="-I${LIBCRYPT_DIR}/include"
+   if test "${AST_SPEEXDSP_FOUND}" = "yes"; then
+      SPEEXDSP_LIB="${pbxlibdir} -lspeexdsp -lm"
+      # if --with-SPEEXDSP=DIR has been specified, use it.
+      if test "x${SPEEXDSP_DIR}" != "x"; then
+         SPEEXDSP_INCLUDE="-I${SPEEXDSP_DIR}/include"
       fi
-      LIBCRYPT_INCLUDE="${LIBCRYPT_INCLUDE} "
+      SPEEXDSP_INCLUDE="${SPEEXDSP_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${LIBCRYPT_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "crypt.h" "ac_cv_header_crypt_h" "$ac_includes_default"
-if test "x$ac_cv_header_crypt_h" = xyes; then :
-  LIBCRYPT_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SPEEXDSP_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "speex/speex.h" "ac_cv_header_speex_speex_h" "$ac_includes_default"
+if test "x$ac_cv_header_speex_speex_h" = xyes; then :
+  SPEEXDSP_HEADER_FOUND=1
 else
-  LIBCRYPT_HEADER_FOUND=0
+  SPEEXDSP_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${LIBCRYPT_HEADER_FOUND}" = "x0" ; then
-         LIBCRYPT_LIB=""
-         LIBCRYPT_INCLUDE=""
+      if test "x${SPEEXDSP_HEADER_FOUND}" = "x0" ; then
+         SPEEXDSP_LIB=""
+         SPEEXDSP_INCLUDE=""
       else
 
-         PBX_LIBCRYPT=1
+         PBX_SPEEXDSP=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBCRYPT 1
+#define HAVE_SPEEXDSP 1
 _ACEOF
 
       fi
@@ -30938,39 +31237,33 @@ _ACEOF
 fi
 
 
-ac_fn_c_check_func "$LINENO" "crypt" "ac_cv_func_crypt"
-if test "x$ac_cv_func_crypt" = xyes; then :
-  SYSCRYPT=true
-else
-  SYSCRYPT=""
+if test "${PBX_SPEEXDSP}" = 1; then
+   PBX_SPEEX_PREPROCESS=1
 fi
 
 
-if test "x$LIBCRYPT_LIB" != "x" ; then
-    CRYPT_LIB="$LIBCRYPT_LIB"
-    CRYPT_INCLUDE="$LIBCRYPT_INCLUDE"
-
-$as_echo "#define HAVE_CRYPT 1" >>confdefs.h
-
-elif test "x$SYSCRYPT" != "x" ; then
-    CRYPT_LIB=""
-    CRYPT_INCLUDE=""
-
-$as_echo "#define HAVE_CRYPT 1" >>confdefs.h
-
-fi
-
 
 
+if test "x${PBX_SQLITE}" != "x1" -a "${USE_SQLITE}" != "no"; then
+   pbxlibdir=""
+   # if --with-SQLITE=DIR has been specified, use it.
+   if test "x${SQLITE_DIR}" != "x"; then
+      if test -d ${SQLITE_DIR}/lib; then
+         pbxlibdir="-L${SQLITE_DIR}/lib"
+      else
+         pbxlibdir="-L${SQLITE_DIR}"
+      fi
+   fi
 
-# Find crypt_r support
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt_r in -lcrypt" >&5
-$as_echo_n "checking for crypt_r in -lcrypt... " >&6; }
-if ${ac_cv_lib_crypt_crypt_r+:} false; then :
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite_exec in -lsqlite" >&5
+$as_echo_n "checking for sqlite_exec in -lsqlite... " >&6; }
+if ${ac_cv_lib_sqlite_sqlite_exec+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypt  $LIBS"
+LIBS="-lsqlite ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -30980,54 +31273,94 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char crypt_r ();
+char sqlite_exec ();
 int
 main ()
 {
-return crypt_r ();
+return sqlite_exec ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_crypt_crypt_r=yes
+  ac_cv_lib_sqlite_sqlite_exec=yes
 else
-  ac_cv_lib_crypt_crypt_r=no
+  ac_cv_lib_sqlite_sqlite_exec=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt_r" >&5
-$as_echo "$ac_cv_lib_crypt_crypt_r" >&6; }
-if test "x$ac_cv_lib_crypt_crypt_r" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite_sqlite_exec" >&5
+$as_echo "$ac_cv_lib_sqlite_sqlite_exec" >&6; }
+if test "x$ac_cv_lib_sqlite_sqlite_exec" = xyes; then :
+  AST_SQLITE_FOUND=yes
+else
+  AST_SQLITE_FOUND=no
+fi
 
-$as_echo "#define HAVE_CRYPT_R 1" >>confdefs.h
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+
+
+   # now check for the header.
+   if test "${AST_SQLITE_FOUND}" = "yes"; then
+      SQLITE_LIB="${pbxlibdir} -lsqlite "
+      # if --with-SQLITE=DIR has been specified, use it.
+      if test "x${SQLITE_DIR}" != "x"; then
+         SQLITE_INCLUDE="-I${SQLITE_DIR}/include"
+      fi
+      SQLITE_INCLUDE="${SQLITE_INCLUDE} "
+
+         # check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${SQLITE_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "sqlite.h" "ac_cv_header_sqlite_h" "$ac_includes_default"
+if test "x$ac_cv_header_sqlite_h" = xyes; then :
+  SQLITE_HEADER_FOUND=1
+else
+  SQLITE_HEADER_FOUND=0
+fi
+
+
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+
+      if test "x${SQLITE_HEADER_FOUND}" = "x0" ; then
+         SQLITE_LIB=""
+         SQLITE_INCLUDE=""
+      else
+
+         PBX_SQLITE=1
+         cat >>confdefs.h <<_ACEOF
+#define HAVE_SQLITE 1
+_ACEOF
 
+      fi
+   fi
 fi
 
 
 
-if test "x${PBX_CRYPTO}" != "x1" -a "${USE_CRYPTO}" != "no"; then
+
+if test "x${PBX_SQLITE3}" != "x1" -a "${USE_SQLITE3}" != "no"; then
    pbxlibdir=""
-   # if --with-CRYPTO=DIR has been specified, use it.
-   if test "x${CRYPTO_DIR}" != "x"; then
-      if test -d ${CRYPTO_DIR}/lib; then
-         pbxlibdir="-L${CRYPTO_DIR}/lib"
+   # if --with-SQLITE3=DIR has been specified, use it.
+   if test "x${SQLITE3_DIR}" != "x"; then
+      if test -d ${SQLITE3_DIR}/lib; then
+         pbxlibdir="-L${SQLITE3_DIR}/lib"
       else
-         pbxlibdir="-L${CRYPTO_DIR}"
+         pbxlibdir="-L${SQLITE3_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AES_encrypt in -lcrypto" >&5
-$as_echo_n "checking for AES_encrypt in -lcrypto... " >&6; }
-if ${ac_cv_lib_crypto_AES_encrypt+:} false; then :
+      CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5
+$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; }
+if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypto ${pbxlibdir}  $LIBS"
+LIBS="-lsqlite3 ${pbxlibdir} ${PTHREAD_LIBS} $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -31037,65 +31370,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char AES_encrypt ();
+char sqlite3_open ();
 int
 main ()
 {
-return AES_encrypt ();
+return sqlite3_open ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_crypto_AES_encrypt=yes
+  ac_cv_lib_sqlite3_sqlite3_open=yes
 else
-  ac_cv_lib_crypto_AES_encrypt=no
+  ac_cv_lib_sqlite3_sqlite3_open=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_AES_encrypt" >&5
-$as_echo "$ac_cv_lib_crypto_AES_encrypt" >&6; }
-if test "x$ac_cv_lib_crypto_AES_encrypt" = xyes; then :
-  AST_CRYPTO_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5
+$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; }
+if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then :
+  AST_SQLITE3_FOUND=yes
 else
-  AST_CRYPTO_FOUND=no
+  AST_SQLITE3_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_CRYPTO_FOUND}" = "yes"; then
-      CRYPTO_LIB="${pbxlibdir} -lcrypto "
-      # if --with-CRYPTO=DIR has been specified, use it.
-      if test "x${CRYPTO_DIR}" != "x"; then
-         CRYPTO_INCLUDE="-I${CRYPTO_DIR}/include"
+   if test "${AST_SQLITE3_FOUND}" = "yes"; then
+      SQLITE3_LIB="${pbxlibdir} -lsqlite3 ${PTHREAD_LIBS}"
+      # if --with-SQLITE3=DIR has been specified, use it.
+      if test "x${SQLITE3_DIR}" != "x"; then
+         SQLITE3_INCLUDE="-I${SQLITE3_DIR}/include"
       fi
-      CRYPTO_INCLUDE="${CRYPTO_INCLUDE} "
+      SQLITE3_INCLUDE="${SQLITE3_INCLUDE} ${PTHREAD_CFLAGS}"
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${CRYPTO_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "openssl/aes.h" "ac_cv_header_openssl_aes_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_aes_h" = xyes; then :
-  CRYPTO_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${SQLITE3_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default"
+if test "x$ac_cv_header_sqlite3_h" = xyes; then :
+  SQLITE3_HEADER_FOUND=1
 else
-  CRYPTO_HEADER_FOUND=0
+  SQLITE3_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${CRYPTO_HEADER_FOUND}" = "x0" ; then
-         CRYPTO_LIB=""
-         CRYPTO_INCLUDE=""
+      if test "x${SQLITE3_HEADER_FOUND}" = "x0" ; then
+         SQLITE3_LIB=""
+         SQLITE3_INCLUDE=""
       else
 
-         PBX_CRYPTO=1
+         PBX_SQLITE3=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_CRYPTO 1
+#define HAVE_SQLITE3 1
 _ACEOF
 
       fi
@@ -31104,29 +31437,36 @@ fi
 
 
 
-if test "$PBX_CRYPTO" = "1";
-then
+if test "${PBX_SQLITE3}" != 1; then
+	as_fn_error $? "*** Asterisk now uses SQLite3 for the internal Asterisk database." "$LINENO" 5
+	as_fn_error $? "*** Please install the SQLite3 development package." "$LINENO" 5
+	exit 1
+fi
 
-if test "x${PBX_OPENSSL}" != "x1" -a "${USE_OPENSSL}" != "no"; then
+# Find crypt support
+# * -lcrypt on *NIX
+# * in libsystem on OS X
+
+if test "x${PBX_LIBCRYPT}" != "x1" -a "${USE_LIBCRYPT}" != "no"; then
    pbxlibdir=""
-   # if --with-OPENSSL=DIR has been specified, use it.
-   if test "x${OPENSSL_DIR}" != "x"; then
-      if test -d ${OPENSSL_DIR}/lib; then
-         pbxlibdir="-L${OPENSSL_DIR}/lib"
+   # if --with-LIBCRYPT=DIR has been specified, use it.
+   if test "x${LIBCRYPT_DIR}" != "x"; then
+      if test -d ${LIBCRYPT_DIR}/lib; then
+         pbxlibdir="-L${LIBCRYPT_DIR}/lib"
       else
-         pbxlibdir="-L${OPENSSL_DIR}"
+         pbxlibdir="-L${LIBCRYPT_DIR}"
       fi
    fi
 
       ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
       CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_connect in -lssl" >&5
-$as_echo_n "checking for SSL_connect in -lssl... " >&6; }
-if ${ac_cv_lib_ssl_SSL_connect+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5
+$as_echo_n "checking for crypt in -lcrypt... " >&6; }
+if ${ac_cv_lib_crypt_crypt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lssl ${pbxlibdir} -lcrypto $LIBS"
+LIBS="-lcrypt ${pbxlibdir}  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -31136,65 +31476,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char SSL_connect ();
+char crypt ();
 int
 main ()
 {
-return SSL_connect ();
+return crypt ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ssl_SSL_connect=yes
+  ac_cv_lib_crypt_crypt=yes
 else
-  ac_cv_lib_ssl_SSL_connect=no
+  ac_cv_lib_crypt_crypt=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_connect" >&5
-$as_echo "$ac_cv_lib_ssl_SSL_connect" >&6; }
-if test "x$ac_cv_lib_ssl_SSL_connect" = xyes; then :
-  AST_OPENSSL_FOUND=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5
+$as_echo "$ac_cv_lib_crypt_crypt" >&6; }
+if test "x$ac_cv_lib_crypt_crypt" = xyes; then :
+  AST_LIBCRYPT_FOUND=yes
 else
-  AST_OPENSSL_FOUND=no
+  AST_LIBCRYPT_FOUND=no
 fi
 
       CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
 
 
    # now check for the header.
-   if test "${AST_OPENSSL_FOUND}" = "yes"; then
-      OPENSSL_LIB="${pbxlibdir} -lssl -lcrypto"
-      # if --with-OPENSSL=DIR has been specified, use it.
-      if test "x${OPENSSL_DIR}" != "x"; then
-         OPENSSL_INCLUDE="-I${OPENSSL_DIR}/include"
+   if test "${AST_LIBCRYPT_FOUND}" = "yes"; then
+      LIBCRYPT_LIB="${pbxlibdir} -lcrypt "
+      # if --with-LIBCRYPT=DIR has been specified, use it.
+      if test "x${LIBCRYPT_DIR}" != "x"; then
+         LIBCRYPT_INCLUDE="-I${LIBCRYPT_DIR}/include"
       fi
-      OPENSSL_INCLUDE="${OPENSSL_INCLUDE} "
+      LIBCRYPT_INCLUDE="${LIBCRYPT_INCLUDE} "
 
          # check for the header
          ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${OPENSSL_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_ssl_h" = xyes; then :
-  OPENSSL_HEADER_FOUND=1
+         CPPFLAGS="${CPPFLAGS} ${LIBCRYPT_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "crypt.h" "ac_cv_header_crypt_h" "$ac_includes_default"
+if test "x$ac_cv_header_crypt_h" = xyes; then :
+  LIBCRYPT_HEADER_FOUND=1
 else
-  OPENSSL_HEADER_FOUND=0
+  LIBCRYPT_HEADER_FOUND=0
 fi
 
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${OPENSSL_HEADER_FOUND}" = "x0" ; then
-         OPENSSL_LIB=""
-         OPENSSL_INCLUDE=""
+      if test "x${LIBCRYPT_HEADER_FOUND}" = "x0" ; then
+         LIBCRYPT_LIB=""
+         LIBCRYPT_INCLUDE=""
       else
 
-         PBX_OPENSSL=1
+         PBX_LIBCRYPT=1
          cat >>confdefs.h <<_ACEOF
-#define HAVE_OPENSSL 1
+#define HAVE_LIBCRYPT 1
 _ACEOF
 
       fi
@@ -31202,27 +31542,39 @@ _ACEOF
 fi
 
 
+ac_fn_c_check_func "$LINENO" "crypt" "ac_cv_func_crypt"
+if test "x$ac_cv_func_crypt" = xyes; then :
+  SYSCRYPT=true
+else
+  SYSCRYPT=""
+fi
+
+
+if test "x$LIBCRYPT_LIB" != "x" ; then
+    CRYPT_LIB="$LIBCRYPT_LIB"
+    CRYPT_INCLUDE="$LIBCRYPT_INCLUDE"
 
-if test "x${PBX_OPENSSL_BIO_METHOD}" != "x1" -a "${USE_OPENSSL_BIO_METHOD}" != "no"; then
-   pbxlibdir=""
-   # if --with-OPENSSL_BIO_METHOD=DIR has been specified, use it.
-   if test "x${OPENSSL_BIO_METHOD_DIR}" != "x"; then
-      if test -d ${OPENSSL_BIO_METHOD_DIR}/lib; then
-         pbxlibdir="-L${OPENSSL_BIO_METHOD_DIR}/lib"
-      else
-         pbxlibdir="-L${OPENSSL_BIO_METHOD_DIR}"
-      fi
-   fi
+$as_echo "#define HAVE_CRYPT 1" >>confdefs.h
 
-      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_meth_new in -lssl" >&5
-$as_echo_n "checking for BIO_meth_new in -lssl... " >&6; }
-if ${ac_cv_lib_ssl_BIO_meth_new+:} false; then :
+elif test "x$SYSCRYPT" != "x" ; then
+    CRYPT_LIB=""
+    CRYPT_INCLUDE=""
+
+$as_echo "#define HAVE_CRYPT 1" >>confdefs.h
+
+fi
+
+
+
+
+# Find crypt_r support
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt_r in -lcrypt" >&5
+$as_echo_n "checking for crypt_r in -lcrypt... " >&6; }
+if ${ac_cv_lib_crypt_crypt_r+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lssl ${pbxlibdir} -lcrypto $LIBS"
+LIBS="-lcrypt  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -31232,74 +31584,33 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char BIO_meth_new ();
+char crypt_r ();
 int
 main ()
 {
-return BIO_meth_new ();
+return crypt_r ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ssl_BIO_meth_new=yes
+  ac_cv_lib_crypt_crypt_r=yes
 else
-  ac_cv_lib_ssl_BIO_meth_new=no
+  ac_cv_lib_crypt_crypt_r=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_BIO_meth_new" >&5
-$as_echo "$ac_cv_lib_ssl_BIO_meth_new" >&6; }
-if test "x$ac_cv_lib_ssl_BIO_meth_new" = xyes; then :
-  AST_OPENSSL_BIO_METHOD_FOUND=yes
-else
-  AST_OPENSSL_BIO_METHOD_FOUND=no
-fi
-
-      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
-
-
-   # now check for the header.
-   if test "${AST_OPENSSL_BIO_METHOD_FOUND}" = "yes"; then
-      OPENSSL_BIO_METHOD_LIB="${pbxlibdir} -lssl -lcrypto"
-      # if --with-OPENSSL_BIO_METHOD=DIR has been specified, use it.
-      if test "x${OPENSSL_BIO_METHOD_DIR}" != "x"; then
-         OPENSSL_BIO_METHOD_INCLUDE="-I${OPENSSL_BIO_METHOD_DIR}/include"
-      fi
-      OPENSSL_BIO_METHOD_INCLUDE="${OPENSSL_BIO_METHOD_INCLUDE} "
-
-         # check for the header
-         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${OPENSSL_BIO_METHOD_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_ssl_h" = xyes; then :
-  OPENSSL_BIO_METHOD_HEADER_FOUND=1
-else
-  OPENSSL_BIO_METHOD_HEADER_FOUND=0
-fi
-
-
-         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
-      if test "x${OPENSSL_BIO_METHOD_HEADER_FOUND}" = "x0" ; then
-         OPENSSL_BIO_METHOD_LIB=""
-         OPENSSL_BIO_METHOD_INCLUDE=""
-      else
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt_r" >&5
+$as_echo "$ac_cv_lib_crypt_crypt_r" >&6; }
+if test "x$ac_cv_lib_crypt_crypt_r" = xyes; then :
 
-         PBX_OPENSSL_BIO_METHOD=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_OPENSSL_BIO_METHOD 1
-_ACEOF
+$as_echo "#define HAVE_CRYPT_R 1" >>confdefs.h
 
-      fi
-   fi
 fi
 
 
-fi
-
 if test "$PBX_OPENSSL" = "1";
 then
 
diff --git a/configure.ac b/configure.ac
index d0c3976fb3..6e814e2cbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -313,6 +313,8 @@ AC_PATH_PROG([LDCONFIG], [ldconfig], :)
 AC_PATH_PROG([SHA1SUM], [sha1sum], $ac_aux_dir/build_tools/sha1sum-sh)
 AC_PATH_PROG([OPENSSL], [openssl], :)
 
+PKG_PROG_PKG_CONFIG()
+
 AC_CACHE_CHECK([for bison that supports parse-param], [ac_cv_path_BISON2], [
 	if test "x$BISON" != "x:" ; then
 		# Create a temporary directory $tmp in $TMPDIR (default /tmp).
@@ -458,6 +460,52 @@ if test "${with_pjproject}" == "no" || test "${with_pjproject}" == "n" ; then
 	PJPROJECT_BUNDLED=no
 fi
 
+#
+# OpenSSL stuff has to be done here because we want to pass
+# any resulting CFLAGS and LDFLAGS to the bundled pjproject
+# configure done in THIRD_PARTY_CONFIGURE()
+#
+AST_EXT_LIB_SETUP([CRYPTO], [OpenSSL Cryptography], [crypto])
+AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL Secure Sockets Layer], [ssl])
+AST_EXT_LIB_SETUP_OPTIONAL([OPENSSL_BIO_METHOD], [OpenSSL BIO Method Support], [CRYPTO], [crypto])
+
+# If neither --without-ssl (PBX_OPENSSL=-1) nor --without-crypto (PBX_CRYPTO=-1)
+# and there were no directories atdded to --with-ssl and --with-crypto, and
+# pkg-config is installed (which is should be by install_prereq).
+if test "x$PKG_CONFIG" != "x" -a $PBX_OPENSSL -ge 0 -a $PBX_CRYPTO -ge 0 -a "x$OPENSSL_DIR" == "x" ; then
+	AC_MSG_NOTICE(checking OPENSSL with pkg-config)
+	AC_MSG_NOTICE(checking whether system openssl > 1.1.0)
+	AST_PKG_CONFIG_CHECK([OPENSSL], [openssl >= 1.1.0])
+	if test $PBX_OPENSSL -eq 0 ; then
+		AC_MSG_NOTICE(checking whether alternate openssl11 is installed)
+		AST_PKG_CONFIG_CHECK([OPENSSL], [openssl11])
+	fi
+	if test $PBX_OPENSSL -eq 1 ; then
+		AC_DEFINE([HAVE_OPENSSL_BIO_METHOD], 1)
+		PBX_OPENSSL_BIO_METHOD=1
+	else
+		AC_MSG_NOTICE(checking fallback system openssl)
+		AST_PKG_CONFIG_CHECK([OPENSSL], [openssl])
+	fi
+
+	if test $PBX_OPENSSL -eq 1; then
+		AC_DEFINE([HAVE_CRYPTO], 1)
+		PBX_CRYPTO=1
+	fi
+else
+	AC_MSG_NOTICE(Checking OPENSSL without pkg-config)
+	AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h])
+	if test "$PBX_CRYPTO" = "1";
+	then
+		AST_EXT_LIB_CHECK([OPENSSL], [ssl], [SSL_connect], [openssl/ssl.h], [-lcrypto])
+		AST_EXT_LIB_CHECK([OPENSSL_BIO_METHOD], [ssl], [BIO_meth_new], [openssl/ssl.h], [-lcrypto])
+	fi
+fi
+if test $PBX_OPENSSL -eq 0 ; then
+	AC_MSG_WARN(OpenSSL does not seem to be installed)
+fi
+
+
 THIRD_PARTY_CONFIGURE()
 
 # AST_EXT_LIB_SETUP is used to tell configure to handle variables for
@@ -482,8 +530,6 @@ AST_EXT_LIB_SETUP([CODEC2], [Codec 2 Audio Decoder/Encoder], [codec2])
 AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg])
 AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg])
 AST_EXT_LIB_SETUP([CRYPT], [password and data encryption], [crypt])
-AST_EXT_LIB_SETUP([CRYPTO], [OpenSSL Cryptography], [crypto])
-AST_EXT_LIB_SETUP_OPTIONAL([OPENSSL_BIO_METHOD], [OpenSSL BIO Method Support], [CRYPTO], [crypto])
 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
 AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec], [avcodec])
 AST_EXT_LIB_SETUP([GSM], [External GSM], [gsm], [, use 'internal' GSM otherwise])
@@ -593,7 +639,6 @@ AST_EXT_LIB_SETUP_OPTIONAL([SRTP_192], [SRTP Library AES-192 (ICM)], [SRTP], [sr
 AST_EXT_LIB_SETUP_OPTIONAL([SRTP_GCM], [SRTP Library AES-128 (GCM) and AES-256 (GCM)], [SRTP], [srtp])
 AST_EXT_LIB_SETUP_OPTIONAL([SRTP_SHUTDOWN], [SRTP Library Shutdown Function], [SRTP], [srtp])
 AST_EXT_LIB_SETUP_OPTIONAL([SRTP_GET_VERSION], [SRTP Library Version Function], [SRTP], [srtp])
-AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL Secure Sockets Layer], [ssl])
 AST_EXT_LIB_SETUP_OPTIONAL([RT], [Realtime functions], [rt])
 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
 AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
@@ -640,8 +685,6 @@ AC_CHECK_HEADERS([ \
 
 AC_CHECK_HEADERS([arpa/inet.h libintl.h malloc.h netdb.h stddef.h strings.h sys/event.h utime.h])
 
-PKG_PROG_PKG_CONFIG()
-
 # Find required NetBSD Editline library (libedit).
 AST_PKG_CONFIG_CHECK(LIBEDIT, libedit)
 # some platforms do not list libedit via pkg-config, for example OpenBSD 6.2
@@ -2642,14 +2685,6 @@ AC_SUBST(CRYPT_INCLUDE)
 AC_CHECK_LIB([crypt], [crypt_r],
     [AC_DEFINE([HAVE_CRYPT_R], [1], [Define to 1 if you have the 'crypt_r' function.])])
 
-AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h])
-
-if test "$PBX_CRYPTO" = "1";
-then
-	AST_EXT_LIB_CHECK([OPENSSL], [ssl], [SSL_connect], [openssl/ssl.h], [-lcrypto])
-	AST_EXT_LIB_CHECK([OPENSSL_BIO_METHOD], [ssl], [BIO_meth_new], [openssl/ssl.h], [-lcrypto])
-fi
-
 if test "$PBX_OPENSSL" = "1";
 then
         AST_CHECK_OSPTK([4], [0], [0])
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 27c64aa928..af6df9d070 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -585,7 +585,7 @@
 /* Define to 1 if you have the MFR2 library. */
 #undef HAVE_OPENR2
 
-/* Define to 1 if you have the OpenSSL Secure Sockets Layer library. */
+/* Define if your system has the OPENSSL libraries. */
 #undef HAVE_OPENSSL
 
 /* Define to 1 if CRYPTO has the OpenSSL BIO Method Support feature. */
diff --git a/makeopts.in b/makeopts.in
index 27a5bdc15b..61d6437610 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -239,6 +239,7 @@ PJPROJECT_BUNDLED=@PJPROJECT_BUNDLED@
 PJPROJECT_INCLUDE=@PJPROJECT_INCLUDE@
 PJPROJECT_LIB=@PJPROJECT_LIB@
 PJPROJECT_DIR=@PJPROJECT_DIR@
+PJPROJECT_CONFIGURE_OPTS=@PJPROJECT_CONFIGURE_OPTS@
 
 POPT_INCLUDE=@POPT_INCLUDE@
 POPT_LIB=@POPT_LIB@
diff --git a/menuselect/configure b/menuselect/configure
index 1d15c1c138..9986b4f989 100755
--- a/menuselect/configure
+++ b/menuselect/configure
@@ -696,6 +696,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -777,6 +778,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1029,6 +1031,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1166,7 +1177,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1319,6 +1330,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile
index fce27687d0..96a6491555 100644
--- a/third-party/pjproject/Makefile
+++ b/third-party/pjproject/Makefile
@@ -88,8 +88,8 @@ else
 endif
 
 export PJ_CFLAGS := $(filter-out -O% -g%,$(PJ_CFLAGS))
-export CFLAGS += $(CF)
-export LDFLAGS += $(CC_LDFLAGS)
+export CFLAGS += $(CF) $(OPENSSL_INCLUDE)
+export LDFLAGS += $(CC_LDFLAGS) $(OPENSSL_LIB)
 
 ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] '
 SHELL_ECHO_PREFIX := echo '[pjproject] '
@@ -129,7 +129,7 @@ source/pjlib/include/pj/%.h: patches/%.h
 	$(CMD_PREFIX) $(MAKE) clean $(REALLY_QUIET)
 
 source/build.mak: Makefile.rules source/version.mak source/user.mak $(addprefix source/pjlib/include/pj/,$(notdir $(wildcard patches/*.h))) .rebuild_needed
-	$(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS)
+	$(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS) 
 	$(CMD_PREFIX) (cd source ; ./aconfigure $(QUIET_CONFIGURE) $(PJPROJECT_CONFIG_OPTS))
 
 build.mak: source/build.mak
diff --git a/third-party/pjproject/configure.m4 b/third-party/pjproject/configure.m4
index 485e4f1a74..f67ef577e2 100644
--- a/third-party/pjproject/configure.m4
+++ b/third-party/pjproject/configure.m4
@@ -117,6 +117,7 @@ AC_DEFUN([_PJPROJECT_CONFIGURE],
 		AC_SUBST([PBX_PJPROJECT])
 		AC_SUBST([PJPROJECT_LIB])
 		AC_SUBST([PJPROJECT_INCLUDE])
+		AC_SUBST([PJPROJECT_CONFIGURE_OPTS])
 		AC_MSG_RESULT(yes)
 
 	fi
-- 
GitLab