Skip to content
Snippets Groups Projects
configure.ac 73.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • AST_C_DEFINE_CHECK([GLOB_BRACE], [GLOB_BRACE], [glob.h])
    
    
    AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
    
    
    AC_CHECK_HEADER([libkern/OSAtomic.h],
                    [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
    
    
    AC_CHECK_SIZEOF([int])
    AC_CHECK_SIZEOF([long])
    AC_CHECK_SIZEOF([long long])
    AC_CHECK_SIZEOF([char *])
    
    AC_CHECK_SIZEOF(long)
    AC_CHECK_SIZEOF(long long)
    AC_COMPUTE_INT([ac_cv_sizeof_fd_set_fds_bits], [sizeof(foo.fds_bits[[0]])], [$ac_includes_default
    fd_set foo;])
    # This doesn't actually work; what it does is to use the variable set in the
    # previous test as a cached value to set the right output variables.
    AC_CHECK_SIZEOF(fd_set.fds_bits)
    
    # Set a type compatible with the previous.  We cannot just use a generic type
    # for these bits, because on big-endian systems, the bits won't match up
    # correctly if the size is wrong.
    if test $ac_cv_sizeof_int = $ac_cv_sizeof_fd_set_fds_bits; then
      AC_DEFINE([TYPEOF_FD_SET_FDS_BITS], [int], [Define to a type of the same size as fd_set.fds_bits[[0]]])
    else if test $ac_cv_sizeof_long = $ac_cv_sizeof_fd_set_fds_bits; then
      AC_DEFINE([TYPEOF_FD_SET_FDS_BITS], [long], [Define to a type of the same size as fd_set.fds_bits[[0]]])
    else if test $ac_cv_sizeof_long_long = $ac_cv_sizeof_fd_set_fds_bits; then
      AC_DEFINE([TYPEOF_FD_SET_FDS_BITS], [long long], [Define to a type of the same size as fd_set.fds_bits[[0]]])
    fi ; fi ; fi
    
    
    AC_MSG_CHECKING(for dladdr in dlfcn.h)
    PBX_DLADDR=0
    old_LIBS=${LIBS}
    LIBS="${LIBS} -ldl"
    AC_LINK_IFELSE(
    	AC_LANG_PROGRAM([#define _GNU_SOURCE 1
    #include <dlfcn.h>],
    		[dladdr((void *)0, (void *)0)]
    	),
    	AC_MSG_RESULT(yes)
    	PBX_DLADDR=1
    	AC_SUBST([PBX_DLADDR])
    	AC_DEFINE([HAVE_DLADDR], 1, [Define to 1 if your system has the dladdr() GNU extension]),
    	AC_MSG_RESULT(no)
    )
    LIBS=${old_LIBS}
    
    
    # PKGCONFIG is used in later tests
    AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
    
    
    AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
    
    
    AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_openr], [bfd.h])
    
    
    AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
    
    
    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_RESET_COUNTERS], [dahdi/user.h], [230])
    AST_C_DEFINE_CHECK([DAHDI], [DAHDI_DEFAULT_MTU_MRU], [dahdi/user.h], [220])
    AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h], [200])
    
    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])
    
       if test "${GSM_DIR}" = "internal"; then
          GSM_SYSTEM="no"
       elif test "${GSM_DIR}" != ""; then
          GSM_INTERNAL="no"
       fi
    
          if test "x${GSM_DIR}" != "x"; then
    
             if test -d ${GSM_DIR}/lib; then
                gsmlibdir="-L${GSM_DIR}/lib"
             else
                gsmlibdir="-L${GSM_DIR}"
             fi
    
          AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
    
          [Define to indicate the GSM library]), [], ${gsmlibdir})
    
          if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
    
             if test "x${GSM_DIR}" != "x" ; then
                AC_CHECK_HEADER([${GSM_DIR}/include/gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
                AC_CHECK_HEADER([${GSM_DIR}/include/gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
             else
                AC_CHECK_HEADER([gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
                AC_CHECK_HEADER([gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
             fi
             if test "${GSM_HEADER_FOUND}" = "0" ; then
                if test "{GSM_GSM_HEADER_FOUND}" = "0" ; then
                   if test "x${GSM_MANDATORY}" = "xyes" ; then
                      AC_MSG_NOTICE([***])
                      AC_MSG_NOTICE([*** It appears that you do not have the gsm development package installed.])
                      AC_MSG_NOTICE([*** Please install it to include ${GSM_DESCRIP} support, or re-run configure])
                      AC_MSG_NOTICE([*** without explicitly specifying --with-${GSM_OPTION}])
                      exit 1
                   fi
                fi
             fi
             GSM_OK=0
             if test "${GSM_HEADER_FOUND}" = "1" ; then
                AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
                GSM_OK=1
             else
                if test "${GSM_GSM_HEADER_FOUND}" = "1" ; then
                   AC_DEFINE_UNQUOTED([HAVE_GSM_GSM_HEADER], 1, [Define to indicate that gsm.h is in gsm/gsm.h])
                   GSM_OK=1
                fi
             fi
             if test "${GSM_OK}" = "1" ; then
                GSM_LIB="-lgsm"
                if test "x${GSM_DIR}" != "x"; then
                   GSM_LIB="${gsmlibdir} ${GSM_LIB}"
                   GSM_INCLUDE="-I${GSM_DIR}/include"
                fi
                PBX_GSM=1
                GSM_INTERNAL="no"
             fi
    
          AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
    
    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])
    
    # If ical.h is NOT in the libical directory, then it is of a version insufficient for us.
    
    AST_EXT_LIB_CHECK([ICAL], [ical], [icaltimezone_get_utc_timezone], [libical/ical.h], [${PTHREAD_LIBS}], [${PTHREAD_CFLAGS}])
    
    AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
    
    	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
    
    			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 
    	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.])
    
    	CPPFLAGS="${saved_cppflags}"
    	LIBS="${saved_libs}"
    
    AST_EXT_LIB_CHECK([IODBC], [iodbc], [SQLConnect], [sql.h], [${PTHREAD_LIBS}], [${PTHREAD_CFLAGS}])
    
    AST_EXT_LIB_CHECK([INOTIFY], [c], [inotify_init], [sys/inotify.h])
    
    
    AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
    
    
    # BSD (and OS X) equivalent of inotify
    AST_EXT_LIB_CHECK([KQUEUE], [c], [kqueue], [sys/event.h])
    
    # 64-bit version of kevent (from kqueue) on OS X
    AC_CHECK_FUNCS([kevent64])
    
    
    # Needed by unixodbc
    AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], [])
    
    
    AST_EXT_LIB_CHECK([LDAP], [ldap], [ldap_initialize], [ldap.h])
    
    AC_ARG_ENABLE([xmldoc],
    	[AS_HELP_STRING([--disable-xmldoc],
    		[Explicity disable XML documentation])],
    	[case "${enableval}" in
    		y|ye|yes) disable_xmldoc=no ;;
    		n|no)  disable_xmldoc=yes ;;
    		*) AC_MSG_ERROR(bad value ${enableval} for --disable-xmldoc)  ;;
    	esac], [disable_xmldoc=no])
    
    if test "${disable_xmldoc}" != "yes"; then
    
    	AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , ,
    
    	[#include <libxml/tree.h>
    	#include <libxml/parser.h>],
    	[LIBXML_TEST_VERSION])
    	if test "${PBX_LIBXML2}" != 1; then
    		AC_MSG_NOTICE(*** XML documentation will not be available because the 'libxml2' development package is missing.)
    		AC_MSG_NOTICE(*** Please run the 'configure' script with the '--disable-xmldoc' parameter option)
    		AC_MSG_NOTICE(*** or install the 'libxml2' development package.)
    		exit 1
    	fi
    fi
    
    
    AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
    
    if test "${PBX_MISDN}" = 1; then
       AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
       AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
    
       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>])
    
    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_TOOL_CHECK([NEON], [neon-config])
    
    AST_EXT_TOOL_CHECK([NEON29], [neon-config], , [--libs],
    [#include <ne_auth.h>],
    [#ifndef NE_AUTH_NTLM
    #error Need libneon >= 0.29.0
    #endif])
    
    
    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>],
    [int callback = snmp_register_callback(0, 0, NULL, NULL)])
    
    AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
    
    
    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])
    
    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])
    AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
    
    if test "${USE_PGSQL}" != "no"; then	
       if test "x${PGSQL_DIR}" != "x"; then
          AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
    
             AC_MSG_NOTICE([***])
             AC_MSG_NOTICE([*** pg_config was not found in the path you specified:])
             AC_MSG_NOTICE([*** ${PGSQL_DIR}/bin])
             AC_MSG_NOTICE([*** Either correct the installation, or run configure])
             AC_MSG_NOTICE([*** including --without-postgres])
    
       PGSQL_libdir=`${PG_CONFIG} --libdir`
       PGSQL_includedir=`${PG_CONFIG} --includedir`
    
       if test "x$?" != "x0" ; then
          if test -n "${PGSQL_MANDATORY}" ; then
             AC_MSG_NOTICE([***])
             AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
             AC_MSG_NOTICE([*** Either correct the installation, or run configure])
             AC_MSG_NOTICE([*** including --without-postgres])
             exit 1
    	  fi
       else 
    
          AC_CHECK_LIB([pq], [PQescapeStringConn], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
    
          [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
    
    
          AC_MSG_CHECKING(for pg_encoding_to_char within Postgres headers)
          old_CFLAGS=${CFLAGS}
          CFLAGS="${CFLAGS} -I${PGSQL_includedir} -Werror"
          old_LDFLAGS=${LDFLAGS}
          LDFLAGS="${LDFLAGS} -L${PGSQL_libdir} -lpq -lz"
          AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libpq-fe.h>],
              [const char *foo = pg_encoding_to_char(1)])],
            [AC_MSG_RESULT(yes)
             AC_DEFINE_UNQUOTED([HAVE_PGSQL_pg_encoding_to_char], 1, [Define to indicate presence of the pg_encoding_to_char API.])],
            [AC_MSG_RESULT(no)])
          CFLAGS=${old_CFLAGS}
          LDFLAGS=${old_LDFLAGS}
    
    
          if test "${ac_cv_lib_pq_PQescapeStringConn}" = "yes"; then
    
             PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
             PGSQL_INCLUDE="-I${PGSQL_includedir}"
             PBX_PGSQL=1
          elif test -n "${PGSQL_MANDATORY}";
          then
             AC_MSG_NOTICE([***])
             AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
             AC_MSG_NOTICE([*** Either correct the installation, or run configure])
             AC_MSG_NOTICE([*** including --without-postgres])
             exit 1
          fi
    
    AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
    
    AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
    
    
    AST_EXT_LIB_CHECK([PRI], [pri], [pri_connected_line_update], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_MWI_V2], [pri], [pri_mwi_indicate_v2], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_DISPLAY_TEXT], [pri], [pri_display_text], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_MWI], [pri], [pri_mwi_indicate], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_MCID], [pri], [pri_mcid_enable], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_CALL_WAITING], [pri], [pri_connect_ack_enable], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_AOC_EVENTS], [pri], [pri_aoc_events_enable], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_TRANSFER], [pri], [pri_transfer_enable], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_CCSS], [pri], [pri_cc_enable], [libpri.h])
    
    AST_EXT_LIB_CHECK([PRI_HANGUP_FIX], [pri], [pri_hangup_fix_enable], [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_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_C_COMPILE_CHECK([SPANDSP], [
    		#if SPANDSP_RELEASE_DATE < 20080516
    		#error "spandsp 0.0.5 or greater is required"
    		#endif
    
    	], [spandsp/version.h], , [minimum version of SpanDSP])
    
    if test "x${PBX_SPANDSP}" = "x1" ; then
    	# We found the correct version in the header, now let's make sure it links
    	# properly, and that libtiff is available
    	PBX_SPANDSP=0
    	AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [span_set_message_handler], [spandsp.h], [-ltiff])
    fi
    
    
    if test "x${PBX_SPANDSP}" = "x1" ; then
    	# We also need t38_terminal_init()
    	PBX_SPANDSP=0
    	AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [t38_terminal_init], [spandsp.h], [-ltiff])
    fi
    
    
    AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_pollflags], [libss7.h])
    
    AST_EXT_LIB_CHECK([OPENR2], [openr2], [openr2_chan_new], [openr2.h])
    
    
    	if test -n "${PWLIB_DIR}"; then
    
    		PWLIBDIR="${PWLIB_DIR}"
    	fi
    	AST_CHECK_PWLIB()
    
    	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()
    
    		PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r"
    
    		AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
    			[Define if your system has the PWLib libraries.],
    			[#include "ptlib.h"],
    
    			[int q = (int) PTime::IsDaylightSavings();])
    
    	fi
    fi
    
    if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
    
    	if test -n "${OPENH323_DIR}"; then
    
    		OPENH323DIR="${OPENH323_DIR}"
    	fi
    	AST_CHECK_OPENH323()
    
    	AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3], [], [1], [19], [0])
    
    	AST_CHECK_OPENH323_BUILD()
    	PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
    	AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],
    		[Define if your system has the OpenH323 libraries.],
    		[#include "ptlib.h"
    		#include "h323.h"
    		#include "h323ep.h"],
    		[H323EndPoint ep = H323EndPoint();],
    		[${PWLIB_INCLUDE}], [${PWLIB_LIB}])
    fi
    
    
    AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h], [-lm]) 
    
    	if test x"${LUA_DIR}" = x; then
    		LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua5.1"
    	else
    		LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua5.1"
    	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])
    
    
    # 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
    # that was found as 'AIS'.
    
    PBX_AIS=0
    
    # OpenAIS installs its libraries into /usr/lib/openais by default, so check there
    
    
    AST_EXT_LIB_CHECK([OPENAIS], [SaClm], [saClmInitialize], [openais/saClm.h], [-L/usr/lib/openais -L/usr/lib64/openais])
    
    
    if test "${PBX_OPENAIS}" = 1; then
       PBX_AIS=1
       if test -n "${OPENAIS_DIR}"; then
          AIS_INCLUDE="${OPENAIS_INCLUDE}/openais"
          AIS_LIB="-lSaEvt ${OPENAIS_LIB}"
       else
          AIS_INCLUDE="-I/usr/include/openais"
    
          AIS_LIB="-lSaClm -lSaEvt -L/usr/lib/openais -L/usr/lib64/openais"
    
    AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
    
    
    # See if the main speex library contains the preprocess functions
    
    AST_EXT_LIB_CHECK([SPEEX_PREPROCESS], [speex], [speex_preprocess_ctl], [speex/speex.h], [-lm])
    
    if test "${PBX_SPEEX_PREPROCESS}" = 1; then
       PBX_SPEEX_PREPROCESS=1
    fi
    
    
    AST_EXT_LIB_CHECK([SPEEXDSP], [speexdsp], [speex_preprocess_ctl], [speex/speex.h], [-lm])
    
    if test "${PBX_SPEEXDSP}" = 1; then
       PBX_SPEEX_PREPROCESS=1
    fi
    
    AC_SUBST(PBX_SPEEX_PREPROCESS)
    
    AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
    
    
    AST_EXT_LIB_CHECK([SQLITE3], [sqlite3], [sqlite3_open], [sqlite3.h], [${PTHREAD_LIBS}], [${PTHREAD_CFLAGS}])
    
    AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h])
    
    
    Kevin P. Fleming's avatar
    Kevin P. Fleming committed
    if test "$PBX_CRYPTO" = "1";
    
    	AST_EXT_LIB_CHECK([OPENSSL], [ssl], [SSL_connect], [openssl/ssl.h], [-lcrypto])
    
    Kevin P. Fleming's avatar
    Kevin P. Fleming committed
    if test "$PBX_OPENSSL" = "1";
    then
    
        AST_CHECK_OSPTK([3], [6], [0])
    
    AST_EXT_LIB_CHECK([SRTP], [srtp], [srtp_init], [srtp/srtp.h])
    
    
    if test "$PBX_SRTP" = "1";
    then
        saved_libs="${LIBS}"
        saved_ldflags="${LDFLAGS}"
    
        saved_cflags="${CFLAGS}"
        LIBS="${LIBS} ${SRTP_LIB}"
    
        LDFLAGS="${LDFLAGS} -shared -fPIC"
    
        CFLAGS="${CFLAGS} ${SRTP_INCLUDE}"
    
        AC_MSG_CHECKING(for the ability of -lsrtp to be linked in a shared object)
        AC_LINK_IFELSE(
        [
            AC_LANG_PROGRAM(
                [#include <srtp/srtp.h>],
                [srtp_init();]
            )
        ],
        [ AC_MSG_RESULT(yes) ],
        [