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