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