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