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