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