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