Merged revisions 49102 via svnmerge from
[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.59)
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
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      ac_default_prefix=/usr
41      if test ${sysconfdir} = '${prefix}/etc'; then
42         sysconfdir=/etc
43      fi
44      if test ${mandir} = '${prefix}/man'; then
45         mandir=/usr/share/man
46      fi
47      ;;
48 esac
49
50 if test ${localstatedir} = '${prefix}/var'; then
51      localstatedir=/var
52 fi
53
54 BUILD_PLATFORM=${build}
55 BUILD_CPU=${build_cpu}
56 BUILD_VENDOR=${build_vendor}
57 BUILD_OS=${build_os}
58
59 AC_SUBST(BUILD_PLATFORM)
60 AC_SUBST(BUILD_CPU)
61 AC_SUBST(BUILD_VENDOR)
62 AC_SUBST(BUILD_OS)
63
64 HOST_PLATFORM=${host}
65 HOST_CPU=${host_cpu}
66 HOST_VENDOR=${host_vendor}
67 HOST_OS=${host_os}
68
69 AC_SUBST(HOST_PLATFORM)
70 AC_SUBST(HOST_CPU)
71 AC_SUBST(HOST_VENDOR)
72 AC_SUBST(HOST_OS)
73
74 case "${host_os}" in
75      freebsd*)
76      OSARCH=FreeBSD
77      ;;
78      netbsd*)
79      OSARCH=NetBSD
80      ;;
81      openbsd*)
82      OSARCH=OpenBSD
83      ;;
84      solaris*)
85      OSARCH=SunOS
86      ;;
87      *)
88      OSARCH=${HOST_OS}
89      ;;
90 esac
91
92 AC_SUBST(OSARCH)
93
94 #  check for uname
95 AC_PATH_TOOL([UNAME], [uname], No)
96 if test ! x"${UNAME}" = xNo; then
97    PBX_OSREV=$(${UNAME} -r)
98 fi
99 AC_SUBST(PBX_OSREV)
100
101 AH_TOP(
102 #ifndef ASTERISK_AUTOCONFIG_H
103 #define ASTERISK_AUTOCONFIG_H
104
105 #include "asterisk/buildopts.h"
106
107 #ifndef _REENTRANT
108 #define _REENTRANT
109 #endif
110 )
111
112 AH_BOTTOM(
113 #endif
114 )
115
116 # cross-compile checks
117 if test "${cross_compiling}" = "yes"; 
118 then
119    AC_CHECK_TOOL(CC, gcc, :)
120    AC_CHECK_TOOL(CXX, g++, :)
121    AC_CHECK_TOOL(LD, ld, :)
122    AC_CHECK_TOOL(RANLIB, ranlib, :)
123    AC_CHECK_TOOL(AR, ar, :)
124 fi
125
126 # Checks for programs.
127 AC_PROG_CC
128 AC_PROG_CXX
129 AC_PROG_CPP
130 AC_PROG_CXXCPP
131 # This macro is just copied into our local acinclude.m4 from libtool.m4 so that
132 # the developers regenerating the configure script don't have to install libtool.
133 AST_PROG_LD
134 AC_PROG_AWK
135 AC_PROG_INSTALL
136 AC_PROG_LN_S
137 AC_PROG_RANLIB
138 AST_CHECK_GNU_MAKE
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([AR], [ar], :)
148 AC_PATH_PROG([FIND], [find], :)
149 AC_PATH_PROG([COMPRESS], [compress], :)
150 AC_PATH_PROG([BASENAME], [basename], :)
151 AC_PATH_PROG([ID], [id], :)
152 AC_PATH_PROG([DIRNAME], [dirname], :)
153 AC_PATH_PROG([SHELL], [sh], :)
154 AC_PATH_PROG([LN], [ln], :)
155 AC_PATH_PROG([DOT], [dot], :)
156 AC_PATH_PROG([STRIP], [strip], :)
157 AC_PATH_PROG([WGET], [wget], :)
158 if test "${WGET}" != ":" ; then
159   DOWNLOAD=${WGET}
160 else
161   AC_PATH_PROG([FETCH], [fetch], [:])
162   DOWNLOAD=${FETCH}
163 fi
164 AC_SUBST(DOWNLOAD)
165
166 AC_LANG(C)
167
168 AC_ARG_ENABLE(dev-mode,
169         [  --enable-dev-mode    Turn on developer mode],
170         [case "${enableval}" in
171               y|ye|yes) AST_DEVMODE=yes ;;
172               n|no)  AST_DEVMODE=no ;;
173               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
174         esac])
175 AC_SUBST(AST_DEVMODE)
176
177 # package option names should be in alphabetical order
178 # by the --with option name, to make things easier for the users :-)
179
180 AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
181 AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap])
182 AST_EXT_LIB_SETUP([CURL], [cURL], [curl])
183 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
184 AST_EXT_LIB_SETUP([GNUTLS], [GNU TLS support (used for iksemel only)], [gnutls])
185 AST_EXT_LIB_SETUP([GSM], [GSM], [gsm], [, or 'internal'])
186 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
187 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
188 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
189 AST_EXT_LIB_SETUP([KDE], [KDE], [kde])
190 AST_EXT_LIB_SETUP([MISDN], [mISDN User Library], [misdn])
191 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
192 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
193 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
194 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
195 AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [odbc])
196 AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
197 AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
198 AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
199 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
200 AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
201 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
202 AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7])
203 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
204 AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
205 AST_EXT_LIB_SETUP([QT], [Qt], [qt])
206 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
207 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
208 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
209 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
210 AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL], [ssl])
211 AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
212 AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap])
213 AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
214 AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
215 AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
216 AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
217 AST_EXT_LIB_SETUP([ZLIB], [zlib], [z])
218 AST_EXT_LIB_SETUP([ZAPTEL], [Zaptel], [zaptel])
219
220 # check for basic system features and functionality before
221 # checking for package libraries
222
223 AC_FUNC_ALLOCA
224 AC_HEADER_DIRENT
225 AC_HEADER_STDC
226 AC_HEADER_SYS_WAIT
227 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])
228
229 AC_SYS_LARGEFILE
230
231 # Checks for typedefs, structures, and compiler characteristics.
232 AC_HEADER_STDBOOL
233 AC_C_CONST
234 AC_TYPE_UID_T
235 AC_C_INLINE
236 AC_TYPE_MODE_T
237 AC_TYPE_OFF_T
238 AC_TYPE_PID_T
239 AC_TYPE_SIZE_T
240 AC_CHECK_MEMBERS([struct stat.st_blksize])
241 AC_HEADER_TIME
242 AC_STRUCT_TM
243 AC_C_VOLATILE
244 AC_CHECK_TYPES([ptrdiff_t])
245
246 # Checks for library functions.
247 AC_FUNC_CHOWN
248 AC_FUNC_CLOSEDIR_VOID
249 AC_FUNC_ERROR_AT_LINE
250 AST_FUNC_FORK
251 AC_FUNC_FSEEKO
252 AC_PROG_GCC_TRADITIONAL
253 # XXX: these are commented out until we determine whether it matters if our malloc()
254 # acts exactly like glibc's or not
255 # AC_FUNC_MALLOC
256 # AC_FUNC_REALLOC
257 AC_FUNC_MEMCMP
258 AC_FUNC_MKTIME
259 AC_FUNC_MMAP
260 AC_FUNC_SELECT_ARGTYPES
261 AC_FUNC_SETVBUF_REVERSED
262 AC_TYPE_SIGNAL
263 AC_FUNC_STAT
264 AC_FUNC_STRCOLL
265 AC_FUNC_STRFTIME
266 AC_FUNC_STRNLEN
267 AC_FUNC_STRTOD
268 AC_FUNC_UTIME_NULL
269 AC_FUNC_VPRINTF
270 AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
271
272 # https support (in main/http.c) uses funopen on BSD systems,
273 # fopencookie on linux
274 AC_CHECK_FUNCS([funopen fopencookie])
275
276 # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
277 AC_CHECK_FUNCS([gethostbyname_r])
278
279 AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_INITIALIZER], [PTHREAD_RWLOCK_INITIALIZER], [pthread.h])
280 AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_PREFER_WRITER_NP], [PTHREAD_RWLOCK_PREFER_WRITER_NP], [pthread.h])
281
282 AC_MSG_CHECKING(for compiler atomic operations)
283 AC_LINK_IFELSE(
284 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
285 AC_MSG_RESULT(yes)
286 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
287 AC_MSG_RESULT(no)
288 )
289
290 AST_GCC_ATTRIBUTE(pure)
291 AST_GCC_ATTRIBUTE(malloc)
292 AST_GCC_ATTRIBUTE(const)
293 AST_GCC_ATTRIBUTE(unused)
294 AST_GCC_ATTRIBUTE(always_inline)
295
296 AC_MSG_CHECKING(for -ffunction-sections support)
297 saved_CFLAGS="${CFLAGS}"
298 CFLAGS="${CFLAGS} -ffunction-sections"
299 AC_COMPILE_IFELSE(
300         AC_LANG_PROGRAM([], [int x = 1;]),
301         AC_MSG_RESULT(yes)
302         [saved_LDFLAGS="${LDFLAGS}"]
303         [LDFLAGS="${LDFLAGS} -Wl,--gc-sections"]
304         AC_MSG_CHECKING(for --gc-sections support)
305         AC_LINK_IFELSE(
306                 AC_LANG_PROGRAM([], [int x = 1;]),
307                 AC_MSG_RESULT(yes)
308                 [GC_CFLAGS="-ffunction-sections"]
309                 [[GC_LDFLAGS="-Wl,--gc-sections"]],
310                 AC_MSG_RESULT(no)
311         )
312         [LDFLAGS="${saved_LDFLAGS}"],
313         AC_MSG_RESULT(no)
314 )
315 CFLAGS="${saved_CFLAGS}"
316 AC_SUBST(GC_CFLAGS)
317 AC_SUBST(GC_LDFLAGS)
318
319 AC_MSG_CHECKING(for res_ninit)
320 AC_LINK_IFELSE(
321         AC_LANG_PROGRAM([#include <resolv.h>],
322                         [int foo = res_ninit(NULL);]),
323         AC_MSG_RESULT(yes)
324         AC_DEFINE([HAVE_RES_NINIT], 1, [Define to 1 if your system has the re-entrant resolver functions.]),
325         AC_MSG_RESULT(no)
326 )
327
328 AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
329
330 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
331
332 AC_CHECK_HEADER([libkern/OSAtomic.h],
333                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
334
335 AC_CHECK_SIZEOF(int)
336
337 # do the package library checks now
338
339 AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
340
341 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
342
343 if test "x${host_os}" = "xlinux-gnu" ; then
344   AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
345 fi
346
347 GSM_INTERNAL="yes"
348 AC_SUBST(GSM_INTERNAL)
349 GSM_SYSTEM="yes"
350 if test "${USE_GSM}" != "no"; then
351    if test "${GSM_DIR}" = "internal"; then
352       GSM_SYSTEM="no"
353    elif test "${GSM_DIR}" != ""; then
354       GSM_INTERNAL="no"
355    fi
356    if test "${GSM_SYSTEM}" = "yes"; then
357       gsmlibdir=""
358       if test "x${GSM_DIR}" != "x"; then
359          if test -d ${GSM_DIR}/lib; then
360             gsmlibdir="-L${GSM_DIR}/lib"
361          else
362             gsmlibdir="-L${GSM_DIR}"
363          fi
364       fi
365       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
366       [Define to indicate the GSM library]), [], ${gsmlibdir})
367       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
368          GSM_LIB="-lgsm"
369          if test "x${GSM_DIR}" != "x"; then
370             GSM_LIB="${gsmlibdir} ${GSM_LIB}"
371             GSM_INCLUDE="-I${GSM_DIR}/include"
372          fi
373          PBX_GSM=1
374          GSM_INTERNAL="no"
375       fi
376    fi
377    if test "${GSM_INTERNAL}" = "yes"; then
378       PBX_GSM=1
379    fi
380 fi
381
382 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
383
384 if test "${PBX_IKSEMEL}" = 1; then
385    AST_EXT_LIB_CHECK([GNUTLS], [gnutls], [gnutls_bye])
386    if test "${PBX_GNUTLS}" = 1; then
387       IKSEMEL_LIB="${IKSEMEL_LIB} -lgnutls -lz -lgcrypt -lnsl -lgpg-error"
388    fi
389 fi
390
391 if test "${USE_IMAP_TK}" != "no"; then
392    if test "${IMAP_TK_DIR}" = ""; then
393       IMAP_TK_DIR=`pwd`"/../imap-2004g"
394    fi
395    AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
396    saved_cppflags="${CPPFLAGS}"
397    saved_libs="${LIBS}"
398    if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
399       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
400    fi
401    CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
402    LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
403    AC_LINK_IFELSE(
404         AC_LANG_PROGRAM(
405                 [#include "c-client.h"
406                 void mm_searched (MAILSTREAM *stream,unsigned long number)
407                 {
408                 }
409                 void mm_exists (MAILSTREAM *stream,unsigned long number)
410                 {
411                 }
412                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
413                 {
414                 }
415                 void mm_flags (MAILSTREAM *stream,unsigned long number)
416                 {
417                 }
418                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
419                 {
420                 }
421                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
422                 {
423                 }
424                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
425                 {
426                 }
427                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
428                 {
429                 }
430                 void mm_log (char *string,long errflg)
431                 {
432                 }
433                 void mm_dlog (char *string)
434                 {
435                 }
436                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
437                 {
438                 }
439                 void mm_critical (MAILSTREAM *stream)
440                 {
441                 }
442                 void mm_nocritical (MAILSTREAM *stream)
443                 {
444                 }
445                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
446                 {
447                 }
448                 void mm_fatal (char *string)
449                 {
450                 }],
451                 [
452                 MAILSTREAM *foo = mail_open(NULL, "", 0);
453                 ]
454         ),
455         [ac_cv_imap_tk="yes"],
456         [ac_cv_imap_tk="no"]
457    )
458    if test "${ac_cv_imap_tk}" = "yes"; then
459    AC_LINK_IFELSE(
460       AC_LANG_PROGRAM(
461          [#include "c-client.h"
462          void mm_searched (MAILSTREAM *stream,unsigned long number)
463          {
464          }
465          void mm_exists (MAILSTREAM *stream,unsigned long number)
466          {
467          }
468          void mm_expunged (MAILSTREAM *stream,unsigned long number)
469          {
470          }
471          void mm_flags (MAILSTREAM *stream,unsigned long number)
472          {
473          }
474          void mm_notify (MAILSTREAM *stream,char *string,long errflg)
475          {
476          }
477          void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
478          {
479          }
480          void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
481          {
482          }
483          void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
484          {
485          }
486          void mm_log (char *string,long errflg)
487          {
488          }
489          void mm_dlog (char *string)
490          {
491          }
492          void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
493          {
494          }
495          void mm_critical (MAILSTREAM *stream)
496          {
497          }
498          void mm_nocritical (MAILSTREAM *stream)
499          {
500          }
501          long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
502          {
503          }
504          void mm_fatal (char *string)
505          {
506          }],
507          [
508          long check = mail_expunge_full(NULL, "", 0);
509          ]
510       ),
511       [ac_cv_imap_tk2006="yes"],
512       [ac_cv_imap_tk2006="no"]
513   )
514   fi
515    CPPFLAGS="${saved_cppflags}"
516    LIBS="${saved_libs}"
517    if test "${ac_cv_imap_tk}" = "yes"; then
518       AC_MSG_RESULT(yes) 
519       IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
520       IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
521       PBX_IMAP_TK=1
522       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
523       if test "${ac_cv_imap_tk2006}" = "yes"; then
524          AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
525       fi
526    else
527       AC_MSG_RESULT(no) 
528    fi
529 fi
530
531 AC_LANG_PUSH(C++)
532
533 if test "${USE_KDE}" != "no"; then
534    AC_MSG_CHECKING(for crashHandler in -lkdecore)
535    saved_libs="${LIBS}"
536    saved_cppflags="${CPPFLAGS}"
537    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
538    if test -d ${KDE_DIR}/lib; then
539       kdelibdir="${KDE_DIR}/lib"
540    else
541       kdelibdir="${KDE_DIR}"
542    fi
543    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
544
545    AC_LINK_IFELSE(
546         [AC_LANG_PROGRAM(
547                         [#include "kcrash.h"],
548                         [KCrash::defaultCrashHandler(1);])
549         ],
550         [ac_cv_lib_kde_crash="yes"],
551         [ac_cv_lib_kde_crash="no"])
552                 
553    LIBS="${saved_libs}"
554    CPPFLAGS="${saved_cppflags}"
555         
556    if test "${ac_cv_lib_kde_crash}" = "yes"; then
557       AC_MSG_RESULT(yes) 
558       KDE_LIB="-lkdecore -lkdeui"
559       if test "${KDE_DIR}" != ""; then
560          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
561          KDE_INCLUDE="-I${KDE_DIR}/include"
562       fi
563       PBX_KDE=1
564       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
565    else
566       AC_MSG_RESULT(no) 
567    fi
568 fi
569 if test "${PBX_KDE}" = 1; then
570    AC_PATH_TOOL(KDEINIT, kdeinit, No)
571    if test ! x"${KDEINIT}" = xNo; then
572       KDEDIR=$(${DIRNAME} ${KDEINIT})
573       KDEDIR=$(${DIRNAME} ${KDEDIR})
574    fi
575    AC_SUBST([KDEDIR])
576 fi
577
578 AC_LANG_POP
579
580 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
581
582 if test "${PBX_MISDN}" = 1; then
583    AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
584    AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
585 fi
586
587 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
588
589 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
590
591 NETSNMP_CONFIG=No
592 if test "${USE_NETSNMP}" != "no"; then  
593    if test "x${NETSNMP_DIR}" != "x"; then
594       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
595       if test x"${NETSNMP_CONFIG}" = xNo; then
596          AC_MSG_NOTICE([***])
597          AC_MSG_NOTICE([*** net-snmp-config was not found in the path you specified:])
598          AC_MSG_NOTICE([*** ${NETSNMP_DIR}/bin])
599          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
600          AC_MSG_NOTICE([*** including --without-netsnmp])
601          exit 1
602       fi
603    else
604       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
605    fi
606 fi
607 if test x"${NETSNMP_CONFIG}" != xNo; then
608    NETSNMP_libs=`net-snmp-config --agent-libs`
609    
610    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
611    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
612
613    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
614       NETSNMP_LIB="${NETSNMP_libs}"
615       PBX_NETSNMP=1
616    fi
617 fi
618
619 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
620
621 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [-lltdl])
622
623 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
624
625 AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
626
627 # possible places for oss definitions
628 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
629 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
630 AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
631
632 PG_CONFIG=No
633 if test "${USE_PGSQL}" != "no"; then    
634    if test "x${PGSQL_DIR}" != "x"; then
635       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
636       if test x"${PG_CONFIG}" = xNo; then
637          AC_MSG_NOTICE([***])
638          AC_MSG_NOTICE([*** pg_config was not found in the path you specified:])
639          AC_MSG_NOTICE([*** ${PGSQL_DIR}/bin])
640          AC_MSG_NOTICE([*** Either correct the installation, or run configure])
641          AC_MSG_NOTICE([*** including --without-postgres])
642          exit 1
643       fi
644    else
645       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
646    fi
647 fi
648 if test "${PG_CONFIG}" != No; then
649    PGSQL_libdir=`pg_config --libdir`
650    PGSQL_includedir=`pg_config --includedir`
651    
652    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
653    [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
654
655    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
656       PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
657       PGSQL_INCLUDE="-I${PGSQL_includedir}"
658       PBX_PGSQL=1
659    fi
660 fi
661
662 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
663
664 AST_EXT_LIB_CHECK([PRI], [pri], [pri_call], [libpri.h])
665
666 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_new], [libss7.h])
667
668 if test "${USE_PWLIB}" != "no"; then
669         if test ! -z "${PWLIB_DIR}"; then
670                 PWLIBDIR="${PWLIB_DIR}"
671         fi
672         AST_CHECK_PWLIB()
673         AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2])
674                 
675         if test "${HAS_PWLIB:-unset}" != "unset"; then
676                 AST_CHECK_OPENH323_PLATFORM()
677
678                 PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r"
679
680                 AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
681                         [Define if your system has the PWLib libraries.],
682                         [#include "ptlib.h"],
683                         [BOOL q = PTime::IsDaylightSavings();])
684         fi
685 fi
686
687 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
688         if test ! -z "${OPENH323_DIR}"; then
689                 OPENH323DIR="${OPENH323_DIR}"
690         fi
691         AST_CHECK_OPENH323()
692         AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3])
693         AST_CHECK_OPENH323_BUILD()
694         PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
695         AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],
696                 [Define if your system has the OpenH323 libraries.],
697                 [#include "ptlib.h"
698                 #include "h323.h"
699                 #include "h323ep.h"],
700                 [H323EndPoint ep = H323EndPoint();],
701                 [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
702 fi
703
704 AC_LANG_PUSH(C++)
705
706 if test "${USE_QT}" != "no"; then
707    AC_MSG_CHECKING(for QDate in -lqt)
708    saved_libs="${LIBS}"
709    saved_cppflags="${CPPFLAGS}"
710    if test "x${QT_DIR}" != "x"; then
711       LIBS="${LIBS} -L${QT_DIR}/lib"
712       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
713    fi
714    LIBS="${LIBS} -lqt"
715    qtlib="qt"
716    AC_LINK_IFELSE(
717         [
718                 AC_LANG_PROGRAM(
719                 [#include <qt3/qdatetime.h>],
720                 [QDate date();])
721         ],
722         [ac_cv_lib_qt_qt_date="yes"],
723         [ac_cv_lib_qt_qt_date="no"])
724    LIBS="${saved_libs}"
725    CPPFLAGS="${saved_cppflags}"
726         
727    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
728       saved_libs="${LIBS}"
729       saved_cppflags="${CPPFLAGS}"
730       if test "x${QT_DIR}" != "x"; then
731          LIBS="${LIBS} -L${QT_DIR}/lib"
732          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
733       fi
734       LIBS="${LIBS} -lqt-mt"
735       qtlib="qt-mt"     
736       AC_LINK_IFELSE(
737                 [
738                         AC_LANG_PROGRAM(
739                         [#include <qt3/qdatetime.h>],
740                         [QDate date();])
741                 ],
742                 [ac_cv_lib_qt_qt_date="yes"],
743                 [ac_cv_lib_qt_qt_date="no"])
744       LIBS="${saved_libs}"
745       CPPFLAGS="${saved_cppflags}"
746    fi   
747
748    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
749       AC_MSG_RESULT(yes) 
750    else
751       AC_MSG_RESULT(no) 
752    fi
753         
754    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
755       QT_LIB="-l${qtlib}"
756       if test "${QT_DIR}" != ""; then
757          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
758          QT_INCLUDE="-I${QT_DIR}/include"
759       fi
760       PBX_QT=1
761       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
762       AC_PATH_TOOL(QTMOC, moc, No)
763    fi
764 fi
765
766 AC_LANG_POP
767
768 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
769
770 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
771
772 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
773
774 AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
775
776 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
777 if test "${PBX_FREETDS}" != "0";
778 then
779     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
780         *0.64*)
781                 FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
782         ;;
783     *0.63*)
784         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
785         ;;
786     *0.62*)
787         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
788         ;;
789     *)
790         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
791         ;;
792     esac
793 fi
794
795 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
796
797 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
798
799 if test "${host_os}" != "linux-gnu" ; then
800   tonezone_extra="-lm"
801 fi
802
803 # new tonezone, version 1.4.0
804 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}], [140])
805 # other case, old tonezone (0.80)
806 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/zaptel.h], [${tonezone_extra}], [80])
807
808 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
809
810 AC_LANG_PUSH(C++)
811
812 if test "${USE_VPB}" != "no"; then
813    AC_MSG_CHECKING(for vpb_open in -lvpb)
814    saved_libs="${LIBS}"
815    saved_cppflags="${CPPFLAGS}"
816    if test "x${VPB_DIR}" != "x"; then
817       if test -d ${VPB_DIR}/lib; then
818          vpblibdir=${VPB_DIR}/lib
819       else
820          vpblibdir=${VPB_DIR}
821       fi
822       LIBS="${LIBS} -L${vpblibdir}"
823       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
824    fi
825    LIBS="${LIBS} -lvpb -lpthread"
826    AC_LINK_IFELSE(
827         [
828         AC_LANG_PROGRAM(
829         [#include <vpbapi.h>],
830         [int q = vpb_open(0,0);])
831         ],
832         [       AC_MSG_RESULT(yes) 
833                 ac_cv_lib_vpb_vpb_open="yes" 
834         ],
835         [       AC_MSG_RESULT(no) 
836                 ac_cv_lib_vpb_vpb_open="no" 
837         ]
838         )
839    LIBS="${saved_libs}"
840    CPPFLAGS="${saved_cppflags}"
841    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
842         VPB_LIB="-lvpb"
843         if test "${VPB_DIR}" != ""; then
844            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
845            VPB_INCLUDE="-I${VPB_DIR}/include"
846         fi
847         PBX_VPB=1
848         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
849    fi
850 fi
851
852 AC_LANG_POP
853
854 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
855
856 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_DIAL_OP_CANCEL], [zaptel/zaptel.h])
857
858 if test "${PBX_ZAPTEL}" = 1; then
859    AC_MSG_CHECKING(for ZT_TONE_DTMF_BASE in zaptel/zaptel.h)
860    saved_cppflags="${CPPFLAGS}"
861    if test "x${ZAPTEL_DIR}" != "x"; then
862       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
863    fi
864    AC_COMPILE_IFELSE(
865         [
866         AC_LANG_PROGRAM(
867         [#include <zaptel/zaptel.h>],
868         [int foo = ZT_TONE_DTMF_BASE;])
869         ],
870         [       AC_MSG_RESULT(yes) 
871                 ac_cv_zaptel_vldtmf="yes" 
872         ],
873         [       AC_MSG_RESULT(no) 
874                 ac_cv_zaptel_vldtmf="no" 
875         ]
876         )
877    CPPFLAGS="${saved_cppflags}"
878    if test "${ac_cv_zaptel_vldtmf}" = "yes"; then
879         PBX_ZAPTEL_VLDTMF=1
880    fi
881    AC_MSG_CHECKING(for ZT_TCOP_TRANSCODE in zaptel/zaptel.h)
882    saved_cppflags="${CPPFLAGS}"
883    if test "x${ZAPTEL_DIR}" != "x"; then
884       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
885    fi
886    AC_COMPILE_IFELSE(
887         [
888         AC_LANG_PROGRAM(
889         [#include <zaptel/zaptel.h>],
890         [int foo = ZT_TCOP_TRANSCODE;])
891         ],
892         [       AC_MSG_RESULT(yes) 
893                 ac_cv_zaptel_transcode="yes" 
894         ],
895         [       AC_MSG_RESULT(no) 
896                 ac_cv_zaptel_transcode="no" 
897         ]
898         )
899    CPPFLAGS="${saved_cppflags}"
900    if test "${ac_cv_zaptel_transcode}" = "yes"; then
901         PBX_ZAPTEL_TRANSCODE=1
902    fi
903 fi
904 AC_SUBST(PBX_ZAPTEL_VLDTMF)
905 AC_SUBST(PBX_ZAPTEL_TRANSCODE)
906
907 EDITLINE_LIB=""
908 if test "x$TERMCAP_LIB" != "x" ; then
909   EDITLINE_LIB="$TERMCAP_LIB"
910 elif test "x$TINFO_LIB" != "x" ; then
911   EDITLINE_LIB="$TINFO_LIB"
912 elif test "x$CURSES_LIB" != "x" ; then
913   EDITLINE_LIB="$CURSES_LIB"
914 elif test "x$NCURSES_LIB" != "x" ; then
915   EDITLINE_LIB="$NCURSES_LIB"
916 else
917   AC_MSG_ERROR(*** termcap support not found)
918 fi
919 AC_SUBST(EDITLINE_LIB)
920
921 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
922 AC_SUBST(PBX_H323)
923
924 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
925                                    #include <linux/version.h>
926                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
927                                    #include <linux/compiler.h>
928                                    #endif
929                                    ])
930 AC_SUBST(PBX_IXJUSER)
931
932 PBX_GTK=0
933 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
934 if test ! "x${GTKCONFIG}" = xNo; then
935    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
936    GTK_LIB=$(${GTKCONFIG} --libs gthread)
937    PBX_GTK=1
938    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
939 fi
940 AC_SUBST(PBX_GTK)
941 AC_SUBST(GTK_INCLUDE)
942 AC_SUBST(GTK_LIB)
943
944 if test "${USE_CURL}" != "no"; then
945    AC_PATH_TOOL([CURL], [curl-config], No)
946    if test ! x"${CURL}" = xNo; then
947    # check for version
948       if test $(printf "%d" 0x$(curl-config --vernum)) -ge $(printf "%d" 0x070907); then
949          CURL_INCLUDE=$(${CURL} --cflags)
950          CURL_LIB=$(${CURL} --libs)
951          PBX_CURL=1
952          AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
953       fi
954    fi
955 fi
956
957 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
958 AST_CHECK_MANDATORY
959
960 AC_OUTPUT
961
962 if test "x${silent}" != "xyes" ; then
963 echo
964 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
965 echo "            .\$7\$7..          .7\$\$7:.    "
966 echo "          .\$\$:.                 ,\$7.7   "
967 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
968 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
969 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
970 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
971 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
972 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
973 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
974 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
975 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
976 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
977 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
978 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
979 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
980 echo " \$\$\$\$\$                        \$\$\$       "
981 echo "  \$\$\$\$7.                       \$\$  (TM)     "
982 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
983 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
984 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
985 echo
986 fi
987
988 AC_MSG_NOTICE(Package configured for: )
989 AC_MSG_NOTICE( OS type  : $host_os)
990 AC_MSG_NOTICE( Host CPU : $host_cpu)
991 if test "${cross_compiling}" = "yes"; then
992    AC_MSG_NOTICE( Cross Compilation = YES)
993 fi