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