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