Fix a typo
[asterisk/asterisk.git] / configure.ac
index bcc3bbb..498bf69 100644 (file)
@@ -8,7 +8,7 @@
 
 AC_PREREQ(2.60)
 
-AC_INIT(asterisk, 1.4, www.asterisk.org)
+AC_INIT(asterisk, 1.6, www.asterisk.org)
 
 # cross-compile macros
 AC_CANONICAL_BUILD
@@ -150,7 +150,6 @@ if test "x$with_gnu_ld" = "xyes" ; then
 fi
 AC_SUBST(GNU_LD)
 
-AC_PATH_PROG([AWK], [awk], :)
 AC_PATH_PROG([GREP], [grep], :)
 AC_PATH_PROG([FIND], [find], :)
 AC_PATH_PROG([COMPRESS], [compress], :)
@@ -208,14 +207,17 @@ 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([CRYPTO], [OpenSSL Cryptography support], [crypto])
+AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec library], [avcodec])
 AST_EXT_LIB_SETUP([GSM], [External GSM library], [gsm], [, use 'internal' GSM otherwise])
 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([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([ISDNNET], [ISDN4Linux Library], [isdnnet])
 AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
+AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
 AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
 AST_EXT_LIB_SETUP([MISDN], [mISDN User Library], [misdn])
@@ -235,6 +237,8 @@ AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7])
 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([SDL], [Sdl], [sdl])
+AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image library], [SDL_image])
 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
 AST_EXT_LIB_SETUP([SPEEXDSP], [Speexdsp], [speexdsp])
 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
@@ -251,15 +255,6 @@ AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
 AST_EXT_LIB_SETUP([X11], [X11 support], [x11])
 AST_EXT_LIB_SETUP([ZLIB], [zlib], [z])
 AST_EXT_LIB_SETUP([ZAPTEL], [Zaptel], [zaptel])
-AST_EXT_LIB_SETUP([ZAPTEL_TRANSCODE], [Zaptel Transcoder Support], [zaptel_transcode])
-AST_EXT_LIB_SETUP([ZAPTEL_VLDTMF], [Zaptel VLDTMF Support], [zaptel_vldtmf])
-AST_EXT_LIB_SETUP([ZAPTEL_HWGAIN], [Zaptel Hardware Gain Support], [zaptel_hwgain])
-AST_EXT_LIB_SETUP([ZAPTEL_ECHOCANPARAMS], [Zaptel Echo Canceler Parameter Support], [zaptel_echocanparams])
-AST_EXT_LIB_SETUP([ZAPTEL_CHANALARMS], [Zaptel Channel Alarm Support], [zaptel_chanalarms])
-
-AST_EXT_LIB_SETUP([SDL], [Sdl], [sdl])
-AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image library], [SDL_image])
-AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec library], [avcodec])
 
 # check for basic system features and functionality before
 # checking for package libraries
@@ -301,7 +296,6 @@ AC_PROG_GCC_TRADITIONAL
 # AC_FUNC_MALLOC
 # AC_FUNC_REALLOC
 AC_FUNC_MEMCMP
-AC_FUNC_MKTIME
 AC_FUNC_MMAP
 AC_FUNC_SELECT_ARGTYPES
 AC_FUNC_SETVBUF_REVERSED
@@ -414,20 +408,20 @@ AC_MSG_RESULT(no)
 
 AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
 
-if test "${cross_compiling}" = "no";
-then
-AC_MSG_CHECKING(for working epoll support)
-AC_LINK_IFELSE(
-AC_LANG_PROGRAM([#include <sys/epoll.h>], [int res = epoll_create(10);
-                                         if (res < 0)
-                                            return 1;
-                                         close (res);
-                                         return 0;]),
-AC_MSG_RESULT(yes)
-AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]),
-AC_MSG_RESULT(no)
-)
-fi
+#if test "${cross_compiling}" = "no";
+#then
+#AC_MSG_CHECKING(for working epoll support)
+#AC_LINK_IFELSE(
+#AC_LANG_PROGRAM([#include <sys/epoll.h>], [int res = epoll_create(10);
+#                                        if (res < 0)
+#                                           return 1;
+#                                        close (res);
+#                                        return 0;]),
+#AC_MSG_RESULT(yes)
+#AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]),
+#AC_MSG_RESULT(no)
+#)
+#fi
 
 AC_MSG_CHECKING(for compiler atomic operations)
 AC_LINK_IFELSE(
@@ -477,6 +471,15 @@ else
 fi
 AC_SUBST(AST_DECLARATION_AFTER_STATEMENT)
 
+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)
+   AST_NO_STRICT_OVERFLOW=-fno-strict-overflow
+else
+       AC_MSG_RESULT(no)
+       AST_NO_STRICT_OVERFLOW=
+fi
+AC_SUBST(AST_NO_STRICT_OVERFLOW)
 
 AC_MSG_CHECKING(for sysinfo)
 AC_LINK_IFELSE(
@@ -571,6 +574,8 @@ 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_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h])
+
 GSM_INTERNAL="yes"
 AC_SUBST(GSM_INTERNAL)
 GSM_SYSTEM="yes"
@@ -646,167 +651,525 @@ fi
 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
 
 if test "${USE_IMAP_TK}" != "no"; then
-   if test "${IMAP_TK_DIR}" = "system" ; then
-      AC_MSG_NOTICE([Checking for system c-client library...])
-   elif test "${IMAP_TK_DIR}" = ""; then
-      IMAP_TK_DIR=`pwd`"/../imap-2004g"
-      if test  -n "${IMAP_TK_MANDATORY}"; then
-        AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
-        AC_MSG_NOTICE([c-client library/header files. Since you did not provide a path])
-        AC_MSG_NOTICE([the configure script will assume you have placed built the c-client])
-        AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
-      fi
-   fi
-   if test "${IMAP_TK_DIR}" != "system" ; then
-      AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
-   fi
-   saved_cppflags="${CPPFLAGS}"
-   saved_libs="${LIBS}"
-   if test "${IMAP_TK_DIR}" = "system" ; then
-      imap_ldflags=""
-      imap_libs="-lc-client"
-      imap_include="-DUSE_SYSTEM_IMAP"
-   elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
-      imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
-      imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
-      imap_include="-I${IMAP_TK_DIR}/c-client"
-   fi
-   CPPFLAGS="${CPPFLAGS} ${imap_include}"
-   LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
-   AC_LINK_IFELSE(
-       AC_LANG_PROGRAM(
-               [#ifdef USE_SYSTEM_IMAP
-               #include <imap/c-client.h>
-               #else
-               #include "c-client.h"
-               #endif
-               void mm_searched (MAILSTREAM *stream,unsigned long number)
-               {
-               }
-               void mm_exists (MAILSTREAM *stream,unsigned long number)
-               {
-               }
-               void mm_expunged (MAILSTREAM *stream,unsigned long number)
-               {
-               }
-               void mm_flags (MAILSTREAM *stream,unsigned long number)
-               {
-               }
-               void mm_notify (MAILSTREAM *stream,char *string,long errflg)
-               {
-               }
-               void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
-               {
-               }
-               void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
-               {
-               }
-               void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
-               {
-               }
-               void mm_log (char *string,long errflg)
-               {
-               }
-               void mm_dlog (char *string)
-               {
-               }
-               void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
-               {
-               }
-               void mm_critical (MAILSTREAM *stream)
-               {
-               }
-               void mm_nocritical (MAILSTREAM *stream)
-               {
-               }
-               long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
-               {
-               }
-               void mm_fatal (char *string)
-               {
-               }],
-               [
-               MAILSTREAM *foo = mail_open(NULL, "", 0);
-               ]
-       ),
-       [ac_cv_imap_tk="yes"],
-       [ac_cv_imap_tk="no"]
-   )
-   if test "${ac_cv_imap_tk}" = "yes"; then
-   AC_LINK_IFELSE(
-      AC_LANG_PROGRAM(
-         [#ifdef USE_SYSTEM_IMAP
-        #include <imap/c-client.h>
-        #else
-        #include "c-client.h"
-        #endif
-         void mm_searched (MAILSTREAM *stream,unsigned long number)
-         {
-         }
-         void mm_exists (MAILSTREAM *stream,unsigned long number)
-         {
-         }
-         void mm_expunged (MAILSTREAM *stream,unsigned long number)
-         {
-         }
-         void mm_flags (MAILSTREAM *stream,unsigned long number)
-         {
-         }
-         void mm_notify (MAILSTREAM *stream,char *string,long errflg)
-         {
-         }
-         void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
-         {
-         }
-         void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
-         {
-         }
-         void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
-         {
-         }
-         void mm_log (char *string,long errflg)
-         {
-         }
-         void mm_dlog (char *string)
-         {
-         }
-         void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
-         {
-         }
-         void mm_critical (MAILSTREAM *stream)
-         {
-         }
-         void mm_nocritical (MAILSTREAM *stream)
-         {
-         }
-         long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
-         {
-         }
-         void mm_fatal (char *string)
-         {
-         }],
-         [
-         long check = mail_expunge_full(NULL, "", 0);
-         ]
-      ),
-      [ac_cv_imap_tk2006="yes"],
-      [ac_cv_imap_tk2006="no"]
-  )
-  fi
-   CPPFLAGS="${saved_cppflags}"
-   LIBS="${saved_libs}"
-   if test "${ac_cv_imap_tk}" = "yes"; then
-      AC_MSG_RESULT(yes) 
-      IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
-      IMAP_TK_INCLUDE="${imap_include}"
-      PBX_IMAP_TK=1
-      AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
-      if test "${ac_cv_imap_tk2006}" = "yes"; then
-         AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
-      fi
-   else
-      AC_MSG_RESULT(no) 
-   fi
+       saved_cppflags="${CPPFLAGS}"
+       saved_libs="${LIBS}"
+       switch_to_system_on_failure="no"
+       if test "${IMAP_TK_DIR}" = ""; then
+               IMAP_TK_DIR=`pwd`"/../imap-2004g"
+               switch_to_system_on_failure="yes"
+       fi
+       if test "${IMAP_TK_DIR}" != "system"; then
+               AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
+               if test -f "${IMAP_TK_DIR}/c-client/LDFLAGS"; then
+               imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
+               fi
+               imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
+               imap_include="-I${IMAP_TK_DIR}/c-client"
+       CPPFLAGS="${CPPFLAGS} ${imap_include}"
+               LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
+               AC_LINK_IFELSE(
+               AC_LANG_PROGRAM(
+                               [#include "c-client.h"
+                               void mm_searched (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_exists (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_flags (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                               {
+                               }
+                               void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                               {
+                               }
+                               void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                               {
+                               }
+                               void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                               {
+                               }
+                               void mm_log (char *string,long errflg)
+                               {
+                               }
+                               void mm_dlog (char *string)
+                               {
+                               }
+                               void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                               {
+                               }
+                               void mm_critical (MAILSTREAM *stream)
+                               {
+                               }
+                               void mm_nocritical (MAILSTREAM *stream)
+                               {
+                               }
+                               long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                               {
+                               }
+                               void mm_fatal (char *string)
+                               {
+                               }],
+                               [
+                               MAILSTREAM *foo = mail_open(NULL, "", 0);
+                               ]
+                       ),
+                       [ac_cv_imap_tk="yes"],
+                       [ac_cv_imap_tk="no"]
+               )
+               if test "${ac_cv_imap_tk}" = "yes"; then
+                       AC_LINK_IFELSE(
+                               AC_LANG_PROGRAM(
+                                       [#include "c-client.h"
+                                       void mm_searched (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_exists (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_flags (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                                       {
+                                       }
+                                       void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                       {
+                                       }
+                                       void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                       {
+                                       }
+                                       void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                                       {
+                                       }
+                                       void mm_log (char *string,long errflg)
+                                       {
+                                       }
+                                       void mm_dlog (char *string)
+                                       {
+                                       }
+                                       void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                                       {
+                                       }
+                                       void mm_critical (MAILSTREAM *stream)
+                                       {
+                                       }
+                                       void mm_nocritical (MAILSTREAM *stream)
+                                       {
+                                       }
+                                       long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                                       {
+                                       }
+                                       void mm_fatal (char *string)
+                                       {
+                                       }],
+                                       [
+                                       long check = mail_expunge_full(NULL, "", 0);
+                                       ]
+                               ),
+                               [ac_cv_imap_tk2006="yes"],
+                               [ac_cv_imap_tk2006="no"]
+                       )
+               fi
+               CPPFLAGS="${saved_cppflags}"
+               LIBS="${saved_libs}"
+               if test "${ac_cv_imap_tk}" = "no"; then
+                       AC_MSG_RESULT(no)
+                       if test "${switch_to_system_on_failure}" = "yes"; then
+                               IMAP_TK_DIR="system"
+                       else #This means they specified a directory. Search for a package installation there too
+                               AC_MSG_CHECKING([for system c-client library...])
+                               CPPFLAGS="${saved_cppflags}"
+                               LIBS="${saved_libs}"
+                               imap_include="-I${IMAP_TK_DIR}/include"
+                               imap_ldflags="-L${IMAP_TK_DIR}/lib"
+                               imap_libs="-lc-client"
+                               CPPFLAGS="${CPPFLAGS} ${imap_include}"
+                               LIBS="${LIBS} ${imap_libs} ${imap_ldflags}"
+                               AC_LINK_IFELSE(
+                               AC_LANG_PROGRAM(
+                                               [#include "c-client.h"
+                                               void mm_searched (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_exists (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_flags (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                                               {
+                                               }
+                                               void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                               {
+                                               }
+                                               void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                               {
+                                               }
+                                               void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                                               {
+                                               }
+                                               void mm_log (char *string,long errflg)
+                                               {
+                                               }
+                                               void mm_dlog (char *string)
+                                               {
+                                               }
+                                               void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                                               {
+                                               }
+                                               void mm_critical (MAILSTREAM *stream)
+                                               {
+                                               }
+                                               void mm_nocritical (MAILSTREAM *stream)
+                                               {
+                                               }
+                                               long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                                               {
+                                               }
+                                               void mm_fatal (char *string)
+                                               {
+                                               }],
+                                               [
+                                               MAILSTREAM *foo = mail_open(NULL, "", 0);
+                                               ]
+                                       ),
+                                       [ac_cv_imap_tk="yes"],
+                                       [ac_cv_imap_tk="no"]
+                               )
+                               if test "${ac_cv_imap_tk}" = "yes"; then
+                                       AC_LINK_IFELSE(
+                                               AC_LANG_PROGRAM(
+                                                       [#include "c-client.h"
+                                                       void mm_searched (MAILSTREAM *stream,unsigned long number)
+                                                       {
+                                                       }
+                                                       void mm_exists (MAILSTREAM *stream,unsigned long number)
+                                                       {
+                                                       }
+                                                       void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                                                       {
+                                                       }
+                                                       void mm_flags (MAILSTREAM *stream,unsigned long number)
+                                                       {
+                                                       }
+                                                       void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                                                       {
+                                                       }
+                                                       void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                                       {
+                                                       }
+                                                       void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                                       {
+                                                       }
+                                                       void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                                                       {
+                                                       }
+                                                       void mm_log (char *string,long errflg)
+                                                       {
+                                                       }
+                                                       void mm_dlog (char *string)
+                                                       {
+                                                       }
+                                                       void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                                                       {
+                                                       }
+                                                       void mm_critical (MAILSTREAM *stream)
+                                                       {
+                                                       }
+                                                       void mm_nocritical (MAILSTREAM *stream)
+                                                       {
+                                                       }
+                                                       long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                                                       {
+                                                       }
+                                                       void mm_fatal (char *string)
+                                                       {
+                                                       }],
+                                                       [
+                                                       long check = mail_expunge_full(NULL, "", 0);
+                                                       ]
+                                               ),
+                                               [ac_cv_imap_tk2006="yes"],
+                                               [ac_cv_imap_tk2006="no"]
+                                       )
+                               fi
+                       fi
+               fi
+       fi 
+       if test "${IMAP_TK_DIR}" = "system"; then
+               #We will enter here if user specified "system" or if any of above checks failed
+               AC_MSG_CHECKING([for system c-client library...])
+               CPPFLAGS="${saved_cppflags}"
+               LIBS="${saved_libs}"
+               imap_ldflags=""
+               imap_libs="-lc-client"
+               imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first
+               CPPFLAGS="${CPPFLAGS} ${imap_include}"
+               LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
+               AC_LINK_IFELSE(
+               AC_LANG_PROGRAM(
+                               [#include <stdio.h>
+                               #include <imap/c-client.h>
+                               void mm_searched (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_exists (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_flags (MAILSTREAM *stream,unsigned long number)
+                               {
+                               }
+                               void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                               {
+                               }
+                               void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                               {
+                               }
+                               void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                               {
+                               }
+                               void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                               {
+                               }
+                               void mm_log (char *string,long errflg)
+                               {
+                               }
+                               void mm_dlog (char *string)
+                               {
+                               }
+                               void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                               {
+                               }
+                               void mm_critical (MAILSTREAM *stream)
+                               {
+                               }
+                               void mm_nocritical (MAILSTREAM *stream)
+                               {
+                               }
+                               long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                               {
+                               }
+                               void mm_fatal (char *string)
+                               {
+                               }],
+                               [
+                               MAILSTREAM *foo = mail_open(NULL, "", 0);
+                               ]
+                       ),
+                       [ac_cv_imap_tk="yes"],
+                       [ac_cv_imap_tk="no"]
+               )
+               if test "${ac_cv_imap_tk}" = "yes"; then
+                       AC_LINK_IFELSE(
+                               AC_LANG_PROGRAM(
+                                       [#include <stdio.h>
+                                       #include <imap/c-client.h>
+                                       void mm_searched (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_exists (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_flags (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                                       {
+                                       }
+                                       void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                       {
+                                       }
+                                       void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                       {
+                                       }
+                                       void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                                       {
+                                       }
+                                       void mm_log (char *string,long errflg)
+                                       {
+                                       }
+                                       void mm_dlog (char *string)
+                                       {
+                                       }
+                                       void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                                       {
+                                       }
+                                       void mm_critical (MAILSTREAM *stream)
+                                       {
+                                       }
+                                       void mm_nocritical (MAILSTREAM *stream)
+                                       {
+                                       }
+                                       long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                                       {
+                                       }
+                                       void mm_fatal (char *string)
+                                       {
+                                       }],
+                                       [
+                                       long check = mail_expunge_full(NULL, "", 0);
+                                       ]
+                               ),
+                               [ac_cv_imap_tk2006="yes"],
+                               [ac_cv_imap_tk2006="no"]
+                       )
+               else #looking in imap directory didn't work, try c-client
+                       imap_ldflags=""
+                       imap_libs="-lc-client"
+                       imap_include="-DUSE_SYSTEM_CCLIENT"
+                       CPPFLAGS="${saved_cppflags}"
+                       LIBS="${saved_libs}"
+                       CPPFLAGS="${CPPFLAGS} ${imap_include}"
+                       LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
+                       AC_LINK_IFELSE(
+                       AC_LANG_PROGRAM(
+                                       [#include <stdio.h>
+                                       #include <c-client/c-client.h>
+                                       void mm_searched (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_exists (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_flags (MAILSTREAM *stream,unsigned long number)
+                                       {
+                                       }
+                                       void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                                       {
+                                       }
+                                       void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                       {
+                                       }
+                                       void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                       {
+                                       }
+                                       void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                                       {
+                                       }
+                                       void mm_log (char *string,long errflg)
+                                       {
+                                       }
+                                       void mm_dlog (char *string)
+                                       {
+                                       }
+                                       void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                                       {
+                                       }
+                                       void mm_critical (MAILSTREAM *stream)
+                                       {
+                                       }
+                                       void mm_nocritical (MAILSTREAM *stream)
+                                       {
+                                       }
+                                       long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                                       {
+                                       }
+                                       void mm_fatal (char *string)
+                                       {
+                                       }],
+                                       [
+                                       MAILSTREAM *foo = mail_open(NULL, "", 0);
+                                       ]
+                               ),
+                               [ac_cv_imap_tk="yes"],
+                               [ac_cv_imap_tk="no"]
+                       )
+                       if test "${ac_cv_imap_tk}" = "yes"; then
+                               AC_LINK_IFELSE(
+                                       AC_LANG_PROGRAM(
+                                               [#include <stdio.h>
+                                               #include <c-client/c-client.h>
+                                               void mm_searched (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_exists (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_expunged (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_flags (MAILSTREAM *stream,unsigned long number)
+                                               {
+                                               }
+                                               void mm_notify (MAILSTREAM *stream,char *string,long errflg)
+                                               {
+                                               }
+                                               void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                               {
+                                               }
+                                               void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
+                                               {
+                                               }
+                                               void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
+                                               {
+                                               }
+                                               void mm_log (char *string,long errflg)
+                                               {
+                                               }
+                                               void mm_dlog (char *string)
+                                               {
+                                               }
+                                               void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
+                                               {
+                                               }
+                                               void mm_critical (MAILSTREAM *stream)
+                                               {
+                                               }
+                                               void mm_nocritical (MAILSTREAM *stream)
+                                               {
+                                               }
+                                               long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
+                                               {
+                                               }
+                                               void mm_fatal (char *string)
+                                               {
+                                               }],
+                                               [
+                                               long check = mail_expunge_full(NULL, "", 0);
+                                               ]
+                                       ),
+                                       [ac_cv_imap_tk2006="yes"],
+                                       [ac_cv_imap_tk2006="no"]
+                               )
+                       fi
+               fi
+       fi
+       if test "${ac_cv_imap_tk}" = "yes"; then
+               AC_MSG_RESULT(yes)
+               IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
+               IMAP_TK_INCLUDE="${imap_include}"
+               PBX_IMAP_TK=1
+               AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
+               if test "${ac_cv_imap_tk2006}" = "yes"; then
+                       AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
+               fi
+       else
+               AC_MSG_RESULT(no) 
+       fi
+       CPPFLAGS="${saved_cppflags}"
+       LIBS="${saved_libs}"
 fi
 
 AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
@@ -814,6 +1177,8 @@ AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
 # Needed by unixodbc
 AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], [])
 
+AST_EXT_LIB_CHECK([LDAP], [ldap], [ldap_initialize], [ldap.h])
+
 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
 
 if test "${PBX_MISDN}" = 1; then
@@ -828,32 +1193,11 @@ AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
 
 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
 
-NETSNMP_CONFIG=No
-if test "${USE_NETSNMP}" != "no"; then
-   if test "x${NETSNMP_DIR}" != "x"; then
-      AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
-      if test x"${NETSNMP_CONFIG}" = xNo; then
-         AC_MSG_NOTICE([***])
-         AC_MSG_NOTICE([*** net-snmp-config was not found in the path you specified:])
-         AC_MSG_NOTICE([*** ${NETSNMP_DIR}/bin])
-         AC_MSG_NOTICE([*** Either correct the installation, or run configure])
-         AC_MSG_NOTICE([*** including --without-netsnmp])
-         exit 1
-      fi
-   else
-      AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
-   fi
-fi
-if test x"${NETSNMP_CONFIG}" != xNo; then
-   NETSNMP_libs=`${NETSNMP_CONFIG} --agent-libs`
-
-   AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
-   [Define to indicate the Net-SNMP library]), [], ${NETSNMP_LIBS})
-   if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
-      NETSNMP_LIB="${NETSNMP_libs}"
-      PBX_NETSNMP=1
-   fi
-fi
+AST_EXT_TOOL_CHECK([NETSNMP], [net-snmp], , [--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>],
+[int callback = snmp_register_callback(0, 0, NULL, NULL)])
 
 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
 
@@ -861,7 +1205,10 @@ AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
 
 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
 
+# Non-glibc platforms require libexecinfo for backtrace support
 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])
 
 # possible places for oss definitions
 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
@@ -984,6 +1331,8 @@ then
     AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
 fi
 
+AST_EXT_TOOL_CHECK([GMIME], [gmime])
+
 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
 if test "${PBX_FREETDS}" != "0";
 then
@@ -1086,6 +1435,9 @@ AST_C_DEFINE_CHECK([ZAPTEL_TRANSCODE], [ZT_TCOP_ALLOCATE], [zaptel/zaptel.h])
 # Check for hwgain support
 AST_C_DEFINE_CHECK([ZAPTEL_HWGAIN], [ZT_SET_HWGAIN], [zaptel/zaptel.h])
 
+# Check for neon mwi support
+AST_C_DEFINE_CHECK([ZAPTEL_NEONMWI], [ZT_EVENT_NEONMWI_ACTIVE], [zaptel/zaptel.h])
+
 # Check for channel alarm support
 AST_C_COMPILE_CHECK([ZAPTEL_CHANALARMS], [size_t foo = sizeof(struct zt_params_v1)], [zaptel/zaptel.h])
 
@@ -1141,6 +1493,11 @@ AC_CHECK_HEADER([linux/videodev.h],
 AST_EXT_LIB_CHECK([X11], [X11], [XOpenDisplay], [X11/Xlib.h],,, [standard_path])
 AST_EXT_LIB_CHECK([X11], [X11], [XOpenDisplay], [X11/Xlib.h],, [-I/usr/X11R6/include], [X11R6])
 
+if test "${cross_compiling}" = "no";
+then
+  AC_CHECK_FILE(/sbin/launchd, AC_DEFINE([HAVE_SBIN_LAUNCHD], 1, [Define to 1 if your system has /sbin/launchd.]))
+fi
+
 PBX_GTK=0
 AST_EXT_TOOL_CHECK([GTK], [gtk], [--cflags gthread], [--libs gthread])