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