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