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