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