instead of trying to forcibly load res_agi when app_stack is loaded (even if the...
[asterisk/asterisk.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 #
3 # Make sure we use autoconf 2.60 to generate the "configure" script,
4 # in case we want to commit it. Other than that, version 2.59 is
5 # perfectly fine for our purposes, so people who want to modify
6 # this file just have to remember to set the AC_PREREQ argument
7 # to something that suits their needs.
8
9 AC_PREREQ(2.60)
10
11 AC_INIT(asterisk, 1.6, www.asterisk.org)
12
13 # cross-compile macros
14 AC_CANONICAL_BUILD
15 AC_CANONICAL_HOST
16
17 # check existence of the package
18 AC_CONFIG_SRCDIR([main/asterisk.c])
19
20 # specify output header file
21 AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
22
23 AC_COPYRIGHT("Asterisk")
24 AC_REVISION($Revision$)
25
26 AC_GNU_SOURCE
27 AC_USE_SYSTEM_EXTENSIONS        # note- does not work on FreeBSD
28
29 case "${host_os}" in
30      freebsd*)
31      ac_default_prefix=/usr/local
32      CPPFLAGS=-I/usr/local/include
33      LDFLAGS=-L/usr/local/lib
34      ;;
35      openbsd*)
36      ac_default_prefix=/usr/local
37      if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then
38         if test ${sysconfdir} = '${prefix}/etc'; then
39            sysconfdir=/etc
40         fi
41         if test ${mandir} = '${prefix}/man'; then
42            mandir=/usr/share/man
43         fi
44      fi
45      CPPFLAGS=-I/usr/local/include
46      LDFLAGS=-L/usr/local/lib
47      ;;
48      *)
49      ac_default_prefix=/usr
50      if test ${prefix} = '/usr' || test ${prefix} = 'NONE'; then
51         if test ${sysconfdir} = '${prefix}/etc'; then
52            sysconfdir=/etc
53         fi
54         if test ${mandir} = '${prefix}/man'; then
55            mandir=/usr/share/man
56         fi
57      fi
58      ;;
59 esac
60
61 if test ${localstatedir} = '${prefix}/var'; then
62      localstatedir=/var
63 fi
64
65 BUILD_PLATFORM=${build}
66 BUILD_CPU=${build_cpu}
67 BUILD_VENDOR=${build_vendor}
68 BUILD_OS=${build_os}
69
70 AC_SUBST(BUILD_PLATFORM)
71 AC_SUBST(BUILD_CPU)
72 AC_SUBST(BUILD_VENDOR)
73 AC_SUBST(BUILD_OS)
74
75 HOST_PLATFORM=${host}
76 HOST_CPU=${host_cpu}
77 HOST_VENDOR=${host_vendor}
78 HOST_OS=${host_os}
79
80 AC_SUBST(HOST_PLATFORM)
81 AC_SUBST(HOST_CPU)
82 AC_SUBST(HOST_VENDOR)
83 AC_SUBST(HOST_OS)
84
85 WINARCH=0
86
87 case "${host_os}" in
88      freebsd*)
89      OSARCH=FreeBSD
90      ;;
91      netbsd*)
92      OSARCH=NetBSD
93      ;;
94      openbsd*)
95      OSARCH=OpenBSD
96      ;;
97      solaris*)
98      OSARCH=SunOS
99      ;;
100      mingw32)
101      OSARCH=mingw32
102      WINARCH=1
103      ;;
104      cygwin)
105      OSARCH=cygwin
106      WINARCH=1
107      ;;
108      *)
109      OSARCH=${host_os}
110      ;;
111 esac
112
113 AC_SUBST(OSARCH)
114 AC_SUBST(WINARCH)
115
116 #  check for uname
117 AC_PATH_TOOL([UNAME], [uname], No)
118 if test ! x"${UNAME}" = xNo; then
119    PBX_OSREV=$(${UNAME} -r)
120 fi
121 AC_SUBST(PBX_OSREV)
122
123 AH_TOP(
124 #ifndef ASTERISK_AUTOCONFIG_H
125 #define ASTERISK_AUTOCONFIG_H
126
127 #include "asterisk/buildopts.h"
128
129 )
130
131 AH_BOTTOM(
132 #endif
133 )
134
135 # cross-compile checks
136 if test "${cross_compiling}" = "yes"; 
137 then
138    AC_CHECK_TOOL(CC, gcc, :)
139    AC_CHECK_TOOL(CXX, g++, :)
140    AC_CHECK_TOOL(LD, ld, :)
141    AC_CHECK_TOOL(RANLIB, ranlib, :)
142 fi
143
144 # Checks for programs.
145 AC_PROG_CC
146 AC_PROG_CXX
147 AC_PROG_CPP
148 AC_PROG_CXXCPP
149 # This macro is just copied into our local acinclude.m4 from libtool.m4 so that
150 # the developers regenerating the configure script don't have to install libtool.
151 AST_PROG_LD     # note, does not work on FreeBSD
152 AC_PROG_AWK
153 AC_PROG_INSTALL
154 AC_PROG_LN_S
155 AC_PROG_RANLIB
156 AST_CHECK_GNU_MAKE
157
158 AC_PATH_TOOL([STRIP], [strip], :)
159 AC_PATH_TOOL([AR], [ar], :)
160
161 GNU_LD=0
162 if test "x$with_gnu_ld" = "xyes" ; then
163    GNU_LD=1
164 fi
165 AC_SUBST(GNU_LD)
166
167 AC_PATH_PROG([GREP], [grep], :)
168 AC_PATH_PROG([FIND], [find], :)
169 AC_PATH_PROG([COMPRESS], [compress], :)
170 AC_PATH_PROG([BASENAME], [basename], :)
171 AC_PATH_PROG([ID], [id], :)
172 AC_PATH_PROG([DIRNAME], [dirname], :)
173 AC_PATH_PROG([SHELL], [sh], :)
174 AC_PATH_PROG([LN], [ln], :)
175 AC_PATH_PROG([DOT], [dot], :)
176 AC_PATH_PROG([WGET], [wget], :)
177 AC_PATH_PROG([RUBBER], [rubber], :)
178 AC_PATH_PROG([KPATHSEA], [kpsewhich], :)
179 AC_PATH_PROG([XMLSTARLET], [xmlstarlet], :)
180 if test "${WGET}" != ":" ; then
181   DOWNLOAD=${WGET}
182 else
183   AC_PATH_PROG([FETCH], [fetch], [:])
184   DOWNLOAD=${FETCH}
185 fi
186 AC_SUBST(DOWNLOAD)
187
188 AC_CHECK_TOOL([SOXMIX], [soxmix], [:])
189 if test "${SOXMIX}" != ":" ; then
190         AC_DEFINE([HAVE_SOXMIX], 1, [Define to 1 if your system has soxmix application.])
191 fi
192
193 ACX_PTHREAD
194
195 AC_LANG(C)
196
197 AC_ARG_ENABLE([dev-mode],
198         [AS_HELP_STRING([--enable-dev-mode],
199                 [Turn on developer mode])],
200         [case "${enableval}" in
201               y|ye|yes) AST_DEVMODE=yes ;;
202               n|no)  AST_DEVMODE=no ;;
203               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
204         esac])
205 AC_SUBST(AST_DEVMODE)
206
207 # AST_EXT_LIB_SETUP is used to tell configure to handle variables for
208 # various packages.
209 # $1 is the prefix for the variables in makeopts and autoconfig.h
210 # $2 is the short comment, $4 is the long comment
211 # $3 is the name used in --with- or --without- flags for configure.
212 #
213 # Package option names should be in alphabetical order
214 # by the --with option name (the third field),
215 # to make things easier for the users.
216
217 AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
218
219 # BKTR is used for backtrace support on platforms that do not
220 # have it natively.
221 AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace support], [execinfo])
222 AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap])
223 AST_EXT_LIB_SETUP([CURL], [cURL], [curl])
224 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
225 AST_EXT_LIB_SETUP([CRYPTO], [OpenSSL Cryptography support], [crypto])
226 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
227 AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec library], [avcodec])
228 AST_EXT_LIB_SETUP([GSM], [External GSM library], [gsm], [, use 'internal' GSM otherwise])
229 AST_EXT_LIB_SETUP([GTK], [gtk libraries], [gtk])
230 AST_EXT_LIB_SETUP([GTK2], [gtk2 libraries], [gtk2])
231 AST_EXT_LIB_SETUP([GMIME], [GMime library], [gmime])
232 AST_EXT_LIB_SETUP([HOARD], [Hoard Memory Allocator], [hoard])
233 AST_EXT_LIB_SETUP([ICONV], [Iconv Library], [iconv])
234 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
235 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
236 AST_EXT_LIB_SETUP([IODBC], [iODBC], [iodbc])
237 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
238 AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
239 AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
240 AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2])
241 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
242 AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
243 AST_EXT_LIB_SETUP([MISDN], [mISDN User Library], [misdn])
244 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
245 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
246 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
247 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
248 AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
249 AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
250 AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
251 AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
252 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
253 AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
254 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
255 AST_EXT_LIB_SETUP([RESAMPLE], [LIBRESAMPLE], [resample])
256 AST_EXT_LIB_SETUP([SPANDSP], [SPANDSP], [spandsp])
257 AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7])
258 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
259 AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
260 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
261 AST_EXT_LIB_SETUP([SDL], [Sdl], [sdl])
262 AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image library], [SDL_image])
263 AST_EXT_LIB_SETUP([OPENAIS], [OpenAIS], [openais])
264 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
265 AST_EXT_LIB_SETUP([SPEEXDSP], [Speexdsp], [speexdsp])
266 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
267 AST_EXT_LIB_SETUP([SQLITE3], [SQLite], [sqlite3])
268 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
269 AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL Secure Sockets Layer support], [ssl])
270 AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
271 AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap])
272 AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
273 AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
274 AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [unixodbc])
275 AST_EXT_LIB_SETUP([USB], [usb], [usb])
276 AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
277 AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
278 AST_EXT_LIB_SETUP([X11], [X11 support], [x11])
279 AST_EXT_LIB_SETUP([ZLIB], [zlib], [z])
280
281 # check for basic system features and functionality before
282 # checking for package libraries
283
284 AC_FUNC_ALLOCA
285 AC_HEADER_DIRENT
286 AC_HEADER_STDC
287 AC_HEADER_SYS_WAIT
288 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])
289
290 AC_CHECK_HEADERS([winsock.h winsock2.h])
291
292 AC_SYS_LARGEFILE
293
294 # Checks for typedefs, structures, and compiler characteristics.
295 AC_HEADER_STDBOOL
296 AC_C_CONST
297 AC_TYPE_UID_T
298 AC_C_INLINE
299 AC_TYPE_MODE_T
300 AC_TYPE_OFF_T
301 AC_TYPE_PID_T
302 AC_TYPE_SIZE_T
303 AC_CHECK_MEMBERS([struct stat.st_blksize])
304 AC_HEADER_TIME
305 AC_STRUCT_TM
306 AC_C_VOLATILE
307 AC_CHECK_TYPES([ptrdiff_t])
308
309 # Checks for library functions.
310 AC_FUNC_CHOWN
311 AC_FUNC_CLOSEDIR_VOID
312 AC_FUNC_ERROR_AT_LINE
313 AST_FUNC_FORK
314 AC_FUNC_FSEEKO
315 AC_PROG_GCC_TRADITIONAL
316 # XXX: these are commented out until we determine whether it matters if our malloc()
317 # acts exactly like glibc's or not
318 # AC_FUNC_MALLOC
319 # AC_FUNC_REALLOC
320 AC_FUNC_MEMCMP
321 AC_FUNC_MMAP
322 AC_FUNC_SELECT_ARGTYPES
323 AC_FUNC_SETVBUF_REVERSED
324 AC_TYPE_SIGNAL
325 AC_FUNC_STAT
326 AC_FUNC_STRCOLL
327 AC_FUNC_STRFTIME
328 AC_FUNC_STRNLEN
329 AC_FUNC_STRTOD
330 AC_FUNC_UTIME_NULL
331 AC_FUNC_VPRINTF
332 AC_CHECK_FUNCS([asprintf atexit dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
333
334 AC_CHECK_FUNCS([glob])
335
336 AC_MSG_CHECKING(for timersub in time.h)
337 AC_LINK_IFELSE(
338         AC_LANG_PROGRAM([#include <sys/time.h>],
339                 [struct timeval *a; timersub(a, a, a);]),
340         AC_MSG_RESULT(yes)
341                 AC_DEFINE([HAVE_TIMERSUB], 1, [Define to 1 if your system defines timersub.]),
342         AC_MSG_RESULT(no)
343 )
344
345 AC_CHECK_HEADER([sys/poll.h], 
346    [HAS_POLL=1]
347    AC_DEFINE([HAVE_SYS_POLL_H], 1, [Define to 1 if your system has working sys/poll.h]),
348    )
349
350 AC_ARG_ENABLE([internal-poll],
351         [AS_HELP_STRING([--enable-internal-poll],
352                 [Use Asterisk's poll implementation])],
353         [case "${enableval}" in
354                 y|ye|yes) HAS_POLL="";;
355                 n|no) HAS_POLL="${HAS_POLL}" ;;
356                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-internal-poll) ;;
357         esac])
358 AC_SUBST(HAS_POLL)
359
360
361
362 # https support (in main/http.c) uses funopen on BSD systems,
363 # fopencookie on linux
364 AC_CHECK_FUNCS([funopen fopencookie])
365
366 AC_CHECK_FUNCS([inet_aton])
367
368 # check if we have IP_PKTINFO constant defined
369 AC_MSG_CHECKING(for IP_PKTINFO)
370 AC_LINK_IFELSE(
371                 AC_LANG_PROGRAM([#include <netinet/in.h>],
372                                                 [int pi = IP_PKTINFO;]),
373                 AC_MSG_RESULT(yes)
374                 AC_DEFINE([HAVE_PKTINFO], 1, [Define to 1 if your system defines IP_PKTINFO.]),
375                 AC_MSG_RESULT(no)
376 )
377
378 # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
379 AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])
380
381 AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
382 AC_LINK_IFELSE(
383         AC_LANG_PROGRAM([#include <stdlib.h>
384                          #include <netdb.h>],
385                         [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);]),
386         AC_MSG_RESULT(yes)
387         AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
388         AC_MSG_RESULT(no)
389 )
390
391 AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
392 AC_LINK_IFELSE(
393         AC_LANG_PROGRAM([#include <stdlib.h>
394                          #include <netdb.h>],
395                         [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);]),
396         AC_MSG_RESULT(yes)
397         AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
398         AC_MSG_RESULT(no)
399 )
400
401 AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])])
402
403 AC_MSG_CHECKING(for __swap16 variant of <sys/endian.h> byteswapping macros)
404 AC_LINK_IFELSE(
405 AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = __swap16(a);]),
406 AC_MSG_RESULT(yes)
407 AC_DEFINE([HAVE_SYS_ENDIAN_SWAP16], 1, [Define to 1 if your sys/endian.h header file provides the __swap16 macro.]),
408 AC_MSG_RESULT(no)
409 )
410
411 AC_MSG_CHECKING(for bswap16 variant of <sys/endian.h> byteswapping macros)
412 AC_LINK_IFELSE(
413 AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = bswap16(a);]),
414 AC_MSG_RESULT(yes)
415 AC_DEFINE([HAVE_SYS_ENDIAN_BSWAP16], 1, [Define to 1 if your sys/endian.h header file provides the bswap16 macro.]),
416 AC_MSG_RESULT(no)
417 )
418
419 if test "${cross_compiling}" = "no";
420 then
421   AC_CHECK_FILE(/dev/urandom, AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define to 1 if your system has /dev/urandom.]))
422 fi
423
424 AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_INITIALIZER], [PTHREAD_RWLOCK_INITIALIZER], [pthread.h])
425
426 AC_MSG_CHECKING(for PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h)
427 AC_LINK_IFELSE(
428 AC_LANG_PROGRAM([#include <pthread.h>], [int a = PTHREAD_RWLOCK_PREFER_WRITER_NP;]),
429 AC_MSG_RESULT(yes)
430 AC_DEFINE([HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP], 1, [Define to 1 if your system defines PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h]),
431 AC_MSG_RESULT(no)
432 )
433
434 AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE_NP in pthread.h)
435 AC_LINK_IFELSE(
436 AC_LANG_PROGRAM([#include <pthread.h>], [int a = PTHREAD_MUTEX_RECURSIVE_NP;]),
437 AC_MSG_RESULT(yes)
438 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1, [Define to 1 if your system defines PTHREAD_MUTEX_RECURSIVE_NP in pthread.h]),
439 AC_MSG_RESULT(no)
440 )
441
442 AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
443
444 #if test "${cross_compiling}" = "no";
445 #then
446 #AC_MSG_CHECKING(for working epoll support)
447 #AC_LINK_IFELSE(
448 #AC_LANG_PROGRAM([#include <sys/epoll.h>], [int res = epoll_create(10);
449 #                                         if (res < 0)
450 #                                            return 1;
451 #                                         close (res);
452 #                                         return 0;]),
453 #AC_MSG_RESULT(yes)
454 #AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]),
455 #AC_MSG_RESULT(no)
456 #)
457 #fi
458
459 AC_MSG_CHECKING(for compiler atomic operations)
460 AC_LINK_IFELSE(
461 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
462 AC_MSG_RESULT(yes)
463 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
464 AC_MSG_RESULT(no)
465 )
466
467 AST_GCC_ATTRIBUTE(pure)
468 AST_GCC_ATTRIBUTE(malloc)
469 AST_GCC_ATTRIBUTE(const)
470 AST_GCC_ATTRIBUTE(unused)
471 AST_GCC_ATTRIBUTE(always_inline)
472 AST_GCC_ATTRIBUTE(deprecated)
473 AST_GCC_ATTRIBUTE(sentinel)
474 AST_GCC_ATTRIBUTE(warn_unused_result)
475 AST_GCC_ATTRIBUTE(weak)
476
477 AC_MSG_CHECKING(for -ffunction-sections support)
478 saved_CFLAGS="${CFLAGS}"
479 CFLAGS="${CFLAGS} -ffunction-sections"
480 AC_COMPILE_IFELSE(
481         AC_LANG_PROGRAM([], [int x = 1;]),
482         AC_MSG_RESULT(yes)
483         [saved_LDFLAGS="${LDFLAGS}"]
484         [LDFLAGS="${LDFLAGS} -Wl,--gc-sections"]
485         AC_MSG_CHECKING(for --gc-sections support)
486         AC_LINK_IFELSE(
487                 AC_LANG_PROGRAM([], [int x = 1;]),
488                 AC_MSG_RESULT(yes)
489                 [GC_CFLAGS="-ffunction-sections"]
490                 [[GC_LDFLAGS="-Wl,--gc-sections"]],
491                 AC_MSG_RESULT(no)
492         )
493         [LDFLAGS="${saved_LDFLAGS}"],
494         AC_MSG_RESULT(no)
495 )
496 CFLAGS="${saved_CFLAGS}"
497 AC_SUBST(GC_CFLAGS)
498 AC_SUBST(GC_LDFLAGS)
499
500 AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
501 if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
502         AC_MSG_RESULT(yes)
503         AST_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
504 else
505         AC_MSG_RESULT(no)
506         AST_DECLARATION_AFTER_STATEMENT=
507 fi
508 AC_SUBST(AST_DECLARATION_AFTER_STATEMENT)
509
510 AC_MSG_CHECKING(for -fno-strict-overflow)
511 if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
512         AC_MSG_RESULT(yes)
513         AST_NO_STRICT_OVERFLOW=-fno-strict-overflow
514 else
515         AC_MSG_RESULT(no)
516         AST_NO_STRICT_OVERFLOW=
517 fi
518 AC_SUBST(AST_NO_STRICT_OVERFLOW)
519
520 AC_MSG_CHECKING(for -Wshadow)
521 if $(${CC} -Wshadow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
522         AC_MSG_RESULT(yes)
523         AST_SHADOW_WARNINGS=-Wshadow
524 else
525         AC_MSG_RESULT(no)
526         AST_SHADOW_WARNINGS=
527 fi
528 AC_SUBST(AST_SHADOW_WARNINGS)
529
530 AC_MSG_CHECKING(for sysinfo)
531 AC_LINK_IFELSE(
532         AC_LANG_PROGRAM([#include <sys/sysinfo.h>],
533                         [struct sysinfo sys_info; int uptime = sys_info.uptime]),
534         AC_MSG_RESULT(yes)
535         AC_DEFINE([HAVE_SYSINFO], 1, [Define to 1 if your system has sysinfo support]),
536         AC_MSG_RESULT(no)
537 )
538
539 AC_SEARCH_LIBS(res_9_ninit, resolv)
540 AC_MSG_CHECKING(for res_ninit)
541 AC_LINK_IFELSE(
542         AC_LANG_PROGRAM([
543                         #ifdef HAVE_SYS_SOCKET_H
544                         #include <sys/socket.h>
545                         #endif
546                         #ifdef HAVE_NETINET_IN_H
547                         #include <netinet/in.h>
548                         #endif
549                         #ifdef HAVE_ARPA_NAMESER_H
550                         #include <arpa/nameser.h>
551                         #endif
552                         #include <resolv.h>],
553                         [int foo = res_ninit(NULL);]),
554         AC_MSG_RESULT(yes)
555         AC_DEFINE([HAVE_RES_NINIT], 1, [Define to 1 if your system has the re-entrant resolver functions.])
556         AC_SEARCH_LIBS(res_9_ndestroy, resolv)
557         AC_MSG_CHECKING(for res_ndestroy)
558         AC_LINK_IFELSE(
559                 AC_LANG_PROGRAM([
560                                 #ifdef HAVE_SYS_SOCKET_H
561                                 #include <sys/socket.h>
562                                 #endif
563                                 #ifdef HAVE_NETINET_IN_H
564                                 #include <netinet/in.h>
565                                 #endif
566                                 #ifdef HAVE_ARPA_NAMESER_H
567                                 #include <arpa/nameser.h>
568                                 #endif
569                                 #include <resolv.h>],
570                                 [res_ndestroy(NULL);]),
571                 AC_MSG_RESULT(yes)
572                 AC_DEFINE([HAVE_RES_NDESTROY], 1, [Define to 1 if your system has the ndestroy resolver function.]),
573                 AC_MSG_RESULT(no)
574         ),
575         AC_MSG_RESULT(no)
576 )
577
578 AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
579
580 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
581
582 AC_CHECK_HEADER([libkern/OSAtomic.h],
583                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
584
585 AC_CHECK_SIZEOF(int)
586
587 # do the package library checks now
588
589 AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
590
591 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
592
593 if test "x${host_os}" = "xlinux-gnu" ; then
594   AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
595 fi
596
597 AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
598
599 # BSD might not have exp2, and/or log2
600 AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
601 AST_EXT_LIB_CHECK([LOG2L], [m], [log2l])
602 AST_EXT_LIB_CHECK([EXP10L], [m], [exp10l])
603 AST_EXT_LIB_CHECK([LOG10L], [m], [log10l])
604 AST_EXT_LIB_CHECK([SINL], [m], [sinl])
605 AST_EXT_LIB_CHECK([COSL], [m], [cosl])
606 AST_EXT_LIB_CHECK([TANL], [m], [tanl])
607 AST_EXT_LIB_CHECK([ASINL], [m], [asinl])
608 AST_EXT_LIB_CHECK([ACOSL], [m], [acosl])
609 AST_EXT_LIB_CHECK([ATANL], [m], [atanl])
610 AST_EXT_LIB_CHECK([ATAN2L], [m], [atan2l])
611 AST_EXT_LIB_CHECK([POWL], [m], [powl])
612 AST_EXT_LIB_CHECK([SQRTL], [m], [sqrtl])
613 AST_EXT_LIB_CHECK([RINTL], [m], [rintl])
614 AST_EXT_LIB_CHECK([EXPL], [m], [expl])
615 AST_EXT_LIB_CHECK([LOGL], [m], [logl])
616 AST_EXT_LIB_CHECK([REMAINDERL], [m], [remainderl])
617 AST_EXT_LIB_CHECK([FMODL], [m], [fmodl])
618 AST_EXT_LIB_CHECK([ROUNDL], [m], [roundl])
619 AST_EXT_LIB_CHECK([TRUNCL], [m], [truncl])
620 AST_EXT_LIB_CHECK([STRTOLD], [c], [strtold], [stdlib.h])
621 AST_EXT_LIB_CHECK([FLOORL], [m], [floorl])
622 AST_EXT_LIB_CHECK([CEILL], [m], [ceill])
623 AST_EXT_LIB_CHECK([EXP2], [m], [exp2])
624 AST_EXT_LIB_CHECK([LOG2], [m], [log2])
625 AST_EXT_LIB_CHECK([EXP10], [m], [exp10])
626 AST_EXT_LIB_CHECK([LOG10], [m], [log10])
627 AST_EXT_LIB_CHECK([SIN], [m], [sin])
628 AST_EXT_LIB_CHECK([COS], [m], [cos])
629 AST_EXT_LIB_CHECK([TAN], [m], [tan])
630 AST_EXT_LIB_CHECK([ASIN], [m], [asin])
631 AST_EXT_LIB_CHECK([ACOS], [m], [acos])
632 AST_EXT_LIB_CHECK([ATAN], [m], [atan])
633 AST_EXT_LIB_CHECK([ATAN2], [m], [atan2])
634 AST_EXT_LIB_CHECK([POW], [m], [pow])
635 AST_EXT_LIB_CHECK([SQRT], [m], [sqrt])
636 AST_EXT_LIB_CHECK([RINT], [m], [rint])
637 AST_EXT_LIB_CHECK([EXP], [m], [exp])
638 AST_EXT_LIB_CHECK([LOG], [m], [log])
639 AST_EXT_LIB_CHECK([REMAINDER], [m], [remainder])
640 AST_EXT_LIB_CHECK([FMOD], [m], [fmod])
641 AST_EXT_LIB_CHECK([ROUND], [m], [round])
642 AST_EXT_LIB_CHECK([TRUNC], [m], [trunc])
643 AST_EXT_LIB_CHECK([STRTOD], [c], [strtod], [stdlib.h])
644 AST_EXT_LIB_CHECK([FLOOR], [m], [floor])
645 AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
646
647 AST_C_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h], , [getifaddrs() support])
648
649 GSM_INTERNAL="yes"
650 AC_SUBST(GSM_INTERNAL)
651 GSM_SYSTEM="yes"
652 if test "${USE_GSM}" != "no"; then
653    if test "${GSM_DIR}" = "internal"; then
654       GSM_SYSTEM="no"
655    elif test "${GSM_DIR}" != ""; then
656       GSM_INTERNAL="no"
657    fi
658    if test "${GSM_SYSTEM}" = "yes"; then
659       gsmlibdir=""
660       if test "x${GSM_DIR}" != "x"; then
661          if test -d ${GSM_DIR}/lib; then
662             gsmlibdir="-L${GSM_DIR}/lib"
663          else
664             gsmlibdir="-L${GSM_DIR}"
665          fi
666       fi
667       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
668       [Define to indicate the GSM library]), [], ${gsmlibdir})
669       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
670          if test "x${GSM_DIR}" != "x" ; then
671             AC_CHECK_HEADER([${GSM_DIR}/include/gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
672             AC_CHECK_HEADER([${GSM_DIR}/include/gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
673          else
674             AC_CHECK_HEADER([gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
675             AC_CHECK_HEADER([gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
676          fi
677          if test "${GSM_HEADER_FOUND}" = "0" ; then
678             if test "{GSM_GSM_HEADER_FOUND}" = "0" ; then
679                if test "x${GSM_MANDATORY}" = "xyes" ; then
680                   AC_MSG_NOTICE([***])
681                   AC_MSG_NOTICE([*** It appears that you do not have the gsm development package installed.])
682                   AC_MSG_NOTICE([*** Please install it to include ${GSM_DESCRIP} support, or re-run configure])
683                   AC_MSG_NOTICE([*** without explicitly specifying --with-${GSM_OPTION}])
684                   exit 1
685                fi
686             fi
687          fi
688          GSM_OK=0
689          if test "${GSM_HEADER_FOUND}" = "1" ; then
690             AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
691             GSM_OK=1
692          else
693             if test "${GSM_GSM_HEADER_FOUND}" = "1" ; then
694                AC_DEFINE_UNQUOTED([HAVE_GSM_GSM_HEADER], 1, [Define to indicate that gsm.h is in gsm/gsm.h])
695                GSM_OK=1
696             fi
697          fi
698          if test "${GSM_OK}" = "1" ; then
699             GSM_LIB="-lgsm"
700             if test "x${GSM_DIR}" != "x"; then
701                GSM_LIB="${gsmlibdir} ${GSM_LIB}"
702                GSM_INCLUDE="-I${GSM_DIR}/include"
703             fi
704             PBX_GSM=1
705             GSM_INTERNAL="no"
706          fi
707       fi
708    fi
709    if test "${GSM_INTERNAL}" = "yes"; then
710       PBX_GSM=1
711       AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
712    fi
713 fi
714
715 if test "${host_os}" != "linux-gnu" ; then
716   AST_EXT_LIB_CHECK([ICONV], [iconv], [iconv_open], [iconv.h])
717 else
718   PBX_ICONV=1
719 fi
720
721 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
722
723 if test "${USE_IMAP_TK}" != "no"; then
724         saved_cppflags="${CPPFLAGS}"
725         saved_libs="${LIBS}"
726         switch_to_system_on_failure="no"
727         if test "${IMAP_TK_DIR}" = ""; then
728                 IMAP_TK_DIR=`pwd`"/../imap-2004g"
729                 switch_to_system_on_failure="yes"
730         fi
731         if test "${IMAP_TK_DIR}" != "system"; then
732                 AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
733                 if test -f "${IMAP_TK_DIR}/c-client/LDFLAGS"; then
734                 imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
735                 fi
736                 imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
737                 imap_include="-I${IMAP_TK_DIR}/c-client"
738         CPPFLAGS="${CPPFLAGS} ${imap_include}"
739                 LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
740                 AC_LINK_IFELSE(
741                 AC_LANG_PROGRAM(
742                                 [#include "c-client.h"
743                                 void mm_searched (MAILSTREAM *stream,unsigned long number)
744                                 {
745                                 }
746                                 void mm_exists (MAILSTREAM *stream,unsigned long number)
747                                 {
748                                 }
749                                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
750                                 {
751                                 }
752                                 void mm_flags (MAILSTREAM *stream,unsigned long number)
753                                 {
754                                 }
755                                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
756                                 {
757                                 }
758                                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
759                                 {
760                                 }
761                                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
762                                 {
763                                 }
764                                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
765                                 {
766                                 }
767                                 void mm_log (char *string,long errflg)
768                                 {
769                                 }
770                                 void mm_dlog (char *string)
771                                 {
772                                 }
773                                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
774                                 {
775                                 }
776                                 void mm_critical (MAILSTREAM *stream)
777                                 {
778                                 }
779                                 void mm_nocritical (MAILSTREAM *stream)
780                                 {
781                                 }
782                                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
783                                 {
784                                 }
785                                 void mm_fatal (char *string)
786                                 {
787                                 }],
788                                 [
789                                 MAILSTREAM *foo = mail_open(NULL, "", 0);
790                                 ]
791                         ),
792                         [ac_cv_imap_tk="yes"],
793                         [ac_cv_imap_tk="no"]
794                 )
795                 if test "${ac_cv_imap_tk}" = "yes"; then
796                         AC_LINK_IFELSE(
797                                 AC_LANG_PROGRAM(
798                                         [#include "c-client.h"
799                                         void mm_searched (MAILSTREAM *stream,unsigned long number)
800                                         {
801                                         }
802                                         void mm_exists (MAILSTREAM *stream,unsigned long number)
803                                         {
804                                         }
805                                         void mm_expunged (MAILSTREAM *stream,unsigned long number)
806                                         {
807                                         }
808                                         void mm_flags (MAILSTREAM *stream,unsigned long number)
809                                         {
810                                         }
811                                         void mm_notify (MAILSTREAM *stream,char *string,long errflg)
812                                         {
813                                         }
814                                         void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
815                                         {
816                                         }
817                                         void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
818                                         {
819                                         }
820                                         void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
821                                         {
822                                         }
823                                         void mm_log (char *string,long errflg)
824                                         {
825                                         }
826                                         void mm_dlog (char *string)
827                                         {
828                                         }
829                                         void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
830                                         {
831                                         }
832                                         void mm_critical (MAILSTREAM *stream)
833                                         {
834                                         }
835                                         void mm_nocritical (MAILSTREAM *stream)
836                                         {
837                                         }
838                                         long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
839                                         {
840                                         }
841                                         void mm_fatal (char *string)
842                                         {
843                                         }],
844                                         [
845                                         long check = mail_expunge_full(NULL, "", 0);
846                                         ]
847                                 ),
848                                 [ac_cv_imap_tk2006="yes"],
849                                 [ac_cv_imap_tk2006="no"]
850                         )
851                 fi
852                 CPPFLAGS="${saved_cppflags}"
853                 LIBS="${saved_libs}"
854                 if test "${ac_cv_imap_tk}" = "no"; then
855                         AC_MSG_RESULT(no)
856                         if test "${switch_to_system_on_failure}" = "yes"; then
857                                 IMAP_TK_DIR="system"
858                         else #This means they specified a directory. Search for a package installation there too
859                                 AC_MSG_CHECKING([for system c-client library...])
860                                 CPPFLAGS="${saved_cppflags}"
861                                 LIBS="${saved_libs}"
862                                 imap_include="-I${IMAP_TK_DIR}/include"
863                                 imap_ldflags="-L${IMAP_TK_DIR}/lib"
864                                 imap_libs="-lc-client"
865                                 CPPFLAGS="${CPPFLAGS} ${imap_include}"
866                                 LIBS="${LIBS} ${imap_libs} ${imap_ldflags}"
867                                 AC_LINK_IFELSE(
868                                 AC_LANG_PROGRAM(
869                                                 [#include "c-client.h"
870                                                 void mm_searched (MAILSTREAM *stream,unsigned long number)
871                                                 {
872                                                 }
873                                                 void mm_exists (MAILSTREAM *stream,unsigned long number)
874                                                 {
875                                                 }
876                                                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
877                                                 {
878                                                 }
879                                                 void mm_flags (MAILSTREAM *stream,unsigned long number)
880                                                 {
881                                                 }
882                                                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
883                                                 {
884                                                 }
885                                                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
886                                                 {
887                                                 }
888                                                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
889                                                 {
890                                                 }
891                                                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
892                                                 {
893                                                 }
894                                                 void mm_log (char *string,long errflg)
895                                                 {
896                                                 }
897                                                 void mm_dlog (char *string)
898                                                 {
899                                                 }
900                                                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
901                                                 {
902                                                 }
903                                                 void mm_critical (MAILSTREAM *stream)
904                                                 {
905                                                 }
906                                                 void mm_nocritical (MAILSTREAM *stream)
907                                                 {
908                                                 }
909                                                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
910                                                 {
911                                                 }
912                                                 void mm_fatal (char *string)
913                                                 {
914                                                 }],
915                                                 [
916                                                 MAILSTREAM *foo = mail_open(NULL, "", 0);
917                                                 ]
918                                         ),
919                                         [ac_cv_imap_tk="yes"],
920                                         [ac_cv_imap_tk="no"]
921                                 )
922                                 if test "${ac_cv_imap_tk}" = "yes"; then
923                                         AC_LINK_IFELSE(
924                                                 AC_LANG_PROGRAM(
925                                                         [#include "c-client.h"
926                                                         void mm_searched (MAILSTREAM *stream,unsigned long number)
927                                                         {
928                                                         }
929                                                         void mm_exists (MAILSTREAM *stream,unsigned long number)
930                                                         {
931                                                         }
932                                                         void mm_expunged (MAILSTREAM *stream,unsigned long number)
933                                                         {
934                                                         }
935                                                         void mm_flags (MAILSTREAM *stream,unsigned long number)
936                                                         {
937                                                         }
938                                                         void mm_notify (MAILSTREAM *stream,char *string,long errflg)
939                                                         {
940                                                         }
941                                                         void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
942                                                         {
943                                                         }
944                                                         void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
945                                                         {
946                                                         }
947                                                         void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
948                                                         {
949                                                         }
950                                                         void mm_log (char *string,long errflg)
951                                                         {
952                                                         }
953                                                         void mm_dlog (char *string)
954                                                         {
955                                                         }
956                                                         void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
957                                                         {
958                                                         }
959                                                         void mm_critical (MAILSTREAM *stream)
960                                                         {
961                                                         }
962                                                         void mm_nocritical (MAILSTREAM *stream)
963                                                         {
964                                                         }
965                                                         long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
966                                                         {
967                                                         }
968                                                         void mm_fatal (char *string)
969                                                         {
970                                                         }],
971                                                         [
972                                                         long check = mail_expunge_full(NULL, "", 0);
973                                                         ]
974                                                 ),
975                                                 [ac_cv_imap_tk2006="yes"],
976                                                 [ac_cv_imap_tk2006="no"]
977                                         )
978                                 fi
979                         fi
980                 fi
981         fi 
982         if test "${IMAP_TK_DIR}" = "system"; then
983                 #We will enter here if user specified "system" or if any of above checks failed
984                 AC_MSG_CHECKING([for system c-client library...])
985                 CPPFLAGS="${saved_cppflags}"
986                 LIBS="${saved_libs}"
987                 imap_ldflags=""
988                 imap_libs="-lc-client"
989                 imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first
990                 CPPFLAGS="${CPPFLAGS} ${imap_include}"
991                 LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
992                 AC_LINK_IFELSE(
993                 AC_LANG_PROGRAM(
994                                 [#include <stdio.h>
995                                 #include <imap/c-client.h>
996                                 void mm_searched (MAILSTREAM *stream,unsigned long number)
997                                 {
998                                 }
999                                 void mm_exists (MAILSTREAM *stream,unsigned long number)
1000                                 {
1001                                 }
1002                                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
1003                                 {
1004                                 }
1005                                 void mm_flags (MAILSTREAM *stream,unsigned long number)
1006                                 {
1007                                 }
1008                                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
1009                                 {
1010                                 }
1011                                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1012                                 {
1013                                 }
1014                                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1015                                 {
1016                                 }
1017                                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
1018                                 {
1019                                 }
1020                                 void mm_log (char *string,long errflg)
1021                                 {
1022                                 }
1023                                 void mm_dlog (char *string)
1024                                 {
1025                                 }
1026                                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
1027                                 {
1028                                 }
1029                                 void mm_critical (MAILSTREAM *stream)
1030                                 {
1031                                 }
1032                                 void mm_nocritical (MAILSTREAM *stream)
1033                                 {
1034                                 }
1035                                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
1036                                 {
1037                                 }
1038                                 void mm_fatal (char *string)
1039                                 {
1040                                 }],
1041                                 [
1042                                 MAILSTREAM *foo = mail_open(NULL, "", 0);
1043                                 ]
1044                         ),
1045                         [ac_cv_imap_tk="yes"],
1046                         [ac_cv_imap_tk="no"]
1047                 )
1048                 if test "${ac_cv_imap_tk}" = "yes"; then
1049                         AC_LINK_IFELSE(
1050                                 AC_LANG_PROGRAM(
1051                                         [#include <stdio.h>
1052                                         #include <imap/c-client.h>
1053                                         void mm_searched (MAILSTREAM *stream,unsigned long number)
1054                                         {
1055                                         }
1056                                         void mm_exists (MAILSTREAM *stream,unsigned long number)
1057                                         {
1058                                         }
1059                                         void mm_expunged (MAILSTREAM *stream,unsigned long number)
1060                                         {
1061                                         }
1062                                         void mm_flags (MAILSTREAM *stream,unsigned long number)
1063                                         {
1064                                         }
1065                                         void mm_notify (MAILSTREAM *stream,char *string,long errflg)
1066                                         {
1067                                         }
1068                                         void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1069                                         {
1070                                         }
1071                                         void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1072                                         {
1073                                         }
1074                                         void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
1075                                         {
1076                                         }
1077                                         void mm_log (char *string,long errflg)
1078                                         {
1079                                         }
1080                                         void mm_dlog (char *string)
1081                                         {
1082                                         }
1083                                         void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
1084                                         {
1085                                         }
1086                                         void mm_critical (MAILSTREAM *stream)
1087                                         {
1088                                         }
1089                                         void mm_nocritical (MAILSTREAM *stream)
1090                                         {
1091                                         }
1092                                         long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
1093                                         {
1094                                         }
1095                                         void mm_fatal (char *string)
1096                                         {
1097                                         }],
1098                                         [
1099                                         long check = mail_expunge_full(NULL, "", 0);
1100                                         ]
1101                                 ),
1102                                 [ac_cv_imap_tk2006="yes"],
1103                                 [ac_cv_imap_tk2006="no"]
1104                         )
1105                 else #looking in imap directory didn't work, try c-client
1106                         imap_ldflags=""
1107                         imap_libs="-lc-client"
1108                         imap_include="-DUSE_SYSTEM_CCLIENT"
1109                         CPPFLAGS="${saved_cppflags}"
1110                         LIBS="${saved_libs}"
1111                         CPPFLAGS="${CPPFLAGS} ${imap_include}"
1112                         LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
1113                         AC_LINK_IFELSE(
1114                         AC_LANG_PROGRAM(
1115                                         [#include <stdio.h>
1116                                         #include <c-client/c-client.h>
1117                                         void mm_searched (MAILSTREAM *stream,unsigned long number)
1118                                         {
1119                                         }
1120                                         void mm_exists (MAILSTREAM *stream,unsigned long number)
1121                                         {
1122                                         }
1123                                         void mm_expunged (MAILSTREAM *stream,unsigned long number)
1124                                         {
1125                                         }
1126                                         void mm_flags (MAILSTREAM *stream,unsigned long number)
1127                                         {
1128                                         }
1129                                         void mm_notify (MAILSTREAM *stream,char *string,long errflg)
1130                                         {
1131                                         }
1132                                         void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1133                                         {
1134                                         }
1135                                         void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1136                                         {
1137                                         }
1138                                         void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
1139                                         {
1140                                         }
1141                                         void mm_log (char *string,long errflg)
1142                                         {
1143                                         }
1144                                         void mm_dlog (char *string)
1145                                         {
1146                                         }
1147                                         void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
1148                                         {
1149                                         }
1150                                         void mm_critical (MAILSTREAM *stream)
1151                                         {
1152                                         }
1153                                         void mm_nocritical (MAILSTREAM *stream)
1154                                         {
1155                                         }
1156                                         long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
1157                                         {
1158                                         }
1159                                         void mm_fatal (char *string)
1160                                         {
1161                                         }],
1162                                         [
1163                                         MAILSTREAM *foo = mail_open(NULL, "", 0);
1164                                         ]
1165                                 ),
1166                                 [ac_cv_imap_tk="yes"],
1167                                 [ac_cv_imap_tk="no"]
1168                         )
1169                         if test "${ac_cv_imap_tk}" = "yes"; then
1170                                 AC_LINK_IFELSE(
1171                                         AC_LANG_PROGRAM(
1172                                                 [#include <stdio.h>
1173                                                 #include <c-client/c-client.h>
1174                                                 void mm_searched (MAILSTREAM *stream,unsigned long number)
1175                                                 {
1176                                                 }
1177                                                 void mm_exists (MAILSTREAM *stream,unsigned long number)
1178                                                 {
1179                                                 }
1180                                                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
1181                                                 {
1182                                                 }
1183                                                 void mm_flags (MAILSTREAM *stream,unsigned long number)
1184                                                 {
1185                                                 }
1186                                                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
1187                                                 {
1188                                                 }
1189                                                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1190                                                 {
1191                                                 }
1192                                                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
1193                                                 {
1194                                                 }
1195                                                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
1196                                                 {
1197                                                 }
1198                                                 void mm_log (char *string,long errflg)
1199                                                 {
1200                                                 }
1201                                                 void mm_dlog (char *string)
1202                                                 {
1203                                                 }
1204                                                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
1205                                                 {
1206                                                 }
1207                                                 void mm_critical (MAILSTREAM *stream)
1208                                                 {
1209                                                 }
1210                                                 void mm_nocritical (MAILSTREAM *stream)
1211                                                 {
1212                                                 }
1213                                                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
1214                                                 {
1215                                                 }
1216                                                 void mm_fatal (char *string)
1217                                                 {
1218                                                 }],
1219                                                 [
1220                                                 long check = mail_expunge_full(NULL, "", 0);
1221                                                 ]
1222                                         ),
1223                                         [ac_cv_imap_tk2006="yes"],
1224                                         [ac_cv_imap_tk2006="no"]
1225                                 )
1226                         fi
1227                 fi
1228         fi
1229         if test "${ac_cv_imap_tk}" = "yes"; then
1230                 AC_MSG_RESULT(yes)
1231                 IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
1232                 IMAP_TK_INCLUDE="${imap_include}"
1233                 PBX_IMAP_TK=1
1234                 AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
1235                 if test "${ac_cv_imap_tk2006}" = "yes"; then
1236                         AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
1237                 fi
1238         else
1239                 AC_MSG_RESULT(no) 
1240         fi
1241         CPPFLAGS="${saved_cppflags}"
1242         LIBS="${saved_libs}"
1243 fi
1244
1245 AST_EXT_LIB_CHECK([IODBC], [iodbc], [SQLConnect], [sql.h], [-lpthread])
1246
1247 AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
1248
1249 # Needed by unixodbc
1250 AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], [])
1251
1252 AST_EXT_LIB_CHECK([LDAP], [ldap], [ldap_initialize], [ldap.h])
1253
1254 AC_ARG_ENABLE([xmldoc],
1255         [AS_HELP_STRING([--disable-xmldoc],
1256                 [Explicity disable XML documentation])],
1257         [case "${enableval}" in
1258                 y|ye|yes) disable_xmldoc=no ;;
1259                 n|no)  disable_xmldoc=yes ;;
1260                 *) AC_MSG_ERROR(bad value ${enableval} for --disable-xmldoc)  ;;
1261         esac], [disable_xmldoc=no])
1262
1263 if test "${disable_xmldoc}" != "yes"; then
1264         AST_EXT_TOOL_CHECK([LIBXML2], [xml2], , ,
1265         [#include <libxml/tree.h>
1266         #include <libxml/parser.h>],
1267         [LIBXML_TEST_VERSION])
1268         if test "${PBX_LIBXML2}" != 1; then
1269                 AC_MSG_NOTICE(*** XML documentation will not be available because the 'libxml2' development package is missing.)
1270                 AC_MSG_NOTICE(*** Please run the 'configure' script with the '--disable-xmldoc' parameter option)
1271                 AC_MSG_NOTICE(*** or install the 'libxml2' development package.)
1272                 exit 1
1273         fi
1274 fi
1275
1276 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
1277
1278 if test "${PBX_MISDN}" = 1; then
1279    AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
1280    AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
1281    AST_C_DEFINE_CHECK([MISDN_FAC_RESULT], [Fac_RESULT], [mISDNuser/suppserv.h])
1282    AST_C_DEFINE_CHECK([MISDN_FAC_ERROR], [Fac_ERROR], [mISDNuser/suppserv.h])
1283    AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
1284 fi
1285
1286 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
1287
1288 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
1289
1290 AST_EXT_TOOL_CHECK([NETSNMP], [net-snmp], , [--agent-libs],
1291 [#include <net-snmp/net-snmp-config.h>
1292 #include <net-snmp/net-snmp-includes.h>
1293 #include <net-snmp/agent/net-snmp-agent-includes.h>],
1294 [int callback = snmp_register_callback(0, 0, NULL, NULL)])
1295
1296 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
1297
1298 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
1299
1300 PBX_ODBC=0
1301 if test "$PBX_IODBC" = "1" -o "$PBX_UNIXODBC" = "1"; then
1302    PBX_ODBC=1
1303 fi
1304 AC_SUBST(PBX_ODBC)
1305
1306 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
1307
1308 # Non-glibc platforms require libexecinfo for backtrace support
1309 AST_EXT_LIB_CHECK([BKTR], [execinfo], [backtrace], [execinfo.h])
1310 # Linux, however, has backtrace directly in glibc
1311 AST_EXT_LIB_CHECK([BKTR], [c], [backtrace], [execinfo.h])
1312
1313 # possible places for oss definitions
1314 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
1315 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
1316 AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
1317
1318 PG_CONFIG=No
1319 if test "${USE_PGSQL}" != "no"; then    
1320    if test "x${PGSQL_DIR}" != "x"; then
1321       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
1322       if test x"${PG_CONFIG}" = xNo; then
1323          AC_MSG_NOTICE([***])
1324          AC_MSG_NOTICE([*** pg_config was not found in the path you specified:])
1325          AC_MSG_NOTICE([*** ${PGSQL_DIR}/bin])
1326          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
1327          AC_MSG_NOTICE([*** including --without-postgres])
1328          exit 1
1329       fi
1330    else
1331       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
1332    fi
1333 fi
1334 if test "${PG_CONFIG}" != No; then
1335    PGSQL_libdir=`${PG_CONFIG} --libdir`
1336    PGSQL_includedir=`${PG_CONFIG} --includedir`
1337    if test "x$?" != "x0" ; then
1338       if test -n "${PGSQL_MANDATORY}" ; then
1339          AC_MSG_NOTICE([***])
1340          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
1341          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
1342          AC_MSG_NOTICE([*** including --without-postgres])
1343          exit 1
1344           fi
1345    else 
1346       AC_CHECK_LIB([pq], [PQescapeStringConn], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
1347       [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
1348
1349       if test "${ac_cv_lib_pq_PQescapeStringConn}" = "yes"; then
1350          PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
1351          PGSQL_INCLUDE="-I${PGSQL_includedir}"
1352          PBX_PGSQL=1
1353       elif test -n "${PGSQL_MANDATORY}";
1354       then
1355          AC_MSG_NOTICE([***])
1356          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
1357          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
1358          AC_MSG_NOTICE([*** including --without-postgres])
1359          exit 1
1360       fi
1361    fi
1362 fi
1363
1364 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
1365
1366 AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
1367
1368 AST_EXT_LIB_CHECK([PRI], [pri], [pri_progress_with_cause], [libpri.h])
1369
1370 AST_EXT_LIB_CHECK([PRI_INBANDDISCONNECT], [pri], [pri_set_inbanddisconnect], [libpri.h])
1371
1372 AST_EXT_LIB_CHECK([RESAMPLE], [resample], [resample_open], [libresample.h], [-lm])
1373
1374 AST_C_COMPILE_CHECK([SPANDSP], [
1375                 #if SPANDSP_RELEASE_DATE < 20080516
1376                 #error "spandsp 0.0.5 or greater is required"
1377                 #endif
1378         ], [spandsp/version.h], , [minimum version of SpanDSP])
1379
1380 if test "x${PBX_SPANDSP}" = "x1" ; then
1381         # We found the correct version in the header, now let's make sure it links
1382         # properly, and that libtiff is available
1383         PBX_SPANDSP=0
1384         AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [span_set_message_handler], [spandsp.h], [-ltiff])
1385 fi
1386
1387 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_pollflags], [libss7.h])
1388
1389 if test "${USE_PWLIB}" != "no"; then
1390         if test -n "${PWLIB_DIR}"; then
1391                 PWLIBDIR="${PWLIB_DIR}"
1392         fi
1393         AST_CHECK_PWLIB()
1394         AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2])
1395                 
1396         if test "${HAS_PWLIB:-unset}" != "unset"; then
1397                 AST_CHECK_PWLIB_PLATFORM()
1398
1399                 PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r"
1400
1401                 AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
1402                         [Define if your system has the PWLib libraries.],
1403                         [#include "ptlib.h"],
1404                         [BOOL q = PTime::IsDaylightSavings();])
1405         fi
1406 fi
1407
1408 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
1409         if test -n "${OPENH323_DIR}"; then
1410                 OPENH323DIR="${OPENH323_DIR}"
1411         fi
1412         AST_CHECK_OPENH323()
1413         AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3])
1414         AST_CHECK_OPENH323_BUILD()
1415         PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
1416         AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],
1417                 [Define if your system has the OpenH323 libraries.],
1418                 [#include "ptlib.h"
1419                 #include "h323.h"
1420                 #include "h323ep.h"],
1421                 [H323EndPoint ep = H323EndPoint();],
1422                 [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
1423 fi
1424
1425 AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h]) 
1426
1427 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
1428
1429 # This is a bit complex... in reality, Asterisk's AIS support is dependent on finding
1430 # *any* implementation of AIS, not just OpenAIS. However, the configure script needs
1431 # to know the specifics of each possible implementation, and then represent the one
1432 # that was found as 'AIS'.
1433
1434 PBX_AIS=0
1435
1436 # OpenAIS installs its libraries into /usr/lib/openais by default, so check there
1437
1438 AST_EXT_LIB_CHECK([OPENAIS], [SaClm], [saClmInitialize], [openais/saClm.h], [-L/usr/lib/openais -L/usr/lib64/openais])
1439
1440 if test "${PBX_OPENAIS}" = 1; then
1441    PBX_AIS=1
1442    if test -n "${OPENAIS_DIR}"; then
1443       AIS_INCLUDE="${OPENAIS_INCLUDE}/openais"
1444       AIS_LIB="-lSaEvt ${OPENAIS_LIB}"
1445    else
1446       AIS_INCLUDE="-I/usr/include/openais"
1447       AIS_LIB="-lSaClm -lSaEvt -L/usr/lib/openais -L/usr/lib64/openais"
1448    fi
1449 fi
1450
1451 AC_SUBST(PBX_AIS)
1452 AC_SUBST(AIS_INCLUDE)
1453 AC_SUBST(AIS_LIB)
1454
1455 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
1456
1457 # See if the main speex library contains the preprocess functions
1458 AST_EXT_LIB_CHECK([SPEEX_PREPROCESS], [speex], [speex_preprocess_ctl], [speex/speex.h], [-lm])
1459 if test "${PBX_SPEEX_PREPROCESS}" = 1; then
1460    PBX_SPEEX_PREPROCESS=1
1461 fi
1462
1463 AST_EXT_LIB_CHECK([SPEEXDSP], [speexdsp], [speex_preprocess_ctl], [speex/speex.h], [-lm])
1464 if test "${PBX_SPEEXDSP}" = 1; then
1465    PBX_SPEEX_PREPROCESS=1
1466 fi
1467
1468 AC_SUBST(PBX_SPEEX_PREPROCESS)
1469
1470 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
1471
1472 AST_EXT_LIB_CHECK([SQLITE3], [sqlite3], [sqlite3_open], [sqlite3.h])
1473
1474 AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h])
1475
1476 if test "$PBX_CRYPTO" = "1";
1477 then
1478     AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
1479 fi
1480
1481 if test "$PBX_OPENSSL" = "1";
1482 then
1483     AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
1484 fi
1485
1486 AST_EXT_TOOL_CHECK([GMIME], [gmime], [], [], [#include <gmime/gmime.h>], [gboolean q = g_mime_check_version(0,0,0);])
1487
1488 AST_EXT_LIB_CHECK([HOARD], [hoard], [malloc], [])
1489
1490 AST_EXT_LIB_CHECK([FREETDS], [sybdb], [dbinit], [sybdb.h])
1491
1492 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
1493
1494 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
1495
1496 if test "${host_os}" != "linux-gnu" ; then
1497   tonezone_extra="-lm"
1498 fi
1499
1500 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [dahdi/tonezone.h], [${tonezone_extra} ${DAHDI_INCLUDE}])
1501
1502 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h], [])
1503
1504 if test "${OSARCH}" = "OpenBSD";
1505 then
1506         AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -logg])
1507 else
1508         AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
1509 fi
1510
1511 AC_LANG_PUSH(C++)
1512
1513 if test "${USE_VPB}" != "no"; then
1514    AC_MSG_CHECKING(for vpb_open in -lvpb)
1515    saved_libs="${LIBS}"
1516    saved_cppflags="${CPPFLAGS}"
1517    if test "x${VPB_DIR}" != "x"; then
1518       if test -d ${VPB_DIR}/lib; then
1519          vpblibdir=${VPB_DIR}/lib
1520       else
1521          vpblibdir=${VPB_DIR}
1522       fi
1523       LIBS="${LIBS} -L${vpblibdir}"
1524       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
1525    fi
1526    LIBS="${LIBS} -lvpb -lpthread"
1527    AC_LINK_IFELSE(
1528         [
1529         AC_LANG_PROGRAM(
1530         [#include <vpbapi.h>],
1531         [int q = vpb_open(0,0);])
1532         ],
1533         [       AC_MSG_RESULT(yes) 
1534                 ac_cv_lib_vpb_vpb_open="yes" 
1535         ],
1536         [       AC_MSG_RESULT(no) 
1537                 ac_cv_lib_vpb_vpb_open="no" 
1538         ]
1539         )
1540    LIBS="${saved_libs}"
1541    CPPFLAGS="${saved_cppflags}"
1542    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
1543         VPB_LIB="-lvpb"
1544         if test "${VPB_DIR}" != ""; then
1545            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
1546            VPB_INCLUDE="-I${VPB_DIR}/include"
1547         fi
1548         PBX_VPB=1
1549         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
1550    fi
1551 fi
1552
1553 AC_LANG_POP
1554
1555 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
1556
1557 EDITLINE_LIB=""
1558 if test "x$TERMCAP_LIB" != "x" ; then
1559   EDITLINE_LIB="$TERMCAP_LIB"
1560 elif test "x$TINFO_LIB" != "x" ; then
1561   EDITLINE_LIB="$TINFO_LIB"
1562 elif test "x$CURSES_LIB" != "x" ; then
1563   EDITLINE_LIB="$CURSES_LIB"
1564 elif test "x$NCURSES_LIB" != "x" ; then
1565   EDITLINE_LIB="$NCURSES_LIB"
1566 else
1567   AC_MSG_ERROR(*** termcap support not found)
1568 fi
1569 AC_SUBST(EDITLINE_LIB)
1570
1571 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
1572 AC_SUBST(PBX_H323)
1573
1574 AC_CHECK_HEADER([linux/compiler.h],
1575                 [AC_DEFINE_UNQUOTED([HAVE_LINUX_COMPILER_H], 1, [Define to 1 if your system has linux/compiler.h.])])
1576
1577 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
1578                                    #include <linux/version.h>
1579                                    #ifdef HAVE_LINUX_COMPILER_H
1580                                    #include <linux/compiler.h>
1581                                    #endif
1582                                    ])
1583 AC_SUBST(PBX_IXJUSER)
1584
1585 AST_EXT_TOOL_CHECK([SDL], [sdl])
1586 AST_EXT_LIB_CHECK([SDL_IMAGE], [SDL_image], [IMG_Load], [SDL_image.h], [${SDL_LIB}], [${SDL_INCLUDE}])
1587 AST_EXT_LIB_CHECK([FFMPEG], [avcodec], [sws_getContext], [ffmpeg/avcodec.h], [-lpthread -lz -lm])
1588
1589 # possible places for video4linux version 1
1590 AC_CHECK_HEADER([linux/videodev.h],
1591         [AC_DEFINE_UNQUOTED([HAVE_VIDEODEV_H], 1, [Define to 1 if your system has linux/videodev.h.])])
1592
1593 # possible places for X11
1594 AST_EXT_LIB_CHECK([X11], [X11], [XOpenDisplay], [X11/Xlib.h],,, [standard_path])
1595 AST_EXT_LIB_CHECK([X11], [X11], [XOpenDisplay], [X11/Xlib.h],, [-I/usr/X11R6/include], [X11R6])
1596
1597 if test "${cross_compiling}" = "no";
1598 then
1599   AC_CHECK_FILE(/sbin/launchd, AC_DEFINE([HAVE_SBIN_LAUNCHD], 1, [Define to 1 if your system has /sbin/launchd.]))
1600 fi
1601
1602 PBX_GTK=0
1603 AST_EXT_TOOL_CHECK([GTK], [gtk], [--cflags gthread], [--libs gthread])
1604
1605 PBX_GTK2=0
1606 AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
1607 if test ! "x${PKGCONFIG}" = xNo; then
1608    GTK2_INCLUDE=$(${PKGCONFIG} gtk+-2.0 --cflags 2>/dev/null)
1609    GTK2_LIB=$(${PKGCONFIG} gtk+-2.0 --libs)
1610    PBX_GTK2=1
1611    AC_DEFINE([HAVE_GTK2], 1, [Define if your system has the GTK2 libraries.])
1612 fi
1613 AC_SUBST(PBX_GTK2)
1614 AC_SUBST(GTK2_INCLUDE)
1615 AC_SUBST(GTK2_LIB)
1616
1617 if test "${USE_CURL}" != "no"; then
1618    AC_PATH_TOOL([CURL_CONFIG], [curl-config], No)
1619    if test ! x"${CURL_CONFIG}" = xNo; then
1620    # check for version
1621       if test $(printf "%d" 0x$(${CURL_CONFIG} --vernum)) -ge $(printf "%d" 0x070907); then
1622          CURL_INCLUDE=$(${CURL_CONFIG} --cflags)
1623          CURL_LIB=$(${CURL_CONFIG} --libs)
1624
1625          AC_MSG_CHECKING(for curl_version() in curl/curl.h)
1626          saved_cppflags="${CPPFLAGS}"
1627          CPPFLAGS="${CPPFLAGS} ${CURL_INCLUDE}"
1628          AC_COMPILE_IFELSE(
1629             [AC_LANG_PROGRAM(
1630                 [#include <curl/curl.h>],
1631                     [curl_version();])
1632             ],[
1633                 AC_MSG_RESULT(yes)
1634                 ac_cv_curl_h="yes"
1635             ],[
1636                 AC_MSG_RESULT(no)
1637                 ac_cv_curl_h="no"
1638             ]
1639          )
1640          CPPFLAGS="${saved_cppflags}"
1641          if test "${ac_cv_curl_h}" = "yes"; then
1642              PBX_CURL=1
1643              AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
1644          fi
1645       fi
1646    fi
1647 fi
1648
1649 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
1650 AST_CHECK_MANDATORY
1651
1652 AC_OUTPUT
1653
1654 if test "x${silent}" != "xyes" ; then
1655 echo
1656 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
1657 echo "            .\$7\$7..          .7\$\$7:.    "
1658 echo "          .\$\$:.                 ,\$7.7   "
1659 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
1660 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
1661 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
1662 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
1663 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
1664 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
1665 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
1666 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
1667 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
1668 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
1669 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
1670 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
1671 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
1672 echo " \$\$\$\$\$                        \$\$\$       "
1673 echo "  \$\$\$\$7.                       \$\$  (TM)     "
1674 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
1675 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
1676 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
1677 echo
1678 fi
1679
1680 AC_MSG_NOTICE(Package configured for: )
1681 AC_MSG_NOTICE( OS type  : $host_os)
1682 AC_MSG_NOTICE( Host CPU : $host_cpu)
1683 AC_MSG_NOTICE( build-cpu:vendor:os: $build_cpu : $build_vendor : $build_os :) 
1684 AC_MSG_NOTICE( host-cpu:vendor:os: $host_cpu : $host_vendor : $host_os :) 
1685 if test "${cross_compiling}" = "yes"; then
1686    AC_MSG_NOTICE( Cross Compilation = YES)
1687 fi