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