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