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