update OSS so it works again
[asterisk/asterisk.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2
3 AC_PREREQ(2.59)
4
5 m4_define([PBX_VERSION],
6           m4_bpatsubst(m4_esyscmd([build_tools/make_version .]),
7                        [\([0-9.]*\)\(\w\|\W\)*],
8                        [\1]))
9 AC_INIT(asterisk, PBX_VERSION, www.asterisk.org)
10
11 # cross-compile macros
12 AC_CANONICAL_BUILD
13 AC_CANONICAL_HOST
14 AC_CANONICAL_TARGET
15
16 # check existence of the package
17 AC_CONFIG_SRCDIR([asterisk.c])
18
19 # specify output header file
20 AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
21
22 AC_COPYRIGHT("Asterisk")
23 AC_REVISION($Revision$)
24
25 case "${host}" in
26      *freebsd*)
27      ac_default_prefix=/usr/local
28      ;;
29      *)
30      ac_default_prefix=/usr
31      if test ${sysconfdir} = '${prefix}/etc'; then
32         sysconfdir=/etc
33      fi
34      if test ${mandir} = '${prefix}/man'; then
35         mandir=/usr/share/man
36      fi
37      ;;
38 esac
39
40 if test ${localstatedir} = '${prefix}/var'; then
41      localstatedir=/var
42 fi
43
44 ### ** Platform.
45 AC_DEFINE_UNQUOTED(PBX_PLATFORM, "${host}",
46 [Define this to be the canonical name (cpu-vendor-os) of your system.])
47 AC_DEFINE_UNQUOTED(PBX_CPU, "${host_cpu}",
48 [Define this to be the name of the CPU of your system.])
49 AC_DEFINE_UNQUOTED(PBX_VENDOR, "${host_vendor}",
50 [Define this to be the name of the vendor of your system.])
51 AC_DEFINE_UNQUOTED(PBX_OS, "${host_os}",
52 [Define this to be the name of the OS of your system.])
53
54 # export some useful defines
55 PBX_PLATFORM=${host}
56 PBX_CPU=${host_cpu}
57 PBX_VENDOR=${host_vendor}
58 PBX_OS=${host_os}
59 AC_SUBST(PBX_PLATFORM)
60 AC_SUBST(PBX_CPU)
61 AC_SUBST(PBX_VENDOR)
62 AC_SUBST(PBX_OS)
63
64 #  check for uname
65 AC_PATH_TOOL([UNAME], [uname], No)
66 if test ! x"${UNAME}" = xNo; then
67    PBX_OSREV=$(${UNAME} -r)
68 fi
69 AC_SUBST(PBX_OSREV)
70
71 # guest OS type
72 case "${host}" in
73   cygwin*|mingw*|windows*|winnt)
74     AC_DEFINE(Win32, 1,
75               [Define according to your operating system type.])
76     PBX_OSTYPE="CYGWIN"
77 # this is ugly - KPF
78   OSISWIN32=1
79   AC_SUBST(OSISWIN32)
80     ;;
81   *linux*)
82     AC_DEFINE(Linux, 1,
83               [Define according to your operating system type.])
84     PBX_OSTYPE="Linux"
85     ;;
86   *netbsd*)
87     AC_DEFINE(NetBSD, 1,
88               [Define according to your operating system type.])
89     PBX_OSTYPE="NetBSD"
90     ;;
91   *freebsd*)
92     AC_DEFINE(FreeBSD, 1,
93               [Define according to your operating system type.])
94     PBX_OSTYPE="FreeBSD"
95     # XXX temporary hack to let FreeBSD use the default paths
96     # for local stuff. We need a better solution.
97     if test x"${CPPFLAGS}" = x; then
98         CPPFLAGS="-I/usr/local/include"
99     fi
100     if test x"${LDFLAGS}" = x; then
101         LDFLAGS="-L/usr/local/lib"
102     fi
103     ;;
104   *openbsd*)
105     AC_DEFINE(OpenBSD, 1,
106               [Define according to your operating system type.])
107     PBX_OSTYPE="OpenBSD"
108     ;;
109   *sun*)
110     AC_DEFINE(SunOS, 1,
111               [Define according to your operating system type.])
112     PBX_OSTYPE="SunOS"
113     ;;
114   *darwin*)
115     AC_DEFINE(Darwin, 1,
116               [Define according to your operating system type.])
117     PBX_OSTYPE="Darwin"
118     ;;
119   *)
120     AC_DEFINE(Unix, 1,
121               [Define according to your operating system type.])
122     PBX_OSTYPE="Unix"
123    ;;
124 esac
125 AC_SUBST(PBX_OSTYPE)
126
127 # This needs to be before any macros that use the C compiler
128 AC_GNU_SOURCE
129
130 AH_TOP(
131 #ifndef ASTERISK_AUTOCONFIG_H
132 #define ASTERISK_AUTOCONFIG_H
133
134 #ifndef MENUSELECT
135 #include "asterisk/buildopts.h"
136 #endif
137
138 #ifndef _REENTRANT
139 #define _REENTRANT
140 #endif
141 )
142
143 AH_BOTTOM(
144 #endif
145 )
146
147 # cross-compile checks
148 if test x"${build}" != x"${host}"; 
149 then
150    AC_CHECK_TOOL(CC, gcc, :)
151    AC_CHECK_TOOL(CXX, g++, :)
152    AC_CHECK_TOOL(RANLIB, ranlib, :)
153    AC_CHECK_TOOL(AR, ar, :)
154
155    if test x"${PBX_OSTYPE}" = xWin32;
156    then
157       AC_CHECK_TOOL(NM, nm, :)
158       AC_CHECK_TOOL(WINDRES, windres, :)
159       AC_CHECK_TOOL(DLLWRAP, dllwrap, :)
160    fi
161    crossCompile="Yes"
162 fi
163
164 # Checks for programs.
165 AC_PROG_CC
166 AC_PROG_CXX
167 AC_PROG_CPP
168 AC_PROG_CXXCPP
169 AC_PROG_AWK
170 AC_PROG_INSTALL
171 AC_PROG_LN_S
172 AC_PROG_RANLIB
173 AST_CHECK_GNU_MAKE
174
175 AC_PATH_PROG([GREP], [grep], :)
176 AC_PATH_PROG([AR], [ar], :)
177 AC_PATH_PROG([FIND], [find], :)
178 AC_PATH_PROG([COMPRESS], [compress], :)
179 AC_PATH_PROG([BASENAME], [basename], :)
180 AC_PATH_PROG([DIRNAME], [dirname], :)
181 AC_PATH_PROG([SHELL], [sh], :)
182 AC_PATH_PROG([LN], [ln], :)
183 AC_PATH_PROG([DOT], [dot], :)
184
185 AC_LANG(C)
186
187 AC_ARG_ENABLE(dev-mode,
188         [  --enable-dev-mode    Turn on developer mode],
189         [case "${enableval}" in
190               y|ye|yes) AST_DEVMODE=yes ;;
191               n|no)  AST_DEVMODE=no ;;
192               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
193         esac])
194 AC_SUBST(AST_DEVMODE)
195
196 # package option names should be in alphabetical order
197 # by the --with option name, to make things easier for the users :-)
198
199 AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
200 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
201 AST_EXT_LIB_SETUP([GSM], [GSM], [gsm], [, or 'internal'])
202 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
203 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
204 AST_EXT_LIB_SETUP([KDE], [KDE], [kde])
205 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
206 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
207 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
208 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
209 AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [odbc])
210 AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
211 AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
212 AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
213 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
214 AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
215 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
216 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
217 AST_EXT_LIB_SETUP([QT], [Qt], [qt])
218 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
219 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
220 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
221 AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL], [ssl])
222 AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
223 AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap])
224 AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
225 AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
226 AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
227 AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
228 AST_EXT_LIB_SETUP([ZLIB], [zlib], [z])
229 AST_EXT_LIB_SETUP([ZAPTEL], [Zaptel], [zaptel])
230
231 # check for basic system features and functionality before
232 # checking for package libraries
233
234 AC_FUNC_ALLOCA
235 AC_HEADER_DIRENT
236 AC_HEADER_STDC
237 AC_HEADER_SYS_WAIT
238 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])
239
240 AC_SYS_LARGEFILE
241
242 # Checks for typedefs, structures, and compiler characteristics.
243 AC_HEADER_STDBOOL
244 AC_C_CONST
245 AC_TYPE_UID_T
246 AC_C_INLINE
247 AC_TYPE_MODE_T
248 AC_TYPE_OFF_T
249 AC_TYPE_PID_T
250 AC_TYPE_SIZE_T
251 AC_CHECK_MEMBERS([struct stat.st_blksize])
252 AC_HEADER_TIME
253 AC_STRUCT_TM
254 AC_C_VOLATILE
255 AC_CHECK_TYPES([ptrdiff_t])
256
257 # Checks for library functions.
258 AC_FUNC_CHOWN
259 AC_FUNC_CLOSEDIR_VOID
260 AC_FUNC_ERROR_AT_LINE
261 AC_FUNC_FORK
262 AC_FUNC_FSEEKO
263 AC_PROG_GCC_TRADITIONAL
264 AC_FUNC_MALLOC
265 AC_FUNC_MEMCMP
266 AC_FUNC_MKTIME
267 AC_FUNC_MMAP
268 AC_FUNC_REALLOC
269 AC_FUNC_SELECT_ARGTYPES
270 AC_FUNC_SETVBUF_REVERSED
271 AC_TYPE_SIGNAL
272 AC_FUNC_STAT
273 AC_FUNC_STRCOLL
274 AC_FUNC_STRFTIME
275 AC_FUNC_STRNLEN
276 AC_FUNC_STRTOD
277 AC_FUNC_UTIME_NULL
278 AC_FUNC_VPRINTF
279 AC_CHECK_FUNCS([atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol unsetenv utime strtoq strcasestr asprintf vasprintf])
280
281 echo -n "checking for compiler atomic operations... "
282 AC_LINK_IFELSE(
283 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
284 AC_MSG_RESULT(yes)
285 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
286 AC_MSG_RESULT(no)
287 )
288
289 AC_CHECK_HEADER([libkern/OSAtomic.h],
290                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
291
292 AC_CHECK_SIZEOF(int)
293
294 # do the package library checks now
295
296 AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
297
298 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
299
300 GSM_INTERNAL="yes"
301 GSM_SYSTEM="yes"
302 if test "${USE_GSM}" != "no"; then
303    if test "${GSM_SYSTEM}" = "yes"; then
304       gsmlibdir=""
305       if test "x${GSM_DIR}" != "x"; then
306          if test -d ${GSM_DIR}/lib; then
307             gsmlibdir="-L${GSM_DIR}/lib"
308          else
309             gsmlibdir="-L${GSM_DIR}"
310          fi
311       fi
312       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
313       [Define to indicate the GSM library]), [], ${gsmlibdir})
314       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
315          GSM_LIB="-lgsm"
316          if test "x${GSM_DIR}" != "x"; then
317             GSM_LIB="${gsmlibdir} ${GSM_LIB}"
318             GSM_INCLUDE="-I${GSM_DIR}/include"
319          fi
320          PBX_GSM=1
321          GSM_INTERNAL="no"
322       fi
323    fi
324    if test "${GSM_INTERNAL}" = "yes"; then
325       GSM_LIB="internal"
326       PBX_GSM=1
327    fi
328 fi
329
330 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
331
332 if test "${USE_IMAP_TK}" != "no"; then
333    if test "${IMAP_TK_DIR}" = ""; then
334       IMAP_TK_DIR=../imap-2004g
335    fi
336 fi
337
338 AC_LANG_PUSH(C++)
339
340 if test "${USE_KDE}" != "no"; then
341    echo -n "checking for crashHandler in -lkdecore... "
342    saved_libs="${LIBS}"
343    saved_cppflags="${CPPFLAGS}"
344    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
345    if test -d ${KDE_DIR}/lib; then
346       kdelibdir="${KDE_DIR}/lib"
347    else
348       kdelibdir="${KDE_DIR}"
349    fi
350    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
351
352    AC_LINK_IFELSE(
353         [AC_LANG_PROGRAM(
354                         [#include "kcrash.h"],
355                         [KCrash::defaultCrashHandler(1);])
356         ],
357         [ac_cv_lib_kde_crash="yes"],
358         [ac_cv_lib_kde_crash="no"])
359                 
360    LIBS="${saved_libs}"
361    CPPFLAGS="${saved_cppflags}"
362         
363    if test "${ac_cv_lib_kde_crash}" = "yes"; then
364       AC_MSG_RESULT(yes) 
365       KDE_LIB="-lkdecore -lkdeui"
366       if test "${KDE_DIR}" != ""; then
367          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
368          KDE_INCLUDE="-I${KDE_DIR}/include"
369       fi
370       PBX_KDE=1
371       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
372    elif test ! -z "${KDE_MANDATORY}"; then
373       AC_MSG_RESULT(no) 
374       echo "***"
375       echo "*** The KDE installation on this system appears to be broken."
376       echo "*** Either correct the installation, or run configure"
377       echo "*** including --without-kde."
378       exit 1
379    else
380       AC_MSG_RESULT(no) 
381    fi
382 fi
383 if test "${PBX_KDE}" = 1; then
384    AC_PATH_TOOL(KDEINIT, kdeinit, No)
385    if test ! x"${KDEINIT}" = xNo; then
386       KDEDIR=$(${DIRNAME} ${KDEINIT})
387       KDEDIR=$(${DIRNAME} ${KDEDIR})
388    fi
389    AC_SUBST([KDEDIR])
390 fi
391
392 AC_LANG_POP
393
394 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
395
396 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
397
398 NETSNMP_CONFIG=No
399 if test "${USE_NETSNMP}" != "no"; then  
400    if test "x${NETSNMP_DIR}" != "x"; then
401       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
402       if test x"${NETSNMP_CONFIG}" = xNo; then
403          echo "***"
404          echo "*** net-snmp-config was not found in the path you specified:"
405          echo "*** ${NETSNMP_DIR}/bin"
406          echo "*** Either correct the installation, or run configure"
407          echo "*** including --without-netsnmp"
408          exit 1
409       fi
410    else
411       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
412    fi
413 fi
414 if test x"${NETSNMP_CONFIG}" != xNo; then
415    NETSNMP_libs=`net-snmp-config --agent-libs`
416    
417    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
418    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
419
420    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
421       NETSNMP_LIB="${NETSNMP_libs}"
422       PBX_NETSNMP=1
423    elif test ! -z "${NETSNMP_MANDATORY}";
424    then
425       echo "***"
426       echo "*** The Net-SNMP installation on this system appears to be broken."
427       echo "*** Either correct the installation, or run configure"
428       echo "*** including --without-netsnmp"
429       exit 1
430    fi
431 elif test ! -z "${NETSNMP_MANDATORY}";
432 then
433    echo "***"
434    echo "*** The Net-SNMP installation on this system appears to be broken."
435    echo "*** Either correct the installation, or run configure"
436    echo "*** including --without-netsnmp"
437    exit 1
438 fi
439
440 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
441
442 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h])
443
444 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
445
446 AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
447
448 PBX_OSS=0
449 AC_CHECK_HEADER([linux/soundcard.h],
450                 [
451                 PBX_OSS=1
452                 AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
453                 ])
454 if test "$PBX_OSS" = "0"; then
455    AC_CHECK_HEADER([sys/soundcard.h],
456                    [
457                    PBX_OSS=1
458                    AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
459                    ])
460 fi
461 if test "$PBX_OSS" = "0"; then
462    AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
463 fi
464
465 PG_CONFIG=No
466 if test "${USE_PGSQL}" != "no"; then    
467    if test "x${PGSQL_DIR}" != "x"; then
468       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
469       if test x"${PG_CONFIG}" = xNo; then
470          echo "***"
471          echo "*** pg_config was not found in the path you specified:"
472          echo "*** ${PGSQL_DIR}/bin"
473          echo "*** Either correct the installation, or run configure"
474          echo "*** including --without-postgres"
475          exit 1
476       fi
477    else
478       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
479    fi
480 fi
481 if test "${PG_CONFIG}" != No; then
482    PGSQL_libdir=`pg_config --libdir`
483    PGSQL_includedir=`pg_config --includedir`
484    
485    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
486    [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
487
488    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
489       PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
490       PGSQL_INCLUDE="-I${PGSQL_includedir}"
491       PBX_PGSQL=1
492    elif test ! -z "${PGSQL_MANDATORY}";
493    then
494       echo "***"
495       echo "*** The PostgreSQL installation on this system appears to be broken."
496       echo "*** Either correct the installation, or run configure"
497       echo "*** including --without-postgres"
498       exit 1
499    fi
500 elif test ! -z "${PGSQL_MANDATORY}";
501 then
502    echo "***"
503    echo "*** The PostgreSQL installation on this system appears to be broken."
504    echo "*** Either correct the installation, or run configure"
505    echo "*** including --without-postgres"
506    exit 1
507 fi
508
509 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
510
511 AST_EXT_LIB_CHECK([PRI], [pri], [pri_call], [libpri.h])
512
513 PLATFORM_PTLIB="ptlib_${OSTYPE}_${MACHTYPE}_r"
514 if test "${USE_PWLIB}" != "no"; then
515    echo -n "checking for existence of pwlib... "
516         
517    saved_cppflags="${CPPFLAGS}"
518    saved_libs="${LIBS}"
519    LIBS="${LIBS} -L${PWLIB_DIR} -l${PLATFORM_PTLIB}"
520    CPPFLAGS="${CPPFLAGS} -I${PWLIB_DIR}/include"
521         
522    AC_LINK_IFELSE(
523         [
524         AC_LANG_PROGRAM(
525         [#include "ptime.h"],
526         [int q = PTime::IsDaylightSaving();])
527         ],
528         [       AC_MSG_RESULT(yes) 
529                 ac_cv_lib_pwlib="yes" 
530         ],
531         [       AC_MSG_RESULT(no) 
532                 ac_cv_lib_pwlib="no" 
533         ]
534         )
535
536    LIBS="${saved_libs}"
537    CPPFLAGS="${saved_cppflags}"
538
539    if test "${ac_cv_lib_pwlib}" = "yes"; then
540       PWLIB_LIB="-l{PLATFORM_PWLIB}"
541       if test "${PWLIB_DIR}" != ""; then
542          PWLIB_LIB="-L${PWLIB_DIR}/lib ${PWLIB_LIB}"
543          PWLIB_INCLUDE="-I${PWLIB_DIR}/include"
544       fi
545         PBX_PWLIB=1
546         AC_DEFINE([HAVE_PWLIB], 1, [Define if your system has the pwlib libraries.])
547    elif test ! -z "${PWLIB_MANDATORY}"; then
548       echo "***"
549       echo "*** The PWLIB installation on this system appears to be broken."
550       echo "*** Either correct the installation, or run configure"
551       echo "*** including --without-pwlib"
552       exit 1
553    fi
554 fi
555
556 AC_LANG_PUSH(C++)
557
558 if test "${USE_QT}" != "no"; then
559    echo -n "checking for QDate in -lqt... "
560    saved_libs="${LIBS}"
561    saved_cppflags="${CPPFLAGS}"
562    if test "x${QT_DIR}" != "x"; then
563       LIBS="${LIBS} -L${QT_DIR}/lib"
564       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
565    fi
566    LIBS="${LIBS} -lqt"
567    qtlib="qt"
568    AC_LINK_IFELSE(
569         [
570                 AC_LANG_PROGRAM(
571                 [#include <qt3/qdatetime.h>],
572                 [QDate date();])
573         ],
574         [ac_cv_lib_qt_qt_date="yes"],
575         [ac_cv_lib_qt_qt_date="no"])
576    LIBS="${saved_libs}"
577    CPPFLAGS="${saved_cppflags}"
578         
579    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
580       saved_libs="${LIBS}"
581       saved_cppflags="${CPPFLAGS}"
582       if test "x${QT_DIR}" != "x"; then
583          LIBS="${LIBS} -L${QT_DIR}/lib"
584          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
585       fi
586       LIBS="${LIBS} -lqt-mt"
587       qtlib="qt-mt"     
588       AC_LINK_IFELSE(
589                 [
590                         AC_LANG_PROGRAM(
591                         [#include <qt3/qdatetime.h>],
592                         [QDate date();])
593                 ],
594                 [ac_cv_lib_qt_qt_date="yes"],
595                 [ac_cv_lib_qt_qt_date="no"])
596       LIBS="${saved_libs}"
597       CPPFLAGS="${saved_cppflags}"
598    fi   
599
600    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
601       AC_MSG_RESULT(yes) 
602    else
603       AC_MSG_RESULT(no) 
604    fi
605         
606    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
607       QT_LIB="-l${qtlib}"
608       if test "${QT_DIR}" != ""; then
609          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
610          QT_INCLUDE="-I${QT_DIR}/include"
611       fi
612       PBX_QT=1
613       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
614       AC_PATH_TOOL(QTMOC, moc, No)
615    elif test ! -z "${QT_MANDATORY}"; 
616    then
617       echo "***"
618       echo "*** The Qt installation on this system appears to be broken."
619       echo "*** Either correct the installation, or run configure"
620       echo "*** including --without-qt."
621       exit 1
622    fi
623 fi
624
625 AC_LANG_POP
626
627 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
628
629 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
630
631 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
632
633 AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
634
635 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
636 if test "${PBX_FREETDS}" != "0";
637 then
638     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
639     *0.63*)
640         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
641         ;;
642     *0.62*)
643         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
644         ;;
645     *)
646         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
647         ;;
648     esac
649 fi
650
651 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
652
653 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
654
655 if test "${PBX_OSTYPE}" != "Linux" ; then
656   tonezone_extra="-lm"
657 fi
658
659 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}])
660
661 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
662
663 AC_LANG_PUSH(C++)
664
665 if test "${USE_VPB}" != "no"; then
666    echo -n "checking for vpb_open in -lvpb... "
667    saved_libs="${LIBS}"
668    saved_cppflags="${CPPFLAGS}"
669    if test "x${VPB_DIR}" != "x"; then
670       if test -d ${VPB_DIR}/lib; then
671          vpblibdir=${VPB_DIR}/lib
672       else
673          vpblibdir=${VPB_DIR}
674       fi
675       LIBS="${LIBS} -L${vpblibdir}"
676       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
677    fi
678    LIBS="${LIBS} -lvpb -lpthread"
679    AC_LINK_IFELSE(
680         [
681         AC_LANG_PROGRAM(
682         [#include <vpbapi.h>],
683         [int q = vpb_open(0,0);])
684         ],
685         [       AC_MSG_RESULT(yes) 
686                 ac_cv_lib_vpb_vpb_open="yes" 
687         ],
688         [       AC_MSG_RESULT(no) 
689                 ac_cv_lib_vpb_vpb_open="no" 
690         ]
691         )
692    LIBS="${saved_libs}"
693    CPPFLAGS="${saved_cppflags}"
694    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
695         VPB_LIB="-lvpb"
696         if test "${VPB_DIR}" != ""; then
697            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
698            VPB_INCLUDE="-I${VPB_DIR}/include"
699         fi
700         PBX_VPB=1
701         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
702    elif test ! -z "${VPB_MANDATORY}"; then
703       echo "***"
704       echo "*** The VoiceTronix (vpb) installation on this system appears to be broken."
705       echo "*** Either correct the installation, or run configure"
706       echo "*** including --without-vpb."
707       exit 1
708    fi
709 fi
710
711 AC_LANG_POP
712
713 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
714
715 if test "${USE_ZAPTEL}" != "no"; then
716    echo -n "checking for zt_transcode_header in zaptel.h... "
717    saved_cppflags="${CPPFLAGS}"
718    if test "x${ZAPTEL_DIR}" != "x"; then
719       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
720    fi
721    AC_COMPILE_IFELSE(
722         [
723         AC_LANG_PROGRAM(
724         [#include <zaptel/zaptel.h>],
725         [struct zt_transcode_header test;])
726         ],
727         [       AC_MSG_RESULT(yes) 
728                 ac_cv_zaptel_h="yes" 
729         ],
730         [       AC_MSG_RESULT(no) 
731                 ac_cv_zaptel_h="no" 
732         ]
733         )
734    CPPFLAGS="${saved_cppflags}"
735    if test "${ac_cv_zaptel_h}" = "yes"; then
736         if test "${ZAPTEL_DIR}" != ""; then
737            ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
738         fi
739         PBX_ZAPTEL=1
740         AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
741    elif test ! -z "${ZAPTEL_MANDATORY}"; 
742    then
743       echo "***"
744       echo "*** The Zaptel installation on this system appears to be broken."
745       echo "*** Either correct the installation, or run configure"
746       echo "*** including --without-zaptel."
747       exit 1
748    fi
749 fi
750
751 EDITLINE_LIB=""
752 if test "x$TERMCAP_LIB" != "x" ; then
753   EDITLINE_LIB="$TERMCAP_LIB"
754 elif test "x$TINFO_LIB" != "x" ; then
755   EDITLINE_LIB="$TINFO_LIB"
756 elif test "x$CURSES_LIB" != "x" ; then
757   EDITLINE_LIB="$CURSES_LIB"
758 elif test "x$NCURSES_LIB" != "x" ; then
759   EDITLINE_LIB="$NCURSES_LIB"
760 else
761   echo "*** termcap support not found"
762   exit 1
763 fi
764 AC_SUBST(EDITLINE_LIB)
765
766 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
767 AC_SUBST(PBX_H323)
768
769 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
770                                    #include <linux/version.h>
771                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
772                                    #include <linux/compiler.h>
773                                    #endif
774                                    ])
775 AC_SUBST(PBX_IXJUSER)
776
777 PBX_GTK=0
778 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
779 if test ! "x${GTKCONFIG}" = xNo; then
780    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
781    GTK_LIB=$(${GTKCONFIG} --libs gthread)
782    PBX_GTK=1
783    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
784 fi
785 AC_SUBST(PBX_GTK)
786 AC_SUBST(GTK_INCLUDE)
787 AC_SUBST(GTK_LIB)
788
789 PBX_CURL=0
790 AC_PATH_TOOL([CURL], [curl-config], No)
791 if test ! x"${CURL}" = xNo; then
792 # check for version
793    CURLLIB=$(${CURL} --libs)
794    PBX_CURL=1
795    AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
796 fi
797 AC_SUBST(PBX_CURL)
798 AC_SUBST(CURLLIB)
799
800 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
801 AC_OUTPUT
802
803 echo
804 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
805 echo "            .\$7\$7..          .7\$\$7:.    "
806 echo "          .\$\$:.                 ,\$7.7   "
807 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
808 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
809 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
810 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
811 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
812 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
813 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
814 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
815 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
816 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
817 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
818 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
819 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
820 echo " \$\$\$\$\$                        \$\$\$       "
821 echo "  \$\$\$\$7.                       \$\$  (TM)     "
822 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
823 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
824 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
825 echo
826
827 echo "Package configured for: "
828 echo " OS type  : $PBX_OSTYPE"
829 echo " Host CPU : $host_cpu"
830 if test "x${crossCompile}" = xYes; then
831    echo ""
832    echo " Cross Compilation = YES"
833    echo " Target            = ${host}"
834 fi