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