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