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