Autoconf requires version 2.60, not 2.59, to process (Closes issue #10842)
[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([GNUTLS], [GNU TLS support (used for iksemel only)], [gnutls])
191 AST_EXT_LIB_SETUP([GSM], [GSM], [gsm], [, or 'internal'])
192 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
193 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
194 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
195 AST_EXT_LIB_SETUP([KDE], [KDE], [kde])
196 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
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 "${PBX_IKSEMEL}" = 1; then
562    AST_EXT_LIB_CHECK([GNUTLS], [gnutls], [gnutls_bye], [gnutls/gnutls.h], [-lz -lgcrypt -lgpg-error])
563 fi
564
565 if test "${USE_IMAP_TK}" != "no"; then
566    if test "${IMAP_TK_DIR}" = "system" ; then
567       AC_MSG_NOTICE([Checking for system c-client library...])
568    elif test "${IMAP_TK_DIR}" = ""; then
569       IMAP_TK_DIR=`pwd`"/../imap-2004g"
570       if test  -n "${IMAP_TK_MANDATORY}"; then
571          AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
572          AC_MSG_NOTICE([c-client library/header files. Since you did not provide a path])
573          AC_MSG_NOTICE([the configure script will assume you have placed built the c-client])
574          AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
575       fi
576    fi
577    if test "${IMAP_TK_DIR}" != "system" ; then
578       AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
579    fi
580    saved_cppflags="${CPPFLAGS}"
581    saved_libs="${LIBS}"
582    if test "${IMAP_TK_DIR}" = "system" ; then
583       imap_ldflags=""
584       imap_libs="-lc-client"
585       imap_include="-DUSE_SYSTEM_IMAP"
586    elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
587       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
588       imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
589       imap_include="-I${IMAP_TK_DIR}/c-client"
590    fi
591    CPPFLAGS="${CPPFLAGS} ${imap_include}"
592    LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
593    AC_LINK_IFELSE(
594         AC_LANG_PROGRAM(
595                 [#ifdef USE_SYSTEM_IMAP
596                 #include <imap/c-client.h>
597                 #else
598                 #include "c-client.h"
599                 #endif
600                 void mm_searched (MAILSTREAM *stream,unsigned long number)
601                 {
602                 }
603                 void mm_exists (MAILSTREAM *stream,unsigned long number)
604                 {
605                 }
606                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
607                 {
608                 }
609                 void mm_flags (MAILSTREAM *stream,unsigned long number)
610                 {
611                 }
612                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
613                 {
614                 }
615                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
616                 {
617                 }
618                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
619                 {
620                 }
621                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
622                 {
623                 }
624                 void mm_log (char *string,long errflg)
625                 {
626                 }
627                 void mm_dlog (char *string)
628                 {
629                 }
630                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
631                 {
632                 }
633                 void mm_critical (MAILSTREAM *stream)
634                 {
635                 }
636                 void mm_nocritical (MAILSTREAM *stream)
637                 {
638                 }
639                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
640                 {
641                 }
642                 void mm_fatal (char *string)
643                 {
644                 }],
645                 [
646                 MAILSTREAM *foo = mail_open(NULL, "", 0);
647                 ]
648         ),
649         [ac_cv_imap_tk="yes"],
650         [ac_cv_imap_tk="no"]
651    )
652    if test "${ac_cv_imap_tk}" = "yes"; then
653    AC_LINK_IFELSE(
654       AC_LANG_PROGRAM(
655          [#ifdef USE_SYSTEM_IMAP
656          #include <imap/c-client.h>
657          #else
658          #include "c-client.h"
659          #endif
660          void mm_searched (MAILSTREAM *stream,unsigned long number)
661          {
662          }
663          void mm_exists (MAILSTREAM *stream,unsigned long number)
664          {
665          }
666          void mm_expunged (MAILSTREAM *stream,unsigned long number)
667          {
668          }
669          void mm_flags (MAILSTREAM *stream,unsigned long number)
670          {
671          }
672          void mm_notify (MAILSTREAM *stream,char *string,long errflg)
673          {
674          }
675          void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
676          {
677          }
678          void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
679          {
680          }
681          void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
682          {
683          }
684          void mm_log (char *string,long errflg)
685          {
686          }
687          void mm_dlog (char *string)
688          {
689          }
690          void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
691          {
692          }
693          void mm_critical (MAILSTREAM *stream)
694          {
695          }
696          void mm_nocritical (MAILSTREAM *stream)
697          {
698          }
699          long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
700          {
701          }
702          void mm_fatal (char *string)
703          {
704          }],
705          [
706          long check = mail_expunge_full(NULL, "", 0);
707          ]
708       ),
709       [ac_cv_imap_tk2006="yes"],
710       [ac_cv_imap_tk2006="no"]
711   )
712   fi
713    CPPFLAGS="${saved_cppflags}"
714    LIBS="${saved_libs}"
715    if test "${ac_cv_imap_tk}" = "yes"; then
716       AC_MSG_RESULT(yes) 
717       IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
718       IMAP_TK_INCLUDE="${imap_include}"
719       PBX_IMAP_TK=1
720       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
721       if test "${ac_cv_imap_tk2006}" = "yes"; then
722          AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
723       fi
724    else
725       AC_MSG_RESULT(no) 
726    fi
727 fi
728
729 # Needed by unixodbc
730 AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], [])
731
732 AC_LANG_PUSH(C++)
733
734 if test "${USE_KDE}" != "no"; then
735    AC_MSG_CHECKING(for crashHandler in -lkdecore)
736    saved_libs="${LIBS}"
737    saved_cppflags="${CPPFLAGS}"
738    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
739    if test -d ${KDE_DIR}/lib; then
740       kdelibdir="${KDE_DIR}/lib"
741    else
742       kdelibdir="${KDE_DIR}"
743    fi
744    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
745
746    AC_LINK_IFELSE(
747         [AC_LANG_PROGRAM(
748                         [#include "kcrash.h"],
749                         [KCrash::defaultCrashHandler(1);])
750         ],
751         [ac_cv_lib_kde_crash="yes"],
752         [ac_cv_lib_kde_crash="no"])
753                 
754    LIBS="${saved_libs}"
755    CPPFLAGS="${saved_cppflags}"
756         
757    if test "${ac_cv_lib_kde_crash}" = "yes"; then
758       AC_MSG_RESULT(yes) 
759       KDE_LIB="-lkdecore -lkdeui"
760       if test "${KDE_DIR}" != ""; then
761          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
762          KDE_INCLUDE="-I${KDE_DIR}/include"
763       fi
764       PBX_KDE=1
765       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
766    else
767       AC_MSG_RESULT(no) 
768    fi
769 fi
770 if test "${PBX_KDE}" = 1; then
771    AC_PATH_TOOL(KDEINIT, kdeinit, No)
772    if test ! x"${KDEINIT}" = xNo; then
773       KDEDIR=$(${DIRNAME} ${KDEINIT})
774       KDEDIR=$(${DIRNAME} ${KDEDIR})
775    fi
776    AC_SUBST([KDEDIR])
777 fi
778
779 AC_LANG_POP
780
781 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
782
783 if test "${PBX_MISDN}" = 1; then
784    AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
785    AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
786    AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
787 fi
788
789 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
790
791 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
792
793 NETSNMP_CONFIG=No
794 if test "${USE_NETSNMP}" != "no"; then  
795    if test "x${NETSNMP_DIR}" != "x"; then
796       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
797       if test x"${NETSNMP_CONFIG}" = xNo; then
798          AC_MSG_NOTICE([***])
799          AC_MSG_NOTICE([*** net-snmp-config was not found in the path you specified:])
800          AC_MSG_NOTICE([*** ${NETSNMP_DIR}/bin])
801          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
802          AC_MSG_NOTICE([*** including --without-netsnmp])
803          exit 1
804       fi
805    else
806       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
807    fi
808 fi
809 if test x"${NETSNMP_CONFIG}" != xNo; then
810    NETSNMP_libs=`${NETSNMP_CONFIG} --agent-libs`
811    
812    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
813    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
814
815    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
816       NETSNMP_LIB="${NETSNMP_libs}"
817       PBX_NETSNMP=1
818    fi
819 fi
820
821 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
822
823 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
824
825 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
826
827 AST_EXT_LIB_CHECK([BKTR], [execinfo], [backtrace], [execinfo.h], [-lexecinfo])
828
829 # possible places for oss definitions
830 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
831 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
832 AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
833
834 PG_CONFIG=No
835 if test "${USE_PGSQL}" != "no"; then    
836    if test "x${PGSQL_DIR}" != "x"; then
837       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
838       if test x"${PG_CONFIG}" = xNo; then
839          AC_MSG_NOTICE([***])
840          AC_MSG_NOTICE([*** pg_config was not found in the path you specified:])
841          AC_MSG_NOTICE([*** ${PGSQL_DIR}/bin])
842          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
843          AC_MSG_NOTICE([*** including --without-postgres])
844          exit 1
845       fi
846    else
847       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
848    fi
849 fi
850 if test "${PG_CONFIG}" != No; then
851    PGSQL_libdir=`${PG_CONFIG} --libdir`
852    PGSQL_includedir=`${PG_CONFIG} --includedir`
853    if test "x$?" != "x0" ; then
854       if test -n "${PGSQL_MANDATORY}" ; then
855          AC_MSG_NOTICE([***])
856          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
857          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
858          AC_MSG_NOTICE([*** including --without-postgres])
859          exit 1
860           fi
861    else 
862       AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
863       [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
864
865       if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
866          PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
867          PGSQL_INCLUDE="-I${PGSQL_includedir}"
868          PBX_PGSQL=1
869       elif test -n "${PGSQL_MANDATORY}";
870       then
871          AC_MSG_NOTICE([***])
872          AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.])
873          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
874          AC_MSG_NOTICE([*** including --without-postgres])
875          exit 1
876       fi
877    fi
878 fi
879
880 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
881
882 AST_EXT_LIB_CHECK([PRI], [pri], [pri_keypad_facility], [libpri.h])
883
884 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_new], [libss7.h])
885
886 if test "${USE_PWLIB}" != "no"; then
887         if test -n "${PWLIB_DIR}"; then
888                 PWLIBDIR="${PWLIB_DIR}"
889         fi
890         AST_CHECK_PWLIB()
891         AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2])
892                 
893         if test "${HAS_PWLIB:-unset}" != "unset"; then
894                 AST_CHECK_OPENH323_PLATFORM()
895
896                 PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r"
897
898                 AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
899                         [Define if your system has the PWLib libraries.],
900                         [#include "ptlib.h"],
901                         [BOOL q = PTime::IsDaylightSavings();])
902         fi
903 fi
904
905 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
906         if test -n "${OPENH323_DIR}"; then
907                 OPENH323DIR="${OPENH323_DIR}"
908         fi
909         AST_CHECK_OPENH323()
910         AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3])
911         AST_CHECK_OPENH323_BUILD()
912         PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
913         AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],
914                 [Define if your system has the OpenH323 libraries.],
915                 [#include "ptlib.h"
916                 #include "h323.h"
917                 #include "h323ep.h"],
918                 [H323EndPoint ep = H323EndPoint();],
919                 [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
920 fi
921
922 AC_LANG_PUSH(C++)
923
924 if test "${USE_QT}" != "no"; then
925    AC_MSG_CHECKING(for QDate in -lqt)
926    saved_libs="${LIBS}"
927    saved_cppflags="${CPPFLAGS}"
928    if test "x${QT_DIR}" != "x"; then
929       LIBS="${LIBS} -L${QT_DIR}/lib"
930       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
931    fi
932    LIBS="${LIBS} -lqt"
933    qtlib="qt"
934    AC_LINK_IFELSE(
935         [
936                 AC_LANG_PROGRAM(
937                 [#include <qt3/qdatetime.h>],
938                 [QDate date();])
939         ],
940         [ac_cv_lib_qt_qt_date="yes"],
941         [ac_cv_lib_qt_qt_date="no"])
942    LIBS="${saved_libs}"
943    CPPFLAGS="${saved_cppflags}"
944         
945    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
946       saved_libs="${LIBS}"
947       saved_cppflags="${CPPFLAGS}"
948       if test "x${QT_DIR}" != "x"; then
949          LIBS="${LIBS} -L${QT_DIR}/lib"
950          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
951       fi
952       LIBS="${LIBS} -lqt-mt"
953       qtlib="qt-mt"     
954       AC_LINK_IFELSE(
955                 [
956                         AC_LANG_PROGRAM(
957                         [#include <qt3/qdatetime.h>],
958                         [QDate date();])
959                 ],
960                 [ac_cv_lib_qt_qt_date="yes"],
961                 [ac_cv_lib_qt_qt_date="no"])
962       LIBS="${saved_libs}"
963       CPPFLAGS="${saved_cppflags}"
964    fi   
965
966    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
967       AC_MSG_RESULT(yes) 
968    else
969       AC_MSG_RESULT(no) 
970    fi
971         
972    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
973       QT_LIB="-l${qtlib}"
974       if test "${QT_DIR}" != ""; then
975          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
976          QT_INCLUDE="-I${QT_DIR}/include"
977       fi
978       PBX_QT=1
979       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
980       AC_PATH_TOOL(QTMOC, moc, No)
981    fi
982 fi
983
984 AC_LANG_POP
985
986 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
987
988 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
989
990 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
991
992 AST_EXT_LIB_CHECK([SQLITE3], [sqlite3], [sqlite3_open], [sqlite3.h])
993
994 AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h])
995
996 if test "$PBX_CRYPTO" = "1";
997 then
998     AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
999 fi
1000
1001 if test "$PBX_OPENSSL" = "1";
1002 then
1003     AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
1004 fi
1005
1006 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
1007 if test "${PBX_FREETDS}" != "0";
1008 then
1009     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr}/include/tdsver.h` in
1010         *0.64*)
1011                 FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
1012         ;;
1013     *0.63*)
1014         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
1015         ;;
1016     *0.62*)
1017         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
1018         ;;
1019     *)
1020         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
1021         ;;
1022     esac
1023 fi
1024
1025 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
1026
1027 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
1028
1029 if test "${host_os}" != "linux-gnu" ; then
1030   tonezone_extra="-lm"
1031 fi
1032
1033 # new tonezone, version 1.4.0
1034 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}], [140])
1035 # other case, old tonezone (0.80)
1036 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/zaptel.h], [${tonezone_extra}], [80])
1037
1038 AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h], [])
1039
1040 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
1041
1042 AC_LANG_PUSH(C++)
1043
1044 if test "${USE_VPB}" != "no"; then
1045    AC_MSG_CHECKING(for vpb_open in -lvpb)
1046    saved_libs="${LIBS}"
1047    saved_cppflags="${CPPFLAGS}"
1048    if test "x${VPB_DIR}" != "x"; then
1049       if test -d ${VPB_DIR}/lib; then
1050          vpblibdir=${VPB_DIR}/lib
1051       else
1052          vpblibdir=${VPB_DIR}
1053       fi
1054       LIBS="${LIBS} -L${vpblibdir}"
1055       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
1056    fi
1057    LIBS="${LIBS} -lvpb -lpthread"
1058    AC_LINK_IFELSE(
1059         [
1060         AC_LANG_PROGRAM(
1061         [#include <vpbapi.h>],
1062         [int q = vpb_open(0,0);])
1063         ],
1064         [       AC_MSG_RESULT(yes) 
1065                 ac_cv_lib_vpb_vpb_open="yes" 
1066         ],
1067         [       AC_MSG_RESULT(no) 
1068                 ac_cv_lib_vpb_vpb_open="no" 
1069         ]
1070         )
1071    LIBS="${saved_libs}"
1072    CPPFLAGS="${saved_cppflags}"
1073    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
1074         VPB_LIB="-lvpb"
1075         if test "${VPB_DIR}" != ""; then
1076            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
1077            VPB_INCLUDE="-I${VPB_DIR}/include"
1078         fi
1079         PBX_VPB=1
1080         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
1081    fi
1082 fi
1083
1084 AC_LANG_POP
1085
1086 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
1087
1088 # Check for various zaptel features and locations.
1089 # The version number, which goes into HAVE_ZAPTEL_VERSION,
1090 # will be used in the system headers to determine the location
1091 # of the zaptel.h header.
1092
1093 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_TONE_DTMF_BASE], [zaptel/zaptel.h], [140])
1094 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_DIAL_OP_CANCEL], [zaptel/zaptel.h], [90])
1095
1096 # Check for VLDTMF support
1097 AST_C_DEFINE_CHECK([ZAPTEL_VLDTMF], [ZT_EVENT_REMOVED], [zaptel/zaptel.h])
1098
1099 # Check for transcode support
1100 AST_C_DEFINE_CHECK([ZAPTEL_TRANSCODE], [ZT_TCOP_ALLOCATE], [zaptel/zaptel.h])
1101
1102 # On FreeBSD, try old zaptel (0.80 or so) and pretend we have vldtmf
1103 case "${host_os}" in
1104     freebsd*)
1105         AST_EXT_LIB_CHECK([ZAPTEL], [zaptel],, [zaptel.h],, [80])
1106         AST_EXT_LIB_CHECK([ZAPTEL_VLDTMF], [zaptel],, [zaptel/zaptel.h],, [90])
1107         AST_EXT_LIB_CHECK([ZAPTEL_VLDTMF], [zaptel],, [zaptel.h],, [80])
1108
1109         # other case, old tonezone (0.80)
1110         AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel.h], [${tonezone_extra}], [80])
1111         ;;
1112 esac
1113
1114 EDITLINE_LIB=""
1115 if test "x$TERMCAP_LIB" != "x" ; then
1116   EDITLINE_LIB="$TERMCAP_LIB"
1117 elif test "x$TINFO_LIB" != "x" ; then
1118   EDITLINE_LIB="$TINFO_LIB"
1119 elif test "x$CURSES_LIB" != "x" ; then
1120   EDITLINE_LIB="$CURSES_LIB"
1121 elif test "x$NCURSES_LIB" != "x" ; then
1122   EDITLINE_LIB="$NCURSES_LIB"
1123 else
1124   AC_MSG_ERROR(*** termcap support not found)
1125 fi
1126 AC_SUBST(EDITLINE_LIB)
1127
1128 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
1129 AC_SUBST(PBX_H323)
1130
1131 AC_CHECK_HEADER([linux/compiler.h],
1132                 [AC_DEFINE_UNQUOTED([HAVE_LINUX_COMPILER_H], 1, [Define to 1 if your system has linux/compiler.h.])])
1133
1134 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
1135                                    #include <linux/version.h>
1136                                    #ifdef HAVE_LINUX_COMPILER_H
1137                                    #include <linux/compiler.h>
1138                                    #endif
1139                                    ])
1140 AC_SUBST(PBX_IXJUSER)
1141
1142 PBX_GTK=0
1143 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
1144 if test ! "x${GTKCONFIG}" = xNo; then
1145    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
1146    GTK_LIB=$(${GTKCONFIG} --libs gthread)
1147    PBX_GTK=1
1148    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
1149 fi
1150 AC_SUBST(PBX_GTK)
1151 AC_SUBST(GTK_INCLUDE)
1152 AC_SUBST(GTK_LIB)
1153
1154 PBX_GTK2=0
1155 AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
1156 if test ! "x${PKGCONFIG}" = xNo; then
1157    GTK2_INCLUDE=$(${PKGCONFIG} gtk+-2.0 --cflags 2>/dev/null)
1158    GTK2_LIB=$(${PKGCONFIG} gtk+-2.0 --libs)
1159    PBX_GTK2=1
1160    AC_DEFINE([HAVE_GTK2], 1, [Define if your system has the GTK2 libraries.])
1161 fi
1162 AC_SUBST(PBX_GTK2)
1163 AC_SUBST(GTK2_INCLUDE)
1164 AC_SUBST(GTK2_LIB)
1165
1166 if test "${USE_CURL}" != "no"; then
1167    AC_PATH_TOOL([CURL_CONFIG], [curl-config], No)
1168    if test ! x"${CURL_CONFIG}" = xNo; then
1169    # check for version
1170       if test $(printf "%d" 0x$(${CURL_CONFIG} --vernum)) -ge $(printf "%d" 0x070907); then
1171          CURL_INCLUDE=$(${CURL_CONFIG} --cflags)
1172          CURL_LIB=$(${CURL_CONFIG} --libs)
1173
1174          AC_MSG_CHECKING(for curl_version() in curl/curl.h)
1175          saved_cppflags="${CPPFLAGS}"
1176          CPPFLAGS="${CPPFLAGS} ${CURL_INCLUDE}"
1177          AC_COMPILE_IFELSE(
1178             [AC_LANG_PROGRAM(
1179                 [#include <curl/curl.h>],
1180                     [curl_version();])
1181             ],[
1182                 AC_MSG_RESULT(yes)
1183                 ac_cv_curl_h="yes"
1184             ],[
1185                 AC_MSG_RESULT(no)
1186                 ac_cv_curl_h="no"
1187             ]
1188          )
1189          CPPFLAGS="${saved_cppflags}"
1190          if test "${ac_cv_curl_h}" = "yes"; then
1191              PBX_CURL=1
1192              AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
1193          fi
1194       fi
1195    fi
1196 fi
1197
1198 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
1199 AST_CHECK_MANDATORY
1200
1201 AC_OUTPUT
1202
1203 if test "x${silent}" != "xyes" ; then
1204 echo
1205 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
1206 echo "            .\$7\$7..          .7\$\$7:.    "
1207 echo "          .\$\$:.                 ,\$7.7   "
1208 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
1209 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
1210 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
1211 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
1212 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
1213 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
1214 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
1215 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
1216 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
1217 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
1218 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
1219 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
1220 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
1221 echo " \$\$\$\$\$                        \$\$\$       "
1222 echo "  \$\$\$\$7.                       \$\$  (TM)     "
1223 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
1224 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
1225 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
1226 echo
1227 fi
1228
1229 AC_MSG_NOTICE(Package configured for: )
1230 AC_MSG_NOTICE( OS type  : $host_os)
1231 AC_MSG_NOTICE( Host CPU : $host_cpu)
1232 if test "${cross_compiling}" = "yes"; then
1233    AC_MSG_NOTICE( Cross Compilation = YES)
1234 fi