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