diff --git a/autoconf/ast_c_compile_check.m4 b/autoconf/ast_c_compile_check.m4
index 0d49ec3ca71be7e7d55e1e762ba649c845142386..ed15630178bdd7a1ac785fb98232eab518433cf3 100644
--- a/autoconf/ast_c_compile_check.m4
+++ b/autoconf/ast_c_compile_check.m4
@@ -22,7 +22,7 @@ AC_DEFUN([AST_C_COMPILE_CHECK],
 	    [   AC_MSG_RESULT(yes)
 		PBX_$1=1
 		AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
-		AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
+		m4_ifval([$4], [AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])])
 	    ],
 	    [       AC_MSG_RESULT(no) ] 
 	)
diff --git a/autoconf/ast_c_define_check.m4 b/autoconf/ast_c_define_check.m4
index adf31223ea9bd5db2624773b4f5dd68a42f3e1f1..52b97911089fa982fbe24ae93bd7e70a73307e6b 100644
--- a/autoconf/ast_c_define_check.m4
+++ b/autoconf/ast_c_define_check.m4
@@ -23,7 +23,7 @@ AC_DEFUN([AST_C_DEFINE_CHECK],
 	    [   AC_MSG_RESULT(yes)
 		PBX_$1=1
 		AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
-		AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
+		m4_ifval([$4], [AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])])
 	    ],
 	    [   AC_MSG_RESULT(no) ] 
 	)
diff --git a/autoconf/ast_ext_lib.m4 b/autoconf/ast_ext_lib.m4
index 3d9d039dd3dbbf58659e51588a651e4b6d8b6115..4038bfb12a0af576ff0d457fdd0f1557a0a378c1 100644
--- a/autoconf/ast_ext_lib.m4
+++ b/autoconf/ast_ext_lib.m4
@@ -30,7 +30,6 @@ AC_DEFUN([AST_EXT_LIB_SETUP],
 	esac
     ])
     AH_TEMPLATE(m4_bpatsubst([[HAVE_$1]], [(.*)]), [Define to 1 if you have the $2 library.])
-    AH_TEMPLATE(m4_bpatsubst([[HAVE_$1_VERSION]], [(.*)]), [Define to the version of the $2 library.])
     AC_SUBST([$1_LIB])
     AC_SUBST([$1_INCLUDE])
     AC_SUBST([$1_DIR])
@@ -81,7 +80,10 @@ if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_$1_FOUND=yes
    else
-      AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} $6"
+      AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], [${pbxlibdir} $5])
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -95,10 +97,10 @@ if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
       if test "x$4" = "x" ; then	# no header, assume found
          $1_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
          AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${$1_HEADER_FOUND}" = "x0" ; then
          $1_LIB=""
@@ -110,9 +112,14 @@ if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
          PBX_$1=1
          cat >>confdefs.h <<_ACEOF
 [@%:@define] HAVE_$1 1
+_ACEOF
+         m4_ifval([$7], [
+         cat >>confdefs.h <<_ACEOF
 [@%:@define] HAVE_$1_VERSION $7
 _ACEOF
+            ])
       fi
    fi
 fi
+m4_ifval([$7], [AH_TEMPLATE(m4_bpatsubst([[HAVE_$1_VERSION]], [(.*)]), [Define to the version of the $2 library.])])
 ])
diff --git a/configure b/configure
index 708fb92a969499d2de0f96ec833bab7024cffd92..b094349b38c91c82c65ac1ae801b6686d6b6f62b 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 261913 .
+# From configure.ac Revision: 262048 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.6.
 #
@@ -8400,8 +8400,6 @@ fi
 
 
 
-
-
 # BKTR is used for backtrace support on platforms that do not
 # have it natively.
 
@@ -8438,8 +8436,6 @@ fi
 
 
 
-
-
     BLUETOOTH_DESCRIP="Bluetooth"
     BLUETOOTH_OPTION="bluetooth"
     PBX_BLUETOOTH=0
@@ -8473,8 +8469,6 @@ fi
 
 
 
-
-
     CAP_DESCRIP="POSIX 1.e capabilities"
     CAP_OPTION="cap"
     PBX_CAP=0
@@ -8508,8 +8502,6 @@ fi
 
 
 
-
-
     CURL_DESCRIP="cURL"
     CURL_OPTION="curl"
     PBX_CURL=0
@@ -8543,8 +8535,6 @@ fi
 
 
 
-
-
     CURSES_DESCRIP="curses"
     CURSES_OPTION="curses"
     PBX_CURSES=0
@@ -8578,8 +8568,6 @@ fi
 
 
 
-
-
     CRYPTO_DESCRIP="OpenSSL Cryptography"
     CRYPTO_OPTION="crypto"
     PBX_CRYPTO=0
@@ -8613,8 +8601,6 @@ fi
 
 
 
-
-
     DAHDI_DESCRIP="DAHDI"
     DAHDI_OPTION="dahdi"
     PBX_DAHDI=0
@@ -8648,8 +8634,6 @@ fi
 
 
 
-
-
     FFMPEG_DESCRIP="Ffmpeg and avcodec"
     FFMPEG_OPTION="avcodec"
     PBX_FFMPEG=0
@@ -8683,8 +8667,6 @@ fi
 
 
 
-
-
     GSM_DESCRIP="External GSM"
     GSM_OPTION="gsm"
     PBX_GSM=0
@@ -8718,8 +8700,6 @@ fi
 
 
 
-
-
     GTK2_DESCRIP="gtk2"
     GTK2_OPTION="gtk2"
     PBX_GTK2=0
@@ -8753,8 +8733,6 @@ fi
 
 
 
-
-
     GMIME_DESCRIP="GMime"
     GMIME_OPTION="gmime"
     PBX_GMIME=0
@@ -8788,8 +8766,6 @@ fi
 
 
 
-
-
     HOARD_DESCRIP="Hoard Memory Allocator"
     HOARD_OPTION="hoard"
     PBX_HOARD=0
@@ -8823,8 +8799,6 @@ fi
 
 
 
-
-
     ICAL_DESCRIP="iCal"
     ICAL_OPTION="ical"
     PBX_ICAL=0
@@ -8858,8 +8832,6 @@ fi
 
 
 
-
-
     ICONV_DESCRIP="Iconv"
     ICONV_OPTION="iconv"
     PBX_ICONV=0
@@ -8893,8 +8865,6 @@ fi
 
 
 
-
-
     IKSEMEL_DESCRIP="Iksemel Jabber"
     IKSEMEL_OPTION="iksemel"
     PBX_IKSEMEL=0
@@ -8928,8 +8898,6 @@ fi
 
 
 
-
-
     IMAP_TK_DESCRIP="UW IMAP Toolkit"
     IMAP_TK_OPTION="imap"
     PBX_IMAP_TK=0
@@ -8963,8 +8931,6 @@ fi
 
 
 
-
-
     INOTIFY_DESCRIP="inotify support"
     INOTIFY_OPTION="inotify"
     PBX_INOTIFY=0
@@ -8998,8 +8964,6 @@ fi
 
 
 
-
-
     IODBC_DESCRIP="iODBC"
     IODBC_OPTION="iodbc"
     PBX_IODBC=0
@@ -9033,8 +8997,6 @@ fi
 
 
 
-
-
     ISDNNET_DESCRIP="ISDN4Linux"
     ISDNNET_OPTION="isdnnet"
     PBX_ISDNNET=0
@@ -9068,8 +9030,6 @@ fi
 
 
 
-
-
     JACK_DESCRIP="Jack Audio Connection Kit"
     JACK_OPTION="jack"
     PBX_JACK=0
@@ -9103,8 +9063,6 @@ fi
 
 
 
-
-
     LDAP_DESCRIP="OpenLDAP"
     LDAP_OPTION="ldap"
     PBX_LDAP=0
@@ -9138,8 +9096,6 @@ fi
 
 
 
-
-
     LIBXML2_DESCRIP="LibXML2"
     LIBXML2_OPTION="libxml2"
     PBX_LIBXML2=0
@@ -9173,8 +9129,6 @@ fi
 
 
 
-
-
     LTDL_DESCRIP="libtool"
     LTDL_OPTION="ltdl"
     PBX_LTDL=0
@@ -9208,8 +9162,6 @@ fi
 
 
 
-
-
     LUA_DESCRIP="Lua"
     LUA_OPTION="lua"
     PBX_LUA=0
@@ -9243,8 +9195,6 @@ fi
 
 
 
-
-
     MISDN_DESCRIP="mISDN user"
     MISDN_OPTION="misdn"
     PBX_MISDN=0
@@ -9278,8 +9228,6 @@ fi
 
 
 
-
-
     MYSQLCLIENT_DESCRIP="MySQL client"
     MYSQLCLIENT_OPTION="mysqlclient"
     PBX_MYSQLCLIENT=0
@@ -9313,8 +9261,6 @@ fi
 
 
 
-
-
     NBS_DESCRIP="Network Broadcast Sound"
     NBS_OPTION="nbs"
     PBX_NBS=0
@@ -9348,8 +9294,6 @@ fi
 
 
 
-
-
     NCURSES_DESCRIP="ncurses"
     NCURSES_OPTION="ncurses"
     PBX_NCURSES=0
@@ -9383,8 +9327,6 @@ fi
 
 
 
-
-
     NEON_DESCRIP="neon"
     NEON_OPTION="neon"
     PBX_NEON=0
@@ -9418,8 +9360,6 @@ fi
 
 
 
-
-
     NETSNMP_DESCRIP="Net-SNMP"
     NETSNMP_OPTION="netsnmp"
     PBX_NETSNMP=0
@@ -9453,8 +9393,6 @@ fi
 
 
 
-
-
     NEWT_DESCRIP="newt"
     NEWT_OPTION="newt"
     PBX_NEWT=0
@@ -9488,8 +9426,6 @@ fi
 
 
 
-
-
     OGG_DESCRIP="OGG"
     OGG_OPTION="ogg"
     PBX_OGG=0
@@ -9523,8 +9459,6 @@ fi
 
 
 
-
-
     OSPTK_DESCRIP="OSP Toolkit"
     OSPTK_OPTION="osptk"
     PBX_OSPTK=0
@@ -9558,8 +9492,6 @@ fi
 
 
 
-
-
     OSS_DESCRIP="Open Sound System"
     OSS_OPTION="oss"
     PBX_OSS=0
@@ -9593,8 +9525,6 @@ fi
 
 
 
-
-
     PGSQL_DESCRIP="PostgreSQL"
     PGSQL_OPTION="postgres"
     PBX_PGSQL=0
@@ -9628,8 +9558,6 @@ fi
 
 
 
-
-
     POPT_DESCRIP="popt"
     POPT_OPTION="popt"
     PBX_POPT=0
@@ -9663,8 +9591,6 @@ fi
 
 
 
-
-
     PORTAUDIO_DESCRIP="PortAudio"
     PORTAUDIO_OPTION="portaudio"
     PBX_PORTAUDIO=0
@@ -9698,8 +9624,6 @@ fi
 
 
 
-
-
     PRI_DESCRIP="ISDN PRI"
     PRI_OPTION="pri"
     PBX_PRI=0
@@ -9733,8 +9657,6 @@ fi
 
 
 
-
-
 PRI_CCSS_DESCRIP="ISDN PRI call completion supplementary service"
 PRI_CCSS_OPTION=pri
 
@@ -9962,8 +9884,6 @@ fi
 
 
 
-
-
     SPANDSP_DESCRIP="SPANDSP"
     SPANDSP_OPTION="spandsp"
     PBX_SPANDSP=0
@@ -9997,8 +9917,6 @@ fi
 
 
 
-
-
     SS7_DESCRIP="ISDN SS7"
     SS7_OPTION="ss7"
     PBX_SS7=0
@@ -10032,8 +9950,6 @@ fi
 
 
 
-
-
     OPENR2_DESCRIP="MFR2"
     OPENR2_OPTION="openr2"
     PBX_OPENR2=0
@@ -10067,8 +9983,6 @@ fi
 
 
 
-
-
     PWLIB_DESCRIP="PWlib"
     PWLIB_OPTION="pwlib"
     PBX_PWLIB=0
@@ -10102,8 +10016,6 @@ fi
 
 
 
-
-
     OPENH323_DESCRIP="OpenH323"
     OPENH323_OPTION="h323"
     PBX_OPENH323=0
@@ -10137,8 +10049,6 @@ fi
 
 
 
-
-
     RADIUS_DESCRIP="Radius Client"
     RADIUS_OPTION="radius"
     PBX_RADIUS=0
@@ -10172,8 +10082,6 @@ fi
 
 
 
-
-
     SDL_DESCRIP="Sdl"
     SDL_OPTION="sdl"
     PBX_SDL=0
@@ -10207,8 +10115,6 @@ fi
 
 
 
-
-
     SDL_IMAGE_DESCRIP="Sdl Image"
     SDL_IMAGE_OPTION="SDL_image"
     PBX_SDL_IMAGE=0
@@ -10242,8 +10148,6 @@ fi
 
 
 
-
-
     OPENAIS_DESCRIP="OpenAIS"
     OPENAIS_OPTION="openais"
     PBX_OPENAIS=0
@@ -10277,8 +10181,6 @@ fi
 
 
 
-
-
     SPEEX_DESCRIP="Speex"
     SPEEX_OPTION="speex"
     PBX_SPEEX=0
@@ -10312,8 +10214,6 @@ fi
 
 
 
-
-
     SPEEX_PREPROCESS_DESCRIP="Speex preprocess routines"
     SPEEX_PREPROCESS_OPTION="speex"
     PBX_SPEEX_PREPROCESS=0
@@ -10347,8 +10247,6 @@ fi
 
 
 
-
-
     SPEEXDSP_DESCRIP="SpeexDSP"
     SPEEXDSP_OPTION="speexdsp"
     PBX_SPEEXDSP=0
@@ -10382,8 +10280,6 @@ fi
 
 
 
-
-
 SPEEX_PREPROCESS_DESCRIP="speex_preprocess_ctl"
 SPEEX_PREPROCESS_OPTION=speex
 
@@ -10429,8 +10325,6 @@ fi
 
 
 
-
-
     SQLITE3_DESCRIP="SQLite"
     SQLITE3_OPTION="sqlite3"
     PBX_SQLITE3=0
@@ -10464,8 +10358,6 @@ fi
 
 
 
-
-
     SUPPSERV_DESCRIP="mISDN Supplemental Services"
     SUPPSERV_OPTION="suppserv"
     PBX_SUPPSERV=0
@@ -10499,8 +10391,6 @@ fi
 
 
 
-
-
     OPENSSL_DESCRIP="OpenSSL Secure Sockets Layer"
     OPENSSL_OPTION="ssl"
     PBX_OPENSSL=0
@@ -10534,8 +10424,6 @@ fi
 
 
 
-
-
     FREETDS_DESCRIP="FreeTDS"
     FREETDS_OPTION="tds"
     PBX_FREETDS=0
@@ -10569,8 +10457,6 @@ fi
 
 
 
-
-
     TERMCAP_DESCRIP="Termcap"
     TERMCAP_OPTION="termcap"
     PBX_TERMCAP=0
@@ -10604,8 +10490,6 @@ fi
 
 
 
-
-
     TINFO_DESCRIP="Term Info"
     TINFO_OPTION="tinfo"
     PBX_TINFO=0
@@ -10639,8 +10523,6 @@ fi
 
 
 
-
-
     TONEZONE_DESCRIP="tonezone"
     TONEZONE_OPTION="tonezone"
     PBX_TONEZONE=0
@@ -10674,8 +10556,6 @@ fi
 
 
 
-
-
     UNIXODBC_DESCRIP="unixODBC"
     UNIXODBC_OPTION="unixodbc"
     PBX_UNIXODBC=0
@@ -10709,8 +10589,6 @@ fi
 
 
 
-
-
     USB_DESCRIP="usb"
     USB_OPTION="usb"
     PBX_USB=0
@@ -10744,8 +10622,6 @@ fi
 
 
 
-
-
     VORBIS_DESCRIP="Vorbis"
     VORBIS_OPTION="vorbis"
     PBX_VORBIS=0
@@ -10779,8 +10655,6 @@ fi
 
 
 
-
-
     VPB_DESCRIP="Voicetronix API"
     VPB_OPTION="vpb"
     PBX_VPB=0
@@ -10814,8 +10688,6 @@ fi
 
 
 
-
-
     X11_DESCRIP="X11"
     X11_OPTION="x11"
     PBX_X11=0
@@ -10849,8 +10721,6 @@ fi
 
 
 
-
-
     ZLIB_DESCRIP="zlib compression"
     ZLIB_OPTION="z"
     PBX_ZLIB=0
@@ -10884,8 +10754,6 @@ fi
 
 
 
-
-
     TIMERFD_DESCRIP="timerfd"
     TIMERFD_OPTION="timerfd"
     PBX_TIMERFD=0
@@ -10919,8 +10787,6 @@ fi
 
 
 
-
-
 # check for basic system features and functionality before
 # checking for package libraries
 
@@ -18264,10 +18130,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_PTHREAD_RWLOCK_INITIALIZER_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -18584,10 +18446,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -20626,10 +20484,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_GLOB_NOMAGIC_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -20703,10 +20557,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_GLOB_BRACE_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -20780,10 +20630,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_IP_MTU_DISCOVER_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -22578,6 +22424,8 @@ if test "x${PBX_ALSA}" != "x1" -a "${USE_ALSA}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_ALSA_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_asound_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lasound" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lasound... $ECHO_C" >&6; }
@@ -22647,6 +22495,7 @@ else
   AST_ALSA_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -22660,7 +22509,7 @@ fi
       if test "xalsa/asoundlib.h" = "x" ; then	# no header, assume found
          ALSA_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${ALSA_INCLUDE}"
          if test "${ac_cv_header_alsa_asoundlib_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for alsa/asoundlib.h" >&5
@@ -22799,7 +22648,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${ALSA_HEADER_FOUND}" = "x0" ; then
          ALSA_LIB=""
@@ -22811,14 +22660,15 @@ fi
          PBX_ALSA=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_ALSA 1
-#define HAVE_ALSA_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_CURSES}" != "x1" -a "${USE_CURSES}" != "no"; then
    pbxlibdir=""
    # if --with-CURSES=DIR has been specified, use it.
@@ -22833,6 +22683,8 @@ if test "x${PBX_CURSES}" != "x1" -a "${USE_CURSES}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_CURSES_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_curses_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lcurses" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lcurses... $ECHO_C" >&6; }
@@ -22902,6 +22754,7 @@ else
   AST_CURSES_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -22915,7 +22768,7 @@ fi
       if test "xcurses.h" = "x" ; then	# no header, assume found
          CURSES_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${CURSES_INCLUDE}"
          if test "${ac_cv_header_curses_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for curses.h" >&5
@@ -23054,7 +22907,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${CURSES_HEADER_FOUND}" = "x0" ; then
          CURSES_LIB=""
@@ -23066,13 +22919,14 @@ fi
          PBX_CURSES=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_CURSES 1
-#define HAVE_CURSES_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${OSARCH}" = "xlinux-gnu" ; then
 
 if test "x${PBX_CAP}" != "x1" -a "${USE_CAP}" != "no"; then
@@ -23089,6 +22943,8 @@ if test "x${PBX_CAP}" != "x1" -a "${USE_CAP}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_CAP_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_cap_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lcap" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lcap... $ECHO_C" >&6; }
@@ -23158,6 +23014,7 @@ else
   AST_CAP_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -23171,7 +23028,7 @@ fi
       if test "xsys/capability.h" = "x" ; then	# no header, assume found
          CAP_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${CAP_INCLUDE}"
          if test "${ac_cv_header_sys_capability_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sys/capability.h" >&5
@@ -23310,7 +23167,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${CAP_HEADER_FOUND}" = "x0" ; then
          CAP_LIB=""
@@ -23322,12 +23179,13 @@ fi
          PBX_CAP=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_CAP 1
-#define HAVE_CAP_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 fi
 
 
@@ -23387,10 +23245,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_DAHDI_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -23464,10 +23318,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_DAHDI_HALF_FULL_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -23541,10 +23391,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_DAHDI_LINEREVERSE_VMWI_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -23617,10 +23463,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_DAHDI_ECHOCANCEL_FAX_MODE_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -23693,10 +23535,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_GETIFADDRS_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -23768,10 +23606,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_TIMERFD_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -24501,6 +24335,8 @@ if test "x${PBX_ICONV}" != "x1" -a "${USE_ICONV}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_ICONV_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_iconv_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -liconv" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -liconv... $ECHO_C" >&6; }
@@ -24570,6 +24406,7 @@ else
   AST_ICONV_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -24583,7 +24420,7 @@ fi
       if test "xiconv.h" = "x" ; then	# no header, assume found
          ICONV_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${ICONV_INCLUDE}"
          if test "${ac_cv_header_iconv_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for iconv.h" >&5
@@ -24722,7 +24559,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${ICONV_HEADER_FOUND}" = "x0" ; then
          ICONV_LIB=""
@@ -24734,12 +24571,13 @@ fi
          PBX_ICONV=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_ICONV 1
-#define HAVE_ICONV_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 # Some versions of Linux package iconv in glibc
 
 if test "x${PBX_ICONV}" != "x1" -a "${USE_ICONV}" != "no"; then
@@ -24756,6 +24594,8 @@ if test "x${PBX_ICONV}" != "x1" -a "${USE_ICONV}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_ICONV_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_c_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lc" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lc... $ECHO_C" >&6; }
@@ -24825,6 +24665,7 @@ else
   AST_ICONV_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -24838,7 +24679,7 @@ fi
       if test "xiconv.h" = "x" ; then	# no header, assume found
          ICONV_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${ICONV_INCLUDE}"
          if test "${ac_cv_header_iconv_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for iconv.h" >&5
@@ -24977,7 +24818,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${ICONV_HEADER_FOUND}" = "x0" ; then
          ICONV_LIB=""
@@ -24989,14 +24830,15 @@ fi
          PBX_ICONV=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_ICONV 1
-#define HAVE_ICONV_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_ICAL}" != "x1" -a "${USE_ICAL}" != "no"; then
    pbxlibdir=""
    # if --with-ICAL=DIR has been specified, use it.
@@ -25011,6 +24853,8 @@ if test "x${PBX_ICAL}" != "x1" -a "${USE_ICAL}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_ICAL_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
       as_ac_Lib=`echo "ac_cv_lib_ical_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lical" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lical... $ECHO_C" >&6; }
@@ -25080,6 +24924,7 @@ else
   AST_ICAL_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -25093,7 +24938,7 @@ fi
       if test "xical.h" = "x" ; then	# no header, assume found
          ICAL_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${ICAL_INCLUDE}"
          if test "${ac_cv_header_ical_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for ical.h" >&5
@@ -25232,7 +25077,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${ICAL_HEADER_FOUND}" = "x0" ; then
          ICAL_LIB=""
@@ -25244,13 +25089,14 @@ fi
          PBX_ICAL=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_ICAL 1
-#define HAVE_ICAL_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # Some distributions (like RedHat) add a libical subdirectory for the headers
 
 if test "x${PBX_ICAL}" != "x1" -a "${USE_ICAL}" != "no"; then
@@ -25267,6 +25113,8 @@ if test "x${PBX_ICAL}" != "x1" -a "${USE_ICAL}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_ICAL_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
       as_ac_Lib=`echo "ac_cv_lib_ical_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lical" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lical... $ECHO_C" >&6; }
@@ -25336,6 +25184,7 @@ else
   AST_ICAL_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -25349,7 +25198,7 @@ fi
       if test "xlibical/ical.h" = "x" ; then	# no header, assume found
          ICAL_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${ICAL_INCLUDE}"
          if test "${ac_cv_header_libical_ical_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libical/ical.h" >&5
@@ -25488,7 +25337,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${ICAL_HEADER_FOUND}" = "x0" ; then
          ICAL_LIB=""
@@ -25500,14 +25349,15 @@ fi
          PBX_ICAL=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_ICAL 1
-#define HAVE_ICAL_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_IKSEMEL}" != "x1" -a "${USE_IKSEMEL}" != "no"; then
    pbxlibdir=""
    # if --with-IKSEMEL=DIR has been specified, use it.
@@ -25522,6 +25372,8 @@ if test "x${PBX_IKSEMEL}" != "x1" -a "${USE_IKSEMEL}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_IKSEMEL_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_iksemel_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -liksemel" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -liksemel... $ECHO_C" >&6; }
@@ -25591,6 +25443,7 @@ else
   AST_IKSEMEL_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -25604,7 +25457,7 @@ fi
       if test "xiksemel.h" = "x" ; then	# no header, assume found
          IKSEMEL_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${IKSEMEL_INCLUDE}"
          if test "${ac_cv_header_iksemel_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for iksemel.h" >&5
@@ -25743,7 +25596,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${IKSEMEL_HEADER_FOUND}" = "x0" ; then
          IKSEMEL_LIB=""
@@ -25755,13 +25608,14 @@ fi
          PBX_IKSEMEL=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_IKSEMEL 1
-#define HAVE_IKSEMEL_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "${USE_IMAP_TK}" != "no"; then
 	saved_cppflags="${CPPFLAGS}"
 	saved_libs="${LIBS}"
@@ -26609,6 +26463,8 @@ if test "x${PBX_IODBC}" != "x1" -a "${USE_IODBC}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_IODBC_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
       as_ac_Lib=`echo "ac_cv_lib_iodbc_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -liodbc" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -liodbc... $ECHO_C" >&6; }
@@ -26678,6 +26534,7 @@ else
   AST_IODBC_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -26691,7 +26548,7 @@ fi
       if test "xsql.h" = "x" ; then	# no header, assume found
          IODBC_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${IODBC_INCLUDE}"
          if test "${ac_cv_header_sql_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sql.h" >&5
@@ -26830,7 +26687,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${IODBC_HEADER_FOUND}" = "x0" ; then
          IODBC_LIB=""
@@ -26842,14 +26699,15 @@ fi
          PBX_IODBC=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_IODBC 1
-#define HAVE_IODBC_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_INOTIFY}" != "x1" -a "${USE_INOTIFY}" != "no"; then
    pbxlibdir=""
    # if --with-INOTIFY=DIR has been specified, use it.
@@ -26864,6 +26722,8 @@ if test "x${PBX_INOTIFY}" != "x1" -a "${USE_INOTIFY}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_INOTIFY_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_c_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lc" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lc... $ECHO_C" >&6; }
@@ -26933,6 +26793,7 @@ else
   AST_INOTIFY_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -26946,7 +26807,7 @@ fi
       if test "xsys/inotify.h" = "x" ; then	# no header, assume found
          INOTIFY_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${INOTIFY_INCLUDE}"
          if test "${ac_cv_header_sys_inotify_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sys/inotify.h" >&5
@@ -27085,7 +26946,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${INOTIFY_HEADER_FOUND}" = "x0" ; then
          INOTIFY_LIB=""
@@ -27097,14 +26958,15 @@ fi
          PBX_INOTIFY=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_INOTIFY 1
-#define HAVE_INOTIFY_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_JACK}" != "x1" -a "${USE_JACK}" != "no"; then
    pbxlibdir=""
    # if --with-JACK=DIR has been specified, use it.
@@ -27119,6 +26981,8 @@ if test "x${PBX_JACK}" != "x1" -a "${USE_JACK}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_JACK_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_jack_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -ljack" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -ljack... $ECHO_C" >&6; }
@@ -27188,6 +27052,7 @@ else
   AST_JACK_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -27201,7 +27066,7 @@ fi
       if test "xjack/jack.h" = "x" ; then	# no header, assume found
          JACK_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${JACK_INCLUDE}"
          if test "${ac_cv_header_jack_jack_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for jack/jack.h" >&5
@@ -27340,7 +27205,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${JACK_HEADER_FOUND}" = "x0" ; then
          JACK_LIB=""
@@ -27352,13 +27217,14 @@ fi
          PBX_JACK=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_JACK 1
-#define HAVE_JACK_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # Needed by unixodbc
 
 if test "x${PBX_LTDL}" != "x1" -a "${USE_LTDL}" != "no"; then
@@ -27375,6 +27241,8 @@ if test "x${PBX_LTDL}" != "x1" -a "${USE_LTDL}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_LTDL_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ltdl_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lltdl" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lltdl... $ECHO_C" >&6; }
@@ -27444,6 +27312,7 @@ else
   AST_LTDL_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -27457,7 +27326,7 @@ fi
       if test "xltdl.h" = "x" ; then	# no header, assume found
          LTDL_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${LTDL_INCLUDE}"
          if test "${ac_cv_header_ltdl_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for ltdl.h" >&5
@@ -27596,7 +27465,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${LTDL_HEADER_FOUND}" = "x0" ; then
          LTDL_LIB=""
@@ -27608,14 +27477,15 @@ fi
          PBX_LTDL=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_LTDL 1
-#define HAVE_LTDL_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_LDAP}" != "x1" -a "${USE_LDAP}" != "no"; then
    pbxlibdir=""
    # if --with-LDAP=DIR has been specified, use it.
@@ -27630,6 +27500,8 @@ if test "x${PBX_LDAP}" != "x1" -a "${USE_LDAP}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_LDAP_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ldap_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lldap" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lldap... $ECHO_C" >&6; }
@@ -27699,6 +27571,7 @@ else
   AST_LDAP_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -27712,7 +27585,7 @@ fi
       if test "xldap.h" = "x" ; then	# no header, assume found
          LDAP_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${LDAP_INCLUDE}"
          if test "${ac_cv_header_ldap_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for ldap.h" >&5
@@ -27851,7 +27724,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${LDAP_HEADER_FOUND}" = "x0" ; then
          LDAP_LIB=""
@@ -27863,13 +27736,14 @@ fi
          PBX_LDAP=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_LDAP 1
-#define HAVE_LDAP_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # Check whether --enable-xmldoc was given.
 if test "${enable_xmldoc+set}" = set; then
   enableval=$enable_xmldoc; case "${enableval}" in
@@ -28091,6 +27965,8 @@ if test "x${PBX_MISDN}" != "x1" -a "${USE_MISDN}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_MISDN_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_mISDN_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lmISDN" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lmISDN... $ECHO_C" >&6; }
@@ -28160,6 +28036,7 @@ else
   AST_MISDN_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -28173,7 +28050,7 @@ fi
       if test "xmISDNuser/mISDNlib.h" = "x" ; then	# no header, assume found
          MISDN_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${MISDN_INCLUDE}"
          if test "${ac_cv_header_mISDNuser_mISDNlib_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for mISDNuser/mISDNlib.h" >&5
@@ -28312,7 +28189,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${MISDN_HEADER_FOUND}" = "x0" ; then
          MISDN_LIB=""
@@ -28324,13 +28201,14 @@ fi
          PBX_MISDN=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_MISDN 1
-#define HAVE_MISDN_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "${PBX_MISDN}" = 1; then
 
 if test "x${PBX_ISDNNET}" != "x1" -a "${USE_ISDNNET}" != "no"; then
@@ -28347,6 +28225,8 @@ if test "x${PBX_ISDNNET}" != "x1" -a "${USE_ISDNNET}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_ISDNNET_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_isdnnet_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lisdnnet" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lisdnnet... $ECHO_C" >&6; }
@@ -28416,6 +28296,7 @@ else
   AST_ISDNNET_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -28429,7 +28310,7 @@ fi
       if test "xmISDNuser/isdn_net.h" = "x" ; then	# no header, assume found
          ISDNNET_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${ISDNNET_INCLUDE}"
          if test "${ac_cv_header_mISDNuser_isdn_net_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for mISDNuser/isdn_net.h" >&5
@@ -28568,7 +28449,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${ISDNNET_HEADER_FOUND}" = "x0" ; then
          ISDNNET_LIB=""
@@ -28580,13 +28461,14 @@ fi
          PBX_ISDNNET=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_ISDNNET 1
-#define HAVE_ISDNNET_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_SUPPSERV}" != "x1" -a "${USE_SUPPSERV}" != "no"; then
    pbxlibdir=""
    # if --with-SUPPSERV=DIR has been specified, use it.
@@ -28601,6 +28483,8 @@ if test "x${PBX_SUPPSERV}" != "x1" -a "${USE_SUPPSERV}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SUPPSERV_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_suppserv_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lsuppserv" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lsuppserv... $ECHO_C" >&6; }
@@ -28670,6 +28554,7 @@ else
   AST_SUPPSERV_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -28683,7 +28568,7 @@ fi
       if test "xmISDNuser/suppserv.h" = "x" ; then	# no header, assume found
          SUPPSERV_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SUPPSERV_INCLUDE}"
          if test "${ac_cv_header_mISDNuser_suppserv_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for mISDNuser/suppserv.h" >&5
@@ -28822,7 +28707,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SUPPSERV_HEADER_FOUND}" = "x0" ; then
          SUPPSERV_LIB=""
@@ -28834,13 +28719,14 @@ fi
          PBX_SUPPSERV=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SUPPSERV 1
-#define HAVE_SUPPSERV_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
     if test "x${PBX_MISDN_FAC_RESULT}" != "x1"; then
 	{ echo "$as_me:$LINENO: checking for Fac_RESULT in mISDNuser/suppserv.h" >&5
 echo $ECHO_N "checking for Fac_RESULT in mISDNuser/suppserv.h... $ECHO_C" >&6; }
@@ -28897,10 +28783,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_MISDN_FAC_RESULT_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -28973,10 +28855,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_MISDN_FAC_ERROR_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -29428,6 +29306,8 @@ if test "x${PBX_NBS}" != "x1" -a "${USE_NBS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_NBS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_nbs_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lnbs" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lnbs... $ECHO_C" >&6; }
@@ -29497,6 +29377,7 @@ else
   AST_NBS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -29510,7 +29391,7 @@ fi
       if test "xnbs.h" = "x" ; then	# no header, assume found
          NBS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${NBS_INCLUDE}"
          if test "${ac_cv_header_nbs_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for nbs.h" >&5
@@ -29649,7 +29530,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${NBS_HEADER_FOUND}" = "x0" ; then
          NBS_LIB=""
@@ -29661,14 +29542,15 @@ fi
          PBX_NBS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_NBS 1
-#define HAVE_NBS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_NCURSES}" != "x1" -a "${USE_NCURSES}" != "no"; then
    pbxlibdir=""
    # if --with-NCURSES=DIR has been specified, use it.
@@ -29683,6 +29565,8 @@ if test "x${PBX_NCURSES}" != "x1" -a "${USE_NCURSES}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_NCURSES_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ncurses_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lncurses" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lncurses... $ECHO_C" >&6; }
@@ -29752,6 +29636,7 @@ else
   AST_NCURSES_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -29765,7 +29650,7 @@ fi
       if test "xcurses.h" = "x" ; then	# no header, assume found
          NCURSES_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${NCURSES_INCLUDE}"
          if test "${ac_cv_header_curses_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for curses.h" >&5
@@ -29904,7 +29789,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${NCURSES_HEADER_FOUND}" = "x0" ; then
          NCURSES_LIB=""
@@ -29916,14 +29801,15 @@ fi
          PBX_NCURSES=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_NCURSES 1
-#define HAVE_NCURSES_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
     if test "x${PBX_NEON}" != "x1" -a "${USE_NEON}" != "no"; then
 	PBX_NEON=0
 	if test -n "$ac_tool_prefix"; then
@@ -30300,6 +30186,8 @@ if test "x${PBX_NEWT}" != "x1" -a "${USE_NEWT}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_NEWT_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_newt_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lnewt" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lnewt... $ECHO_C" >&6; }
@@ -30369,6 +30257,7 @@ else
   AST_NEWT_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -30382,7 +30271,7 @@ fi
       if test "xnewt.h" = "x" ; then	# no header, assume found
          NEWT_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${NEWT_INCLUDE}"
          if test "${ac_cv_header_newt_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for newt.h" >&5
@@ -30521,7 +30410,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${NEWT_HEADER_FOUND}" = "x0" ; then
          NEWT_LIB=""
@@ -30533,14 +30422,15 @@ fi
          PBX_NEWT=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_NEWT 1
-#define HAVE_NEWT_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_UNIXODBC}" != "x1" -a "${USE_UNIXODBC}" != "no"; then
    pbxlibdir=""
    # if --with-UNIXODBC=DIR has been specified, use it.
@@ -30555,6 +30445,8 @@ if test "x${PBX_UNIXODBC}" != "x1" -a "${USE_UNIXODBC}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_UNIXODBC_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_odbc_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lodbc" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lodbc... $ECHO_C" >&6; }
@@ -30624,6 +30516,7 @@ else
   AST_UNIXODBC_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -30637,7 +30530,7 @@ fi
       if test "xsql.h" = "x" ; then	# no header, assume found
          UNIXODBC_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${UNIXODBC_INCLUDE}"
          if test "${ac_cv_header_sql_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sql.h" >&5
@@ -30776,7 +30669,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${UNIXODBC_HEADER_FOUND}" = "x0" ; then
          UNIXODBC_LIB=""
@@ -30788,14 +30681,15 @@ fi
          PBX_UNIXODBC=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_UNIXODBC 1
-#define HAVE_UNIXODBC_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_OGG}" != "x1" -a "${USE_OGG}" != "no"; then
    pbxlibdir=""
    # if --with-OGG=DIR has been specified, use it.
@@ -30810,6 +30704,8 @@ if test "x${PBX_OGG}" != "x1" -a "${USE_OGG}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_OGG_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ogg_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -logg" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -logg... $ECHO_C" >&6; }
@@ -30879,6 +30775,7 @@ else
   AST_OGG_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -30892,7 +30789,7 @@ fi
       if test "x" = "x" ; then	# no header, assume found
          OGG_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${OGG_INCLUDE}"
          if test "${ac_cv_header_+set}" = set; then
   { echo "$as_me:$LINENO: checking for " >&5
@@ -31031,7 +30928,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${OGG_HEADER_FOUND}" = "x0" ; then
          OGG_LIB=""
@@ -31043,13 +30940,14 @@ fi
          PBX_OGG=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_OGG 1
-#define HAVE_OGG_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # Non-glibc platforms require libexecinfo for backtrace support
 
 if test "x${PBX_BKTR}" != "x1" -a "${USE_BKTR}" != "no"; then
@@ -31066,6 +30964,8 @@ if test "x${PBX_BKTR}" != "x1" -a "${USE_BKTR}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_BKTR_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_execinfo_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lexecinfo" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lexecinfo... $ECHO_C" >&6; }
@@ -31135,6 +31035,7 @@ else
   AST_BKTR_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -31148,7 +31049,7 @@ fi
       if test "xexecinfo.h" = "x" ; then	# no header, assume found
          BKTR_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${BKTR_INCLUDE}"
          if test "${ac_cv_header_execinfo_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for execinfo.h" >&5
@@ -31287,7 +31188,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${BKTR_HEADER_FOUND}" = "x0" ; then
          BKTR_LIB=""
@@ -31299,12 +31200,13 @@ fi
          PBX_BKTR=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_BKTR 1
-#define HAVE_BKTR_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 # Linux, however, has backtrace directly in glibc
 
 if test "x${PBX_BKTR}" != "x1" -a "${USE_BKTR}" != "no"; then
@@ -31321,6 +31223,8 @@ if test "x${PBX_BKTR}" != "x1" -a "${USE_BKTR}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_BKTR_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_c_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lc" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lc... $ECHO_C" >&6; }
@@ -31390,6 +31294,7 @@ else
   AST_BKTR_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -31403,7 +31308,7 @@ fi
       if test "xexecinfo.h" = "x" ; then	# no header, assume found
          BKTR_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${BKTR_INCLUDE}"
          if test "${ac_cv_header_execinfo_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for execinfo.h" >&5
@@ -31542,7 +31447,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${BKTR_HEADER_FOUND}" = "x0" ; then
          BKTR_LIB=""
@@ -31554,14 +31459,15 @@ fi
          PBX_BKTR=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_BKTR 1
-#define HAVE_BKTR_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_BLUETOOTH}" != "x1" -a "${USE_BLUETOOTH}" != "no"; then
    pbxlibdir=""
    # if --with-BLUETOOTH=DIR has been specified, use it.
@@ -31576,6 +31482,8 @@ if test "x${PBX_BLUETOOTH}" != "x1" -a "${USE_BLUETOOTH}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_BLUETOOTH_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_bluetooth_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lbluetooth" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lbluetooth... $ECHO_C" >&6; }
@@ -31645,6 +31553,7 @@ else
   AST_BLUETOOTH_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -31658,7 +31567,7 @@ fi
       if test "xbluetooth/bluetooth.h" = "x" ; then	# no header, assume found
          BLUETOOTH_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${BLUETOOTH_INCLUDE}"
          if test "${ac_cv_header_bluetooth_bluetooth_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for bluetooth/bluetooth.h" >&5
@@ -31797,7 +31706,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${BLUETOOTH_HEADER_FOUND}" = "x0" ; then
          BLUETOOTH_LIB=""
@@ -31809,13 +31718,14 @@ fi
          PBX_BLUETOOTH=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_BLUETOOTH 1
-#define HAVE_BLUETOOTH_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # possible places for oss definitions
 
 if test "x${PBX_OSS}" != "x1" -a "${USE_OSS}" != "no"; then
@@ -31832,6 +31742,8 @@ if test "x${PBX_OSS}" != "x1" -a "${USE_OSS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_OSS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ossaudio_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lossaudio" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lossaudio... $ECHO_C" >&6; }
@@ -31901,6 +31813,7 @@ else
   AST_OSS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -31914,7 +31827,7 @@ fi
       if test "xlinux/soundcard.h" = "x" ; then	# no header, assume found
          OSS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${OSS_INCLUDE}"
          if test "${ac_cv_header_linux_soundcard_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for linux/soundcard.h" >&5
@@ -32053,7 +31966,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${OSS_HEADER_FOUND}" = "x0" ; then
          OSS_LIB=""
@@ -32065,13 +31978,14 @@ fi
          PBX_OSS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_OSS 1
-#define HAVE_OSS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_OSS}" != "x1" -a "${USE_OSS}" != "no"; then
    pbxlibdir=""
    # if --with-OSS=DIR has been specified, use it.
@@ -32086,6 +32000,8 @@ if test "x${PBX_OSS}" != "x1" -a "${USE_OSS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_OSS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ossaudio_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lossaudio" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lossaudio... $ECHO_C" >&6; }
@@ -32155,6 +32071,7 @@ else
   AST_OSS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -32168,7 +32085,7 @@ fi
       if test "xsys/soundcard.h" = "x" ; then	# no header, assume found
          OSS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${OSS_INCLUDE}"
          if test "${ac_cv_header_sys_soundcard_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sys/soundcard.h" >&5
@@ -32307,7 +32224,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${OSS_HEADER_FOUND}" = "x0" ; then
          OSS_LIB=""
@@ -32319,13 +32236,14 @@ fi
          PBX_OSS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_OSS 1
-#define HAVE_OSS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_OSS}" != "x1" -a "${USE_OSS}" != "no"; then
    pbxlibdir=""
    # if --with-OSS=DIR has been specified, use it.
@@ -32340,6 +32258,8 @@ if test "x${PBX_OSS}" != "x1" -a "${USE_OSS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_OSS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ossaudio_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lossaudio" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lossaudio... $ECHO_C" >&6; }
@@ -32409,6 +32329,7 @@ else
   AST_OSS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -32422,7 +32343,7 @@ fi
       if test "xsoundcard.h" = "x" ; then	# no header, assume found
          OSS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${OSS_INCLUDE}"
          if test "${ac_cv_header_soundcard_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for soundcard.h" >&5
@@ -32561,7 +32482,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${OSS_HEADER_FOUND}" = "x0" ; then
          OSS_LIB=""
@@ -32573,13 +32494,14 @@ fi
          PBX_OSS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_OSS 1
-#define HAVE_OSS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 PG_CONFIG=No
 if test "${USE_PGSQL}" != "no"; then
    if test "x${PGSQL_DIR}" != "x"; then
@@ -32923,6 +32845,8 @@ if test "x${PBX_POPT}" != "x1" -a "${USE_POPT}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_POPT_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_popt_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpopt" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpopt... $ECHO_C" >&6; }
@@ -32992,6 +32916,7 @@ else
   AST_POPT_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -33005,7 +32930,7 @@ fi
       if test "xpopt.h" = "x" ; then	# no header, assume found
          POPT_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${POPT_INCLUDE}"
          if test "${ac_cv_header_popt_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for popt.h" >&5
@@ -33144,7 +33069,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${POPT_HEADER_FOUND}" = "x0" ; then
          POPT_LIB=""
@@ -33156,14 +33081,15 @@ fi
          PBX_POPT=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_POPT 1
-#define HAVE_POPT_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
    pbxlibdir=""
    # if --with-PORTAUDIO=DIR has been specified, use it.
@@ -33178,6 +33104,8 @@ if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PORTAUDIO_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_portaudio_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lportaudio" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lportaudio... $ECHO_C" >&6; }
@@ -33247,6 +33175,7 @@ else
   AST_PORTAUDIO_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -33260,7 +33189,7 @@ fi
       if test "xportaudio.h" = "x" ; then	# no header, assume found
          PORTAUDIO_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PORTAUDIO_INCLUDE}"
          if test "${ac_cv_header_portaudio_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for portaudio.h" >&5
@@ -33399,7 +33328,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PORTAUDIO_HEADER_FOUND}" = "x0" ; then
          PORTAUDIO_LIB=""
@@ -33411,14 +33340,15 @@ fi
          PBX_PORTAUDIO=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PORTAUDIO 1
-#define HAVE_PORTAUDIO_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_PRI}" != "x1" -a "${USE_PRI}" != "no"; then
    pbxlibdir=""
    # if --with-PRI=DIR has been specified, use it.
@@ -33433,6 +33363,8 @@ if test "x${PBX_PRI}" != "x1" -a "${USE_PRI}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -33502,6 +33434,7 @@ else
   AST_PRI_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -33515,7 +33448,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -33654,7 +33587,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_HEADER_FOUND}" = "x0" ; then
          PRI_LIB=""
@@ -33666,13 +33599,14 @@ fi
          PBX_PRI=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI 1
-#define HAVE_PRI_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_CCSS}" != "x1" -a "${USE_PRI_CCSS}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_CCSS=DIR has been specified, use it.
@@ -33687,6 +33621,8 @@ if test "x${PBX_PRI_CCSS}" != "x1" -a "${USE_PRI_CCSS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_CCSS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -33756,6 +33692,7 @@ else
   AST_PRI_CCSS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -33769,7 +33706,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_CCSS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_CCSS_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -33908,7 +33845,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_CCSS_HEADER_FOUND}" = "x0" ; then
          PRI_CCSS_LIB=""
@@ -33920,13 +33857,14 @@ fi
          PBX_PRI_CCSS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_CCSS 1
-#define HAVE_PRI_CCSS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_SUBADDR}" != "x1" -a "${USE_PRI_SUBADDR}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_SUBADDR=DIR has been specified, use it.
@@ -33941,6 +33879,8 @@ if test "x${PBX_PRI_SUBADDR}" != "x1" -a "${USE_PRI_SUBADDR}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_SUBADDR_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -34010,6 +33950,7 @@ else
   AST_PRI_SUBADDR_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -34023,7 +33964,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_SUBADDR_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_SUBADDR_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -34162,7 +34103,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_SUBADDR_HEADER_FOUND}" = "x0" ; then
          PRI_SUBADDR_LIB=""
@@ -34174,13 +34115,14 @@ fi
          PBX_PRI_SUBADDR=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_SUBADDR 1
-#define HAVE_PRI_SUBADDR_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_CALL_HOLD}" != "x1" -a "${USE_PRI_CALL_HOLD}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_CALL_HOLD=DIR has been specified, use it.
@@ -34195,6 +34137,8 @@ if test "x${PBX_PRI_CALL_HOLD}" != "x1" -a "${USE_PRI_CALL_HOLD}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_CALL_HOLD_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -34264,6 +34208,7 @@ else
   AST_PRI_CALL_HOLD_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -34277,7 +34222,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_CALL_HOLD_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_CALL_HOLD_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -34416,7 +34361,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_CALL_HOLD_HEADER_FOUND}" = "x0" ; then
          PRI_CALL_HOLD_LIB=""
@@ -34428,13 +34373,14 @@ fi
          PBX_PRI_CALL_HOLD=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_CALL_HOLD 1
-#define HAVE_PRI_CALL_HOLD_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_CALL_REROUTING}" != "x1" -a "${USE_PRI_CALL_REROUTING}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_CALL_REROUTING=DIR has been specified, use it.
@@ -34449,6 +34395,8 @@ if test "x${PBX_PRI_CALL_REROUTING}" != "x1" -a "${USE_PRI_CALL_REROUTING}" != "
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_CALL_REROUTING_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -34518,6 +34466,7 @@ else
   AST_PRI_CALL_REROUTING_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -34531,7 +34480,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_CALL_REROUTING_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_CALL_REROUTING_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -34670,7 +34619,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_CALL_REROUTING_HEADER_FOUND}" = "x0" ; then
          PRI_CALL_REROUTING_LIB=""
@@ -34682,13 +34631,14 @@ fi
          PBX_PRI_CALL_REROUTING=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_CALL_REROUTING 1
-#define HAVE_PRI_CALL_REROUTING_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_SETUP_KEYPAD}" != "x1" -a "${USE_PRI_SETUP_KEYPAD}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_SETUP_KEYPAD=DIR has been specified, use it.
@@ -34703,6 +34653,8 @@ if test "x${PBX_PRI_SETUP_KEYPAD}" != "x1" -a "${USE_PRI_SETUP_KEYPAD}" != "no";
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_SETUP_KEYPAD_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -34772,6 +34724,7 @@ else
   AST_PRI_SETUP_KEYPAD_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -34785,7 +34738,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_SETUP_KEYPAD_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_SETUP_KEYPAD_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -34924,7 +34877,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_SETUP_KEYPAD_HEADER_FOUND}" = "x0" ; then
          PRI_SETUP_KEYPAD_LIB=""
@@ -34936,13 +34889,14 @@ fi
          PBX_PRI_SETUP_KEYPAD=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_SETUP_KEYPAD 1
-#define HAVE_PRI_SETUP_KEYPAD_VERSION
 _ACEOF
+
       fi
    fi
 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.
@@ -34961,6 +34915,8 @@ if test "x${PBX_PRI_PROG_W_CAUSE}" != "x1" -a "${USE_PRI_PROG_W_CAUSE}" != "no";
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_PROG_W_CAUSE_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -35030,6 +34986,7 @@ else
   AST_PRI_PROG_W_CAUSE_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -35043,7 +35000,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_PROG_W_CAUSE_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_PROG_W_CAUSE_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -35182,7 +35139,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_PROG_W_CAUSE_HEADER_FOUND}" = "x0" ; then
          PRI_PROG_W_CAUSE_LIB=""
@@ -35194,13 +35151,14 @@ fi
          PBX_PRI_PROG_W_CAUSE=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_PROG_W_CAUSE 1
-#define HAVE_PRI_PROG_W_CAUSE_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_INBANDDISCONNECT}" != "x1" -a "${USE_PRI_INBANDDISCONNECT}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_INBANDDISCONNECT=DIR has been specified, use it.
@@ -35215,6 +35173,8 @@ if test "x${PBX_PRI_INBANDDISCONNECT}" != "x1" -a "${USE_PRI_INBANDDISCONNECT}"
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_INBANDDISCONNECT_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -35284,6 +35244,7 @@ else
   AST_PRI_INBANDDISCONNECT_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -35297,7 +35258,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_INBANDDISCONNECT_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_INBANDDISCONNECT_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -35436,7 +35397,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_INBANDDISCONNECT_HEADER_FOUND}" = "x0" ; then
          PRI_INBANDDISCONNECT_LIB=""
@@ -35448,13 +35409,14 @@ fi
          PBX_PRI_INBANDDISCONNECT=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_INBANDDISCONNECT 1
-#define HAVE_PRI_INBANDDISCONNECT_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_SERVICE_MESSAGES}" != "x1" -a "${USE_PRI_SERVICE_MESSAGES}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_SERVICE_MESSAGES=DIR has been specified, use it.
@@ -35469,6 +35431,8 @@ if test "x${PBX_PRI_SERVICE_MESSAGES}" != "x1" -a "${USE_PRI_SERVICE_MESSAGES}"
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_SERVICE_MESSAGES_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -35538,6 +35502,7 @@ else
   AST_PRI_SERVICE_MESSAGES_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -35551,7 +35516,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_SERVICE_MESSAGES_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_SERVICE_MESSAGES_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -35690,7 +35655,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_SERVICE_MESSAGES_HEADER_FOUND}" = "x0" ; then
          PRI_SERVICE_MESSAGES_LIB=""
@@ -35702,13 +35667,14 @@ fi
          PBX_PRI_SERVICE_MESSAGES=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_SERVICE_MESSAGES 1
-#define HAVE_PRI_SERVICE_MESSAGES_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_PRI_REVERSE_CHARGE}" != "x1" -a "${USE_PRI_REVERSE_CHARGE}" != "no"; then
    pbxlibdir=""
    # if --with-PRI_REVERSE_CHARGE=DIR has been specified, use it.
@@ -35723,6 +35689,8 @@ if test "x${PBX_PRI_REVERSE_CHARGE}" != "x1" -a "${USE_PRI_REVERSE_CHARGE}" != "
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_PRI_REVERSE_CHARGE_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_pri_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lpri" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lpri... $ECHO_C" >&6; }
@@ -35792,6 +35760,7 @@ else
   AST_PRI_REVERSE_CHARGE_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -35805,7 +35774,7 @@ fi
       if test "xlibpri.h" = "x" ; then	# no header, assume found
          PRI_REVERSE_CHARGE_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${PRI_REVERSE_CHARGE_INCLUDE}"
          if test "${ac_cv_header_libpri_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libpri.h" >&5
@@ -35944,7 +35913,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${PRI_REVERSE_CHARGE_HEADER_FOUND}" = "x0" ; then
          PRI_REVERSE_CHARGE_LIB=""
@@ -35956,12 +35925,13 @@ fi
          PBX_PRI_REVERSE_CHARGE=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_PRI_REVERSE_CHARGE 1
-#define HAVE_PRI_REVERSE_CHARGE_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 # ------------------------------------^
 
 
@@ -35979,6 +35949,8 @@ if test "x${PBX_RESAMPLE}" != "x1" -a "${USE_RESAMPLE}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_RESAMPLE_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_resample_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lresample" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lresample... $ECHO_C" >&6; }
@@ -36048,6 +36020,7 @@ else
   AST_RESAMPLE_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -36061,7 +36034,7 @@ fi
       if test "xlibresample.h" = "x" ; then	# no header, assume found
          RESAMPLE_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${RESAMPLE_INCLUDE}"
          if test "${ac_cv_header_libresample_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libresample.h" >&5
@@ -36200,7 +36173,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${RESAMPLE_HEADER_FOUND}" = "x0" ; then
          RESAMPLE_LIB=""
@@ -36212,14 +36185,15 @@ fi
          PBX_RESAMPLE=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_RESAMPLE 1
-#define HAVE_RESAMPLE_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
     if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
         if test "xminimum version of SpanDSP" != "x"; then
             { echo "$as_me:$LINENO: checking for minimum version of SpanDSP" >&5
@@ -36288,10 +36262,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SPANDSP_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -36326,6 +36296,8 @@ if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SPANDSP_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_spandsp_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lspandsp" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lspandsp... $ECHO_C" >&6; }
@@ -36395,6 +36367,7 @@ else
   AST_SPANDSP_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -36408,7 +36381,7 @@ fi
       if test "xspandsp.h" = "x" ; then	# no header, assume found
          SPANDSP_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
          if test "${ac_cv_header_spandsp_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for spandsp.h" >&5
@@ -36547,7 +36520,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SPANDSP_HEADER_FOUND}" = "x0" ; then
          SPANDSP_LIB=""
@@ -36559,12 +36532,13 @@ fi
          PBX_SPANDSP=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SPANDSP 1
-#define HAVE_SPANDSP_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 fi
 
 if test "x${PBX_SPANDSP}" = "x1" ; then
@@ -36585,6 +36559,8 @@ if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SPANDSP_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_spandsp_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lspandsp" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lspandsp... $ECHO_C" >&6; }
@@ -36654,6 +36630,7 @@ else
   AST_SPANDSP_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -36667,7 +36644,7 @@ fi
       if test "xspandsp.h" = "x" ; then	# no header, assume found
          SPANDSP_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SPANDSP_INCLUDE}"
          if test "${ac_cv_header_spandsp_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for spandsp.h" >&5
@@ -36806,7 +36783,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SPANDSP_HEADER_FOUND}" = "x0" ; then
          SPANDSP_LIB=""
@@ -36818,12 +36795,13 @@ fi
          PBX_SPANDSP=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SPANDSP 1
-#define HAVE_SPANDSP_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 fi
 
 
@@ -36841,6 +36819,8 @@ if test "x${PBX_SS7}" != "x1" -a "${USE_SS7}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SS7_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ss7_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lss7" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lss7... $ECHO_C" >&6; }
@@ -36910,6 +36890,7 @@ else
   AST_SS7_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -36923,7 +36904,7 @@ fi
       if test "xlibss7.h" = "x" ; then	# no header, assume found
          SS7_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SS7_INCLUDE}"
          if test "${ac_cv_header_libss7_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for libss7.h" >&5
@@ -37062,7 +37043,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SS7_HEADER_FOUND}" = "x0" ; then
          SS7_LIB=""
@@ -37074,14 +37055,15 @@ fi
          PBX_SS7=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SS7 1
-#define HAVE_SS7_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_OPENR2}" != "x1" -a "${USE_OPENR2}" != "no"; then
    pbxlibdir=""
    # if --with-OPENR2=DIR has been specified, use it.
@@ -37096,6 +37078,8 @@ if test "x${PBX_OPENR2}" != "x1" -a "${USE_OPENR2}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_OPENR2_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_openr2_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lopenr2" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lopenr2... $ECHO_C" >&6; }
@@ -37165,6 +37149,7 @@ else
   AST_OPENR2_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -37178,7 +37163,7 @@ fi
       if test "xopenr2.h" = "x" ; then	# no header, assume found
          OPENR2_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${OPENR2_INCLUDE}"
          if test "${ac_cv_header_openr2_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for openr2.h" >&5
@@ -37317,7 +37302,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${OPENR2_HEADER_FOUND}" = "x0" ; then
          OPENR2_LIB=""
@@ -37329,13 +37314,14 @@ fi
          PBX_OPENR2=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_OPENR2 1
-#define HAVE_OPENR2_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "${USE_PWLIB}" != "no"; then
 	if test -n "${PWLIB_DIR}"; then
 		PWLIBDIR="${PWLIB_DIR}"
@@ -39206,6 +39192,8 @@ if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_LUA_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_lua5.1_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -llua5.1" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -llua5.1... $ECHO_C" >&6; }
@@ -39275,6 +39263,7 @@ else
   AST_LUA_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -39288,7 +39277,7 @@ fi
       if test "xlua5.1/lua.h" = "x" ; then	# no header, assume found
          LUA_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}"
          if test "${ac_cv_header_lua5_1_lua_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for lua5.1/lua.h" >&5
@@ -39427,7 +39416,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${LUA_HEADER_FOUND}" = "x0" ; then
          LUA_LIB=""
@@ -39439,12 +39428,13 @@ fi
          PBX_LUA=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_LUA 1
-#define HAVE_LUA_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 if test "x${PBX_LUA}" = "x1" ; then
 
 cat >>confdefs.h <<_ACEOF
@@ -39469,6 +39459,8 @@ if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_LUA_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_lua_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -llua" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -llua... $ECHO_C" >&6; }
@@ -39538,6 +39530,7 @@ else
   AST_LUA_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -39551,7 +39544,7 @@ fi
       if test "xlua.h" = "x" ; then	# no header, assume found
          LUA_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}"
          if test "${ac_cv_header_lua_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for lua.h" >&5
@@ -39690,7 +39683,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${LUA_HEADER_FOUND}" = "x0" ; then
          LUA_LIB=""
@@ -39702,14 +39695,15 @@ fi
          PBX_LUA=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_LUA 1
-#define HAVE_LUA_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
    pbxlibdir=""
    # if --with-RADIUS=DIR has been specified, use it.
@@ -39724,6 +39718,8 @@ if test "x${PBX_RADIUS}" != "x1" -a "${USE_RADIUS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_RADIUS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_radiusclient-ng_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lradiusclient-ng" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lradiusclient-ng... $ECHO_C" >&6; }
@@ -39793,6 +39789,7 @@ else
   AST_RADIUS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -39806,7 +39803,7 @@ fi
       if test "xradiusclient-ng.h" = "x" ; then	# no header, assume found
          RADIUS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${RADIUS_INCLUDE}"
          if test "${ac_cv_header_radiusclient_ng_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for radiusclient-ng.h" >&5
@@ -39945,7 +39942,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${RADIUS_HEADER_FOUND}" = "x0" ; then
          RADIUS_LIB=""
@@ -39957,13 +39954,14 @@ fi
          PBX_RADIUS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_RADIUS 1
-#define HAVE_RADIUS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # This is a bit complex... in reality, Asterisk's AIS support is dependent on finding
 # *any* implementation of AIS, not just OpenAIS. However, the configure script needs
 # to know the specifics of each possible implementation, and then represent the one
@@ -39988,6 +39986,8 @@ if test "x${PBX_OPENAIS}" != "x1" -a "${USE_OPENAIS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_OPENAIS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_SaClm_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lSaClm" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lSaClm... $ECHO_C" >&6; }
@@ -40057,6 +40057,7 @@ else
   AST_OPENAIS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -40070,7 +40071,7 @@ fi
       if test "xopenais/saClm.h" = "x" ; then	# no header, assume found
          OPENAIS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${OPENAIS_INCLUDE}"
          if test "${ac_cv_header_openais_saClm_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for openais/saClm.h" >&5
@@ -40209,7 +40210,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${OPENAIS_HEADER_FOUND}" = "x0" ; then
          OPENAIS_LIB=""
@@ -40221,13 +40222,14 @@ fi
          PBX_OPENAIS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_OPENAIS 1
-#define HAVE_OPENAIS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "${PBX_OPENAIS}" = 1; then
    PBX_AIS=1
    if test -n "${OPENAIS_DIR}"; then
@@ -40258,6 +40260,8 @@ if test "x${PBX_SPEEX}" != "x1" -a "${USE_SPEEX}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SPEEX_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_speex_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lspeex" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lspeex... $ECHO_C" >&6; }
@@ -40327,6 +40331,7 @@ else
   AST_SPEEX_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -40340,7 +40345,7 @@ fi
       if test "xspeex/speex.h" = "x" ; then	# no header, assume found
          SPEEX_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SPEEX_INCLUDE}"
          if test "${ac_cv_header_speex_speex_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for speex/speex.h" >&5
@@ -40479,7 +40484,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SPEEX_HEADER_FOUND}" = "x0" ; then
          SPEEX_LIB=""
@@ -40491,13 +40496,14 @@ fi
          PBX_SPEEX=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SPEEX 1
-#define HAVE_SPEEX_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # See if the main speex library contains the preprocess functions
 
 if test "x${PBX_SPEEX_PREPROCESS}" != "x1" -a "${USE_SPEEX_PREPROCESS}" != "no"; then
@@ -40514,6 +40520,8 @@ if test "x${PBX_SPEEX_PREPROCESS}" != "x1" -a "${USE_SPEEX_PREPROCESS}" != "no";
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SPEEX_PREPROCESS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_speex_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lspeex" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lspeex... $ECHO_C" >&6; }
@@ -40583,6 +40591,7 @@ else
   AST_SPEEX_PREPROCESS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -40596,7 +40605,7 @@ fi
       if test "xspeex/speex.h" = "x" ; then	# no header, assume found
          SPEEX_PREPROCESS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SPEEX_PREPROCESS_INCLUDE}"
          if test "${ac_cv_header_speex_speex_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for speex/speex.h" >&5
@@ -40735,7 +40744,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SPEEX_PREPROCESS_HEADER_FOUND}" = "x0" ; then
          SPEEX_PREPROCESS_LIB=""
@@ -40747,12 +40756,13 @@ fi
          PBX_SPEEX_PREPROCESS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SPEEX_PREPROCESS 1
-#define HAVE_SPEEX_PREPROCESS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 if test "${PBX_SPEEX_PREPROCESS}" = 1; then
    PBX_SPEEX_PREPROCESS=1
 fi
@@ -40772,6 +40782,8 @@ if test "x${PBX_SPEEXDSP}" != "x1" -a "${USE_SPEEXDSP}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SPEEXDSP_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_speexdsp_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lspeexdsp" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lspeexdsp... $ECHO_C" >&6; }
@@ -40841,6 +40853,7 @@ else
   AST_SPEEXDSP_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -40854,7 +40867,7 @@ fi
       if test "xspeex/speex.h" = "x" ; then	# no header, assume found
          SPEEXDSP_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SPEEXDSP_INCLUDE}"
          if test "${ac_cv_header_speex_speex_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for speex/speex.h" >&5
@@ -40993,7 +41006,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SPEEXDSP_HEADER_FOUND}" = "x0" ; then
          SPEEXDSP_LIB=""
@@ -41005,12 +41018,13 @@ fi
          PBX_SPEEXDSP=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SPEEXDSP 1
-#define HAVE_SPEEXDSP_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 if test "${PBX_SPEEXDSP}" = 1; then
    PBX_SPEEX_PREPROCESS=1
 fi
@@ -41032,6 +41046,8 @@ if test "x${PBX_SQLITE}" != "x1" -a "${USE_SQLITE}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SQLITE_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_sqlite_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lsqlite" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lsqlite... $ECHO_C" >&6; }
@@ -41101,6 +41117,7 @@ else
   AST_SQLITE_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -41114,7 +41131,7 @@ fi
       if test "xsqlite.h" = "x" ; then	# no header, assume found
          SQLITE_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SQLITE_INCLUDE}"
          if test "${ac_cv_header_sqlite_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sqlite.h" >&5
@@ -41253,7 +41270,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SQLITE_HEADER_FOUND}" = "x0" ; then
          SQLITE_LIB=""
@@ -41265,14 +41282,15 @@ fi
          PBX_SQLITE=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SQLITE 1
-#define HAVE_SQLITE_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_SQLITE3}" != "x1" -a "${USE_SQLITE3}" != "no"; then
    pbxlibdir=""
    # if --with-SQLITE3=DIR has been specified, use it.
@@ -41287,6 +41305,8 @@ if test "x${PBX_SQLITE3}" != "x1" -a "${USE_SQLITE3}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SQLITE3_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_sqlite3_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lsqlite3" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lsqlite3... $ECHO_C" >&6; }
@@ -41356,6 +41376,7 @@ else
   AST_SQLITE3_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -41369,7 +41390,7 @@ fi
       if test "xsqlite3.h" = "x" ; then	# no header, assume found
          SQLITE3_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SQLITE3_INCLUDE}"
          if test "${ac_cv_header_sqlite3_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sqlite3.h" >&5
@@ -41508,7 +41529,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SQLITE3_HEADER_FOUND}" = "x0" ; then
          SQLITE3_LIB=""
@@ -41520,14 +41541,15 @@ fi
          PBX_SQLITE3=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SQLITE3 1
-#define HAVE_SQLITE3_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_CRYPTO}" != "x1" -a "${USE_CRYPTO}" != "no"; then
    pbxlibdir=""
    # if --with-CRYPTO=DIR has been specified, use it.
@@ -41542,6 +41564,8 @@ if test "x${PBX_CRYPTO}" != "x1" -a "${USE_CRYPTO}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_CRYPTO_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_crypto_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lcrypto" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lcrypto... $ECHO_C" >&6; }
@@ -41611,6 +41635,7 @@ else
   AST_CRYPTO_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -41624,7 +41649,7 @@ fi
       if test "xopenssl/aes.h" = "x" ; then	# no header, assume found
          CRYPTO_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${CRYPTO_INCLUDE}"
          if test "${ac_cv_header_openssl_aes_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for openssl/aes.h" >&5
@@ -41763,7 +41788,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${CRYPTO_HEADER_FOUND}" = "x0" ; then
          CRYPTO_LIB=""
@@ -41775,13 +41800,14 @@ fi
          PBX_CRYPTO=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_CRYPTO 1
-#define HAVE_CRYPTO_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "$PBX_CRYPTO" = "1";
 then
 
@@ -41799,6 +41825,8 @@ if test "x${PBX_OPENSSL}" != "x1" -a "${USE_OPENSSL}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_OPENSSL_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_ssl_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lssl" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lssl... $ECHO_C" >&6; }
@@ -41868,6 +41896,7 @@ else
   AST_OPENSSL_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -41881,7 +41910,7 @@ fi
       if test "xopenssl/ssl.h" = "x" ; then	# no header, assume found
          OPENSSL_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${OPENSSL_INCLUDE}"
          if test "${ac_cv_header_openssl_ssl_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for openssl/ssl.h" >&5
@@ -42020,7 +42049,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${OPENSSL_HEADER_FOUND}" = "x0" ; then
          OPENSSL_LIB=""
@@ -42032,12 +42061,13 @@ fi
          PBX_OPENSSL=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_OPENSSL 1
-#define HAVE_OPENSSL_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 fi
 
 if test "$PBX_OPENSSL" = "1";
@@ -42548,6 +42578,8 @@ if test "x${PBX_HOARD}" != "x1" -a "${USE_HOARD}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_HOARD_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_hoard_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lhoard" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lhoard... $ECHO_C" >&6; }
@@ -42617,6 +42649,7 @@ else
   AST_HOARD_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -42630,7 +42663,7 @@ fi
       if test "x" = "x" ; then	# no header, assume found
          HOARD_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${HOARD_INCLUDE}"
          if test "${ac_cv_header_+set}" = set; then
   { echo "$as_me:$LINENO: checking for " >&5
@@ -42769,7 +42802,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${HOARD_HEADER_FOUND}" = "x0" ; then
          HOARD_LIB=""
@@ -42781,14 +42814,15 @@ fi
          PBX_HOARD=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_HOARD 1
-#define HAVE_HOARD_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_FREETDS}" != "x1" -a "${USE_FREETDS}" != "no"; then
    pbxlibdir=""
    # if --with-FREETDS=DIR has been specified, use it.
@@ -42803,6 +42837,8 @@ if test "x${PBX_FREETDS}" != "x1" -a "${USE_FREETDS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_FREETDS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_sybdb_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lsybdb" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lsybdb... $ECHO_C" >&6; }
@@ -42872,6 +42908,7 @@ else
   AST_FREETDS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -42885,7 +42922,7 @@ fi
       if test "xsybdb.h" = "x" ; then	# no header, assume found
          FREETDS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${FREETDS_INCLUDE}"
          if test "${ac_cv_header_sybdb_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for sybdb.h" >&5
@@ -43024,7 +43061,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${FREETDS_HEADER_FOUND}" = "x0" ; then
          FREETDS_LIB=""
@@ -43036,14 +43073,15 @@ fi
          PBX_FREETDS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_FREETDS 1
-#define HAVE_FREETDS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_TERMCAP}" != "x1" -a "${USE_TERMCAP}" != "no"; then
    pbxlibdir=""
    # if --with-TERMCAP=DIR has been specified, use it.
@@ -43058,6 +43096,8 @@ if test "x${PBX_TERMCAP}" != "x1" -a "${USE_TERMCAP}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_TERMCAP_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_termcap_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -ltermcap" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -ltermcap... $ECHO_C" >&6; }
@@ -43127,6 +43167,7 @@ else
   AST_TERMCAP_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -43140,7 +43181,7 @@ fi
       if test "x" = "x" ; then	# no header, assume found
          TERMCAP_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${TERMCAP_INCLUDE}"
          if test "${ac_cv_header_+set}" = set; then
   { echo "$as_me:$LINENO: checking for " >&5
@@ -43279,7 +43320,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${TERMCAP_HEADER_FOUND}" = "x0" ; then
          TERMCAP_LIB=""
@@ -43291,14 +43332,15 @@ fi
          PBX_TERMCAP=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_TERMCAP 1
-#define HAVE_TERMCAP_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_TINFO}" != "x1" -a "${USE_TINFO}" != "no"; then
    pbxlibdir=""
    # if --with-TINFO=DIR has been specified, use it.
@@ -43313,6 +43355,8 @@ if test "x${PBX_TINFO}" != "x1" -a "${USE_TINFO}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_TINFO_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_tinfo_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -ltinfo" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -ltinfo... $ECHO_C" >&6; }
@@ -43382,6 +43426,7 @@ else
   AST_TINFO_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -43395,7 +43440,7 @@ fi
       if test "x" = "x" ; then	# no header, assume found
          TINFO_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${TINFO_INCLUDE}"
          if test "${ac_cv_header_+set}" = set; then
   { echo "$as_me:$LINENO: checking for " >&5
@@ -43534,7 +43579,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${TINFO_HEADER_FOUND}" = "x0" ; then
          TINFO_LIB=""
@@ -43546,13 +43591,14 @@ fi
          PBX_TINFO=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_TINFO 1
-#define HAVE_TINFO_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 { echo "$as_me:$LINENO: checking for tone_zone_find_by_num in -ltonezone" >&5
 echo $ECHO_N "checking for tone_zone_find_by_num in -ltonezone... $ECHO_C" >&6; }
 if test "${ac_cv_lib_tonezone_tone_zone_find_by_num+set}" = set; then
@@ -43640,6 +43686,8 @@ if test "x${PBX_TONEZONE}" != "x1" -a "${USE_TONEZONE}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_TONEZONE_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_tonezone_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -ltonezone" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -ltonezone... $ECHO_C" >&6; }
@@ -43709,6 +43757,7 @@ else
   AST_TONEZONE_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -43722,7 +43771,7 @@ fi
       if test "xdahdi/tonezone.h" = "x" ; then	# no header, assume found
          TONEZONE_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${TONEZONE_INCLUDE}"
          if test "${ac_cv_header_dahdi_tonezone_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for dahdi/tonezone.h" >&5
@@ -43861,7 +43910,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${TONEZONE_HEADER_FOUND}" = "x0" ; then
          TONEZONE_LIB=""
@@ -43873,14 +43922,15 @@ fi
          PBX_TONEZONE=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_TONEZONE 1
-#define HAVE_TONEZONE_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
 
+
 if test "x${PBX_USB}" != "x1" -a "${USE_USB}" != "no"; then
    pbxlibdir=""
    # if --with-USB=DIR has been specified, use it.
@@ -43895,6 +43945,8 @@ if test "x${PBX_USB}" != "x1" -a "${USE_USB}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_USB_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_usb_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lusb" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lusb... $ECHO_C" >&6; }
@@ -43964,6 +44016,7 @@ else
   AST_USB_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -43977,7 +44030,7 @@ fi
       if test "xusb.h" = "x" ; then	# no header, assume found
          USB_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${USB_INCLUDE}"
          if test "${ac_cv_header_usb_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for usb.h" >&5
@@ -44116,7 +44169,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${USB_HEADER_FOUND}" = "x0" ; then
          USB_LIB=""
@@ -44128,13 +44181,14 @@ fi
          PBX_USB=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_USB 1
-#define HAVE_USB_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "${OSARCH}" = "OpenBSD";
 then
 
@@ -44152,6 +44206,8 @@ if test "x${PBX_VORBIS}" != "x1" -a "${USE_VORBIS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_VORBIS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_vorbis_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lvorbis" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lvorbis... $ECHO_C" >&6; }
@@ -44221,6 +44277,7 @@ else
   AST_VORBIS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -44234,7 +44291,7 @@ fi
       if test "xvorbis/codec.h" = "x" ; then	# no header, assume found
          VORBIS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${VORBIS_INCLUDE}"
          if test "${ac_cv_header_vorbis_codec_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for vorbis/codec.h" >&5
@@ -44373,7 +44430,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${VORBIS_HEADER_FOUND}" = "x0" ; then
          VORBIS_LIB=""
@@ -44385,12 +44442,13 @@ fi
          PBX_VORBIS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_VORBIS 1
-#define HAVE_VORBIS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 else
 
 if test "x${PBX_VORBIS}" != "x1" -a "${USE_VORBIS}" != "no"; then
@@ -44407,6 +44465,8 @@ if test "x${PBX_VORBIS}" != "x1" -a "${USE_VORBIS}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_VORBIS_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_vorbis_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lvorbis" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lvorbis... $ECHO_C" >&6; }
@@ -44476,6 +44536,7 @@ else
   AST_VORBIS_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -44489,7 +44550,7 @@ fi
       if test "xvorbis/codec.h" = "x" ; then	# no header, assume found
          VORBIS_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${VORBIS_INCLUDE}"
          if test "${ac_cv_header_vorbis_codec_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for vorbis/codec.h" >&5
@@ -44628,7 +44689,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${VORBIS_HEADER_FOUND}" = "x0" ; then
          VORBIS_LIB=""
@@ -44640,12 +44701,13 @@ fi
          PBX_VORBIS=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_VORBIS 1
-#define HAVE_VORBIS_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
+
 fi
 
 ac_ext=cpp
@@ -44762,6 +44824,8 @@ if test "x${PBX_ZLIB}" != "x1" -a "${USE_ZLIB}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_ZLIB_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_z_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lz" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lz... $ECHO_C" >&6; }
@@ -44831,6 +44895,7 @@ else
   AST_ZLIB_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -44844,7 +44909,7 @@ fi
       if test "xzlib.h" = "x" ; then	# no header, assume found
          ZLIB_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${ZLIB_INCLUDE}"
          if test "${ac_cv_header_zlib_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for zlib.h" >&5
@@ -44983,7 +45048,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${ZLIB_HEADER_FOUND}" = "x0" ; then
          ZLIB_LIB=""
@@ -44995,13 +45060,14 @@ fi
          PBX_ZLIB=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_ZLIB 1
-#define HAVE_ZLIB_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 EDITLINE_LIB=""
 if test "x$TERMCAP_LIB" != "x" ; then
   EDITLINE_LIB="$TERMCAP_LIB"
@@ -45471,10 +45537,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_MSG_NOSIGNAL_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -45547,10 +45609,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SO_NOSIGPIPE_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -45760,6 +45818,8 @@ if test "x${PBX_SDL_IMAGE}" != "x1" -a "${USE_SDL_IMAGE}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_SDL_IMAGE_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} ${SDL_INCLUDE}"
       as_ac_Lib=`echo "ac_cv_lib_SDL_image_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lSDL_image" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lSDL_image... $ECHO_C" >&6; }
@@ -45829,6 +45889,7 @@ else
   AST_SDL_IMAGE_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -45842,7 +45903,7 @@ fi
       if test "xSDL_image.h" = "x" ; then	# no header, assume found
          SDL_IMAGE_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${SDL_IMAGE_INCLUDE}"
          if test "${ac_cv_header_SDL_image_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for SDL_image.h" >&5
@@ -45981,7 +46042,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${SDL_IMAGE_HEADER_FOUND}" = "x0" ; then
          SDL_IMAGE_LIB=""
@@ -45993,13 +46054,14 @@ fi
          PBX_SDL_IMAGE=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_SDL_IMAGE 1
-#define HAVE_SDL_IMAGE_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 if test "x${PBX_FFMPEG}" != "x1" -a "${USE_FFMPEG}" != "no"; then
    pbxlibdir=""
    # if --with-FFMPEG=DIR has been specified, use it.
@@ -46014,6 +46076,8 @@ if test "x${PBX_FFMPEG}" != "x1" -a "${USE_FFMPEG}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_FFMPEG_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
       as_ac_Lib=`echo "ac_cv_lib_avcodec_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lavcodec" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lavcodec... $ECHO_C" >&6; }
@@ -46083,6 +46147,7 @@ else
   AST_FFMPEG_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -46096,7 +46161,7 @@ fi
       if test "xffmpeg/avcodec.h" = "x" ; then	# no header, assume found
          FFMPEG_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${FFMPEG_INCLUDE}"
          if test "${ac_cv_header_ffmpeg_avcodec_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for ffmpeg/avcodec.h" >&5
@@ -46235,7 +46300,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${FFMPEG_HEADER_FOUND}" = "x0" ; then
          FFMPEG_LIB=""
@@ -46247,13 +46312,14 @@ fi
          PBX_FFMPEG=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_FFMPEG 1
-#define HAVE_FFMPEG_VERSION
 _ACEOF
+
       fi
    fi
 fi
 
 
+
 # possible places for video4linux version 1
 if test "${ac_cv_header_linux_videodev_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for linux/videodev.h" >&5
@@ -46411,6 +46477,8 @@ if test "x${PBX_X11}" != "x1" -a "${USE_X11}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_X11_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
       as_ac_Lib=`echo "ac_cv_lib_X11_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lX11" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lX11... $ECHO_C" >&6; }
@@ -46480,6 +46548,7 @@ else
   AST_X11_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -46493,7 +46562,7 @@ fi
       if test "xX11/Xlib.h" = "x" ; then	# no header, assume found
          X11_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${X11_INCLUDE}"
          if test "${ac_cv_header_X11_Xlib_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for X11/Xlib.h" >&5
@@ -46632,7 +46701,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${X11_HEADER_FOUND}" = "x0" ; then
          X11_LIB=""
@@ -46644,13 +46713,19 @@ fi
          PBX_X11=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_X11 1
+_ACEOF
+
+         cat >>confdefs.h <<_ACEOF
 #define HAVE_X11_VERSION standard_path
 _ACEOF
+
       fi
    fi
 fi
 
 
+
+
 if test "x${PBX_X11}" != "x1" -a "${USE_X11}" != "no"; then
    pbxlibdir=""
    # if --with-X11=DIR has been specified, use it.
@@ -46665,6 +46740,8 @@ if test "x${PBX_X11}" != "x1" -a "${USE_X11}" != "no"; then
    if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
       AST_X11_FOUND=yes
    else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} -I/usr/X11R6/include"
       as_ac_Lib=`echo "ac_cv_lib_X11_${pbxfuncname}" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lX11" >&5
 echo $ECHO_N "checking for ${pbxfuncname} in -lX11... $ECHO_C" >&6; }
@@ -46734,6 +46811,7 @@ else
   AST_X11_FOUND=no
 fi
 
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
    fi
 
    # now check for the header.
@@ -46747,7 +46825,7 @@ fi
       if test "xX11/Xlib.h" = "x" ; then	# no header, assume found
          X11_HEADER_FOUND="1"
       else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
          CPPFLAGS="${CPPFLAGS} ${X11_INCLUDE}"
          if test "${ac_cv_header_X11_Xlib_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for X11/Xlib.h" >&5
@@ -46886,7 +46964,7 @@ else
 fi
 
 
-         CPPFLAGS="${saved_cppflags}"
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
       fi
       if test "x${X11_HEADER_FOUND}" = "x0" ; then
          X11_LIB=""
@@ -46898,13 +46976,19 @@ fi
          PBX_X11=1
          cat >>confdefs.h <<_ACEOF
 #define HAVE_X11 1
+_ACEOF
+
+         cat >>confdefs.h <<_ACEOF
 #define HAVE_X11_VERSION X11R6
 _ACEOF
+
       fi
    fi
 fi
 
 
+
+
 if test "${cross_compiling}" = "no";
 then
   { echo "$as_me:$LINENO: checking for /sbin/launchd" >&5
@@ -47628,10 +47712,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_AUTH_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -47704,10 +47784,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_AUTHPRIV_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -47780,10 +47856,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_CRON_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -47856,10 +47928,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_DAEMON_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -47932,10 +48000,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_FTP_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -48008,10 +48072,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_KERN_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -48084,10 +48144,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_LPR_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -48160,10 +48216,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_MAIL_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -48236,10 +48288,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_NEWS_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -48312,10 +48360,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_SYSLOG_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
@@ -48388,10 +48432,6 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG_FACILITY_LOG_UUCP_VERSION
-_ACEOF
-
 
 else
   echo "$as_me: failed program was:" >&5
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 439d27436474db5da7ab9194968126e1f5f9900e..8e378b272017612e1da44cef7f5d1b8b9fe78a8e 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -41,9 +41,6 @@
 /* Define to 1 if you have the Advanced Linux Sound Architecture library. */
 #undef HAVE_ALSA
 
-/* Define to the version of the Advanced Linux Sound Architecture library. */
-#undef HAVE_ALSA_VERSION
-
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 #undef HAVE_ARPA_INET_H
 
@@ -109,24 +106,15 @@
 /* Define to 1 if you have the Stack Backtrace library. */
 #undef HAVE_BKTR
 
-/* Define to the version of the Stack Backtrace library. */
-#undef HAVE_BKTR_VERSION
-
 /* Define to 1 if you have the Bluetooth library. */
 #undef HAVE_BLUETOOTH
 
-/* Define to the version of the Bluetooth library. */
-#undef HAVE_BLUETOOTH_VERSION
-
 /* Define to 1 if byteswap.h macros are available. */
 #undef HAVE_BYTESWAP_H
 
 /* Define to 1 if you have the POSIX 1.e capabilities library. */
 #undef HAVE_CAP
 
-/* Define to the version of the POSIX 1.e capabilities library. */
-#undef HAVE_CAP_VERSION
-
 /* Define to 1 if you have the `ceil' function. */
 #undef HAVE_CEIL
 
@@ -148,45 +136,24 @@
 /* Define to 1 if you have the OpenSSL Cryptography library. */
 #undef HAVE_CRYPTO
 
-/* Define to the version of the OpenSSL Cryptography library. */
-#undef HAVE_CRYPTO_VERSION
-
 /* Define to 1 if you have a functional curl library. */
 #undef HAVE_CURL
 
-/* Define to the version of the cURL library. */
-#undef HAVE_CURL_VERSION
-
 /* Define to 1 if you have the curses library. */
 #undef HAVE_CURSES
 
-/* Define to the version of the curses library. */
-#undef HAVE_CURSES_VERSION
-
 /* Define if your system has the DAHDI headers. */
 #undef HAVE_DAHDI
 
 /* Define if your system has the DAHDI_ECHOCANCEL_FAX_MODE headers. */
 #undef HAVE_DAHDI_ECHOCANCEL_FAX_MODE
 
-/* Define DAHDI_ECHOCANCEL_FAX_MODE headers version */
-#undef HAVE_DAHDI_ECHOCANCEL_FAX_MODE_VERSION
-
 /* Define if your system has the DAHDI_HALF_FULL headers. */
 #undef HAVE_DAHDI_HALF_FULL
 
-/* Define DAHDI_HALF_FULL headers version */
-#undef HAVE_DAHDI_HALF_FULL_VERSION
-
 /* Define if your system has the DAHDI_LINEREVERSE_VMWI headers. */
 #undef HAVE_DAHDI_LINEREVERSE_VMWI
 
-/* Define DAHDI_LINEREVERSE_VMWI headers version */
-#undef HAVE_DAHDI_LINEREVERSE_VMWI_VERSION
-
-/* Define DAHDI headers version */
-#undef HAVE_DAHDI_VERSION
-
 /* Define to 1 if your system has /dev/urandom. */
 #undef HAVE_DEV_URANDOM
 
@@ -233,9 +200,6 @@
 /* Define to 1 if you have the Ffmpeg and avcodec library. */
 #undef HAVE_FFMPEG
 
-/* Define to the version of the Ffmpeg and avcodec library. */
-#undef HAVE_FFMPEG_VERSION
-
 /* Define to 1 if you have the `ffsll' function. */
 #undef HAVE_FFSLL
 
@@ -260,9 +224,6 @@
 /* Define to 1 if you have the FreeTDS library. */
 #undef HAVE_FREETDS
 
-/* Define to the version of the FreeTDS library. */
-#undef HAVE_FREETDS_VERSION
-
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 #undef HAVE_FSEEKO
 
@@ -293,9 +254,6 @@
 /* Define if your system has the GETIFADDRS headers. */
 #undef HAVE_GETIFADDRS
 
-/* Define GETIFADDRS headers version */
-#undef HAVE_GETIFADDRS_VERSION
-
 /* Define to 1 if you have the `getloadavg' function. */
 #undef HAVE_GETLOADAVG
 
@@ -314,21 +272,12 @@
 /* Define if your system has the GLOB_BRACE headers. */
 #undef HAVE_GLOB_BRACE
 
-/* Define GLOB_BRACE headers version */
-#undef HAVE_GLOB_BRACE_VERSION
-
 /* Define if your system has the GLOB_NOMAGIC headers. */
 #undef HAVE_GLOB_NOMAGIC
 
-/* Define GLOB_NOMAGIC headers version */
-#undef HAVE_GLOB_NOMAGIC_VERSION
-
 /* Define if your system has the GMIME libraries. */
 #undef HAVE_GMIME
 
-/* Define to the version of the GMime library. */
-#undef HAVE_GMIME_VERSION
-
 /* Define to indicate the GSM library */
 #undef HAVE_GSM
 
@@ -338,42 +287,24 @@
 /* Define to indicate that gsm.h has no prefix for its location */
 #undef HAVE_GSM_HEADER
 
-/* Define to the version of the External GSM library. */
-#undef HAVE_GSM_VERSION
-
 /* Define if your system has the GTK2 libraries. */
 #undef HAVE_GTK2
 
-/* Define to the version of the gtk2 library. */
-#undef HAVE_GTK2_VERSION
-
 /* Define to 1 if you have the Hoard Memory Allocator library. */
 #undef HAVE_HOARD
 
-/* Define to the version of the Hoard Memory Allocator library. */
-#undef HAVE_HOARD_VERSION
-
 /* Define to 1 if you have the `htonll' function. */
 #undef HAVE_HTONLL
 
 /* Define to 1 if you have the iCal library. */
 #undef HAVE_ICAL
 
-/* Define to the version of the iCal library. */
-#undef HAVE_ICAL_VERSION
-
 /* Define to 1 if you have the Iconv library. */
 #undef HAVE_ICONV
 
-/* Define to the version of the Iconv library. */
-#undef HAVE_ICONV_VERSION
-
 /* Define to 1 if you have the Iksemel Jabber library. */
 #undef HAVE_IKSEMEL
 
-/* Define to the version of the Iksemel Jabber library. */
-#undef HAVE_IKSEMEL_VERSION
-
 /* Define if your system has the UW IMAP Toolkit c-client library. */
 #undef HAVE_IMAP_TK
 
@@ -381,9 +312,6 @@
    or greater. */
 #undef HAVE_IMAP_TK2006
 
-/* Define to the version of the UW IMAP Toolkit library. */
-#undef HAVE_IMAP_TK_VERSION
-
 /* Define to 1 if you have the `inet_aton' function. */
 #undef HAVE_INET_ATON
 
@@ -393,48 +321,30 @@
 /* Define to 1 if you have the inotify support library. */
 #undef HAVE_INOTIFY
 
-/* Define to the version of the inotify support library. */
-#undef HAVE_INOTIFY_VERSION
-
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
 /* Define to 1 if you have the iODBC library. */
 #undef HAVE_IODBC
 
-/* Define to the version of the iODBC library. */
-#undef HAVE_IODBC_VERSION
-
 /* Define to 1 if you have the `ioperm' function. */
 #undef HAVE_IOPERM
 
 /* Define if your system has the IP_MTU_DISCOVER headers. */
 #undef HAVE_IP_MTU_DISCOVER
 
-/* Define IP_MTU_DISCOVER headers version */
-#undef HAVE_IP_MTU_DISCOVER_VERSION
-
 /* Define to 1 if you have the `isascii' function. */
 #undef HAVE_ISASCII
 
 /* Define to 1 if you have the ISDN4Linux library. */
 #undef HAVE_ISDNNET
 
-/* Define to the version of the ISDN4Linux library. */
-#undef HAVE_ISDNNET_VERSION
-
 /* Define to 1 if you have the Jack Audio Connection Kit library. */
 #undef HAVE_JACK
 
-/* Define to the version of the Jack Audio Connection Kit library. */
-#undef HAVE_JACK_VERSION
-
 /* Define to 1 if you have the OpenLDAP library. */
 #undef HAVE_LDAP
 
-/* Define to the version of the OpenLDAP library. */
-#undef HAVE_LDAP_VERSION
-
 /* Define to 1 if you have the <libintl.h> header file. */
 #undef HAVE_LIBINTL_H
 
@@ -444,9 +354,6 @@
 /* Define if your system has the LIBXML2 libraries. */
 #undef HAVE_LIBXML2
 
-/* Define to the version of the LibXML2 library. */
-#undef HAVE_LIBXML2_VERSION
-
 /* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 
@@ -484,15 +391,9 @@
 /* Define to 1 if you have the libtool library. */
 #undef HAVE_LTDL
 
-/* Define to the version of the libtool library. */
-#undef HAVE_LTDL_VERSION
-
 /* Define to 1 if you have the Lua library. */
 #undef HAVE_LUA
 
-/* Define to the version of the Lua library. */
-#undef HAVE_LUA_VERSION
-
 /* Define to 1 if you have the <malloc.h> header file. */
 #undef HAVE_MALLOC_H
 
@@ -514,18 +415,9 @@
 /* Define if your system has the MISDN_FAC_ERROR headers. */
 #undef HAVE_MISDN_FAC_ERROR
 
-/* Define MISDN_FAC_ERROR headers version */
-#undef HAVE_MISDN_FAC_ERROR_VERSION
-
 /* Define if your system has the MISDN_FAC_RESULT headers. */
 #undef HAVE_MISDN_FAC_RESULT
 
-/* Define MISDN_FAC_RESULT headers version */
-#undef HAVE_MISDN_FAC_RESULT_VERSION
-
-/* Define to the version of the mISDN user library. */
-#undef HAVE_MISDN_VERSION
-
 /* Define to 1 if you have the `mkdir' function. */
 #undef HAVE_MKDIR
 
@@ -535,39 +427,24 @@
 /* Define if your system has the MSG_NOSIGNAL headers. */
 #undef HAVE_MSG_NOSIGNAL
 
-/* Define MSG_NOSIGNAL headers version */
-#undef HAVE_MSG_NOSIGNAL_VERSION
-
 /* Define to 1 if you have the `munmap' function. */
 #undef HAVE_MUNMAP
 
 /* Define if your system has the MYSQLCLIENT libraries. */
 #undef HAVE_MYSQLCLIENT
 
-/* Define to the version of the MySQL client library. */
-#undef HAVE_MYSQLCLIENT_VERSION
-
 /* Define to 1 if you have the Network Broadcast Sound library. */
 #undef HAVE_NBS
 
-/* Define to the version of the Network Broadcast Sound library. */
-#undef HAVE_NBS_VERSION
-
 /* Define to 1 if you have the ncurses library. */
 #undef HAVE_NCURSES
 
-/* Define to the version of the ncurses library. */
-#undef HAVE_NCURSES_VERSION
-
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #undef HAVE_NDIR_H
 
 /* Define if your system has the NEON libraries. */
 #undef HAVE_NEON
 
-/* Define to the version of the neon library. */
-#undef HAVE_NEON_VERSION
-
 /* Define to 1 if you have the <netdb.h> header file. */
 #undef HAVE_NETDB_H
 
@@ -577,15 +454,9 @@
 /* Define if your system has the NETSNMP libraries. */
 #undef HAVE_NETSNMP
 
-/* Define to the version of the Net-SNMP library. */
-#undef HAVE_NETSNMP_VERSION
-
 /* Define to 1 if you have the newt library. */
 #undef HAVE_NEWT
 
-/* Define to the version of the newt library. */
-#undef HAVE_NEWT_VERSION
-
 /* Define to 1 if you have the `ntohll' function. */
 #undef HAVE_NTOHLL
 
@@ -598,69 +469,39 @@
 /* Define to 1 if you have the OGG library. */
 #undef HAVE_OGG
 
-/* Define to the version of the OGG library. */
-#undef HAVE_OGG_VERSION
-
 /* Define to 1 if you have the OpenAIS library. */
 #undef HAVE_OPENAIS
 
-/* Define to the version of the OpenAIS library. */
-#undef HAVE_OPENAIS_VERSION
-
 /* Define if your system has the OpenH323 libraries. */
 #undef HAVE_OPENH323
 
-/* Define to the version of the OpenH323 library. */
-#undef HAVE_OPENH323_VERSION
-
 /* Define to 1 if you have the MFR2 library. */
 #undef HAVE_OPENR2
 
-/* Define to the version of the MFR2 library. */
-#undef HAVE_OPENR2_VERSION
-
 /* Define to 1 if you have the OpenSSL Secure Sockets Layer library. */
 #undef HAVE_OPENSSL
 
-/* Define to the version of the OpenSSL Secure Sockets Layer library. */
-#undef HAVE_OPENSSL_VERSION
-
 /* Define this to indicate the ${OSPTK_DESCRIP} library */
 #undef HAVE_OSPTK
 
-/* Define to the version of the OSP Toolkit library. */
-#undef HAVE_OSPTK_VERSION
-
 /* Define to 1 if you have the Open Sound System library. */
 #undef HAVE_OSS
 
-/* Define to the version of the Open Sound System library. */
-#undef HAVE_OSS_VERSION
-
 /* Define to 1 if OSX atomic operations are supported. */
 #undef HAVE_OSX_ATOMICS
 
 /* Define to indicate the PostgreSQL library */
 #undef HAVE_PGSQL
 
-/* Define to the version of the PostgreSQL library. */
-#undef HAVE_PGSQL_VERSION
-
 /* Define to 1 if your system defines IP_PKTINFO. */
 #undef HAVE_PKTINFO
 
 /* Define to 1 if you have the popt library. */
 #undef HAVE_POPT
 
-/* Define to the version of the popt library. */
-#undef HAVE_POPT_VERSION
-
 /* Define to 1 if you have the PortAudio library. */
 #undef HAVE_PORTAUDIO
 
-/* Define to the version of the PortAudio library. */
-#undef HAVE_PORTAUDIO_VERSION
-
 /* Define to 1 if you have the `pow' function. */
 #undef HAVE_POW
 
@@ -713,15 +554,9 @@
    headers. */
 #undef HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 
-/* Define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP headers version */
-#undef HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP_VERSION
-
 /* Define if your system has the PTHREAD_RWLOCK_INITIALIZER headers. */
 #undef HAVE_PTHREAD_RWLOCK_INITIALIZER
 
-/* Define PTHREAD_RWLOCK_INITIALIZER headers version */
-#undef HAVE_PTHREAD_RWLOCK_INITIALIZER_VERSION
-
 /* Define to 1 if your system defines PTHREAD_RWLOCK_PREFER_WRITER_NP in
    pthread.h */
 #undef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
@@ -738,15 +573,9 @@
 /* Define if your system has the PWLib libraries. */
 #undef HAVE_PWLIB
 
-/* Define to the version of the PWlib library. */
-#undef HAVE_PWLIB_VERSION
-
 /* Define to 1 if you have the Radius Client library. */
 #undef HAVE_RADIUS
 
-/* Define to the version of the Radius Client library. */
-#undef HAVE_RADIUS_VERSION
-
 /* Define to 1 if you have the `regcomp' function. */
 #undef HAVE_REGCOMP
 
@@ -759,9 +588,6 @@
 /* Define to 1 if you have the LIBRESAMPLE library. */
 #undef HAVE_RESAMPLE
 
-/* Define to the version of the LIBRESAMPLE library. */
-#undef HAVE_RESAMPLE_VERSION
-
 /* Define to 1 if your system has the close resolver function. */
 #undef HAVE_RES_CLOSE
 
@@ -795,12 +621,6 @@
 /* Define to 1 if you have the Sdl Image library. */
 #undef HAVE_SDL_IMAGE
 
-/* Define to the version of the Sdl Image library. */
-#undef HAVE_SDL_IMAGE_VERSION
-
-/* Define to the version of the Sdl library. */
-#undef HAVE_SDL_VERSION
-
 /* Define to 1 if you have the `select' function. */
 #undef HAVE_SELECT
 
@@ -822,54 +642,30 @@
 /* Define if your system has the SO_NOSIGPIPE headers. */
 #undef HAVE_SO_NOSIGPIPE
 
-/* Define SO_NOSIGPIPE headers version */
-#undef HAVE_SO_NOSIGPIPE_VERSION
-
 /* Define if your system has the SPANDSP headers. */
 #undef HAVE_SPANDSP
 
-/* Define SPANDSP headers version */
-#undef HAVE_SPANDSP_VERSION
-
 /* Define to 1 if you have the Speex library. */
 #undef HAVE_SPEEX
 
 /* Define to 1 if you have the SpeexDSP library. */
 #undef HAVE_SPEEXDSP
 
-/* Define to the version of the SpeexDSP library. */
-#undef HAVE_SPEEXDSP_VERSION
-
 /* Define to 1 if you have the speex_preprocess_ctl library. */
 #undef HAVE_SPEEX_PREPROCESS
 
-/* Define to the version of the Speex preprocess routines library. */
-#undef HAVE_SPEEX_PREPROCESS_VERSION
-
-/* Define to the version of the Speex library. */
-#undef HAVE_SPEEX_VERSION
-
 /* Define to 1 if you have the SQLite library. */
 #undef HAVE_SQLITE
 
 /* Define to 1 if you have the SQLite library. */
 #undef HAVE_SQLITE3
 
-/* Define to the version of the SQLite library. */
-#undef HAVE_SQLITE3_VERSION
-
-/* Define to the version of the SQLite library. */
-#undef HAVE_SQLITE_VERSION
-
 /* Define to 1 if you have the `sqrtl' function. */
 #undef HAVE_SQRTL
 
 /* Define to 1 if you have the ISDN SS7 library. */
 #undef HAVE_SS7
 
-/* Define to the version of the ISDN SS7 library. */
-#undef HAVE_SS7_VERSION
-
 /* Define to 1 if `stat' has the bug that it succeeds when given the
    zero-length file name argument. */
 #undef HAVE_STAT_EMPTY_STRING_BUG
@@ -962,9 +758,6 @@
 /* Define to 1 if you have the mISDN Supplemental Services library. */
 #undef HAVE_SUPPSERV
 
-/* Define to the version of the mISDN Supplemental Services library. */
-#undef HAVE_SUPPSERV_VERSION
-
 /* Define to 1 if you have the `swapctl' function. */
 #undef HAVE_SWAPCTL
 
@@ -980,66 +773,33 @@
 /* Define if your system has the SYSLOG_FACILITY_LOG_AUTHPRIV headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_AUTHPRIV
 
-/* Define SYSLOG_FACILITY_LOG_AUTHPRIV headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_AUTHPRIV_VERSION
-
-/* Define SYSLOG_FACILITY_LOG_AUTH headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_AUTH_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_CRON headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_CRON
 
-/* Define SYSLOG_FACILITY_LOG_CRON headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_CRON_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_DAEMON headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_DAEMON
 
-/* Define SYSLOG_FACILITY_LOG_DAEMON headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_DAEMON_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_FTP headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_FTP
 
-/* Define SYSLOG_FACILITY_LOG_FTP headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_FTP_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_KERN headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_KERN
 
-/* Define SYSLOG_FACILITY_LOG_KERN headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_KERN_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_LPR headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_LPR
 
-/* Define SYSLOG_FACILITY_LOG_LPR headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_LPR_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_MAIL headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_MAIL
 
-/* Define SYSLOG_FACILITY_LOG_MAIL headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_MAIL_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_NEWS headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_NEWS
 
-/* Define SYSLOG_FACILITY_LOG_NEWS headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_NEWS_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_SYSLOG headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_SYSLOG
 
-/* Define SYSLOG_FACILITY_LOG_SYSLOG headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_SYSLOG_VERSION
-
 /* Define if your system has the SYSLOG_FACILITY_LOG_UUCP headers. */
 #undef HAVE_SYSLOG_FACILITY_LOG_UUCP
 
-/* Define SYSLOG_FACILITY_LOG_UUCP headers version */
-#undef HAVE_SYSLOG_FACILITY_LOG_UUCP_VERSION
-
 /* Define to 1 if you have the <syslog.h> header file. */
 #undef HAVE_SYSLOG_H
 
@@ -1100,33 +860,21 @@
 /* Define to 1 if you have the Termcap library. */
 #undef HAVE_TERMCAP
 
-/* Define to the version of the Termcap library. */
-#undef HAVE_TERMCAP_VERSION
-
 /* Define to 1 if you have the <termios.h> header file. */
 #undef HAVE_TERMIOS_H
 
 /* Define if your system has the TIMERFD headers. */
 #undef HAVE_TIMERFD
 
-/* Define TIMERFD headers version */
-#undef HAVE_TIMERFD_VERSION
-
 /* Define to 1 if your system defines timersub. */
 #undef HAVE_TIMERSUB
 
 /* Define to 1 if you have the Term Info library. */
 #undef HAVE_TINFO
 
-/* Define to the version of the Term Info library. */
-#undef HAVE_TINFO_VERSION
-
 /* Define to 1 if you have the tonezone library. */
 #undef HAVE_TONEZONE
 
-/* Define to the version of the tonezone library. */
-#undef HAVE_TONEZONE_VERSION
-
 /* Define to 1 if you have the `trunc' function. */
 #undef HAVE_TRUNC
 
@@ -1139,18 +887,12 @@
 /* Define to 1 if you have the unixODBC library. */
 #undef HAVE_UNIXODBC
 
-/* Define to the version of the unixODBC library. */
-#undef HAVE_UNIXODBC_VERSION
-
 /* Define to 1 if you have the `unsetenv' function. */
 #undef HAVE_UNSETENV
 
 /* Define to 1 if you have the usb library. */
 #undef HAVE_USB
 
-/* Define to the version of the usb library. */
-#undef HAVE_USB_VERSION
-
 /* Define to 1 if you have the `utime' function. */
 #undef HAVE_UTIME
 
@@ -1175,15 +917,9 @@
 /* Define to 1 if you have the Vorbis library. */
 #undef HAVE_VORBIS
 
-/* Define to the version of the Vorbis library. */
-#undef HAVE_VORBIS_VERSION
-
 /* Define if your system has the VoiceTronix API libraries. */
 #undef HAVE_VPB
 
-/* Define to the version of the Voicetronix API library. */
-#undef HAVE_VPB_VERSION
-
 /* Define to 1 if you have the `vprintf' function. */
 #undef HAVE_VPRINTF
 
@@ -1208,9 +944,6 @@
 /* Define to 1 if you have the zlib compression library. */
 #undef HAVE_ZLIB
 
-/* Define to the version of the zlib compression library. */
-#undef HAVE_ZLIB_VERSION
-
 /* Define to 1 if the system has the type `_Bool'. */
 #undef HAVE__BOOL