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