Using a dummy channel causes CDR() testing to fail.
[asterisk/asterisk.git] / configure.ac
index 5da2643..ea0e3eb 100644 (file)
@@ -17,13 +17,24 @@ AC_CANONICAL_HOST
 # check existence of the package
 AC_CONFIG_SRCDIR([main/asterisk.c])
 
 # check existence of the package
 AC_CONFIG_SRCDIR([main/asterisk.c])
 
-# specify output header file
-AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
-
 AC_COPYRIGHT("Asterisk")
 AC_REVISION($Revision$)
 
 AC_COPYRIGHT("Asterisk")
 AC_REVISION($Revision$)
 
-AC_GNU_SOURCE
+# preserve any CFLAGS or LDFLAGS that may be set
+# NOTE: This must be done before calling any macros that end up
+# calling AC_PROG_CC or the like, since they will set a default
+# set of CFLAGS ("-g -O2") if the user did not supply any, and
+# we don't want those default flags to be carried over into the
+# rest of the build system since we have other means of controlling
+# debugging symbol generation and optimization.
+CONFIG_CFLAGS="${CFLAGS}"
+CONFIG_LDFLAGS="${LDFLAGS}"
+AC_SUBST(CONFIG_CFLAGS)
+AC_SUBST(CONFIG_LDFLAGS)
+
+# specify output header file
+AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
+
 AC_USE_SYSTEM_EXTENSIONS       # note- does not work on FreeBSD
 
 case "${host_os}" in
 AC_USE_SYSTEM_EXTENSIONS       # note- does not work on FreeBSD
 
 case "${host_os}" in
@@ -45,6 +56,9 @@ case "${host_os}" in
      CPPFLAGS=-I/usr/local/include
      LDFLAGS=-L/usr/local/lib
      ;;
      CPPFLAGS=-I/usr/local/include
      LDFLAGS=-L/usr/local/lib
      ;;
+     darwin*)
+     AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.])
+     ;;
      *)
      ac_default_prefix=/usr
      if test ${prefix} = '/usr' || test ${prefix} = 'NONE'; then
      *)
      ac_default_prefix=/usr
      if test ${prefix} = '/usr' || test ${prefix} = 'NONE'; then
@@ -58,8 +72,10 @@ case "${host_os}" in
      ;;
 esac
 
      ;;
 esac
 
-if test ${localstatedir} = '${prefix}/var'; then
-     localstatedir=/var
+if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then
+     if test ${localstatedir} = '${prefix}/var'; then
+        localstatedir=/var
+     fi
 fi
 
 BUILD_PLATFORM=${build}
 fi
 
 BUILD_PLATFORM=${build}
@@ -105,6 +121,9 @@ case "${host_os}" in
      OSARCH=cygwin
      PBX_WINARCH=1
      ;;
      OSARCH=cygwin
      PBX_WINARCH=1
      ;;
+     linux-gnueabi)
+     OSARCH=linux-gnu
+     ;;
      *)
      OSARCH=${host_os}
      ;;
      *)
      OSARCH=${host_os}
      ;;
@@ -164,6 +183,8 @@ if test "x$with_gnu_ld" = "xyes" ; then
 fi
 AC_SUBST(GNU_LD)
 
 fi
 AC_SUBST(GNU_LD)
 
+AC_PATH_PROG([BISON], [bison], :)
+AC_PATH_PROG([FLEX], [flex], :)
 AC_PATH_PROG([GREP], [grep], :)
 AC_PATH_PROG([FIND], [find], :)
 AC_PATH_PROG([COMPRESS], [compress], :)
 AC_PATH_PROG([GREP], [grep], :)
 AC_PATH_PROG([FIND], [find], :)
 AC_PATH_PROG([COMPRESS], [compress], :)
@@ -174,17 +195,64 @@ AC_PATH_PROG([SHELL], [sh], :)
 AC_PATH_PROG([LN], [ln], :)
 AC_PATH_PROG([DOT], [dot], :)
 AC_PATH_PROG([WGET], [wget], :)
 AC_PATH_PROG([LN], [ln], :)
 AC_PATH_PROG([DOT], [dot], :)
 AC_PATH_PROG([WGET], [wget], :)
+AC_PATH_PROG([CURL], [curl], :)
 AC_PATH_PROG([RUBBER], [rubber], :)
 AC_PATH_PROG([KPATHSEA], [kpsewhich], :)
 AC_PATH_PROG([XMLSTARLET], [xmlstarlet], :)
 if test "${WGET}" != ":" ; then
   DOWNLOAD=${WGET}
 AC_PATH_PROG([RUBBER], [rubber], :)
 AC_PATH_PROG([KPATHSEA], [kpsewhich], :)
 AC_PATH_PROG([XMLSTARLET], [xmlstarlet], :)
 if test "${WGET}" != ":" ; then
   DOWNLOAD=${WGET}
+else if test "${CURL}" != ":" ; then
+  DOWNLOAD="${CURL} -O --progress-bar -w \"%{url_effective}\n\""
 else
   AC_PATH_PROG([FETCH], [fetch], [:])
   DOWNLOAD=${FETCH}
 fi
 else
   AC_PATH_PROG([FETCH], [fetch], [:])
   DOWNLOAD=${FETCH}
 fi
+fi
 AC_SUBST(DOWNLOAD)
 
 AC_SUBST(DOWNLOAD)
 
+AC_CACHE_CHECK([for bison that supports parse-param], [ac_cv_path_BISON2], [
+       if test "x$BISON" != "x:" ; then
+               # Create a temporary directory $tmp in $TMPDIR (default /tmp).
+               # Use mktemp if possible; otherwise fall back on mkdir,
+               # with $RANDOM to make collisions less likely.
+               : ${TMPDIR=/tmp}
+               {
+                 tmp=`
+                   (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
+                 ` &&
+                 test -n "$tmp" && test -d "$tmp"
+               } || {
+                 tmp=$TMPDIR/foo$$-$RANDOM
+                 (umask 077 && mkdir "$tmp")
+               } || exit $?
+               cat >$tmp/test.y <<__EOL__
+%parse-param {struct parse_io *parseio}
+%%
+file : { \$\$ = parseio->pval = 1; }
+       ;
+%%
+__EOL__
+               ${BISON} -o ${tmp}/test.tab.c ${tmp}/test.y >/dev/null 2>&1
+               if test -e "${tmp}/test.tab.c"; then
+                       ac_cv_path_BISON2=${BISON}
+               fi
+               rm -rf ${tmp}
+       fi
+       ])
+if test "x${ac_cv_path_BISON2}" = "x" ; then
+       BISON=:
+       PBX_BISON=0
+else
+       PBX_BISON=1
+fi
+AC_SUBST(PBX_BISON)
+if test "x${FLEX}" = "x:" ; then
+       PBX_FLEX=0
+else
+       PBX_FLEX=1
+fi
+AC_SUBST(PBX_FLEX)
+
 AC_CHECK_TOOL([SOXMIX], [soxmix], [:])
 if test "${SOXMIX}" != ":" ; then
        AC_DEFINE([HAVE_SOXMIX], 1, [Define to 1 if your system has soxmix application.])
 AC_CHECK_TOOL([SOXMIX], [soxmix], [:])
 if test "${SOXMIX}" != ":" ; then
        AC_DEFINE([HAVE_SOXMIX], 1, [Define to 1 if your system has soxmix application.])
@@ -206,8 +274,13 @@ AC_ARG_ENABLE([dev-mode],
        [case "${enableval}" in
              y|ye|yes) AST_DEVMODE=yes ;;
              n|no)  AST_DEVMODE=no ;;
        [case "${enableval}" in
              y|ye|yes) AST_DEVMODE=yes ;;
              n|no)  AST_DEVMODE=no ;;
+             noisy)
+             AST_DEVMODE=yes
+             NOISY_BUILD=yes
+             ;;
              *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
        esac])
              *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
        esac])
+AC_SUBST(NOISY_BUILD)
 AC_SUBST(AST_DEVMODE)
 
 # AST_EXT_LIB_SETUP is used to tell configure to handle variables for
 AC_SUBST(AST_DEVMODE)
 
 # AST_EXT_LIB_SETUP is used to tell configure to handle variables for
@@ -225,6 +298,7 @@ AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
 # BKTR is used for backtrace support on platforms that do not
 # have it natively.
 AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace support], [execinfo])
 # BKTR is used for backtrace support on platforms that do not
 # have it natively.
 AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace support], [execinfo])
+AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth Support], [bluetooth])
 AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap])
 AST_EXT_LIB_SETUP([CURL], [cURL], [curl])
 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
 AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap])
 AST_EXT_LIB_SETUP([CURL], [cURL], [curl])
 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
@@ -236,9 +310,11 @@ AST_EXT_LIB_SETUP([GTK], [gtk libraries], [gtk])
 AST_EXT_LIB_SETUP([GTK2], [gtk2 libraries], [gtk2])
 AST_EXT_LIB_SETUP([GMIME], [GMime library], [gmime])
 AST_EXT_LIB_SETUP([HOARD], [Hoard Memory Allocator], [hoard])
 AST_EXT_LIB_SETUP([GTK2], [gtk2 libraries], [gtk2])
 AST_EXT_LIB_SETUP([GMIME], [GMime library], [gmime])
 AST_EXT_LIB_SETUP([HOARD], [Hoard Memory Allocator], [hoard])
+AST_EXT_LIB_SETUP([ICAL], [ical libraries], [ical])
 AST_EXT_LIB_SETUP([ICONV], [Iconv Library], [iconv])
 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
 AST_EXT_LIB_SETUP([ICONV], [Iconv Library], [iconv])
 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
+AST_EXT_LIB_SETUP([INOTIFY], [inotify support], [inotify])
 AST_EXT_LIB_SETUP([IODBC], [iODBC], [iodbc])
 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
 AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
 AST_EXT_LIB_SETUP([IODBC], [iODBC], [iodbc])
 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
 AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
@@ -247,8 +323,10 @@ AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2])
 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
 AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
 AST_EXT_LIB_SETUP([MISDN], [mISDN User Library], [misdn])
 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
 AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
 AST_EXT_LIB_SETUP([MISDN], [mISDN User Library], [misdn])
+AST_EXT_LIB_SETUP([MYSQLCLIENT], [mysqlclient], [mysqlclient])
 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
+AST_EXT_LIB_SETUP([NEON], [neon], [neon])
 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
 AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
 AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
@@ -258,9 +336,23 @@ AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
 AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
 AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_SUBADDR], [ISDN PRI subaddressing], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_CALL_HOLD], [ISDN PRI call hold], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_CALL_REROUTING], [ISDN PRI call rerouting and call deflection], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_SETUP_KEYPAD], [ISDN PRI keypad facility in SETUP], [PRI], [pri])
+# ------------------------------------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.
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_VERSION], [ISDN PRI get_version], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_INBANDDISCONNECT], [ISDN PRI set_inbanddisconnect], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_PROG_W_CAUSE], [ISDN progress with cause], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_SERVICE_MESSAGES], [ISDN service messages], [PRI], [pri])
+AST_EXT_LIB_SETUP_DEPENDENT([PRI_REVERSE_CHARGE], [ISDN reverse charge], [PRI], [pri])
+# ------------------------------------^
 AST_EXT_LIB_SETUP([RESAMPLE], [LIBRESAMPLE], [resample])
 AST_EXT_LIB_SETUP([SPANDSP], [SPANDSP], [spandsp])
 AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7])
 AST_EXT_LIB_SETUP([RESAMPLE], [LIBRESAMPLE], [resample])
 AST_EXT_LIB_SETUP([SPANDSP], [SPANDSP], [spandsp])
 AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7])
+AST_EXT_LIB_SETUP([OPENR2], [MFR2], [openr2])
 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
 AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
 AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
@@ -268,7 +360,9 @@ AST_EXT_LIB_SETUP([SDL], [Sdl], [sdl])
 AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image library], [SDL_image])
 AST_EXT_LIB_SETUP([OPENAIS], [OpenAIS], [openais])
 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
 AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image library], [SDL_image])
 AST_EXT_LIB_SETUP([OPENAIS], [OpenAIS], [openais])
 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
+AST_EXT_LIB_SETUP([SPEEX_PREPROCESS], [Speex preprocess routines], [speex])
 AST_EXT_LIB_SETUP([SPEEXDSP], [Speexdsp], [speexdsp])
 AST_EXT_LIB_SETUP([SPEEXDSP], [Speexdsp], [speexdsp])
+AST_EXT_LIB_SETUP_DEPENDENT([SPEEX_PREPROCESS], [speex_preprocess_ctl], [], [speex])
 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
 AST_EXT_LIB_SETUP([SQLITE3], [SQLite], [sqlite3])
 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
 AST_EXT_LIB_SETUP([SQLITE3], [SQLite], [sqlite3])
 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
@@ -292,10 +386,14 @@ AC_FUNC_ALLOCA
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h utime.h arpa/nameser.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h utime.h arpa/nameser.h sys/io.h])
 
 AC_CHECK_HEADERS([winsock.h winsock2.h])
 
 
 AC_CHECK_HEADERS([winsock.h winsock2.h])
 
+AC_CHECK_HEADER([sys/poll.h],
+        [],
+     AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.]))
+
 AC_SYS_LARGEFILE
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_SYS_LARGEFILE
 
 # Checks for typedefs, structures, and compiler characteristics.
@@ -303,6 +401,7 @@ AC_HEADER_STDBOOL
 AC_C_CONST
 AC_TYPE_UID_T
 AC_C_INLINE
 AC_C_CONST
 AC_TYPE_UID_T
 AC_C_INLINE
+AC_TYPE_LONG_DOUBLE_WIDER
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
@@ -336,9 +435,19 @@ AC_FUNC_STRNLEN
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
+AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap ntohll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
 
 
-AC_CHECK_FUNCS([glob])
+# NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
+# so that AC_CHECK_FUNCS can detect functions in that library.
+AC_CHECK_LIB([m], [sqrt])
+# BSD might not have exp2, and/or log2
+AC_CHECK_FUNCS([exp2 log2 exp10 log10 sin cos tan asin acos atan atan2 pow rint exp log remainder fmod round trunc floor ceil])
+
+# Certain architectures don't really have long double, even though
+# AC_CHECK_FUNCS would otherwise find the following functions.
+if test "x${ac_cv_type_long_double_wider}" = "xyes" ; then
+       AC_CHECK_FUNCS([exp2l log2l exp10l log10l sinl cosl tanl asinl acosl atanl atan2l powl sqrtl rintl expl logl remainderl fmodl roundl truncl floorl ceill])
+fi
 
 AC_MSG_CHECKING(for timersub in time.h)
 AC_LINK_IFELSE(
 
 AC_MSG_CHECKING(for timersub in time.h)
 AC_LINK_IFELSE(
@@ -446,6 +555,45 @@ AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1, [Define to 1 if your system defi
 AC_MSG_RESULT(no)
 )
 
 AC_MSG_RESULT(no)
 )
 
+AC_MSG_CHECKING(for pthread_rwlock_timedwrlock() in pthread.h)
+AC_LINK_IFELSE(
+  [AC_LANG_PROGRAM(
+    [#include <pthread.h>
+     #include <time.h>],
+    [pthread_rwlock_t foo; struct timespec bar; pthread_rwlock_timedwrlock(&foo, &bar)])
+  ],[
+    AC_MSG_RESULT(yes)
+    ac_cv_pthread_rwlock_timedwrlock="yes"
+  ],[
+    AC_MSG_RESULT(no)
+    ac_cv_pthread_rwlock_timedwrlock="no"
+  ]
+)
+if test "${ac_cv_pthread_rwlock_timedwrlock}" = "yes"; then
+  AC_DEFINE([HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK], 1, [Define if your system has pthread_rwlock_timedwrlock()])
+fi
+
+AC_MSG_CHECKING(if PTHREAD_ONCE_INIT needs braces)
+saved_CFLAGS="${CFLAGS}"
+CFLAGS="${CFLAGS} -Werror -Wmissing-braces"
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM(
+    [#include <pthread.h>
+     void empty(){}],
+       [pthread_once_t once = PTHREAD_ONCE_INIT; pthread_once(&once, empty);])
+  ],[
+    AC_MSG_RESULT(no)
+    ac_cv_pthread_once_needsbraces="no"
+  ],[
+    AC_MSG_RESULT(yes)
+    ac_cv_pthread_once_needsbraces="yes"
+  ]
+)
+CFLAGS="${saved_CFLAGS}"
+if test "${ac_cv_pthread_once_needsbraces}" = "yes"; then
+  AC_DEFINE([PTHREAD_ONCE_INIT_NEEDS_BRACES], 1, [Define if your system needs braces around PTHREAD_ONCE_INIT])
+fi
+
 AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
 
 #if test "${cross_compiling}" = "no";
 AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
 
 #if test "${cross_compiling}" = "no";
@@ -479,7 +627,8 @@ AST_GCC_ATTRIBUTE(always_inline)
 AST_GCC_ATTRIBUTE(deprecated)
 AST_GCC_ATTRIBUTE(sentinel)
 AST_GCC_ATTRIBUTE(warn_unused_result)
 AST_GCC_ATTRIBUTE(deprecated)
 AST_GCC_ATTRIBUTE(sentinel)
 AST_GCC_ATTRIBUTE(warn_unused_result)
-AST_GCC_ATTRIBUTE(weak)
+AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static)
+AST_GCC_ATTRIBUTE(weak_import)
 
 AC_MSG_CHECKING(for -ffunction-sections support)
 saved_CFLAGS="${CFLAGS}"
 
 AC_MSG_CHECKING(for -ffunction-sections support)
 saved_CFLAGS="${CFLAGS}"
@@ -514,6 +663,16 @@ else
 fi
 AC_SUBST(AST_DECLARATION_AFTER_STATEMENT)
 
 fi
 AC_SUBST(AST_DECLARATION_AFTER_STATEMENT)
 
+AC_MSG_CHECKING(for _FORTIFY_SOURCE support)
+if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
+       AC_MSG_RESULT(yes)
+       AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2
+else
+       AC_MSG_RESULT(no)
+       AST_FORTIFY_SOURCE=
+fi
+AC_SUBST(AST_FORTIFY_SOURCE)
+
 AC_MSG_CHECKING(for -fno-strict-overflow)
 if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
        AC_MSG_RESULT(yes)
 AC_MSG_CHECKING(for -fno-strict-overflow)
 if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
        AC_MSG_RESULT(yes)
@@ -578,11 +737,32 @@ AC_LINK_IFELSE(
                AC_MSG_RESULT(yes)
                AC_DEFINE([HAVE_RES_NDESTROY], 1, [Define to 1 if your system has the ndestroy resolver function.]),
                AC_MSG_RESULT(no)
                AC_MSG_RESULT(yes)
                AC_DEFINE([HAVE_RES_NDESTROY], 1, [Define to 1 if your system has the ndestroy resolver function.]),
                AC_MSG_RESULT(no)
+       )
+       AC_SEARCH_LIBS(res_9_close, resolv)
+       AC_MSG_CHECKING(for res_close)
+       AC_LINK_IFELSE(
+               AC_LANG_PROGRAM([
+                               #ifdef HAVE_SYS_SOCKET_H
+                               #include <sys/socket.h>
+                               #endif
+                               #ifdef HAVE_NETINET_IN_H
+                               #include <netinet/in.h>
+                               #endif
+                               #ifdef HAVE_ARPA_NAMESER_H
+                               #include <arpa/nameser.h>
+                               #endif
+                               #include <resolv.h>],
+                               [res_close();]),
+               AC_MSG_RESULT(yes)
+               AC_DEFINE([HAVE_RES_CLOSE], 1, [Define to 1 if your system has the close resolver function.]),
+               AC_MSG_RESULT(no)
        ),
        AC_MSG_RESULT(no)
 )
 
        ),
        AC_MSG_RESULT(no)
 )
 
-AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
+AST_C_DEFINE_CHECK([GLOB_NOMAGIC], [GLOB_NOMAGIC], [glob.h])
+
+AST_C_DEFINE_CHECK([GLOB_BRACE], [GLOB_BRACE], [glob.h])
 
 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
 
 
 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
 
@@ -597,59 +777,17 @@ AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -l
 
 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
 
 
 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
 
-if test "x${host_os}" = "xlinux-gnu" ; then
+if test "x${OSARCH}" = "xlinux-gnu" ; then
   AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
 fi
 
 AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
 
   AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
 fi
 
 AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
 
-# BSD might not have exp2, and/or log2
-AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
-AST_EXT_LIB_CHECK([LOG2L], [m], [log2l])
-AST_EXT_LIB_CHECK([EXP10L], [m], [exp10l])
-AST_EXT_LIB_CHECK([LOG10L], [m], [log10l])
-AST_EXT_LIB_CHECK([SINL], [m], [sinl])
-AST_EXT_LIB_CHECK([COSL], [m], [cosl])
-AST_EXT_LIB_CHECK([TANL], [m], [tanl])
-AST_EXT_LIB_CHECK([ASINL], [m], [asinl])
-AST_EXT_LIB_CHECK([ACOSL], [m], [acosl])
-AST_EXT_LIB_CHECK([ATANL], [m], [atanl])
-AST_EXT_LIB_CHECK([ATAN2L], [m], [atan2l])
-AST_EXT_LIB_CHECK([POWL], [m], [powl])
-AST_EXT_LIB_CHECK([SQRTL], [m], [sqrtl])
-AST_EXT_LIB_CHECK([RINTL], [m], [rintl])
-AST_EXT_LIB_CHECK([EXPL], [m], [expl])
-AST_EXT_LIB_CHECK([LOGL], [m], [logl])
-AST_EXT_LIB_CHECK([REMAINDERL], [m], [remainderl])
-AST_EXT_LIB_CHECK([FMODL], [m], [fmodl])
-AST_EXT_LIB_CHECK([ROUNDL], [m], [roundl])
-AST_EXT_LIB_CHECK([TRUNCL], [m], [truncl])
-AST_EXT_LIB_CHECK([STRTOLD], [c], [strtold], [stdlib.h])
-AST_EXT_LIB_CHECK([FLOORL], [m], [floorl])
-AST_EXT_LIB_CHECK([CEILL], [m], [ceill])
-AST_EXT_LIB_CHECK([EXP2], [m], [exp2])
-AST_EXT_LIB_CHECK([LOG2], [m], [log2])
-AST_EXT_LIB_CHECK([EXP10], [m], [exp10])
-AST_EXT_LIB_CHECK([LOG10], [m], [log10])
-AST_EXT_LIB_CHECK([SIN], [m], [sin])
-AST_EXT_LIB_CHECK([COS], [m], [cos])
-AST_EXT_LIB_CHECK([TAN], [m], [tan])
-AST_EXT_LIB_CHECK([ASIN], [m], [asin])
-AST_EXT_LIB_CHECK([ACOS], [m], [acos])
-AST_EXT_LIB_CHECK([ATAN], [m], [atan])
-AST_EXT_LIB_CHECK([ATAN2], [m], [atan2])
-AST_EXT_LIB_CHECK([POW], [m], [pow])
-AST_EXT_LIB_CHECK([SQRT], [m], [sqrt])
-AST_EXT_LIB_CHECK([RINT], [m], [rint])
-AST_EXT_LIB_CHECK([EXP], [m], [exp])
-AST_EXT_LIB_CHECK([LOG], [m], [log])
-AST_EXT_LIB_CHECK([REMAINDER], [m], [remainder])
-AST_EXT_LIB_CHECK([FMOD], [m], [fmod])
-AST_EXT_LIB_CHECK([ROUND], [m], [round])
-AST_EXT_LIB_CHECK([TRUNC], [m], [trunc])
-AST_EXT_LIB_CHECK([STRTOD], [c], [strtod], [stdlib.h])
-AST_EXT_LIB_CHECK([FLOOR], [m], [floor])
-AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
+AST_C_DEFINE_CHECK([DAHDI_HALF_FULL], [DAHDI_POLICY_HALF_FULL], [dahdi/user.h])
+
+AST_C_COMPILE_CHECK([DAHDI_LINEREVERSE_VMWI], [struct dahdi_vmwi_info booger], [dahdi/user.h], , [enhanced dahdi vmwi support])
+
+AST_C_COMPILE_CHECK([DAHDI_ECHOCANCEL_FAX_MODE], [int foo = DAHDI_ECHOCANCEL_FAX_MODE], [dahdi/user.h])
 
 AST_C_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h], , [getifaddrs() support])
 AST_C_COMPILE_CHECK([TIMERFD], [timerfd_create(0,0); timerfd_settime(0,0,NULL,NULL);], [sys/timerfd.h], , [timerfd support])
 
 AST_C_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h], , [getifaddrs() support])
 AST_C_COMPILE_CHECK([TIMERFD], [timerfd_create(0,0); timerfd_settime(0,0,NULL,NULL);], [sys/timerfd.h], , [timerfd support])
@@ -720,11 +858,11 @@ if test "${USE_GSM}" != "no"; then
    fi
 fi
 
    fi
 fi
 
-if test "${host_os}" != "linux-gnu" ; then
-  AST_EXT_LIB_CHECK([ICONV], [iconv], [iconv_open], [iconv.h])
-else
-  PBX_ICONV=1
-fi
+AST_EXT_LIB_CHECK([ICONV], [iconv], [iconv_open], [iconv.h])
+# Some versions of Linux package iconv in glibc
+AST_EXT_LIB_CHECK([ICONV], [c], [iconv_close], [iconv.h])
+
+AST_EXT_LIB_CHECK([ICAL], [ical], [icaltimezone_new], [libical/ical.h], [-lpthread])
 
 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
 
 
 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
 
@@ -1252,6 +1390,8 @@ fi
 
 AST_EXT_LIB_CHECK([IODBC], [iodbc], [SQLConnect], [sql.h], [-lpthread])
 
 
 AST_EXT_LIB_CHECK([IODBC], [iodbc], [SQLConnect], [sql.h], [-lpthread])
 
+AST_EXT_LIB_CHECK([INOTIFY], [c], [inotify_init], [sys/inotify.h])
+
 AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
 
 # Needed by unixodbc
 AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
 
 # Needed by unixodbc
@@ -1269,7 +1409,7 @@ AC_ARG_ENABLE([xmldoc],
        esac], [disable_xmldoc=no])
 
 if test "${disable_xmldoc}" != "yes"; then
        esac], [disable_xmldoc=no])
 
 if test "${disable_xmldoc}" != "yes"; then
-       AST_EXT_TOOL_CHECK([LIBXML2], [xml2], , ,
+       AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , ,
        [#include <libxml/tree.h>
        #include <libxml/parser.h>],
        [LIBXML_TEST_VERSION])
        [#include <libxml/tree.h>
        #include <libxml/parser.h>],
        [LIBXML_TEST_VERSION])
@@ -1289,13 +1429,18 @@ if test "${PBX_MISDN}" = 1; then
    AST_C_DEFINE_CHECK([MISDN_FAC_RESULT], [Fac_RESULT], [mISDNuser/suppserv.h])
    AST_C_DEFINE_CHECK([MISDN_FAC_ERROR], [Fac_ERROR], [mISDNuser/suppserv.h])
    AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
    AST_C_DEFINE_CHECK([MISDN_FAC_RESULT], [Fac_RESULT], [mISDNuser/suppserv.h])
    AST_C_DEFINE_CHECK([MISDN_FAC_ERROR], [Fac_ERROR], [mISDNuser/suppserv.h])
    AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
+   AC_CHECK_MEMBER([Q931_info_t.redirect_dn], [], [PBX_MISDN=0], [#include <mISDNuser/mISDNlib.h>])
 fi
 
 fi
 
+AST_EXT_TOOL_CHECK([MYSQLCLIENT], [mysql_config])
+
 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
 
 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
 
 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
 
 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
 
-AST_EXT_TOOL_CHECK([NETSNMP], [net-snmp], , [--agent-libs],
+AST_EXT_TOOL_CHECK([NEON], [neon-config])
+
+AST_EXT_TOOL_CHECK([NETSNMP], [net-snmp-config], , [--agent-libs],
 [#include <net-snmp/net-snmp-config.h>
 #include <net-snmp/net-snmp-includes.h>
 #include <net-snmp/agent/net-snmp-agent-includes.h>],
 [#include <net-snmp/net-snmp-config.h>
 #include <net-snmp/net-snmp-includes.h>
 #include <net-snmp/agent/net-snmp-agent-includes.h>],
@@ -1305,12 +1450,6 @@ AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
 
 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
 
 
 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
 
-PBX_ODBC=0
-if test "$PBX_IODBC" = "1" -o "$PBX_UNIXODBC" = "1"; then
-   PBX_ODBC=1
-fi
-AC_SUBST(PBX_ODBC)
-
 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
 
 # Non-glibc platforms require libexecinfo for backtrace support
 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
 
 # Non-glibc platforms require libexecinfo for backtrace support
@@ -1318,6 +1457,8 @@ AST_EXT_LIB_CHECK([BKTR], [execinfo], [backtrace], [execinfo.h])
 # Linux, however, has backtrace directly in glibc
 AST_EXT_LIB_CHECK([BKTR], [c], [backtrace], [execinfo.h])
 
 # Linux, however, has backtrace directly in glibc
 AST_EXT_LIB_CHECK([BKTR], [c], [backtrace], [execinfo.h])
 
+AST_EXT_LIB_CHECK([BLUETOOTH], [bluetooth], [ba2str], [bluetooth/bluetooth.h])
+
 # possible places for oss definitions
 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
 # possible places for oss definitions
 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
@@ -1373,11 +1514,20 @@ AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
 
 AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
 
 
 AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
 
-AST_EXT_LIB_CHECK([PRI], [pri], [pri_new_bri], [libpri.h])
+AST_EXT_LIB_CHECK([PRI], [pri], [pri_connected_line_update], [libpri.h])
+AST_EXT_LIB_CHECK([PRI_SUBADDR], [pri], [pri_sr_set_called_subaddress], [libpri.h])
+AST_EXT_LIB_CHECK([PRI_CALL_HOLD], [pri], [pri_hold_enable], [libpri.h])
+AST_EXT_LIB_CHECK([PRI_CALL_REROUTING], [pri], [pri_reroute_enable], [libpri.h])
+AST_EXT_LIB_CHECK([PRI_SETUP_KEYPAD], [pri], [pri_sr_set_keypad_digits], [libpri.h])
 
 
+# ------------------------------------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.
 AST_EXT_LIB_CHECK([PRI_PROG_W_CAUSE], [pri], [pri_progress_with_cause], [libpri.h])
 AST_EXT_LIB_CHECK([PRI_PROG_W_CAUSE], [pri], [pri_progress_with_cause], [libpri.h])
-
 AST_EXT_LIB_CHECK([PRI_INBANDDISCONNECT], [pri], [pri_set_inbanddisconnect], [libpri.h])
 AST_EXT_LIB_CHECK([PRI_INBANDDISCONNECT], [pri], [pri_set_inbanddisconnect], [libpri.h])
+AST_EXT_LIB_CHECK([PRI_SERVICE_MESSAGES], [pri], [pri_maintenance_service], [libpri.h])
+AST_EXT_LIB_CHECK([PRI_REVERSE_CHARGE], [pri], [pri_sr_set_reversecharge], [libpri.h])
+# ------------------------------------^
 
 AST_EXT_LIB_CHECK([RESAMPLE], [resample], [resample_open], [libresample.h], [-lm])
 
 
 AST_EXT_LIB_CHECK([RESAMPLE], [resample], [resample_open], [libresample.h], [-lm])
 
@@ -1402,12 +1552,14 @@ fi
 
 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_pollflags], [libss7.h])
 
 
 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_pollflags], [libss7.h])
 
+AST_EXT_LIB_CHECK([OPENR2], [openr2], [openr2_chan_new], [openr2.h])
+
 if test "${USE_PWLIB}" != "no"; then
        if test -n "${PWLIB_DIR}"; then
                PWLIBDIR="${PWLIB_DIR}"
        fi
        AST_CHECK_PWLIB()
 if test "${USE_PWLIB}" != "no"; then
        if test -n "${PWLIB_DIR}"; then
                PWLIBDIR="${PWLIB_DIR}"
        fi
        AST_CHECK_PWLIB()
-       AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2])
+       AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2], [P[[WT]]LIB_VERSION])
                
        if test "${HAS_PWLIB:-unset}" != "unset"; then
                AST_CHECK_PWLIB_PLATFORM()
                
        if test "${HAS_PWLIB:-unset}" != "unset"; then
                AST_CHECK_PWLIB_PLATFORM()
@@ -1417,7 +1569,7 @@ if test "${USE_PWLIB}" != "no"; then
                AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
                        [Define if your system has the PWLib libraries.],
                        [#include "ptlib.h"],
                AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
                        [Define if your system has the PWLib libraries.],
                        [#include "ptlib.h"],
-                       [BOOL q = PTime::IsDaylightSavings();])
+                       [int q = (int) PTime::IsDaylightSavings();])
        fi
 fi
 
        fi
 fi
 
@@ -1438,7 +1590,13 @@ if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
                [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
 fi
 
                [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
 fi
 
-AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h]) 
+AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h], [-lm]) 
+if test "x${PBX_LUA}" = "x1" ; then
+       AC_DEFINE_UNQUOTED([LUA51_PREFIX], [1], [Define to 1 if lua is found with a lua5.1 prefix])
+fi
+       
+# Some distributions (like SuSE) remove the 5.1 suffix.
+AST_EXT_LIB_CHECK([LUA], [lua], [luaL_register], [lua.h], [-lm]) 
 
 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
 
 
 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
 
@@ -1496,10 +1654,10 @@ fi
 
 if test "$PBX_OPENSSL" = "1";
 then
 
 if test "$PBX_OPENSSL" = "1";
 then
-    AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
+    AST_CHECK_OSPTK([3], [6], [0])
 fi
 
 fi
 
-AST_EXT_TOOL_CHECK([GMIME], [gmime], [], [], [#include <gmime/gmime.h>], [gboolean q = g_mime_check_version(0,0,0);])
+AST_EXT_TOOL_CHECK([GMIME], [gmime-config], [], [], [#include <gmime/gmime.h>], [gboolean q = g_mime_check_version(0,0,0);])
 
 AST_EXT_LIB_CHECK([HOARD], [hoard], [malloc], [])
 
 
 AST_EXT_LIB_CHECK([HOARD], [hoard], [malloc], [])
 
@@ -1509,7 +1667,9 @@ AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
 
 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
 
 
 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
 
-if test "${host_os}" != "linux-gnu" ; then
+AC_CHECK_LIB([tonezone], [tone_zone_find_by_num], tonezone_does_not_need_lm=yes, tonezone_does_not_need_lm=no)
+
+if test "${tonezone_does_not_need_lm}" = "no" ; then
   tonezone_extra="-lm"
 fi
 
   tonezone_extra="-lm"
 fi
 
@@ -1580,10 +1740,24 @@ elif test "x$CURSES_LIB" != "x" ; then
 elif test "x$NCURSES_LIB" != "x" ; then
   EDITLINE_LIB="$NCURSES_LIB"
 else
 elif test "x$NCURSES_LIB" != "x" ; then
   EDITLINE_LIB="$NCURSES_LIB"
 else
-  AC_MSG_ERROR(*** termcap support not found)
+  AC_MSG_ERROR([*** termcap support not found (on modern systems, this typically means the ncurses development package is missing)])
 fi
 AC_SUBST(EDITLINE_LIB)
 
 fi
 AC_SUBST(EDITLINE_LIB)
 
+if test "x${PBX_UNIXODBC}" = "x1" -o "x${PBX_IODBC}" = "x1"; then
+       # Does ODBC support wide characters?
+       AC_MSG_CHECKING(whether ODBC has support for Unicode types)
+       AC_LINK_IFELSE(
+               AC_LANG_PROGRAM(
+                       [#include <sql.h>
+#include <sqlext.h>],
+                       [int foo = SQL_WCHAR]),
+               AC_MSG_RESULT(yes)
+                       AC_DEFINE([HAVE_ODBC_WCHAR], [1], [Define to 1 if your ODBC library has wide (Unicode) types.]),
+               AC_MSG_RESULT(no)
+       )
+fi
+
 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
 AC_SUBST(PBX_H323)
 
 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
 AC_SUBST(PBX_H323)
 
@@ -1598,7 +1772,11 @@ AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
                                   ])
 AC_SUBST(PBX_IXJUSER)
 
                                   ])
 AC_SUBST(PBX_IXJUSER)
 
-AST_EXT_TOOL_CHECK([SDL], [sdl])
+# Used in res/res_pktccops
+AST_C_DEFINE_CHECK([MSG_NOSIGNAL], [MSG_NOSIGNAL], [sys/socket.h])
+AST_C_DEFINE_CHECK([SO_NOSIGPIPE], [SO_NOSIGPIPE], [sys/socket.h])
+
+AST_EXT_TOOL_CHECK([SDL], [sdl-config])
 AST_EXT_LIB_CHECK([SDL_IMAGE], [SDL_image], [IMG_Load], [SDL_image.h], [${SDL_LIB}], [${SDL_INCLUDE}])
 AST_EXT_LIB_CHECK([FFMPEG], [avcodec], [sws_getContext], [ffmpeg/avcodec.h], [-lpthread -lz -lm])
 
 AST_EXT_LIB_CHECK([SDL_IMAGE], [SDL_image], [IMG_Load], [SDL_image.h], [${SDL_LIB}], [${SDL_INCLUDE}])
 AST_EXT_LIB_CHECK([FFMPEG], [avcodec], [sws_getContext], [ffmpeg/avcodec.h], [-lpthread -lz -lm])
 
@@ -1616,7 +1794,7 @@ then
 fi
 
 PBX_GTK=0
 fi
 
 PBX_GTK=0
-AST_EXT_TOOL_CHECK([GTK], [gtk], [--cflags gthread], [--libs gthread])
+AST_EXT_TOOL_CHECK([GTK], [gtk-config], [--cflags gthread], [--libs gthread])
 
 PBX_GTK2=0
 AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
 
 PBX_GTK2=0
 AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
@@ -1630,38 +1808,47 @@ AC_SUBST(PBX_GTK2)
 AC_SUBST(GTK2_INCLUDE)
 AC_SUBST(GTK2_LIB)
 
 AC_SUBST(GTK2_INCLUDE)
 AC_SUBST(GTK2_LIB)
 
-if test "${USE_CURL}" != "no"; then
-   AC_PATH_TOOL([CURL_CONFIG], [curl-config], No)
-   if test ! x"${CURL_CONFIG}" = xNo; then
-   # check for version
-      if test $(printf "%d" 0x$(${CURL_CONFIG} --vernum)) -ge $(printf "%d" 0x070907); then
-         CURL_INCLUDE=$(${CURL_CONFIG} --cflags)
-         CURL_LIB=$(${CURL_CONFIG} --libs)
-
-         AC_MSG_CHECKING(for curl_version() in curl/curl.h)
-         saved_cppflags="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${CURL_INCLUDE}"
-         AC_COMPILE_IFELSE(
-            [AC_LANG_PROGRAM(
-                [#include <curl/curl.h>],
-                    [curl_version();])
-            ],[
-                AC_MSG_RESULT(yes)
-                ac_cv_curl_h="yes"
-            ],[
-                AC_MSG_RESULT(no)
-                ac_cv_curl_h="no"
-            ]
-        )
-        CPPFLAGS="${saved_cppflags}"
-         if test "${ac_cv_curl_h}" = "yes"; then
-             PBX_CURL=1
-             AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
-         fi
-      fi
-   fi
+AST_LIBCURL_CHECK_CONFIG([], [7.10.1])
+
+# build a GENERIC_ODBC result based on the presence of either UnixODBC (preferred)
+# or iODBC
+
+PBX_GENERIC_ODBC=0
+
+if test "${PBX_UNIXODBC}" = 1; then
+   PBX_GENERIC_ODBC=1
+   GENERIC_ODBC_LIB="${UNIXODBC_LIB}"
+   GENERIC_ODBC_INCLUDE="${UNIXODBC_INCLUDE}"
+elif test "${PBX_IODBC}" = 1; then
+   PBX_GENERIC_ODBC=1
+   GENERIC_ODBC_LIB="${IODBC_LIB}"
+   GENERIC_ODBC_INCLUDE="${IODBC_INCLUDE}"
 fi
 
 fi
 
+AC_SUBST([GENERIC_ODBC_LIB])
+AC_SUBST([GENERIC_ODBC_INCLUDE])
+AC_SUBST([PBX_GENERIC_ODBC])
+
+PBX_SYSLOG=0
+
+if test "${ac_cv_header_syslog_h}" = "yes"; then
+   # syslog facilities
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_AUTH],     [LOG_AUTH],     [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_AUTHPRIV], [LOG_AUTHPRIV], [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_CRON],     [LOG_CRON],     [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_DAEMON],   [LOG_DAEMON],   [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_FTP],      [LOG_FTP],      [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_KERN],     [LOG_KERN],     [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_LPR],      [LOG_LPR],      [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_MAIL],     [LOG_MAIL],     [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_NEWS],     [LOG_NEWS],     [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_SYSLOG],   [LOG_SYSLOG],   [syslog.h])
+   AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_UUCP],     [LOG_UUCP],     [syslog.h])
+   PBX_SYSLOG=1
+fi
+
+AC_SUBST([PBX_SYSLOG])
+
 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
 AST_CHECK_MANDATORY
 
 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
 AST_CHECK_MANDATORY