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