Merged revisions 45027 via svnmerge from
[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 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
303
304 AC_CHECK_HEADER([libkern/OSAtomic.h],
305                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
306
307 AC_CHECK_SIZEOF(int)
308
309 # do the package library checks now
310
311 AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
312
313 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
314
315 if test "x${host_os}" = "xlinux-gnu" ; then
316   AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
317 fi
318
319 GSM_INTERNAL="yes"
320 AC_SUBST(GSM_INTERNAL)
321 GSM_SYSTEM="yes"
322 if test "${USE_GSM}" != "no"; then
323    if test "${GSM_DIR}" = "internal"; then
324       GSM_SYSTEM="no"
325    elif test "${GSM_DIR}" != ""; then
326       GSM_INTERNAL="no"
327    fi
328    if test "${GSM_SYSTEM}" = "yes"; then
329       gsmlibdir=""
330       if test "x${GSM_DIR}" != "x"; then
331          if test -d ${GSM_DIR}/lib; then
332             gsmlibdir="-L${GSM_DIR}/lib"
333          else
334             gsmlibdir="-L${GSM_DIR}"
335          fi
336       fi
337       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
338       [Define to indicate the GSM library]), [], ${gsmlibdir})
339       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
340          GSM_LIB="-lgsm"
341          if test "x${GSM_DIR}" != "x"; then
342             GSM_LIB="${gsmlibdir} ${GSM_LIB}"
343             GSM_INCLUDE="-I${GSM_DIR}/include"
344          fi
345          PBX_GSM=1
346          GSM_INTERNAL="no"
347       fi
348    fi
349    if test "${GSM_INTERNAL}" = "yes"; then
350       PBX_GSM=1
351    fi
352 fi
353
354 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
355
356 if test "${PBX_IKSEMEL}" = 1; then
357    AST_EXT_LIB_CHECK([GNUTLS], [gnutls], [gnutls_bye])
358    if test "${PBX_GNUTLS}" = 1; then
359       IKSEMEL_LIB="${IKSEMEL_LIB} -lgnutls -lz -lgcrypt -lnsl -lgpg-error"
360    fi
361 fi
362
363 if test "${USE_IMAP_TK}" != "no"; then
364    if test "${IMAP_TK_DIR}" = ""; then
365       IMAP_TK_DIR=`pwd`"/../imap-2004g"
366    fi
367    AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
368    saved_cppflags="${CPPFLAGS}"
369    saved_libs="${LIBS}"
370    if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
371       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
372    fi
373    CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
374    LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
375    AC_LINK_IFELSE(
376         AC_LANG_PROGRAM(
377                 [#include "c-client.h"
378                 void mm_searched (MAILSTREAM *stream,unsigned long number)
379                 {
380                 }
381                 void mm_exists (MAILSTREAM *stream,unsigned long number)
382                 {
383                 }
384                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
385                 {
386                 }
387                 void mm_flags (MAILSTREAM *stream,unsigned long number)
388                 {
389                 }
390                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
391                 {
392                 }
393                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
394                 {
395                 }
396                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
397                 {
398                 }
399                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
400                 {
401                 }
402                 void mm_log (char *string,long errflg)
403                 {
404                 }
405                 void mm_dlog (char *string)
406                 {
407                 }
408                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
409                 {
410                 }
411                 void mm_critical (MAILSTREAM *stream)
412                 {
413                 }
414                 void mm_nocritical (MAILSTREAM *stream)
415                 {
416                 }
417                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
418                 {
419                 }
420                 void mm_fatal (char *string)
421                 {
422                 }],
423                 [
424                 MAILSTREAM *foo = mail_open(NULL, "", 0);
425                 ]
426         ),
427         [ac_cv_imap_tk="yes"],
428         [ac_cv_imap_tk="no"]
429    )
430    if test "${ac_cv_imap_tk}" = "yes"; then
431    AC_LINK_IFELSE(
432       AC_LANG_PROGRAM(
433          [#include "c-client.h"
434          void mm_searched (MAILSTREAM *stream,unsigned long number)
435          {
436          }
437          void mm_exists (MAILSTREAM *stream,unsigned long number)
438          {
439          }
440          void mm_expunged (MAILSTREAM *stream,unsigned long number)
441          {
442          }
443          void mm_flags (MAILSTREAM *stream,unsigned long number)
444          {
445          }
446          void mm_notify (MAILSTREAM *stream,char *string,long errflg)
447          {
448          }
449          void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
450          {
451          }
452          void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
453          {
454          }
455          void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
456          {
457          }
458          void mm_log (char *string,long errflg)
459          {
460          }
461          void mm_dlog (char *string)
462          {
463          }
464          void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
465          {
466          }
467          void mm_critical (MAILSTREAM *stream)
468          {
469          }
470          void mm_nocritical (MAILSTREAM *stream)
471          {
472          }
473          long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
474          {
475          }
476          void mm_fatal (char *string)
477          {
478          }],
479          [
480          long check = mail_expunge_full(NULL, "", 0);
481          ]
482       ),
483       [ac_cv_imap_tk2006="yes"],
484       [ac_cv_imap_tk2006="no"]
485   )
486   fi
487    CPPFLAGS="${saved_cppflags}"
488    LIBS="${saved_libs}"
489    if test "${ac_cv_imap_tk}" = "yes"; then
490       AC_MSG_RESULT(yes) 
491       IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
492       IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
493       PBX_IMAP_TK=1
494       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
495       if test "${ac_cv_imap_tk2006}" = "yes"; then
496          AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
497       fi
498    else
499       AC_MSG_RESULT(no) 
500    fi
501 fi
502
503 AC_LANG_PUSH(C++)
504
505 if test "${USE_KDE}" != "no"; then
506    AC_MSG_CHECKING(for crashHandler in -lkdecore)
507    saved_libs="${LIBS}"
508    saved_cppflags="${CPPFLAGS}"
509    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
510    if test -d ${KDE_DIR}/lib; then
511       kdelibdir="${KDE_DIR}/lib"
512    else
513       kdelibdir="${KDE_DIR}"
514    fi
515    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
516
517    AC_LINK_IFELSE(
518         [AC_LANG_PROGRAM(
519                         [#include "kcrash.h"],
520                         [KCrash::defaultCrashHandler(1);])
521         ],
522         [ac_cv_lib_kde_crash="yes"],
523         [ac_cv_lib_kde_crash="no"])
524                 
525    LIBS="${saved_libs}"
526    CPPFLAGS="${saved_cppflags}"
527         
528    if test "${ac_cv_lib_kde_crash}" = "yes"; then
529       AC_MSG_RESULT(yes) 
530       KDE_LIB="-lkdecore -lkdeui"
531       if test "${KDE_DIR}" != ""; then
532          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
533          KDE_INCLUDE="-I${KDE_DIR}/include"
534       fi
535       PBX_KDE=1
536       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
537    else
538       AC_MSG_RESULT(no) 
539    fi
540 fi
541 if test "${PBX_KDE}" = 1; then
542    AC_PATH_TOOL(KDEINIT, kdeinit, No)
543    if test ! x"${KDEINIT}" = xNo; then
544       KDEDIR=$(${DIRNAME} ${KDEINIT})
545       KDEDIR=$(${DIRNAME} ${KDEDIR})
546    fi
547    AC_SUBST([KDEDIR])
548 fi
549
550 AC_LANG_POP
551
552 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
553
554 if test "${PBX_MISDN}" = 1; then
555    AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
556    AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
557 fi
558
559 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
560
561 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
562
563 NETSNMP_CONFIG=No
564 if test "${USE_NETSNMP}" != "no"; then  
565    if test "x${NETSNMP_DIR}" != "x"; then
566       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
567       if test x"${NETSNMP_CONFIG}" = xNo; then
568          AC_MSG_NOTICE(***)
569          AC_MSG_NOTICE(*** net-snmp-config was not found in the path you specified:)
570          AC_MSG_NOTICE(*** ${NETSNMP_DIR}/bin)
571          AC_MSG_NOTICE(*** Either correct the installation, or run configure)
572          AC_MSG_NOTICE(*** including --without-netsnmp)
573          exit 1
574       fi
575    else
576       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
577    fi
578 fi
579 if test x"${NETSNMP_CONFIG}" != xNo; then
580    NETSNMP_libs=`net-snmp-config --agent-libs`
581    
582    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
583    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
584
585    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
586       NETSNMP_LIB="${NETSNMP_libs}"
587       PBX_NETSNMP=1
588    fi
589 fi
590
591 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
592
593 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [-lltdl])
594
595 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
596
597 AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
598
599 # possible places for oss definitions
600 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])
601 AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])
602 AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
603
604 PG_CONFIG=No
605 if test "${USE_PGSQL}" != "no"; then    
606    if test "x${PGSQL_DIR}" != "x"; then
607       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
608       if test x"${PG_CONFIG}" = xNo; then
609          AC_MSG_NOTICE(***)
610          AC_MSG_NOTICE(*** pg_config was not found in the path you specified:)
611          AC_MSG_NOTICE(*** ${PGSQL_DIR}/bin)
612          AC_MSG_NOTICE(*** Either correct the installation, or run configure)
613          AC_MSG_NOTICE(*** including --without-postgres)
614          exit 1
615       fi
616    else
617       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
618    fi
619 fi
620 if test "${PG_CONFIG}" != No; then
621    PGSQL_libdir=`pg_config --libdir`
622    PGSQL_includedir=`pg_config --includedir`
623    
624    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
625    [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
626
627    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
628       PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz -lcrypt"
629       PGSQL_INCLUDE="-I${PGSQL_includedir}"
630       PBX_PGSQL=1
631    fi
632 fi
633
634 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
635
636 AST_EXT_LIB_CHECK([PRI], [pri], [pri_call], [libpri.h])
637
638 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_new], [libss7.h])
639
640 if test "${USE_PWLIB}" != "no"; then
641         if test ! -z "${PWLIB_DIR}"; then
642                 PWLIBDIR="${PWLIB_DIR}"
643         fi
644         AST_CHECK_PWLIB()
645         AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2])
646                 
647         if test "${HAS_PWLIB:-unset}" != "unset"; then
648                 AST_CHECK_OPENH323_PLATFORM()
649
650                 PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r"
651
652                 AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB],
653                         [Define if your system has the PWLib libraries.],
654                         [#include "ptlib.h"],
655                         [BOOL q = PTime::IsDaylightSavings();])
656         fi
657 fi
658
659 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
660         if test ! -z "${OPENH323_DIR}"; then
661                 OPENH323DIR="${OPENH323_DIR}"
662         fi
663         AST_CHECK_OPENH323()
664         AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3])
665         AST_CHECK_OPENH323_BUILD()
666         PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
667         AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],
668                 [Define if your system has the OpenH323 libraries.],
669                 [#include "ptlib.h"
670                 #include "h323.h"
671                 #include "h323ep.h"],
672                 [H323EndPoint ep = H323EndPoint();],
673                 [${PWLIB_INCLUDE}], [${PWLIB_LIB}])
674 fi
675
676 AC_LANG_PUSH(C++)
677
678 if test "${USE_QT}" != "no"; then
679    AC_MSG_CHECKING(for QDate in -lqt)
680    saved_libs="${LIBS}"
681    saved_cppflags="${CPPFLAGS}"
682    if test "x${QT_DIR}" != "x"; then
683       LIBS="${LIBS} -L${QT_DIR}/lib"
684       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
685    fi
686    LIBS="${LIBS} -lqt"
687    qtlib="qt"
688    AC_LINK_IFELSE(
689         [
690                 AC_LANG_PROGRAM(
691                 [#include <qt3/qdatetime.h>],
692                 [QDate date();])
693         ],
694         [ac_cv_lib_qt_qt_date="yes"],
695         [ac_cv_lib_qt_qt_date="no"])
696    LIBS="${saved_libs}"
697    CPPFLAGS="${saved_cppflags}"
698         
699    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
700       saved_libs="${LIBS}"
701       saved_cppflags="${CPPFLAGS}"
702       if test "x${QT_DIR}" != "x"; then
703          LIBS="${LIBS} -L${QT_DIR}/lib"
704          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
705       fi
706       LIBS="${LIBS} -lqt-mt"
707       qtlib="qt-mt"     
708       AC_LINK_IFELSE(
709                 [
710                         AC_LANG_PROGRAM(
711                         [#include <qt3/qdatetime.h>],
712                         [QDate date();])
713                 ],
714                 [ac_cv_lib_qt_qt_date="yes"],
715                 [ac_cv_lib_qt_qt_date="no"])
716       LIBS="${saved_libs}"
717       CPPFLAGS="${saved_cppflags}"
718    fi   
719
720    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
721       AC_MSG_RESULT(yes) 
722    else
723       AC_MSG_RESULT(no) 
724    fi
725         
726    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
727       QT_LIB="-l${qtlib}"
728       if test "${QT_DIR}" != ""; then
729          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
730          QT_INCLUDE="-I${QT_DIR}/include"
731       fi
732       PBX_QT=1
733       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
734       AC_PATH_TOOL(QTMOC, moc, No)
735    fi
736 fi
737
738 AC_LANG_POP
739
740 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
741
742 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
743
744 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
745
746 AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
747
748 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
749 if test "${PBX_FREETDS}" != "0";
750 then
751     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
752         *0.64*)
753                 FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
754         ;;
755     *0.63*)
756         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
757         ;;
758     *0.62*)
759         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
760         ;;
761     *)
762         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
763         ;;
764     esac
765 fi
766
767 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
768
769 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
770
771 if test "${host_os}" != "linux-gnu" ; then
772   tonezone_extra="-lm"
773 fi
774
775 # new tonezone, version 1.4.0
776 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}], [140])
777 # other case, old tonezone (0.80)
778 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/zaptel.h], [${tonezone_extra}], [80])
779
780 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
781
782 AC_LANG_PUSH(C++)
783
784 if test "${USE_VPB}" != "no"; then
785    AC_MSG_CHECKING(for vpb_open in -lvpb)
786    saved_libs="${LIBS}"
787    saved_cppflags="${CPPFLAGS}"
788    if test "x${VPB_DIR}" != "x"; then
789       if test -d ${VPB_DIR}/lib; then
790          vpblibdir=${VPB_DIR}/lib
791       else
792          vpblibdir=${VPB_DIR}
793       fi
794       LIBS="${LIBS} -L${vpblibdir}"
795       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
796    fi
797    LIBS="${LIBS} -lvpb -lpthread"
798    AC_LINK_IFELSE(
799         [
800         AC_LANG_PROGRAM(
801         [#include <vpbapi.h>],
802         [int q = vpb_open(0,0);])
803         ],
804         [       AC_MSG_RESULT(yes) 
805                 ac_cv_lib_vpb_vpb_open="yes" 
806         ],
807         [       AC_MSG_RESULT(no) 
808                 ac_cv_lib_vpb_vpb_open="no" 
809         ]
810         )
811    LIBS="${saved_libs}"
812    CPPFLAGS="${saved_cppflags}"
813    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
814         VPB_LIB="-lvpb"
815         if test "${VPB_DIR}" != ""; then
816            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
817            VPB_INCLUDE="-I${VPB_DIR}/include"
818         fi
819         PBX_VPB=1
820         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
821    fi
822 fi
823
824 AC_LANG_POP
825
826 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
827
828 # check for zaptel 1.4.0
829 AST_C_DEFINE_CHECK([ZAPTEL], [ZT_TONE_DTMF_BASE], [zaptel/zaptel.h], [140])
830 # or, try old zaptel (0.80 or so)
831 AST_EXT_LIB_CHECK([ZAPTEL], [zaptel],, [zaptel.h],, [80])
832
833 EDITLINE_LIB=""
834 if test "x$TERMCAP_LIB" != "x" ; then
835   EDITLINE_LIB="$TERMCAP_LIB"
836 elif test "x$TINFO_LIB" != "x" ; then
837   EDITLINE_LIB="$TINFO_LIB"
838 elif test "x$CURSES_LIB" != "x" ; then
839   EDITLINE_LIB="$CURSES_LIB"
840 elif test "x$NCURSES_LIB" != "x" ; then
841   EDITLINE_LIB="$NCURSES_LIB"
842 else
843   AC_MSG_ERROR(*** termcap support not found)
844 fi
845 AC_SUBST(EDITLINE_LIB)
846
847 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
848 AC_SUBST(PBX_H323)
849
850 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
851                                    #include <linux/version.h>
852                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
853                                    #include <linux/compiler.h>
854                                    #endif
855                                    ])
856 AC_SUBST(PBX_IXJUSER)
857
858 PBX_GTK=0
859 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
860 if test ! "x${GTKCONFIG}" = xNo; then
861    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
862    GTK_LIB=$(${GTKCONFIG} --libs gthread)
863    PBX_GTK=1
864    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
865 fi
866 AC_SUBST(PBX_GTK)
867 AC_SUBST(GTK_INCLUDE)
868 AC_SUBST(GTK_LIB)
869
870 if test "${USE_CURL}" != "no"; then
871    AC_PATH_TOOL([CURL], [curl-config], No)
872    if test ! x"${CURL}" = xNo; then
873    # check for version
874       if test "${host_os}" = "SunOS"; then
875             if [[ 0x`curl-config --vernum` -ge 0x70907 ]]; then
876                 CURL_INCLUDE=$(${CURL} --cflags)
877                 CURL_LIB=$(${CURL} --libs)
878                 PBX_CURL=1
879                 AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
880             fi
881          else
882             if [[[ 0x`curl-config --vernum` -ge 0x70907 ]]]; then
883                 CURL_INCLUDE=$(${CURL} --cflags)
884                 CURL_LIB=$(${CURL} --libs)
885                 PBX_CURL=1
886                 AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
887             fi
888         fi
889     fi
890 fi
891
892 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile])
893 AST_CHECK_MANDATORY
894
895 AC_OUTPUT
896
897 if test "x${silent}" != "xyes" ; then
898 echo
899 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
900 echo "            .\$7\$7..          .7\$\$7:.    "
901 echo "          .\$\$:.                 ,\$7.7   "
902 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
903 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
904 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
905 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
906 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
907 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
908 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
909 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
910 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
911 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
912 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
913 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
914 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
915 echo " \$\$\$\$\$                        \$\$\$       "
916 echo "  \$\$\$\$7.                       \$\$  (TM)     "
917 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
918 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
919 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
920 echo
921 fi
922
923 AC_MSG_NOTICE(Package configured for: )
924 AC_MSG_NOTICE( OS type  : $host_os)
925 AC_MSG_NOTICE( Host CPU : $host_cpu)
926 if test "${cross_compiling}" = "yes"; then
927    AC_MSG_NOTICE( Cross Compilation = YES)
928 fi