Skip to content
Snippets Groups Projects
configure.ac 60.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • # Process this file with autoconf to produce a configure script.
    
    #
    # Make sure we use autoconf 2.60 to generate the "configure" script,
    # in case we want to commit it. Other than that, version 2.59 is
    # perfectly fine for our purposes, so people who want to modify
    # this file just have to remember to set the AC_PREREQ argument
    # to something that suits their needs.
    
    AC_INIT(asterisk, 1.6, www.asterisk.org)
    
    
    # cross-compile macros
    AC_CANONICAL_BUILD
    AC_CANONICAL_HOST
    
    # check existence of the package
    
    AC_CONFIG_SRCDIR([main/asterisk.c])
    
    AC_CONFIG_AUX_DIR(`pwd`)
    
    
    AC_COPYRIGHT("Asterisk")
    AC_REVISION($Revision$)
    
    
    # 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
    
    
         CPPFLAGS=-I/usr/local/include
         LDFLAGS=-L/usr/local/lib
    
         openbsd*)
         ac_default_prefix=/usr/local
         if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then
            if test ${sysconfdir} = '${prefix}/etc'; then
               sysconfdir=/etc
            fi
            if test ${mandir} = '${prefix}/man'; then
               mandir=/usr/share/man
            fi
         fi
         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.])
         ;;
    
         if test ${prefix} = '/usr' || test ${prefix} = 'NONE'; then
    
            if test ${sysconfdir} = '${prefix}/etc'; then
               sysconfdir=/etc
            fi
            if test ${mandir} = '${prefix}/man'; then
               mandir=/usr/share/man
            fi
    
    if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then
         if test ${localstatedir} = '${prefix}/var'; then
            localstatedir=/var
         fi
    
    BUILD_PLATFORM=${build}
    BUILD_CPU=${build_cpu}
    BUILD_VENDOR=${build_vendor}
    BUILD_OS=${build_os}
    
    AC_SUBST(BUILD_PLATFORM)
    AC_SUBST(BUILD_CPU)
    AC_SUBST(BUILD_VENDOR)
    AC_SUBST(BUILD_OS)
    
    HOST_PLATFORM=${host}
    HOST_CPU=${host_cpu}
    HOST_VENDOR=${host_vendor}
    HOST_OS=${host_os}
    
    AC_SUBST(HOST_PLATFORM)
    AC_SUBST(HOST_CPU)
    AC_SUBST(HOST_VENDOR)
    AC_SUBST(HOST_OS)
    
         netbsd*)
         OSARCH=NetBSD
         ;;
    
    Jason Parker's avatar
    Jason Parker committed
         openbsd*)
         OSARCH=OpenBSD
         ;;
    
         solaris*)
         OSARCH=SunOS
         ;;
    
         OSARCH=${host_os}
    
    #  check for uname
    AC_PATH_TOOL([UNAME], [uname], No)
    if test ! x"${UNAME}" = xNo; then
       PBX_OSREV=$(${UNAME} -r)
    fi
    AC_SUBST(PBX_OSREV)
    
    AH_TOP(
    
    #ifndef ASTERISK_AUTOCONFIG_H
    #define ASTERISK_AUTOCONFIG_H
    
    
    if test "${cross_compiling}" = "yes"; 
    
    then
       AC_CHECK_TOOL(CC, gcc, :)
       AC_CHECK_TOOL(CXX, g++, :)
    
       AC_CHECK_TOOL(RANLIB, ranlib, :)
    fi
    
    # Checks for programs.
    AC_PROG_CC
    AC_PROG_CXX
    AC_PROG_CPP
    AC_PROG_CXXCPP
    
    # This macro is just copied into our local acinclude.m4 from libtool.m4 so that
    # the developers regenerating the configure script don't have to install libtool.
    
    AST_PROG_LD	# note, does not work on FreeBSD
    
    AC_PROG_AWK
    AC_PROG_INSTALL
    AC_PROG_LN_S
    AC_PROG_RANLIB
    AST_CHECK_GNU_MAKE
    
    
    AC_CHECK_TOOLS([STRIP], [strip gstrip], :)
    AC_CHECK_TOOLS([AR], [ar gar], :)
    
    GNU_LD=0
    if test "x$with_gnu_ld" = "xyes" ; then
       GNU_LD=1
    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([BASENAME], [basename], :)
    AC_PATH_PROG([DIRNAME], [dirname], :)
    AC_PATH_PROG([SHELL], [sh], :)
    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([CATDVI], [catdvi], :)
    
    AC_PATH_PROG([KPATHSEA], [kpsewhich], :)
    
    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
    
    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
    
    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.])
    fi
    
    
    AC_CHECK_PROGS([MD5], [md5 md5sum gmd5sum digest])
    
    if test "${MD5}" = "digest" ; then
       MD5="${MD5} -a md5"   
    fi
    
    
    AC_ARG_ENABLE([dev-mode],
    	[AS_HELP_STRING([--enable-dev-mode],
    		[Turn on developer mode])],
    
    	[case "${enableval}" in
    	      y|ye|yes) AST_DEVMODE=yes ;;
    	      n|no)  AST_DEVMODE=no ;;
    
    	      *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
    	esac])
    
    # AST_EXT_LIB_SETUP is used to tell configure to handle variables for
    # various packages.
    # $1 is the prefix for the variables in makeopts and autoconfig.h
    # $2 is the short comment, $4 is the long comment
    # $3 is the name used in --with- or --without- flags for configure.
    #
    # Package option names should be in alphabetical order
    
    # by the --with option name (the third field),
    # to make things easier for the users.
    
    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], [execinfo])
    AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [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([CRYPTO], [OpenSSL Cryptography], [crypto])
    
    AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
    
    AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec], [avcodec])
    AST_EXT_LIB_SETUP([GSM], [External GSM], [gsm], [, use 'internal' GSM otherwise])
    AST_EXT_LIB_SETUP([GTK2], [gtk2], [gtk2])
    AST_EXT_LIB_SETUP([GMIME], [GMime], [gmime])
    
    AST_EXT_LIB_SETUP([HOARD], [Hoard Memory Allocator], [hoard])
    
    AST_EXT_LIB_SETUP([ICAL], [iCal], [ical])
    AST_EXT_LIB_SETUP([ICONV], [Iconv], [iconv])
    AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber], [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], [isdnnet])
    
    AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
    
    AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
    
    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], [misdn])
    AST_EXT_LIB_SETUP([MYSQLCLIENT], [MySQL client], [mysqlclient])
    
    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([OSPTK], [OSP Toolkit], [osptk])
    AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
    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_DEPENDENT([PRI_CCSS], [ISDN PRI call completion supplementary service], [PRI], [pri])
    
    AST_EXT_LIB_SETUP_DEPENDENT([PRI_HANGUP_FIX], [ISDN PRI hangup fix], [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([OPENR2], [MFR2], [openr2])
    
    AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
    
    AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
    
    Sean Bright's avatar
    Sean Bright committed
    AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
    
    AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image], [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_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([OPENSSL], [OpenSSL Secure Sockets Layer], [ssl])
    
    AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
    AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap])
    AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
    AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
    
    AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [unixodbc])
    
    AST_EXT_LIB_SETUP([USB], [usb], [usb])
    
    AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
    
    AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
    
    AST_EXT_LIB_SETUP([X11], [X11], [x11])
    AST_EXT_LIB_SETUP([ZLIB], [zlib compression], [z])
    
    AST_EXT_LIB_SETUP([TIMERFD], [timerfd], [timerfd])
    
    # check for basic system features and functionality before
    # checking for package libraries
    
    AC_FUNC_ALLOCA
    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 sys/io.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_HEADER_STDBOOL
    AC_C_CONST
    AC_TYPE_UID_T
    AC_C_INLINE
    
    AC_TYPE_MODE_T
    AC_TYPE_OFF_T
    AC_TYPE_PID_T
    AC_TYPE_SIZE_T
    AC_CHECK_MEMBERS([struct stat.st_blksize])
    AC_HEADER_TIME
    AC_STRUCT_TM
    AC_C_VOLATILE
    AC_CHECK_TYPES([ptrdiff_t])
    
    # Checks for library functions.
    AC_FUNC_CHOWN
    AC_FUNC_CLOSEDIR_VOID
    AC_FUNC_ERROR_AT_LINE
    
    # XXX: these are commented out until we determine whether it matters if our malloc()
    # acts exactly like glibc's or not
    # AC_FUNC_MALLOC
    # AC_FUNC_REALLOC
    
    AC_FUNC_MEMCMP
    AC_FUNC_MMAP
    AC_FUNC_SELECT_ARGTYPES
    AC_FUNC_SETVBUF_REVERSED
    AC_TYPE_SIGNAL
    AC_FUNC_STAT
    AC_FUNC_STRCOLL
    AC_FUNC_STRFTIME
    AC_FUNC_STRNLEN
    AC_FUNC_STRTOD
    AC_FUNC_UTIME_NULL
    AC_FUNC_VPRINTF
    
    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])
    
    # 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_LINK_IFELSE(
    	AC_LANG_PROGRAM([#include <sys/time.h>],
    		[struct timeval *a; timersub(a, a, a);]),
    	AC_MSG_RESULT(yes)
    		AC_DEFINE([HAVE_TIMERSUB], 1, [Define to 1 if your system defines timersub.]),
    	AC_MSG_RESULT(no)
    )
    
    
    AC_CHECK_HEADER([sys/poll.h], 
       [HAS_POLL=1]
       AC_DEFINE([HAVE_SYS_POLL_H], 1, [Define to 1 if your system has working sys/poll.h]),
       )
    
    AC_ARG_ENABLE([internal-poll],
    	[AS_HELP_STRING([--enable-internal-poll],
    		[Use Asterisk's poll implementation])],
    
    	[case "${enableval}" in
    		y|ye|yes) HAS_POLL="";;
    		n|no) HAS_POLL="${HAS_POLL}" ;;
    		*) AC_MSG_ERROR(bad value ${enableval} for --enable-internal-poll) ;;
    	esac])
    
    # https support (in main/http.c) uses funopen on BSD systems,
    # fopencookie on linux
    AC_CHECK_FUNCS([funopen fopencookie])
    
    
    # check if we have IP_PKTINFO constant defined
    
    AC_LINK_IFELSE(
    		AC_LANG_PROGRAM([#include <netinet/in.h>],
    						[int pi = IP_PKTINFO;]),
    		AC_MSG_RESULT(yes)
    		AC_DEFINE([HAVE_PKTINFO], 1, [Define to 1 if your system defines IP_PKTINFO.]),
    		AC_MSG_RESULT(no)
    )
    
    
    # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
    
    AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])
    
    
    AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
    AC_LINK_IFELSE(
    
            AC_LANG_PROGRAM([#include <stdlib.h>
                             #include <netdb.h>],
    
                            [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);]),
            AC_MSG_RESULT(yes)
            AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
            AC_MSG_RESULT(no)
    )
    
    AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
    AC_LINK_IFELSE(
    
            AC_LANG_PROGRAM([#include <stdlib.h>
    	                 #include <netdb.h>],
    
                            [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);]),
            AC_MSG_RESULT(yes)
            AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
            AC_MSG_RESULT(no)
    )
    
    AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])])
    
    AC_MSG_CHECKING(for __swap16 variant of <sys/endian.h> byteswapping macros)
    AC_LINK_IFELSE(
    AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = __swap16(a);]),
    AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_SYS_ENDIAN_SWAP16], 1, [Define to 1 if your sys/endian.h header file provides the __swap16 macro.]),
    AC_MSG_RESULT(no)
    )
    
    AC_MSG_CHECKING(for bswap16 variant of <sys/endian.h> byteswapping macros)
    AC_LINK_IFELSE(
    AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = bswap16(a);]),
    AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_SYS_ENDIAN_BSWAP16], 1, [Define to 1 if your sys/endian.h header file provides the bswap16 macro.]),
    AC_MSG_RESULT(no)
    )
    
    
    if test "${cross_compiling}" = "no";
    then
      AC_CHECK_FILE(/dev/urandom, AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define to 1 if your system has /dev/urandom.]))
    fi
    
    AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_INITIALIZER], [PTHREAD_RWLOCK_INITIALIZER], [pthread.h])
    
    
    AC_MSG_CHECKING(for PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h)
    AC_LINK_IFELSE(
    AC_LANG_PROGRAM([#include <pthread.h>], [int a = PTHREAD_RWLOCK_PREFER_WRITER_NP;]),
    AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP], 1, [Define to 1 if your system defines PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h]),
    AC_MSG_RESULT(no)
    )
    
    AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE_NP in pthread.h)
    AC_LINK_IFELSE(
    AC_LANG_PROGRAM([#include <pthread.h>], [int a = PTHREAD_MUTEX_RECURSIVE_NP;]),
    AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1, [Define to 1 if your system defines PTHREAD_MUTEX_RECURSIVE_NP in pthread.h]),
    AC_MSG_RESULT(no)
    )
    
    
    AC_MSG_CHECKING(for pthread_rwlock_timedwrlock() in pthread.h)
    
    save_LIBS="$LIBS"
    save_CFLAGS="$CFLAGS"
    LIBS="$PTHREAD_LIBS $LIBS"
    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
    
    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])
    
    # Can we compare a mutex to its initial value?
    # Generally yes on OpenBSD/FreeBSD and no on Mac OS X.
    AC_MSG_CHECKING(whether we can compare a mutex to its initial value)
    AC_LINK_IFELSE(
    	AC_LANG_PROGRAM([#include <pthread.h>], [pthread_mutex_t lock;
    	if ((lock) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
    		return 0;
    	}
    	return 0]),
    	AC_MSG_RESULT(yes)
    	AC_DEFINE([CAN_COMPARE_MUTEX_TO_INIT_VALUE], 1, [Define to 1 if your system's implementation of mutexes supports comparison of a mutex to its initializer.]),
    	AC_MSG_RESULT(no)
    )
    
    
    #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(
    AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
    AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
    AC_MSG_RESULT(no)
    )
    
    
    # glibc, AFAIK, is the only C library that makes printing a NULL to a string safe.
    AC_MSG_CHECKING([if your system printf is NULL-safe.])
    AC_RUN_IFELSE(
    	AC_LANG_PROGRAM([#include <stdio.h>],
    		[printf("%s", NULL)]),
    	AC_DEFINE([HAVE_NULLSAFE_PRINTF], 1, [Define to 1 if your C library can safely print NULL to string formats.])
    	AC_MSG_RESULT(yes),
    	AC_MSG_RESULT(no),
    	# It's unlikely an embedded system will have this.
    	AC_MSG_RESULT(unknown)
    )
    
    
    AST_GCC_ATTRIBUTE(pure)
    AST_GCC_ATTRIBUTE(malloc)
    AST_GCC_ATTRIBUTE(const)
    AST_GCC_ATTRIBUTE(unused)
    AST_GCC_ATTRIBUTE(always_inline)
    
    AST_GCC_ATTRIBUTE(sentinel)
    
    AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static)
    
    AST_GCC_ATTRIBUTE(weak_import)
    
    AC_MSG_CHECKING(for -ffunction-sections support)
    
    saved_CFLAGS="${CFLAGS}"
    CFLAGS="${CFLAGS} -ffunction-sections"
    AC_COMPILE_IFELSE(
    	AC_LANG_PROGRAM([], [int x = 1;]),
    	AC_MSG_RESULT(yes)
    	[saved_LDFLAGS="${LDFLAGS}"]
    	[LDFLAGS="${LDFLAGS} -Wl,--gc-sections"]
    
    	AC_MSG_CHECKING(for --gc-sections support)
    
    	AC_LINK_IFELSE(
    		AC_LANG_PROGRAM([], [int x = 1;]),
    		AC_MSG_RESULT(yes)
    		[GC_CFLAGS="-ffunction-sections"]
    		[[GC_LDFLAGS="-Wl,--gc-sections"]],
    		AC_MSG_RESULT(no)
    	)
    	[LDFLAGS="${saved_LDFLAGS}"],
    	AC_MSG_RESULT(no)
    )
    CFLAGS="${saved_CFLAGS}"
    AC_SUBST(GC_CFLAGS)
    AC_SUBST(GC_LDFLAGS)
    
    
    AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
    if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
    	AC_MSG_RESULT(yes)
    	AST_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
    else
    	AC_MSG_RESULT(no)
    	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)
    	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 -Wshadow)
    if $(${CC} -Wshadow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
    	AC_MSG_RESULT(yes)
    	AST_SHADOW_WARNINGS=-Wshadow
    else
    	AC_MSG_RESULT(no)
    	AST_SHADOW_WARNINGS=
    fi
    AC_SUBST(AST_SHADOW_WARNINGS)
    
    
    AC_MSG_CHECKING(for sysinfo)
    AC_LINK_IFELSE(
            AC_LANG_PROGRAM([#include <sys/sysinfo.h>],
    
                            [struct sysinfo sys_info; int uptime = sys_info.uptime]),
    
            AC_MSG_RESULT(yes)
            AC_DEFINE([HAVE_SYSINFO], 1, [Define to 1 if your system has sysinfo support]),
            AC_MSG_RESULT(no)
    )
    
    
    AC_SEARCH_LIBS(res_9_ninit, resolv)
    
    	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>],
    
    			[int foo = res_ninit(NULL);]),
    	AC_MSG_RESULT(yes)
    
    	AC_DEFINE([HAVE_RES_NINIT], 1, [Define to 1 if your system has the re-entrant resolver functions.])
    
    	AC_SEARCH_LIBS(res_9_ndestroy, resolv)
    
    	AC_MSG_CHECKING(for res_ndestroy)
    	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_ndestroy(NULL);]),
    
    		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)
    
    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])
    
    
    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 *])
    
    AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
    
    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_CODE], [dahdi/user.h])
    
    
    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])
    
    AST_EXT_LIB_CHECK([ICAL], [ical], [icaltimezone_new], [ical.h], [${PTHREAD_LIBS}], [${PTHREAD_CFLAGS}])
    
    # Some distributions (like RedHat) add a libical subdirectory for the headers
    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)
    					{
    					}