Add pbx_lua as a method of doing extensions
[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 m4_define([PBX_VERSION],
12           m4_bpatsubst(m4_esyscmd([build_tools/make_version .]),
13                        [\([0-9.]*\)\(\w\|\W\)*],
14                        [\1]))
15 AC_INIT(asterisk, PBX_VERSION, www.asterisk.org)
16
17 # cross-compile macros
18 AC_CANONICAL_BUILD
19 AC_CANONICAL_HOST
20
21 # check existence of the package
22 AC_CONFIG_SRCDIR([main/asterisk.c])
23
24 # specify output header file
25 AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
26
27 AC_COPYRIGHT("Asterisk")
28 AC_REVISION($Revision$)
29
30 AC_GNU_SOURCE
31 AC_USE_SYSTEM_EXTENSIONS        # note- does not work on FreeBSD
32
33 case "${host_os}" in
34      freebsd*)
35      ac_default_prefix=/usr/local
36      CPPFLAGS=-I/usr/local/include
37      LDFLAGS=-L/usr/local/lib
38      ;;
39
40      *)
41      ac_default_prefix=/usr
42      if test ${sysconfdir} = '${prefix}/etc'; then
43         sysconfdir=/etc
44      fi
45      if test ${mandir} = '${prefix}/man'; then
46         mandir=/usr/share/man
47      fi
48      ;;
49 esac
50
51 if test ${localstatedir} = '${prefix}/var'; then
52      localstatedir=/var
53 fi
54
55 BUILD_PLATFORM=${build}
56 BUILD_CPU=${build_cpu}
57 BUILD_VENDOR=${build_vendor}
58 BUILD_OS=${build_os}
59
60 AC_SUBST(BUILD_PLATFORM)
61 AC_SUBST(BUILD_CPU)
62 AC_SUBST(BUILD_VENDOR)
63 AC_SUBST(BUILD_OS)
64
65 HOST_PLATFORM=${host}
66 HOST_CPU=${host_cpu}
67 HOST_VENDOR=${host_vendor}
68 HOST_OS=${host_os}
69
70 AC_SUBST(HOST_PLATFORM)
71 AC_SUBST(HOST_CPU)
72 AC_SUBST(HOST_VENDOR)
73 AC_SUBST(HOST_OS)
74
75 case "${host_os}" in
76      freebsd*)
77      OSARCH=FreeBSD
78      ;;
79      netbsd*)
80      OSARCH=NetBSD
81      ;;
82      openbsd*)
83      OSARCH=OpenBSD
84      ;;
85      solaris*)
86      OSARCH=SunOS
87      ;;
88      *)
89      OSARCH=${HOST_OS}
90      ;;
91 esac
92
93 AC_SUBST(OSARCH)
94
95 #  check for uname
96 AC_PATH_TOOL([UNAME], [uname], No)
97 if test ! x"${UNAME}" = xNo; then
98    PBX_OSREV=$(${UNAME} -r)
99 fi
100 AC_SUBST(PBX_OSREV)
101
102 AH_TOP(
103 #ifndef ASTERISK_AUTOCONFIG_H
104 #define ASTERISK_AUTOCONFIG_H
105
106 #include "asterisk/buildopts.h"
107
108 )
109
110 AH_BOTTOM(
111 #endif
112 )
113
114 # cross-compile checks
115 if test "${cross_compiling}" = "yes"; 
116 then
117    AC_CHECK_TOOL(CC, gcc, :)
118    AC_CHECK_TOOL(CXX, g++, :)
119    AC_CHECK_TOOL(LD, ld, :)
120    AC_CHECK_TOOL(RANLIB, ranlib, :)
121 fi
122
123 # Checks for programs.
124 AC_PROG_CC
125 AC_PROG_CXX
126 AC_PROG_CPP
127 AC_PROG_CXXCPP
128 # This macro is just copied into our local acinclude.m4 from libtool.m4 so that
129 # the developers regenerating the configure script don't have to install libtool.
130 AST_PROG_LD     # note, does not work on FreeBSD
131 AC_PROG_AWK
132 AC_PROG_INSTALL
133 AC_PROG_LN_S
134 AC_PROG_RANLIB
135 AST_CHECK_GNU_MAKE
136
137 AC_PATH_TOOL([STRIP], [strip], :)
138 AC_PATH_TOOL([AR], [ar], :)
139
140 GNU_LD=0
141 if test "x$with_gnu_ld" = "xyes" ; then
142    GNU_LD=1
143 fi
144 AC_SUBST(GNU_LD)
145
146 AC_PATH_PROG([GREP], [grep], :)
147 AC_PATH_PROG([FIND], [find], :)
148 AC_PATH_PROG([COMPRESS], [compress], :)
149 AC_PATH_PROG([BASENAME], [basename], :)
150 AC_PATH_PROG([ID], [id], :)
151 AC_PATH_PROG([DIRNAME], [dirname], :)
152 AC_PATH_PROG([SHELL], [sh], :)
153 AC_PATH_PROG([LN], [ln], :)
154 AC_PATH_PROG([DOT], [dot], :)
155 AC_PATH_PROG([WGET], [wget], :)
156 AC_PATH_PROG([RUBBER], [rubber], :)
157 if test "${WGET}" != ":" ; then
158   DOWNLOAD=${WGET}
159 else
160   AC_PATH_PROG([FETCH], [fetch], [:])
161   DOWNLOAD=${FETCH}
162 fi
163 AC_SUBST(DOWNLOAD)
164
165 ACX_PTHREAD
166
167 AC_LANG(C)
168
169 AC_ARG_ENABLE(dev-mode,
170         [  --enable-dev-mode    Turn on developer mode],
171         [case "${enableval}" in
172               y|ye|yes) AST_DEVMODE=yes ;;
173               n|no)  AST_DEVMODE=no ;;
174               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
175         esac])
176 AC_SUBST(AST_DEVMODE)
177
178 # package option names should be in alphabetical order
179 # by the --with option name, to make things easier for the users :-)
180
181 AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
182
183 # BKTR is used for backtrace support on platforms that do not
184 # have it natively.
185 AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace support], [execinfo])
186 AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap])
187 AST_EXT_LIB_SETUP([CURL], [cURL], [curl])
188 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
189 AST_EXT_LIB_SETUP([CRYPTO], [OpenSSL Cryptography support], [crypto])
190 AST_EXT_LIB_SETUP([GSM], [GSM], [gsm], [, or 'internal'])
191 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
192 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
193 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
194 AST_EXT_LIB_SETUP([KDE], [KDE], [kde])
195 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
196 AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
197 AST_EXT_LIB_SETUP([MISDN], [mISDN User Library], [misdn])
198 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
199 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
200 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
201 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
202 AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [odbc])
203 AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
204 AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
205 AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
206 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
207 AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
208 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
209 AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7])
210 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
211 AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
212 AST_EXT_LIB_SETUP([QT], [Qt], [qt])
213 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
214 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
215 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
216 AST_EXT_LIB_SETUP([SQLITE3], [SQLite], [sqlite3])
217 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
218 AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL Secure Sockets Layer support], [ssl])
219 AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
220 AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap])
221 AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
222 AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
223 AST_EXT_LIB_SETUP([USB], [usb], [usb])
224 AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
225 AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
226 AST_EXT_LIB_SETUP([ZLIB], [zlib], [z])
227 AST_EXT_LIB_SETUP([ZAPTEL], [Zaptel], [zaptel])
228 AST_EXT_LIB_SETUP([ZAPTEL_TRANSCODE], [Zaptel_transcode], [zaptel_transcode])
229 AST_EXT_LIB_SETUP([ZAPTEL_VLDTMF], [Zaptel_vldtmf], [zaptel_vldtmf])
230
231 # check for basic system features and functionality before
232 # checking for package libraries
233
234 AC_FUNC_ALLOCA
235 AC_HEADER_DIRENT
236 AC_HEADER_STDC
237 AC_HEADER_SYS_WAIT
238 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])
239
240 AC_SYS_LARGEFILE
241
242 # Checks for typedefs, structures, and compiler characteristics.
243 AC_HEADER_STDBOOL
244 AC_C_CONST
245 AC_TYPE_UID_T
246 AC_C_INLINE
247 AC_TYPE_MODE_T
248 AC_TYPE_OFF_T
249 AC_TYPE_PID_T
250 AC_TYPE_SIZE_T
251 AC_CHECK_MEMBERS([struct stat.st_blksize])
252 AC_HEADER_TIME
253 AC_STRUCT_TM
254 AC_C_VOLATILE
255 AC_CHECK_TYPES([ptrdiff_t])
256
257 # Checks for library functions.
258 AC_FUNC_CHOWN
259 AC_FUNC_CLOSEDIR_VOID
260 AC_FUNC_ERROR_AT_LINE
261 AST_FUNC_FORK
262 AC_FUNC_FSEEKO
263 AC_PROG_GCC_TRADITIONAL
264 # XXX: these are commented out until we determine whether it matters if our malloc()
265 # acts exactly like glibc's or not
266 # AC_FUNC_MALLOC
267 # AC_FUNC_REALLOC
268 AC_FUNC_MEMCMP
269 AC_FUNC_MKTIME
270 AC_FUNC_MMAP
271 AC_FUNC_SELECT_ARGTYPES
272 AC_FUNC_SETVBUF_REVERSED
273 AC_TYPE_SIGNAL
274 AC_FUNC_STAT
275 AC_FUNC_STRCOLL
276 AC_FUNC_STRFTIME
277 AC_FUNC_STRNLEN
278 AC_FUNC_STRTOD
279 AC_FUNC_UTIME_NULL
280 AC_FUNC_VPRINTF
281 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])
282
283 # https support (in main/http.c) uses funopen on BSD systems,
284 # fopencookie on linux
285 AC_CHECK_FUNCS([funopen fopencookie])
286
287 # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
288 AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])
289
290 AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
291 AC_LINK_IFELSE(
292         AC_LANG_PROGRAM([#include <stdlib.h>
293                          #include <netdb.h>],
294                         [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);]),
295         AC_MSG_RESULT(yes)
296         AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
297         AC_MSG_RESULT(no)
298 )
299
300 AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
301 AC_LINK_IFELSE(
302         AC_LANG_PROGRAM([#include <stdlib.h>
303                          #include <netdb.h>],
304                         [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);]),
305         AC_MSG_RESULT(yes)
306         AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
307         AC_MSG_RESULT(no)
308 )
309
310 AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])])
311
312 AC_MSG_CHECKING(for __swap16 variant of <sys/endian.h> byteswapping macros)
313 AC_LINK_IFELSE(
314 AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = __swap16(a);]),
315 AC_MSG_RESULT(yes)
316 AC_DEFINE([HAVE_SYS_ENDIAN_SWAP16], 1, [Define to 1 if your sys/endian.h header file provides the __swap16 macro.]),
317 AC_MSG_RESULT(no)
318 )
319
320 AC_MSG_CHECKING(for bswap16 variant of <sys/endian.h> byteswapping macros)
321 AC_LINK_IFELSE(
322 AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = bswap16(a);]),
323 AC_MSG_RESULT(yes)
324 AC_DEFINE([HAVE_SYS_ENDIAN_BSWAP16], 1, [Define to 1 if your sys/endian.h header file provides the bswap16 macro.]),
325 AC_MSG_RESULT(no)
326 )
327
328 if test "${cross_compiling}" = "no";
329 then
330   AC_CHECK_FILE(/dev/urandom, AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define to 1 if your system has /dev/urandom.]))
331 fi
332
333 AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_INITIALIZER], [PTHREAD_RWLOCK_INITIALIZER], [pthread.h])
334 AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_PREFER_WRITER_NP], [PTHREAD_RWLOCK_PREFER_WRITER_NP], [pthread.h])
335
336 if test "${cross_compiling}" = "no";
337 then
338 AC_MSG_CHECKING(for working epoll support)
339 AC_LINK_IFELSE(
340 AC_LANG_PROGRAM([#include <sys/epoll.h>], [int res = epoll_create(10);
341                                           if (res < 0)
342                                              return 1;
343                                           close (res);
344                                           return 0;]),
345 AC_MSG_RESULT(yes)
346 AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]),
347 AC_MSG_RESULT(no)
348 )
349 fi
350
351 AC_MSG_CHECKING(for compiler atomic operations)
352 AC_LINK_IFELSE(
353 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
354 AC_MSG_RESULT(yes)
355 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
356 AC_MSG_RESULT(no)
357 )
358
359 AST_GCC_ATTRIBUTE(pure)
360 AST_GCC_ATTRIBUTE(malloc)
361 AST_GCC_ATTRIBUTE(const)
362 AST_GCC_ATTRIBUTE(unused)
363 AST_GCC_ATTRIBUTE(always_inline)
364 AST_GCC_ATTRIBUTE(deprecated)
365
366 AC_MSG_CHECKING(for -ffunction-sections support)
367 saved_CFLAGS="${CFLAGS}"
368 CFLAGS="${CFLAGS} -ffunction-sections"
369 AC_COMPILE_IFELSE(
370         AC_LANG_PROGRAM([], [int x = 1;]),
371         AC_MSG_RESULT(yes)
372         [saved_LDFLAGS="${LDFLAGS}"]
373         [LDFLAGS="${LDFLAGS} -Wl,--gc-sections"]
374         AC_MSG_CHECKING(for --gc-sections support)
375         AC_LINK_IFELSE(
376                 AC_LANG_PROGRAM([], [int x = 1;]),
377                 AC_MSG_RESULT(yes)
378                 [GC_CFLAGS="-ffunction-sections"]
379                 [[GC_LDFLAGS="-Wl,--gc-sections"]],
380                 AC_MSG_RESULT(no)
381         )
382         [LDFLAGS="${saved_LDFLAGS}"],
383         AC_MSG_RESULT(no)
384 )
385 CFLAGS="${saved_CFLAGS}"
386 AC_SUBST(GC_CFLAGS)
387 AC_SUBST(GC_LDFLAGS)
388
389 AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
390 if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
391         AC_MSG_RESULT(yes)
392         AST_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
393 else
394         AC_MSG_RESULT(no)
395         AST_DECLARATION_AFTER_STATEMENT=
396 fi
397 AC_SUBST(AST_DECLARATION_AFTER_STATEMENT)
398
399
400 AC_MSG_CHECKING(for sysinfo)
401 AC_LINK_IFELSE(
402         AC_LANG_PROGRAM([#include <sys/sysinfo.h>],
403                         [struct sysinfo sys_info; int uptime = sys_info.uptime]),
404         AC_MSG_RESULT(yes)
405         AC_DEFINE([HAVE_SYSINFO], 1, [Define to 1 if your system has sysinfo support]),
406         AC_MSG_RESULT(no)
407 )
408
409 AC_MSG_CHECKING(for res_ninit)
410 AC_LINK_IFELSE(
411         AC_LANG_PROGRAM([#include <resolv.h>],
412                         [int foo = res_ninit(NULL);]),
413         AC_MSG_RESULT(yes)
414         AC_DEFINE([HAVE_RES_NINIT], 1, [Define to 1 if your system has the re-entrant resolver functions.])
415         AC_MSG_CHECKING(for res_ndestroy)
416         AC_LINK_IFELSE(
417                 AC_LANG_PROGRAM([#include <resolv.h>],
418                                 [int foo = res_ndestroy(NULL);]),
419                 AC_MSG_RESULT(yes)
420                 AC_DEFINE([HAVE_RES_NDESTROY], 1, [Define to 1 if your system has the ndestroy resolver function.]),
421                 AC_MSG_RESULT(no)
422         ),
423         AC_MSG_RESULT(no)
424 )
425
426 AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
427
428 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
429
430 AC_CHECK_HEADER([libkern/OSAtomic.h],
431                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
432
433 AC_CHECK_SIZEOF(int)
434
435 # do the package library checks now
436
437 AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
438
439 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
440
441 if test "x${host_os}" = "xlinux-gnu" ; then
442   AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
443 fi
444
445 # BSD might not have exp2, and/or log2
446 AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
447 AST_EXT_LIB_CHECK([LOG2L], [m], [log2l])
448 AST_EXT_LIB_CHECK([EXP10L], [m], [exp10l])
449 AST_EXT_LIB_CHECK([LOG10L], [m], [log10l])
450 AST_EXT_LIB_CHECK([SINL], [m], [sinl])
451 AST_EXT_LIB_CHECK([COSL], [m], [cosl])
452 AST_EXT_LIB_CHECK([TANL], [m], [tanl])
453 AST_EXT_LIB_CHECK([ASINL], [m], [asinl])
454 AST_EXT_LIB_CHECK([ACOSL], [m], [acosl])
455 AST_EXT_LIB_CHECK([ATANL], [m], [atanl])
456 AST_EXT_LIB_CHECK([ATAN2L], [m], [atan2l])
457 AST_EXT_LIB_CHECK([POWL], [m], [powl])
458 AST_EXT_LIB_CHECK([SQRTL], [m], [sqrtl])
459 AST_EXT_LIB_CHECK([RINTL], [m], [rintl])
460 AST_EXT_LIB_CHECK([EXPL], [m], [expl])
461 AST_EXT_LIB_CHECK([LOGL], [m], [logl])
462 AST_EXT_LIB_CHECK([REMAINDERL], [m], [remainderl])
463 AST_EXT_LIB_CHECK([FMODL], [m], [fmodl])
464 AST_EXT_LIB_CHECK([ROUNDL], [m], [roundl])
465 AST_EXT_LIB_CHECK([TRUNCL], [m], [truncl])
466 AST_EXT_LIB_CHECK([STRTOLD], [c], [strtold], [stdlib.h])
467 AST_EXT_LIB_CHECK([FLOORL], [m], [floorl])
468 AST_EXT_LIB_CHECK([CEILL], [m], [ceill])
469 AST_EXT_LIB_CHECK([EXP2], [m], [exp2])
470 AST_EXT_LIB_CHECK([LOG2], [m], [log2])
471 AST_EXT_LIB_CHECK([EXP10], [m], [exp10])
472 AST_EXT_LIB_CHECK([LOG10], [m], [log10])
473 AST_EXT_LIB_CHECK([SIN], [m], [sin])
474 AST_EXT_LIB_CHECK([COS], [m], [cos])
475 AST_EXT_LIB_CHECK([TAN], [m], [tan])
476 AST_EXT_LIB_CHECK([ASIN], [m], [asin])
477 AST_EXT_LIB_CHECK([ACOS], [m], [acos])
478 AST_EXT_LIB_CHECK([ATAN], [m], [atan])
479 AST_EXT_LIB_CHECK([ATAN2], [m], [atan2])
480 AST_EXT_LIB_CHECK([POW], [m], [pow])
481 AST_EXT_LIB_CHECK([SQRT], [m], [sqrt])
482 AST_EXT_LIB_CHECK([RINT], [m], [rint])
483 AST_EXT_LIB_CHECK([EXP], [m], [exp])
484 AST_EXT_LIB_CHECK([LOG], [m], [log])
485 AST_EXT_LIB_CHECK([REMAINDER], [m], [remainder])
486 AST_EXT_LIB_CHECK([FMOD], [m], [fmod])
487 AST_EXT_LIB_CHECK([ROUND], [m], [round])
488 AST_EXT_LIB_CHECK([TRUNC], [m], [trunc])
489 AST_EXT_LIB_CHECK([STRTOD], [c], [strtod], [stdlib.h])
490 AST_EXT_LIB_CHECK([FLOOR], [m], [floor])
491 AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
492
493 GSM_INTERNAL="yes"
494 AC_SUBST(GSM_INTERNAL)
495 GSM_SYSTEM="yes"
496 if test "${USE_GSM}" != "no"; then
497    if test "${GSM_DIR}" = "internal"; then
498       GSM_SYSTEM="no"
499    elif test "${GSM_DIR}" != ""; then
500       GSM_INTERNAL="no"
501    fi
502    if test "${GSM_SYSTEM}" = "yes"; then
503       gsmlibdir=""
504       if test "x${GSM_DIR}" != "x"; then
505          if test -d ${GSM_DIR}/lib; then
506             gsmlibdir="-L${GSM_DIR}/lib"
507          else
508             gsmlibdir="-L${GSM_DIR}"
509          fi
510       fi
511       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
512       [Define to indicate the GSM library]), [], ${gsmlibdir})
513       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
514          if test "x${GSM_DIR}" != "x" ; then
515             AC_CHECK_HEADER([${GSM_DIR}/include/gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
516             AC_CHECK_HEADER([${GSM_DIR}/include/gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
517          else
518             AC_CHECK_HEADER([gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
519             AC_CHECK_HEADER([gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
520          fi
521          if test "${GSM_HEADER_FOUND}" = "0" ; then
522             if test "{GSM_GSM_HEADER_FOUND}" = "0" ; then
523                if test "x${GSM_MANDATORY}" = "xyes" ; then
524                   AC_MSG_NOTICE([***])
525                   AC_MSG_NOTICE([*** It appears that you do not have the gsm development package installed.])
526                   AC_MSG_NOTICE([*** Please install it to include ${GSM_DESCRIP} support, or re-run configure])
527                   AC_MSG_NOTICE([*** without explicitly specifying --with-${GSM_OPTION}])
528                   exit 1
529                fi
530             fi
531          fi
532          GSM_OK=0
533          if test "${GSM_HEADER_FOUND}" = "1" ; then
534             AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
535             GSM_OK=1
536          else
537             if test "${GSM_GSM_HEADER_FOUND}" = "1" ; then
538                AC_DEFINE_UNQUOTED([HAVE_GSM_GSM_HEADER], 1, [Define to indicate that gsm.h is in gsm/gsm.h])
539                GSM_OK=1
540             fi
541          fi
542          if test "${GSM_OK}" = "1" ; then
543             GSM_LIB="-lgsm"
544             if test "x${GSM_DIR}" != "x"; then
545                GSM_LIB="${gsmlibdir} ${GSM_LIB}"
546                GSM_INCLUDE="-I${GSM_DIR}/include"
547             fi
548             PBX_GSM=1
549             GSM_INTERNAL="no"
550          fi
551       fi
552    fi
553    if test "${GSM_INTERNAL}" = "yes"; then
554       PBX_GSM=1
555       AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
556    fi
557 fi
558
559 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
560
561 if test "${USE_IMAP_TK}" != "no"; then
562    if test "${IMAP_TK_DIR}" = "system" ; then
563       AC_MSG_NOTICE([Checking for system c-client library...])
564    elif test "${IMAP_TK_DIR}" = ""; then
565       IMAP_TK_DIR=`pwd`"/../imap-2004g"
566       if test  -n "${IMAP_TK_MANDATORY}"; then
567          AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
568          AC_MSG_NOTICE([c-client library/header files. Since you did not provide a path])
569          AC_MSG_NOTICE([the configure script will assume you have placed built the c-client])
570          AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
571       fi
572    fi
573    if test "${IMAP_TK_DIR}" != "system" ; then
574       AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
575    fi
576    saved_cppflags="${CPPFLAGS}"
577    saved_libs="${LIBS}"
578    if test "${IMAP_TK_DIR}" = "system" ; then
579       imap_ldflags=""
580       imap_libs="-lc-client"
581       imap_include="-DUSE_SYSTEM_IMAP"
582    elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
583       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
584       imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
585       imap_include="-I${IMAP_TK_DIR}/c-client"
586    fi
587    CPPFLAGS="${CPPFLAGS} ${imap_include}"
588    LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
589    AC_LINK_IFELSE(
590         AC_LANG_PROGRAM(
591                 [#ifdef USE_SYSTEM_IMAP
592                 #include <imap/c-client.h>
593                 #else
594                 #include "c-client.h"
595                 #endif
596                 void mm_searched (MAILSTREAM *stream,unsigned long number)
597                 {
598                 }
599                 void mm_exists (MAILSTREAM *stream,unsigned long number)
600                 {
601                 }
602                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
603                 {
604                 }
605                 void mm_flags (MAILSTREAM *stream,unsigned long number)
606                 {
607                 }
608                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
609                 {
610                 }
611                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
612                 {
613                 }
614                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
615                 {
616                 }
617                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
618                 {
619                 }
620                 void mm_log (char *string,long errflg)
621                 {
622                 }
623                 void mm_dlog (char *string)
624                 {
625                 }
626                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
627                 {
628                 }
629                 void mm_critical (MAILSTREAM *stream)
630                 {
631                 }
632                 void mm_nocritical (MAILSTREAM *stream)
633                 {
634                 }
635                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
636                 {
637                 }
638                 void mm_fatal (char *string)
639                 {
640                 }],
641                 [
642                 MAILSTREAM *foo = mail_open(NULL, "", 0);
643                 ]
644         ),
645         [ac_cv_imap_tk="yes"],
646         [ac_cv_imap_tk="no"]
647    )
648    if test "${ac_cv_imap_tk}" = "yes"; then
649    AC_LINK_IFELSE(
650       AC_LANG_PROGRAM(
651          [#ifdef USE_SYSTEM_IMAP
652          #include <imap/c-client.h>
653          #else
654          #include "c-client.h"
655          #endif
656          void mm_searched (MAILSTREAM *stream,unsigned long number)
657          {
658          }
659          void mm_exists (MAILSTREAM *stream,unsigned long number)
660          {
661          }
662          void mm_expunged (MAILSTREAM *stream,unsigned long number)
663          {
664          }
665          void mm_flags (MAILSTREAM *stream,unsigned long number)
666          {
667          }
668          void mm_notify (MAILSTREAM *stream,char *string,long errflg)
669          {
670          }
671          void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
672          {
673          }
674          void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
675          {
676          }
677          void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
678          {
679          }
680          void mm_log (char *string,long errflg)
681          {
682          }
683          void mm_dlog (char *string)
684          {
685          }
686          void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
687          {
688          }
689          void mm_critical (MAILSTREAM *stream)
690          {
691          }
692          void mm_nocritical (MAILSTREAM *stream)
693          {
694          }
695          long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
696          {
697          }
698          void mm_fatal (char *string)
699          {
700          }],
701          [
702          long check = mail_expunge_full(NULL, "", 0);
703          ]
704       ),
705       [ac_cv_imap_tk2006="yes"],
706       [ac_cv_imap_tk2006="no"]
707   )
708   fi
709    CPPFLAGS="${saved_cppflags}"
710    LIBS="${saved_libs}"
711    if test "${ac_cv_imap_tk}" = "yes"; then
712       AC_MSG_RESULT(yes) 
713       IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
714       IMAP_TK_INCLUDE="${imap_include}"
715       PBX_IMAP_TK=1
716       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
717       if test "${ac_cv_imap_tk2006}" = "yes"; then
718          AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
719       fi
720    else
721       AC_MSG_RESULT(no) 
722    fi
723 fi
724
725 # Needed by unixodbc
726 AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], [])
727
728 AC_LANG_PUSH(C++)
729
730 if test "${USE_KDE}" != "no"; then
731    AC_MSG_CHECKING(for crashHandler in -lkdecore)
732    saved_libs="${LIBS}"
733    saved_cppflags="${CPPFLAGS}"
734    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
735    if test -d ${KDE_DIR}/lib; then
736       kdelibdir="${KDE_DIR}/lib"
737    else
738       kdelibdir="${KDE_DIR}"
739    fi
740    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
741
742    AC_LINK_IFELSE(
743         [AC_LANG_PROGRAM(
744                         [#include "kcrash.h"],
745                         [KCrash::defaultCrashHandler(1);])
746         ],
747         [ac_cv_lib_kde_crash="yes"],
748         [ac_cv_lib_kde_crash="no"])
749                 
750    LIBS="${saved_libs}"
751    CPPFLAGS="${saved_cppflags}"
752         
753    if test "${ac_cv_lib_kde_crash}" = "yes"; then
754       AC_MSG_RESULT(yes) 
755       KDE_LIB="-lkdecore -lkdeui"
756       if test "${KDE_DIR}" != ""; then
757          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
758          KDE_INCLUDE="-I${KDE_DIR}/include"
759       fi
760       PBX_KDE=1
761       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
762    else
763       AC_MSG_RESULT(no) 
764    fi
765 fi
766 if test "${PBX_KDE}" = 1; then
767    AC_PATH_TOOL(KDEINIT, kdeinit, No)
768    if test ! x"${KDEINIT}" = xNo; then
769       KDEDIR=$(${DIRNAME} ${KDEINIT})
770       KDEDIR=$(${DIRNAME} ${KDEDIR})
771    fi
772    AC_SUBST([KDEDIR])
773 fi
774
775 AC_LANG_POP
776
777 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
778
779 if test "${PBX_MISDN}" = 1; then
780    AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
781    AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
782    AST_C_DEFINE_CHECK([MISDN_FAC_RESULT], [Fac_RESULT], [mISDNuser/suppserv.h])
783    AST_C_DEFINE_CHECK([MISDN_FAC_ERROR], [Fac_ERROR], [mISDNuser/suppserv.h])
784    AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
785 fi
786
787 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
788
789 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
790
791 NETSNMP_CONFIG=No
792 if test "${USE_NETSNMP}" != "no"; then  
793    if test "x${NETSNMP_DIR}" != "x"; then
794       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
795       if test x"${NETSNMP_CONFIG}" = xNo; then
796          AC_MSG_NOTICE([***])
797          AC_MSG_NOTICE([*** net-snmp-config was not found in the path you specified:])
798          AC_MSG_NOTICE([*** ${NETSNMP_DIR}/bin])
799          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
800          AC_MSG_NOTICE([*** including --without-netsnmp])
801          exit 1
802       fi
803    else
804       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
805    fi
806 fi
807 if test x"${NETSNMP_CONFIG}" != xNo; then
808    NETSNMP_libs=`${NETSNMP_CONFIG} --agent-libs`
809    
810    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
811    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
812
813    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
814       NETSNMP_LIB="${NETSNMP_libs}"
815       PBX_NETSNMP=1
816    fi
817 fi
818
819 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
820
821 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
822
823 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
824
825 AST_EXT_LIB_CHECK([BKTR], [execinfo], [backtrace], [execinfo.h], [-lexecinfo])
826
827 # possible places for oss definitions
828 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
829 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
830 AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
831
832 PG_CONFIG=No
833 if test "${USE_PGSQL}" != "no"; then    
834    if test "x${PGSQL_DIR}" != "x"; then
835       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
836       if test x"${PG_CONFIG}" = xNo; then
837          AC_MSG_NOTICE([***])
838          AC_MSG_NOTICE([*** pg_config was not found in the path you specified:])
839          AC_MSG_NOTICE([*** ${PGSQL_DIR}/bin])
840          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
841          AC_MSG_NOTICE([*** including --without-postgres])
842          exit 1
843       fi
844    else
845       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
846    fi
847 fi
848 if test "${PG_CONFIG}" != No; then
849    PGSQL_libdir=`${PG_CONFIG} --libdir`
850    PGSQL_includedir=`${PG_CONFIG} --includedir`
851    if test "x$?" != "x0" ; then
852       if test -n "${PGSQL_MANDATORY}" ; then
853          AC_MSG_NOTICE([***])
854          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
855          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
856          AC_MSG_NOTICE([*** including --without-postgres])
857          exit 1
858           fi
859    else 
860       AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
861       [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
862
863       if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
864          PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
865          PGSQL_INCLUDE="-I${PGSQL_includedir}"
866          PBX_PGSQL=1
867       elif test -n "${PGSQL_MANDATORY}";
868       then
869          AC_MSG_NOTICE([***])
870          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
871          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
872          AC_MSG_NOTICE([*** including --without-postgres])
873          exit 1
874       fi
875    fi
876 fi
877
878 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
879
880 AST_EXT_LIB_CHECK([PRI], [pri], [pri_keypad_facility], [libpri.h])
881
882 AST_EXT_LIB_CHECK([SS7], [ss7], [isup_cqr], [libss7.h])
883
884 if test "${USE_PWLIB}" != "no"; then
885         if test -n "${PWLIB_DIR}"; then
886                 PWLIBDIR="${PWLIB_DIR}"
887         fi
888         AST_CHECK_PWLIB()
889         AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2])
890                 
891         if test "${HAS_PWLIB:-unset}" != "unset"; then
892                 AST_CHECK_OPENH323_PLATFORM()
893
894                 PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r"
895
896                 AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
897                         [Define if your system has the PWLib libraries.],
898                         [#include "ptlib.h"],
899                         [BOOL q = PTime::IsDaylightSavings();])
900         fi
901 fi
902
903 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
904         if test -n "${OPENH323_DIR}"; then
905                 OPENH323DIR="${OPENH323_DIR}"
906         fi
907         AST_CHECK_OPENH323()
908         AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3])
909         AST_CHECK_OPENH323_BUILD()
910         PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
911         AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],
912                 [Define if your system has the OpenH323 libraries.],
913                 [#include "ptlib.h"
914                 #include "h323.h"
915                 #include "h323ep.h"],
916                 [H323EndPoint ep = H323EndPoint();],
917                 [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
918 fi
919
920 AC_LANG_PUSH(C++)
921
922 if test "${USE_QT}" != "no"; then
923    AC_MSG_CHECKING(for QDate in -lqt)
924    saved_libs="${LIBS}"
925    saved_cppflags="${CPPFLAGS}"
926    if test "x${QT_DIR}" != "x"; then
927       LIBS="${LIBS} -L${QT_DIR}/lib"
928       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
929    fi
930    LIBS="${LIBS} -lqt"
931    qtlib="qt"
932    AC_LINK_IFELSE(
933         [
934                 AC_LANG_PROGRAM(
935                 [#include <qt3/qdatetime.h>],
936                 [QDate date();])
937         ],
938         [ac_cv_lib_qt_qt_date="yes"],
939         [ac_cv_lib_qt_qt_date="no"])
940    LIBS="${saved_libs}"
941    CPPFLAGS="${saved_cppflags}"
942         
943    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
944       saved_libs="${LIBS}"
945       saved_cppflags="${CPPFLAGS}"
946       if test "x${QT_DIR}" != "x"; then
947          LIBS="${LIBS} -L${QT_DIR}/lib"
948          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
949       fi
950       LIBS="${LIBS} -lqt-mt"
951       qtlib="qt-mt"     
952       AC_LINK_IFELSE(
953                 [
954                         AC_LANG_PROGRAM(
955                         [#include <qt3/qdatetime.h>],
956                         [QDate date();])
957                 ],
958                 [ac_cv_lib_qt_qt_date="yes"],
959                 [ac_cv_lib_qt_qt_date="no"])
960       LIBS="${saved_libs}"
961       CPPFLAGS="${saved_cppflags}"
962    fi   
963
964    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
965       AC_MSG_RESULT(yes) 
966    else
967       AC_MSG_RESULT(no) 
968    fi
969         
970    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
971       QT_LIB="-l${qtlib}"
972       if test "${QT_DIR}" != ""; then
973          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
974          QT_INCLUDE="-I${QT_DIR}/include"
975       fi
976       PBX_QT=1
977       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
978       AC_PATH_TOOL(QTMOC, moc, No)
979    fi
980 fi
981
982 AC_LANG_POP
983
984 LUA_INCLUDE="-I/usr/include/lua5.1"
985 LUA_LIB="-llua5.1"
986 AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h]) 
987
988 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
989
990 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
991
992 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
993
994 AST_EXT_LIB_CHECK([SQLITE3], [sqlite3], [sqlite3_open], [sqlite3.h])
995
996 AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h])
997
998 if test "$PBX_CRYPTO" = "1";
999 then
1000     AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
1001 fi
1002
1003 if test "$PBX_OPENSSL" = "1";
1004 then
1005     AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
1006 fi
1007
1008 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
1009 if test "${PBX_FREETDS}" != "0";
1010 then
1011     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr}/include/tdsver.h` in
1012         *0.64*)
1013                 FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
1014         ;;
1015     *0.63*)
1016         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
1017         ;;
1018     *0.62*)
1019         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
1020         ;;
1021     *)
1022         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
1023         ;;
1024     esac
1025 fi
1026
1027 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
1028
1029 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
1030
1031 if test "${host_os}" != "linux-gnu" ; then
1032   tonezone_extra="-lm"
1033 fi
1034
1035 # new tonezone, version 1.4.0
1036 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}], [140])
1037 # other case, old tonezone (0.80)
1038 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/zaptel.h], [${tonezone_extra}], [80])
1039
1040 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h], [])
1041
1042 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
1043
1044 AC_LANG_PUSH(C++)
1045
1046 if test "${USE_VPB}" != "no"; then
1047    AC_MSG_CHECKING(for vpb_open in -lvpb)
1048    saved_libs="${LIBS}"
1049    saved_cppflags="${CPPFLAGS}"
1050    if test "x${VPB_DIR}" != "x"; then
1051       if test -d ${VPB_DIR}/lib; then
1052          vpblibdir=${VPB_DIR}/lib
1053       else
1054          vpblibdir=${VPB_DIR}
1055       fi
1056       LIBS="${LIBS} -L${vpblibdir}"
1057       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
1058    fi
1059    LIBS="${LIBS} -lvpb -lpthread"
1060    AC_LINK_IFELSE(
1061         [
1062         AC_LANG_PROGRAM(
1063         [#include <vpbapi.h>],
1064         [int q = vpb_open(0,0);])
1065         ],
1066         [       AC_MSG_RESULT(yes) 
1067                 ac_cv_lib_vpb_vpb_open="yes" 
1068         ],
1069         [       AC_MSG_RESULT(no) 
1070                 ac_cv_lib_vpb_vpb_open="no" 
1071         ]
1072         )
1073    LIBS="${saved_libs}"
1074    CPPFLAGS="${saved_cppflags}"
1075    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
1076         VPB_LIB="-lvpb"
1077         if test "${VPB_DIR}" != ""; then
1078            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
1079            VPB_INCLUDE="-I${VPB_DIR}/include"
1080         fi
1081         PBX_VPB=1
1082         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
1083    fi
1084 fi
1085
1086 AC_LANG_POP
1087
1088 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
1089
1090 # Check for various zaptel features and locations.
1091 # The version number, which goes into HAVE_ZAPTEL_VERSION,
1092 # will be used in the system headers to determine the location
1093 # of the zaptel.h header.
1094
1095 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_TONE_DTMF_BASE], [zaptel/zaptel.h], [140])
1096 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_DIAL_OP_CANCEL], [zaptel/zaptel.h], [90])
1097
1098 # Check for VLDTMF support
1099 AST_C_DEFINE_CHECK([ZAPTEL_VLDTMF], [ZT_EVENT_REMOVED], [zaptel/zaptel.h])
1100
1101 # Check for transcode support
1102 AST_C_DEFINE_CHECK([ZAPTEL_TRANSCODE], [ZT_TCOP_ALLOCATE], [zaptel/zaptel.h])
1103
1104 # On FreeBSD, try old zaptel (0.80 or so) and pretend we have vldtmf
1105 case "${host_os}" in
1106     freebsd*)
1107         AST_EXT_LIB_CHECK([ZAPTEL], [zaptel],, [zaptel.h],, [80])
1108         AST_EXT_LIB_CHECK([ZAPTEL_VLDTMF], [zaptel],, [zaptel/zaptel.h],, [90])
1109         AST_EXT_LIB_CHECK([ZAPTEL_VLDTMF], [zaptel],, [zaptel.h],, [80])
1110
1111         # other case, old tonezone (0.80)
1112         AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel.h], [${tonezone_extra}], [80])
1113         ;;
1114 esac
1115
1116 EDITLINE_LIB=""
1117 if test "x$TERMCAP_LIB" != "x" ; then
1118   EDITLINE_LIB="$TERMCAP_LIB"
1119 elif test "x$TINFO_LIB" != "x" ; then
1120   EDITLINE_LIB="$TINFO_LIB"
1121 elif test "x$CURSES_LIB" != "x" ; then
1122   EDITLINE_LIB="$CURSES_LIB"
1123 elif test "x$NCURSES_LIB" != "x" ; then
1124   EDITLINE_LIB="$NCURSES_LIB"
1125 else
1126   AC_MSG_ERROR(*** termcap support not found)
1127 fi
1128 AC_SUBST(EDITLINE_LIB)
1129
1130 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
1131 AC_SUBST(PBX_H323)
1132
1133 AC_CHECK_HEADER([linux/compiler.h],
1134                 [AC_DEFINE_UNQUOTED([HAVE_LINUX_COMPILER_H], 1, [Define to 1 if your system has linux/compiler.h.])])
1135
1136 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
1137                                    #include <linux/version.h>
1138                                    #ifdef HAVE_LINUX_COMPILER_H
1139                                    #include <linux/compiler.h>
1140                                    #endif
1141                                    ])
1142 AC_SUBST(PBX_IXJUSER)
1143
1144 PBX_GTK=0
1145 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
1146 if test ! "x${GTKCONFIG}" = xNo; then
1147    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
1148    GTK_LIB=$(${GTKCONFIG} --libs gthread)
1149    PBX_GTK=1
1150    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
1151 fi
1152 AC_SUBST(PBX_GTK)
1153 AC_SUBST(GTK_INCLUDE)
1154 AC_SUBST(GTK_LIB)
1155
1156 PBX_GTK2=0
1157 AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
1158 if test ! "x${PKGCONFIG}" = xNo; then
1159    GTK2_INCLUDE=$(${PKGCONFIG} gtk+-2.0 --cflags 2>/dev/null)
1160    GTK2_LIB=$(${PKGCONFIG} gtk+-2.0 --libs)
1161    PBX_GTK2=1
1162    AC_DEFINE([HAVE_GTK2], 1, [Define if your system has the GTK2 libraries.])
1163 fi
1164 AC_SUBST(PBX_GTK2)
1165 AC_SUBST(GTK2_INCLUDE)
1166 AC_SUBST(GTK2_LIB)
1167
1168 if test "${USE_CURL}" != "no"; then
1169    AC_PATH_TOOL([CURL_CONFIG], [curl-config], No)
1170    if test ! x"${CURL_CONFIG}" = xNo; then
1171    # check for version
1172       if test $(printf "%d" 0x$(${CURL_CONFIG} --vernum)) -ge $(printf "%d" 0x070907); then
1173          CURL_INCLUDE=$(${CURL_CONFIG} --cflags)
1174          CURL_LIB=$(${CURL_CONFIG} --libs)
1175
1176          AC_MSG_CHECKING(for curl_version() in curl/curl.h)
1177          saved_cppflags="${CPPFLAGS}"
1178          CPPFLAGS="${CPPFLAGS} ${CURL_INCLUDE}"
1179          AC_COMPILE_IFELSE(
1180             [AC_LANG_PROGRAM(
1181                 [#include <curl/curl.h>],
1182                     [curl_version();])
1183             ],[
1184                 AC_MSG_RESULT(yes)
1185                 ac_cv_curl_h="yes"
1186             ],[
1187                 AC_MSG_RESULT(no)
1188                 ac_cv_curl_h="no"
1189             ]
1190          )
1191          CPPFLAGS="${saved_cppflags}"
1192          if test "${ac_cv_curl_h}" = "yes"; then
1193              PBX_CURL=1
1194              AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
1195          fi
1196       fi
1197    fi
1198 fi
1199
1200 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
1201 AST_CHECK_MANDATORY
1202
1203 AC_OUTPUT
1204
1205 if test "x${silent}" != "xyes" ; then
1206 echo
1207 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
1208 echo "            .\$7\$7..          .7\$\$7:.    "
1209 echo "          .\$\$:.                 ,\$7.7   "
1210 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
1211 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
1212 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
1213 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
1214 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
1215 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
1216 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
1217 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
1218 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
1219 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
1220 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
1221 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
1222 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
1223 echo " \$\$\$\$\$                        \$\$\$       "
1224 echo "  \$\$\$\$7.                       \$\$  (TM)     "
1225 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
1226 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
1227 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
1228 echo
1229 fi
1230
1231 AC_MSG_NOTICE(Package configured for: )
1232 AC_MSG_NOTICE( OS type  : $host_os)
1233 AC_MSG_NOTICE( Host CPU : $host_cpu)
1234 if test "${cross_compiling}" = "yes"; then
1235    AC_MSG_NOTICE( Cross Compilation = YES)
1236 fi