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