Set up detection of IP_PKTINFO in autoconf for chan_unistim
[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 # check if we have IP_PKTINFO constant defined
288 AC_LINK_IFELSE(
289                 AC_LANG_PROGRAM([#include <netinet/in.h>],
290                                                 [int pi = IP_PKTINFO;]),
291                 AC_MSG_RESULT(yes)
292                 AC_DEFINE([HAVE_PKTINFO], 1, [Define to 1 if your system defines IP_PKTINFO.]),
293                 AC_MSG_RESULT(no)
294 )
295
296 # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
297 AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])
298
299 AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
300 AC_LINK_IFELSE(
301         AC_LANG_PROGRAM([#include <stdlib.h>
302                          #include <netdb.h>],
303                         [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);]),
304         AC_MSG_RESULT(yes)
305         AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
306         AC_MSG_RESULT(no)
307 )
308
309 AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
310 AC_LINK_IFELSE(
311         AC_LANG_PROGRAM([#include <stdlib.h>
312                          #include <netdb.h>],
313                         [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);]),
314         AC_MSG_RESULT(yes)
315         AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
316         AC_MSG_RESULT(no)
317 )
318
319 AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])])
320
321 AC_MSG_CHECKING(for __swap16 variant of <sys/endian.h> byteswapping macros)
322 AC_LINK_IFELSE(
323 AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = __swap16(a);]),
324 AC_MSG_RESULT(yes)
325 AC_DEFINE([HAVE_SYS_ENDIAN_SWAP16], 1, [Define to 1 if your sys/endian.h header file provides the __swap16 macro.]),
326 AC_MSG_RESULT(no)
327 )
328
329 AC_MSG_CHECKING(for bswap16 variant of <sys/endian.h> byteswapping macros)
330 AC_LINK_IFELSE(
331 AC_LANG_PROGRAM([#include <sys/endian.h>], [int a = 1; int b = bswap16(a);]),
332 AC_MSG_RESULT(yes)
333 AC_DEFINE([HAVE_SYS_ENDIAN_BSWAP16], 1, [Define to 1 if your sys/endian.h header file provides the bswap16 macro.]),
334 AC_MSG_RESULT(no)
335 )
336
337 if test "${cross_compiling}" = "no";
338 then
339   AC_CHECK_FILE(/dev/urandom, AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define to 1 if your system has /dev/urandom.]))
340 fi
341
342 AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_INITIALIZER], [PTHREAD_RWLOCK_INITIALIZER], [pthread.h])
343 AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_PREFER_WRITER_NP], [PTHREAD_RWLOCK_PREFER_WRITER_NP], [pthread.h])
344
345 if test "${cross_compiling}" = "no";
346 then
347 AC_MSG_CHECKING(for working epoll support)
348 AC_LINK_IFELSE(
349 AC_LANG_PROGRAM([#include <sys/epoll.h>], [int res = epoll_create(10);
350                                           if (res < 0)
351                                              return 1;
352                                           close (res);
353                                           return 0;]),
354 AC_MSG_RESULT(yes)
355 AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]),
356 AC_MSG_RESULT(no)
357 )
358 fi
359
360 AC_MSG_CHECKING(for compiler atomic operations)
361 AC_LINK_IFELSE(
362 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
363 AC_MSG_RESULT(yes)
364 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
365 AC_MSG_RESULT(no)
366 )
367
368 AST_GCC_ATTRIBUTE(pure)
369 AST_GCC_ATTRIBUTE(malloc)
370 AST_GCC_ATTRIBUTE(const)
371 AST_GCC_ATTRIBUTE(unused)
372 AST_GCC_ATTRIBUTE(always_inline)
373 AST_GCC_ATTRIBUTE(deprecated)
374
375 AC_MSG_CHECKING(for -ffunction-sections support)
376 saved_CFLAGS="${CFLAGS}"
377 CFLAGS="${CFLAGS} -ffunction-sections"
378 AC_COMPILE_IFELSE(
379         AC_LANG_PROGRAM([], [int x = 1;]),
380         AC_MSG_RESULT(yes)
381         [saved_LDFLAGS="${LDFLAGS}"]
382         [LDFLAGS="${LDFLAGS} -Wl,--gc-sections"]
383         AC_MSG_CHECKING(for --gc-sections support)
384         AC_LINK_IFELSE(
385                 AC_LANG_PROGRAM([], [int x = 1;]),
386                 AC_MSG_RESULT(yes)
387                 [GC_CFLAGS="-ffunction-sections"]
388                 [[GC_LDFLAGS="-Wl,--gc-sections"]],
389                 AC_MSG_RESULT(no)
390         )
391         [LDFLAGS="${saved_LDFLAGS}"],
392         AC_MSG_RESULT(no)
393 )
394 CFLAGS="${saved_CFLAGS}"
395 AC_SUBST(GC_CFLAGS)
396 AC_SUBST(GC_LDFLAGS)
397
398 AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
399 if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
400         AC_MSG_RESULT(yes)
401         AST_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
402 else
403         AC_MSG_RESULT(no)
404         AST_DECLARATION_AFTER_STATEMENT=
405 fi
406 AC_SUBST(AST_DECLARATION_AFTER_STATEMENT)
407
408
409 AC_MSG_CHECKING(for sysinfo)
410 AC_LINK_IFELSE(
411         AC_LANG_PROGRAM([#include <sys/sysinfo.h>],
412                         [struct sysinfo sys_info; int uptime = sys_info.uptime]),
413         AC_MSG_RESULT(yes)
414         AC_DEFINE([HAVE_SYSINFO], 1, [Define to 1 if your system has sysinfo support]),
415         AC_MSG_RESULT(no)
416 )
417
418 AC_MSG_CHECKING(for res_ninit)
419 AC_LINK_IFELSE(
420         AC_LANG_PROGRAM([#include <resolv.h>],
421                         [int foo = res_ninit(NULL);]),
422         AC_MSG_RESULT(yes)
423         AC_DEFINE([HAVE_RES_NINIT], 1, [Define to 1 if your system has the re-entrant resolver functions.])
424         AC_MSG_CHECKING(for res_ndestroy)
425         AC_LINK_IFELSE(
426                 AC_LANG_PROGRAM([#include <resolv.h>],
427                                 [int foo = res_ndestroy(NULL);]),
428                 AC_MSG_RESULT(yes)
429                 AC_DEFINE([HAVE_RES_NDESTROY], 1, [Define to 1 if your system has the ndestroy resolver function.]),
430                 AC_MSG_RESULT(no)
431         ),
432         AC_MSG_RESULT(no)
433 )
434
435 AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
436
437 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
438
439 AC_CHECK_HEADER([libkern/OSAtomic.h],
440                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
441
442 AC_CHECK_SIZEOF(int)
443
444 # do the package library checks now
445
446 AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
447
448 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
449
450 if test "x${host_os}" = "xlinux-gnu" ; then
451   AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
452 fi
453
454 # BSD might not have exp2, and/or log2
455 AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
456 AST_EXT_LIB_CHECK([LOG2L], [m], [log2l])
457 AST_EXT_LIB_CHECK([EXP10L], [m], [exp10l])
458 AST_EXT_LIB_CHECK([LOG10L], [m], [log10l])
459 AST_EXT_LIB_CHECK([SINL], [m], [sinl])
460 AST_EXT_LIB_CHECK([COSL], [m], [cosl])
461 AST_EXT_LIB_CHECK([TANL], [m], [tanl])
462 AST_EXT_LIB_CHECK([ASINL], [m], [asinl])
463 AST_EXT_LIB_CHECK([ACOSL], [m], [acosl])
464 AST_EXT_LIB_CHECK([ATANL], [m], [atanl])
465 AST_EXT_LIB_CHECK([ATAN2L], [m], [atan2l])
466 AST_EXT_LIB_CHECK([POWL], [m], [powl])
467 AST_EXT_LIB_CHECK([SQRTL], [m], [sqrtl])
468 AST_EXT_LIB_CHECK([RINTL], [m], [rintl])
469 AST_EXT_LIB_CHECK([EXPL], [m], [expl])
470 AST_EXT_LIB_CHECK([LOGL], [m], [logl])
471 AST_EXT_LIB_CHECK([REMAINDERL], [m], [remainderl])
472 AST_EXT_LIB_CHECK([FMODL], [m], [fmodl])
473 AST_EXT_LIB_CHECK([ROUNDL], [m], [roundl])
474 AST_EXT_LIB_CHECK([TRUNCL], [m], [truncl])
475 AST_EXT_LIB_CHECK([STRTOLD], [c], [strtold], [stdlib.h])
476 AST_EXT_LIB_CHECK([FLOORL], [m], [floorl])
477 AST_EXT_LIB_CHECK([CEILL], [m], [ceill])
478 AST_EXT_LIB_CHECK([EXP2], [m], [exp2])
479 AST_EXT_LIB_CHECK([LOG2], [m], [log2])
480 AST_EXT_LIB_CHECK([EXP10], [m], [exp10])
481 AST_EXT_LIB_CHECK([LOG10], [m], [log10])
482 AST_EXT_LIB_CHECK([SIN], [m], [sin])
483 AST_EXT_LIB_CHECK([COS], [m], [cos])
484 AST_EXT_LIB_CHECK([TAN], [m], [tan])
485 AST_EXT_LIB_CHECK([ASIN], [m], [asin])
486 AST_EXT_LIB_CHECK([ACOS], [m], [acos])
487 AST_EXT_LIB_CHECK([ATAN], [m], [atan])
488 AST_EXT_LIB_CHECK([ATAN2], [m], [atan2])
489 AST_EXT_LIB_CHECK([POW], [m], [pow])
490 AST_EXT_LIB_CHECK([SQRT], [m], [sqrt])
491 AST_EXT_LIB_CHECK([RINT], [m], [rint])
492 AST_EXT_LIB_CHECK([EXP], [m], [exp])
493 AST_EXT_LIB_CHECK([LOG], [m], [log])
494 AST_EXT_LIB_CHECK([REMAINDER], [m], [remainder])
495 AST_EXT_LIB_CHECK([FMOD], [m], [fmod])
496 AST_EXT_LIB_CHECK([ROUND], [m], [round])
497 AST_EXT_LIB_CHECK([TRUNC], [m], [trunc])
498 AST_EXT_LIB_CHECK([STRTOD], [c], [strtod], [stdlib.h])
499 AST_EXT_LIB_CHECK([FLOOR], [m], [floor])
500 AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
501
502 GSM_INTERNAL="yes"
503 AC_SUBST(GSM_INTERNAL)
504 GSM_SYSTEM="yes"
505 if test "${USE_GSM}" != "no"; then
506    if test "${GSM_DIR}" = "internal"; then
507       GSM_SYSTEM="no"
508    elif test "${GSM_DIR}" != ""; then
509       GSM_INTERNAL="no"
510    fi
511    if test "${GSM_SYSTEM}" = "yes"; then
512       gsmlibdir=""
513       if test "x${GSM_DIR}" != "x"; then
514          if test -d ${GSM_DIR}/lib; then
515             gsmlibdir="-L${GSM_DIR}/lib"
516          else
517             gsmlibdir="-L${GSM_DIR}"
518          fi
519       fi
520       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
521       [Define to indicate the GSM library]), [], ${gsmlibdir})
522       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
523          if test "x${GSM_DIR}" != "x" ; then
524             AC_CHECK_HEADER([${GSM_DIR}/include/gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
525             AC_CHECK_HEADER([${GSM_DIR}/include/gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
526          else
527             AC_CHECK_HEADER([gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0])
528             AC_CHECK_HEADER([gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0])
529          fi
530          if test "${GSM_HEADER_FOUND}" = "0" ; then
531             if test "{GSM_GSM_HEADER_FOUND}" = "0" ; then
532                if test "x${GSM_MANDATORY}" = "xyes" ; then
533                   AC_MSG_NOTICE([***])
534                   AC_MSG_NOTICE([*** It appears that you do not have the gsm development package installed.])
535                   AC_MSG_NOTICE([*** Please install it to include ${GSM_DESCRIP} support, or re-run configure])
536                   AC_MSG_NOTICE([*** without explicitly specifying --with-${GSM_OPTION}])
537                   exit 1
538                fi
539             fi
540          fi
541          GSM_OK=0
542          if test "${GSM_HEADER_FOUND}" = "1" ; then
543             AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
544             GSM_OK=1
545          else
546             if test "${GSM_GSM_HEADER_FOUND}" = "1" ; then
547                AC_DEFINE_UNQUOTED([HAVE_GSM_GSM_HEADER], 1, [Define to indicate that gsm.h is in gsm/gsm.h])
548                GSM_OK=1
549             fi
550          fi
551          if test "${GSM_OK}" = "1" ; then
552             GSM_LIB="-lgsm"
553             if test "x${GSM_DIR}" != "x"; then
554                GSM_LIB="${gsmlibdir} ${GSM_LIB}"
555                GSM_INCLUDE="-I${GSM_DIR}/include"
556             fi
557             PBX_GSM=1
558             GSM_INTERNAL="no"
559          fi
560       fi
561    fi
562    if test "${GSM_INTERNAL}" = "yes"; then
563       PBX_GSM=1
564       AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location])
565    fi
566 fi
567
568 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
569
570 if test "${USE_IMAP_TK}" != "no"; then
571    if test "${IMAP_TK_DIR}" = "system" ; then
572       AC_MSG_NOTICE([Checking for system c-client library...])
573    elif test "${IMAP_TK_DIR}" = ""; then
574       IMAP_TK_DIR=`pwd`"/../imap-2004g"
575       if test  -n "${IMAP_TK_MANDATORY}"; then
576          AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
577          AC_MSG_NOTICE([c-client library/header files. Since you did not provide a path])
578          AC_MSG_NOTICE([the configure script will assume you have placed built the c-client])
579          AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
580       fi
581    fi
582    if test "${IMAP_TK_DIR}" != "system" ; then
583       AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
584    fi
585    saved_cppflags="${CPPFLAGS}"
586    saved_libs="${LIBS}"
587    if test "${IMAP_TK_DIR}" = "system" ; then
588       imap_ldflags=""
589       imap_libs="-lc-client"
590       imap_include="-DUSE_SYSTEM_IMAP"
591    elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
592       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
593       imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
594       imap_include="-I${IMAP_TK_DIR}/c-client"
595    fi
596    CPPFLAGS="${CPPFLAGS} ${imap_include}"
597    LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
598    AC_LINK_IFELSE(
599         AC_LANG_PROGRAM(
600                 [#ifdef USE_SYSTEM_IMAP
601                 #include <imap/c-client.h>
602                 #else
603                 #include "c-client.h"
604                 #endif
605                 void mm_searched (MAILSTREAM *stream,unsigned long number)
606                 {
607                 }
608                 void mm_exists (MAILSTREAM *stream,unsigned long number)
609                 {
610                 }
611                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
612                 {
613                 }
614                 void mm_flags (MAILSTREAM *stream,unsigned long number)
615                 {
616                 }
617                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
618                 {
619                 }
620                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
621                 {
622                 }
623                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
624                 {
625                 }
626                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
627                 {
628                 }
629                 void mm_log (char *string,long errflg)
630                 {
631                 }
632                 void mm_dlog (char *string)
633                 {
634                 }
635                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
636                 {
637                 }
638                 void mm_critical (MAILSTREAM *stream)
639                 {
640                 }
641                 void mm_nocritical (MAILSTREAM *stream)
642                 {
643                 }
644                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
645                 {
646                 }
647                 void mm_fatal (char *string)
648                 {
649                 }],
650                 [
651                 MAILSTREAM *foo = mail_open(NULL, "", 0);
652                 ]
653         ),
654         [ac_cv_imap_tk="yes"],
655         [ac_cv_imap_tk="no"]
656    )
657    if test "${ac_cv_imap_tk}" = "yes"; then
658    AC_LINK_IFELSE(
659       AC_LANG_PROGRAM(
660          [#ifdef USE_SYSTEM_IMAP
661          #include <imap/c-client.h>
662          #else
663          #include "c-client.h"
664          #endif
665          void mm_searched (MAILSTREAM *stream,unsigned long number)
666          {
667          }
668          void mm_exists (MAILSTREAM *stream,unsigned long number)
669          {
670          }
671          void mm_expunged (MAILSTREAM *stream,unsigned long number)
672          {
673          }
674          void mm_flags (MAILSTREAM *stream,unsigned long number)
675          {
676          }
677          void mm_notify (MAILSTREAM *stream,char *string,long errflg)
678          {
679          }
680          void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
681          {
682          }
683          void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
684          {
685          }
686          void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
687          {
688          }
689          void mm_log (char *string,long errflg)
690          {
691          }
692          void mm_dlog (char *string)
693          {
694          }
695          void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
696          {
697          }
698          void mm_critical (MAILSTREAM *stream)
699          {
700          }
701          void mm_nocritical (MAILSTREAM *stream)
702          {
703          }
704          long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
705          {
706          }
707          void mm_fatal (char *string)
708          {
709          }],
710          [
711          long check = mail_expunge_full(NULL, "", 0);
712          ]
713       ),
714       [ac_cv_imap_tk2006="yes"],
715       [ac_cv_imap_tk2006="no"]
716   )
717   fi
718    CPPFLAGS="${saved_cppflags}"
719    LIBS="${saved_libs}"
720    if test "${ac_cv_imap_tk}" = "yes"; then
721       AC_MSG_RESULT(yes) 
722       IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
723       IMAP_TK_INCLUDE="${imap_include}"
724       PBX_IMAP_TK=1
725       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
726       if test "${ac_cv_imap_tk2006}" = "yes"; then
727          AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
728       fi
729    else
730       AC_MSG_RESULT(no) 
731    fi
732 fi
733
734 # Needed by unixodbc
735 AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], [])
736
737 AC_LANG_PUSH(C++)
738
739 if test "${USE_KDE}" != "no"; then
740    AC_MSG_CHECKING(for crashHandler in -lkdecore)
741    saved_libs="${LIBS}"
742    saved_cppflags="${CPPFLAGS}"
743    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
744    if test -d ${KDE_DIR}/lib; then
745       kdelibdir="${KDE_DIR}/lib"
746    else
747       kdelibdir="${KDE_DIR}"
748    fi
749    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
750
751    AC_LINK_IFELSE(
752         [AC_LANG_PROGRAM(
753                         [#include "kcrash.h"],
754                         [KCrash::defaultCrashHandler(1);])
755         ],
756         [ac_cv_lib_kde_crash="yes"],
757         [ac_cv_lib_kde_crash="no"])
758                 
759    LIBS="${saved_libs}"
760    CPPFLAGS="${saved_cppflags}"
761         
762    if test "${ac_cv_lib_kde_crash}" = "yes"; then
763       AC_MSG_RESULT(yes) 
764       KDE_LIB="-lkdecore -lkdeui"
765       if test "${KDE_DIR}" != ""; then
766          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
767          KDE_INCLUDE="-I${KDE_DIR}/include"
768       fi
769       PBX_KDE=1
770       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
771    else
772       AC_MSG_RESULT(no) 
773    fi
774 fi
775 if test "${PBX_KDE}" = 1; then
776    AC_PATH_TOOL(KDEINIT, kdeinit, No)
777    if test ! x"${KDEINIT}" = xNo; then
778       KDEDIR=$(${DIRNAME} ${KDEINIT})
779       KDEDIR=$(${DIRNAME} ${KDEDIR})
780    fi
781    AC_SUBST([KDEDIR])
782 fi
783
784 AC_LANG_POP
785
786 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
787
788 if test "${PBX_MISDN}" = 1; then
789    AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
790    AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
791    AST_C_DEFINE_CHECK([MISDN_FAC_RESULT], [Fac_RESULT], [mISDNuser/suppserv.h])
792    AST_C_DEFINE_CHECK([MISDN_FAC_ERROR], [Fac_ERROR], [mISDNuser/suppserv.h])
793    AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
794 fi
795
796 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
797
798 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
799
800 NETSNMP_CONFIG=No
801 if test "${USE_NETSNMP}" != "no"; then  
802    if test "x${NETSNMP_DIR}" != "x"; then
803       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
804       if test x"${NETSNMP_CONFIG}" = xNo; then
805          AC_MSG_NOTICE([***])
806          AC_MSG_NOTICE([*** net-snmp-config was not found in the path you specified:])
807          AC_MSG_NOTICE([*** ${NETSNMP_DIR}/bin])
808          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
809          AC_MSG_NOTICE([*** including --without-netsnmp])
810          exit 1
811       fi
812    else
813       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
814    fi
815 fi
816 if test x"${NETSNMP_CONFIG}" != xNo; then
817    NETSNMP_libs=`${NETSNMP_CONFIG} --agent-libs`
818    
819    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
820    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
821
822    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
823       NETSNMP_LIB="${NETSNMP_libs}"
824       PBX_NETSNMP=1
825    fi
826 fi
827
828 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
829
830 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
831
832 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
833
834 AST_EXT_LIB_CHECK([BKTR], [execinfo], [backtrace], [execinfo.h], [-lexecinfo])
835
836 # possible places for oss definitions
837 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
838 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
839 AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
840
841 PG_CONFIG=No
842 if test "${USE_PGSQL}" != "no"; then    
843    if test "x${PGSQL_DIR}" != "x"; then
844       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
845       if test x"${PG_CONFIG}" = xNo; then
846          AC_MSG_NOTICE([***])
847          AC_MSG_NOTICE([*** pg_config was not found in the path you specified:])
848          AC_MSG_NOTICE([*** ${PGSQL_DIR}/bin])
849          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
850          AC_MSG_NOTICE([*** including --without-postgres])
851          exit 1
852       fi
853    else
854       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
855    fi
856 fi
857 if test "${PG_CONFIG}" != No; then
858    PGSQL_libdir=`${PG_CONFIG} --libdir`
859    PGSQL_includedir=`${PG_CONFIG} --includedir`
860    if test "x$?" != "x0" ; then
861       if test -n "${PGSQL_MANDATORY}" ; then
862          AC_MSG_NOTICE([***])
863          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
864          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
865          AC_MSG_NOTICE([*** including --without-postgres])
866          exit 1
867           fi
868    else 
869       AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
870       [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
871
872       if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
873          PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
874          PGSQL_INCLUDE="-I${PGSQL_includedir}"
875          PBX_PGSQL=1
876       elif test -n "${PGSQL_MANDATORY}";
877       then
878          AC_MSG_NOTICE([***])
879          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
880          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
881          AC_MSG_NOTICE([*** including --without-postgres])
882          exit 1
883       fi
884    fi
885 fi
886
887 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
888
889 AST_EXT_LIB_CHECK([PRI], [pri], [pri_keypad_facility], [libpri.h])
890
891 AST_EXT_LIB_CHECK([SS7], [ss7], [isup_cqr], [libss7.h])
892
893 if test "${USE_PWLIB}" != "no"; then
894         if test -n "${PWLIB_DIR}"; then
895                 PWLIBDIR="${PWLIB_DIR}"
896         fi
897         AST_CHECK_PWLIB()
898         AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2])
899                 
900         if test "${HAS_PWLIB:-unset}" != "unset"; then
901                 AST_CHECK_OPENH323_PLATFORM()
902
903                 PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r"
904
905                 AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
906                         [Define if your system has the PWLib libraries.],
907                         [#include "ptlib.h"],
908                         [BOOL q = PTime::IsDaylightSavings();])
909         fi
910 fi
911
912 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
913         if test -n "${OPENH323_DIR}"; then
914                 OPENH323DIR="${OPENH323_DIR}"
915         fi
916         AST_CHECK_OPENH323()
917         AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3])
918         AST_CHECK_OPENH323_BUILD()
919         PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
920         AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],
921                 [Define if your system has the OpenH323 libraries.],
922                 [#include "ptlib.h"
923                 #include "h323.h"
924                 #include "h323ep.h"],
925                 [H323EndPoint ep = H323EndPoint();],
926                 [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
927 fi
928
929 AC_LANG_PUSH(C++)
930
931 if test "${USE_QT}" != "no"; then
932    AC_MSG_CHECKING(for QDate in -lqt)
933    saved_libs="${LIBS}"
934    saved_cppflags="${CPPFLAGS}"
935    if test "x${QT_DIR}" != "x"; then
936       LIBS="${LIBS} -L${QT_DIR}/lib"
937       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
938    fi
939    LIBS="${LIBS} -lqt"
940    qtlib="qt"
941    AC_LINK_IFELSE(
942         [
943                 AC_LANG_PROGRAM(
944                 [#include <qt3/qdatetime.h>],
945                 [QDate date();])
946         ],
947         [ac_cv_lib_qt_qt_date="yes"],
948         [ac_cv_lib_qt_qt_date="no"])
949    LIBS="${saved_libs}"
950    CPPFLAGS="${saved_cppflags}"
951         
952    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
953       saved_libs="${LIBS}"
954       saved_cppflags="${CPPFLAGS}"
955       if test "x${QT_DIR}" != "x"; then
956          LIBS="${LIBS} -L${QT_DIR}/lib"
957          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
958       fi
959       LIBS="${LIBS} -lqt-mt"
960       qtlib="qt-mt"     
961       AC_LINK_IFELSE(
962                 [
963                         AC_LANG_PROGRAM(
964                         [#include <qt3/qdatetime.h>],
965                         [QDate date();])
966                 ],
967                 [ac_cv_lib_qt_qt_date="yes"],
968                 [ac_cv_lib_qt_qt_date="no"])
969       LIBS="${saved_libs}"
970       CPPFLAGS="${saved_cppflags}"
971    fi   
972
973    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
974       AC_MSG_RESULT(yes) 
975    else
976       AC_MSG_RESULT(no) 
977    fi
978         
979    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
980       QT_LIB="-l${qtlib}"
981       if test "${QT_DIR}" != ""; then
982          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
983          QT_INCLUDE="-I${QT_DIR}/include"
984       fi
985       PBX_QT=1
986       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
987       AC_PATH_TOOL(QTMOC, moc, No)
988    fi
989 fi
990
991 AC_LANG_POP
992
993 LUA_INCLUDE="-I/usr/include/lua5.1"
994 LUA_LIB="-llua5.1"
995 AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h]) 
996
997 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
998
999 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
1000
1001 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
1002
1003 AST_EXT_LIB_CHECK([SQLITE3], [sqlite3], [sqlite3_open], [sqlite3.h])
1004
1005 AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h])
1006
1007 if test "$PBX_CRYPTO" = "1";
1008 then
1009     AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
1010 fi
1011
1012 if test "$PBX_OPENSSL" = "1";
1013 then
1014     AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
1015 fi
1016
1017 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
1018 if test "${PBX_FREETDS}" != "0";
1019 then
1020     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr}/include/tdsver.h` in
1021         *0.64*)
1022                 FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
1023         ;;
1024     *0.63*)
1025         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
1026         ;;
1027     *0.62*)
1028         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
1029         ;;
1030     *)
1031         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
1032         ;;
1033     esac
1034 fi
1035
1036 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
1037
1038 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
1039
1040 if test "${host_os}" != "linux-gnu" ; then
1041   tonezone_extra="-lm"
1042 fi
1043
1044 # new tonezone, version 1.4.0
1045 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}], [140])
1046 # other case, old tonezone (0.80)
1047 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/zaptel.h], [${tonezone_extra}], [80])
1048
1049 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h], [])
1050
1051 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
1052
1053 AC_LANG_PUSH(C++)
1054
1055 if test "${USE_VPB}" != "no"; then
1056    AC_MSG_CHECKING(for vpb_open in -lvpb)
1057    saved_libs="${LIBS}"
1058    saved_cppflags="${CPPFLAGS}"
1059    if test "x${VPB_DIR}" != "x"; then
1060       if test -d ${VPB_DIR}/lib; then
1061          vpblibdir=${VPB_DIR}/lib
1062       else
1063          vpblibdir=${VPB_DIR}
1064       fi
1065       LIBS="${LIBS} -L${vpblibdir}"
1066       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
1067    fi
1068    LIBS="${LIBS} -lvpb -lpthread"
1069    AC_LINK_IFELSE(
1070         [
1071         AC_LANG_PROGRAM(
1072         [#include <vpbapi.h>],
1073         [int q = vpb_open(0,0);])
1074         ],
1075         [       AC_MSG_RESULT(yes) 
1076                 ac_cv_lib_vpb_vpb_open="yes" 
1077         ],
1078         [       AC_MSG_RESULT(no) 
1079                 ac_cv_lib_vpb_vpb_open="no" 
1080         ]
1081         )
1082    LIBS="${saved_libs}"
1083    CPPFLAGS="${saved_cppflags}"
1084    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
1085         VPB_LIB="-lvpb"
1086         if test "${VPB_DIR}" != ""; then
1087            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
1088            VPB_INCLUDE="-I${VPB_DIR}/include"
1089         fi
1090         PBX_VPB=1
1091         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
1092    fi
1093 fi
1094
1095 AC_LANG_POP
1096
1097 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
1098
1099 # Check for various zaptel features and locations.
1100 # The version number, which goes into HAVE_ZAPTEL_VERSION,
1101 # will be used in the system headers to determine the location
1102 # of the zaptel.h header.
1103
1104 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_TONE_DTMF_BASE], [zaptel/zaptel.h], [140])
1105 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_DIAL_OP_CANCEL], [zaptel/zaptel.h], [90])
1106
1107 # Check for VLDTMF support
1108 AST_C_DEFINE_CHECK([ZAPTEL_VLDTMF], [ZT_EVENT_REMOVED], [zaptel/zaptel.h])
1109
1110 # Check for transcode support
1111 AST_C_DEFINE_CHECK([ZAPTEL_TRANSCODE], [ZT_TCOP_ALLOCATE], [zaptel/zaptel.h])
1112
1113 # On FreeBSD, try old zaptel (0.80 or so) and pretend we have vldtmf
1114 case "${host_os}" in
1115     freebsd*)
1116         AST_EXT_LIB_CHECK([ZAPTEL], [zaptel],, [zaptel.h],, [80])
1117         AST_EXT_LIB_CHECK([ZAPTEL_VLDTMF], [zaptel],, [zaptel/zaptel.h],, [90])
1118         AST_EXT_LIB_CHECK([ZAPTEL_VLDTMF], [zaptel],, [zaptel.h],, [80])
1119
1120         # other case, old tonezone (0.80)
1121         AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel.h], [${tonezone_extra}], [80])
1122         ;;
1123 esac
1124
1125 EDITLINE_LIB=""
1126 if test "x$TERMCAP_LIB" != "x" ; then
1127   EDITLINE_LIB="$TERMCAP_LIB"
1128 elif test "x$TINFO_LIB" != "x" ; then
1129   EDITLINE_LIB="$TINFO_LIB"
1130 elif test "x$CURSES_LIB" != "x" ; then
1131   EDITLINE_LIB="$CURSES_LIB"
1132 elif test "x$NCURSES_LIB" != "x" ; then
1133   EDITLINE_LIB="$NCURSES_LIB"
1134 else
1135   AC_MSG_ERROR(*** termcap support not found)
1136 fi
1137 AC_SUBST(EDITLINE_LIB)
1138
1139 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
1140 AC_SUBST(PBX_H323)
1141
1142 AC_CHECK_HEADER([linux/compiler.h],
1143                 [AC_DEFINE_UNQUOTED([HAVE_LINUX_COMPILER_H], 1, [Define to 1 if your system has linux/compiler.h.])])
1144
1145 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
1146                                    #include <linux/version.h>
1147                                    #ifdef HAVE_LINUX_COMPILER_H
1148                                    #include <linux/compiler.h>
1149                                    #endif
1150                                    ])
1151 AC_SUBST(PBX_IXJUSER)
1152
1153 PBX_GTK=0
1154 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
1155 if test ! "x${GTKCONFIG}" = xNo; then
1156    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
1157    GTK_LIB=$(${GTKCONFIG} --libs gthread)
1158    PBX_GTK=1
1159    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
1160 fi
1161 AC_SUBST(PBX_GTK)
1162 AC_SUBST(GTK_INCLUDE)
1163 AC_SUBST(GTK_LIB)
1164
1165 PBX_GTK2=0
1166 AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
1167 if test ! "x${PKGCONFIG}" = xNo; then
1168    GTK2_INCLUDE=$(${PKGCONFIG} gtk+-2.0 --cflags 2>/dev/null)
1169    GTK2_LIB=$(${PKGCONFIG} gtk+-2.0 --libs)
1170    PBX_GTK2=1
1171    AC_DEFINE([HAVE_GTK2], 1, [Define if your system has the GTK2 libraries.])
1172 fi
1173 AC_SUBST(PBX_GTK2)
1174 AC_SUBST(GTK2_INCLUDE)
1175 AC_SUBST(GTK2_LIB)
1176
1177 if test "${USE_CURL}" != "no"; then
1178    AC_PATH_TOOL([CURL_CONFIG], [curl-config], No)
1179    if test ! x"${CURL_CONFIG}" = xNo; then
1180    # check for version
1181       if test $(printf "%d" 0x$(${CURL_CONFIG} --vernum)) -ge $(printf "%d" 0x070907); then
1182          CURL_INCLUDE=$(${CURL_CONFIG} --cflags)
1183          CURL_LIB=$(${CURL_CONFIG} --libs)
1184
1185          AC_MSG_CHECKING(for curl_version() in curl/curl.h)
1186          saved_cppflags="${CPPFLAGS}"
1187          CPPFLAGS="${CPPFLAGS} ${CURL_INCLUDE}"
1188          AC_COMPILE_IFELSE(
1189             [AC_LANG_PROGRAM(
1190                 [#include <curl/curl.h>],
1191                     [curl_version();])
1192             ],[
1193                 AC_MSG_RESULT(yes)
1194                 ac_cv_curl_h="yes"
1195             ],[
1196                 AC_MSG_RESULT(no)
1197                 ac_cv_curl_h="no"
1198             ]
1199          )
1200          CPPFLAGS="${saved_cppflags}"
1201          if test "${ac_cv_curl_h}" = "yes"; then
1202              PBX_CURL=1
1203              AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
1204          fi
1205       fi
1206    fi
1207 fi
1208
1209 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
1210 AST_CHECK_MANDATORY
1211
1212 AC_OUTPUT
1213
1214 if test "x${silent}" != "xyes" ; then
1215 echo
1216 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
1217 echo "            .\$7\$7..          .7\$\$7:.    "
1218 echo "          .\$\$:.                 ,\$7.7   "
1219 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
1220 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
1221 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
1222 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
1223 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
1224 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
1225 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
1226 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
1227 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
1228 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
1229 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
1230 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
1231 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
1232 echo " \$\$\$\$\$                        \$\$\$       "
1233 echo "  \$\$\$\$7.                       \$\$  (TM)     "
1234 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
1235 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
1236 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
1237 echo
1238 fi
1239
1240 AC_MSG_NOTICE(Package configured for: )
1241 AC_MSG_NOTICE( OS type  : $host_os)
1242 AC_MSG_NOTICE( Host CPU : $host_cpu)
1243 if test "${cross_compiling}" = "yes"; then
1244    AC_MSG_NOTICE( Cross Compilation = YES)
1245 fi