allow codec_gsm to be built using internal GSM library again (oops!)
[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_DIR}" = "internal"; then
304       GSM_SYSTEM="no"
305    elif test "${GSM_DIR}" != ""; then
306       GSM_INTERNAL="no"
307    fi
308    if test "${GSM_SYSTEM}" = "yes"; then
309       gsmlibdir=""
310       if test "x${GSM_DIR}" != "x"; then
311          if test -d ${GSM_DIR}/lib; then
312             gsmlibdir="-L${GSM_DIR}/lib"
313          else
314             gsmlibdir="-L${GSM_DIR}"
315          fi
316       fi
317       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
318       [Define to indicate the GSM library]), [], ${gsmlibdir})
319       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
320          GSM_LIB="-lgsm"
321          if test "x${GSM_DIR}" != "x"; then
322             GSM_LIB="${gsmlibdir} ${GSM_LIB}"
323             GSM_INCLUDE="-I${GSM_DIR}/include"
324          fi
325          PBX_GSM=1
326          GSM_INTERNAL="no"
327       fi
328    fi
329    if test "${GSM_INTERNAL}" = "yes"; then
330       GSM_LIB="internal"
331       PBX_GSM=1
332    fi
333 fi
334
335 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
336
337 if test "${USE_IMAP_TK}" != "no"; then
338    if test "${IMAP_TK_DIR}" = ""; then
339       IMAP_TK_DIR=../imap-2004g
340    fi
341 fi
342
343 AC_LANG_PUSH(C++)
344
345 if test "${USE_KDE}" != "no"; then
346    echo -n "checking for crashHandler in -lkdecore... "
347    saved_libs="${LIBS}"
348    saved_cppflags="${CPPFLAGS}"
349    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
350    if test -d ${KDE_DIR}/lib; then
351       kdelibdir="${KDE_DIR}/lib"
352    else
353       kdelibdir="${KDE_DIR}"
354    fi
355    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
356
357    AC_LINK_IFELSE(
358         [AC_LANG_PROGRAM(
359                         [#include "kcrash.h"],
360                         [KCrash::defaultCrashHandler(1);])
361         ],
362         [ac_cv_lib_kde_crash="yes"],
363         [ac_cv_lib_kde_crash="no"])
364                 
365    LIBS="${saved_libs}"
366    CPPFLAGS="${saved_cppflags}"
367         
368    if test "${ac_cv_lib_kde_crash}" = "yes"; then
369       AC_MSG_RESULT(yes) 
370       KDE_LIB="-lkdecore -lkdeui"
371       if test "${KDE_DIR}" != ""; then
372          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
373          KDE_INCLUDE="-I${KDE_DIR}/include"
374       fi
375       PBX_KDE=1
376       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
377    elif test ! -z "${KDE_MANDATORY}"; then
378       AC_MSG_RESULT(no) 
379       echo "***"
380       echo "*** The KDE installation on this system appears to be broken."
381       echo "*** Either correct the installation, or run configure"
382       echo "*** including --without-kde."
383       exit 1
384    else
385       AC_MSG_RESULT(no) 
386    fi
387 fi
388 if test "${PBX_KDE}" = 1; then
389    AC_PATH_TOOL(KDEINIT, kdeinit, No)
390    if test ! x"${KDEINIT}" = xNo; then
391       KDEDIR=$(${DIRNAME} ${KDEINIT})
392       KDEDIR=$(${DIRNAME} ${KDEDIR})
393    fi
394    AC_SUBST([KDEDIR])
395 fi
396
397 AC_LANG_POP
398
399 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
400
401 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
402
403 NETSNMP_CONFIG=No
404 if test "${USE_NETSNMP}" != "no"; then  
405    if test "x${NETSNMP_DIR}" != "x"; then
406       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
407       if test x"${NETSNMP_CONFIG}" = xNo; then
408          echo "***"
409          echo "*** net-snmp-config was not found in the path you specified:"
410          echo "*** ${NETSNMP_DIR}/bin"
411          echo "*** Either correct the installation, or run configure"
412          echo "*** including --without-netsnmp"
413          exit 1
414       fi
415    else
416       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
417    fi
418 fi
419 if test x"${NETSNMP_CONFIG}" != xNo; then
420    NETSNMP_libs=`net-snmp-config --agent-libs`
421    
422    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
423    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
424
425    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
426       NETSNMP_LIB="${NETSNMP_libs}"
427       PBX_NETSNMP=1
428    elif test ! -z "${NETSNMP_MANDATORY}";
429    then
430       echo "***"
431       echo "*** The Net-SNMP installation on this system appears to be broken."
432       echo "*** Either correct the installation, or run configure"
433       echo "*** including --without-netsnmp"
434       exit 1
435    fi
436 elif test ! -z "${NETSNMP_MANDATORY}";
437 then
438    echo "***"
439    echo "*** The Net-SNMP installation on this system appears to be broken."
440    echo "*** Either correct the installation, or run configure"
441    echo "*** including --without-netsnmp"
442    exit 1
443 fi
444
445 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
446
447 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h])
448
449 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
450
451 AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
452
453 PBX_OSS=0
454 AC_CHECK_HEADER([linux/soundcard.h],
455                 [
456                 PBX_OSS=1
457                 AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
458                 ])
459 if test "$PBX_OSS" = "0"; then
460    AC_CHECK_HEADER([sys/soundcard.h],
461                    [
462                    PBX_OSS=1
463                    AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
464                    ])
465 fi
466 if test "$PBX_OSS" = "0"; then
467    AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
468 fi
469
470 PG_CONFIG=No
471 if test "${USE_PGSQL}" != "no"; then    
472    if test "x${PGSQL_DIR}" != "x"; then
473       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
474       if test x"${PG_CONFIG}" = xNo; then
475          echo "***"
476          echo "*** pg_config was not found in the path you specified:"
477          echo "*** ${PGSQL_DIR}/bin"
478          echo "*** Either correct the installation, or run configure"
479          echo "*** including --without-postgres"
480          exit 1
481       fi
482    else
483       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
484    fi
485 fi
486 if test "${PG_CONFIG}" != No; then
487    PGSQL_libdir=`pg_config --libdir`
488    PGSQL_includedir=`pg_config --includedir`
489    
490    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
491    [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
492
493    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
494       PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
495       PGSQL_INCLUDE="-I${PGSQL_includedir}"
496       PBX_PGSQL=1
497    elif test ! -z "${PGSQL_MANDATORY}";
498    then
499       echo "***"
500       echo "*** The PostgreSQL installation on this system appears to be broken."
501       echo "*** Either correct the installation, or run configure"
502       echo "*** including --without-postgres"
503       exit 1
504    fi
505 elif test ! -z "${PGSQL_MANDATORY}";
506 then
507    echo "***"
508    echo "*** The PostgreSQL installation on this system appears to be broken."
509    echo "*** Either correct the installation, or run configure"
510    echo "*** including --without-postgres"
511    exit 1
512 fi
513
514 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
515
516 AST_EXT_LIB_CHECK([PRI], [pri], [pri_call], [libpri.h])
517
518 PLATFORM_PTLIB="ptlib_${OSTYPE}_${MACHTYPE}_r"
519 if test "${USE_PWLIB}" != "no"; then
520    echo -n "checking for existence of pwlib... "
521         
522    saved_cppflags="${CPPFLAGS}"
523    saved_libs="${LIBS}"
524    LIBS="${LIBS} -L${PWLIB_DIR} -l${PLATFORM_PTLIB}"
525    CPPFLAGS="${CPPFLAGS} -I${PWLIB_DIR}/include"
526         
527    AC_LINK_IFELSE(
528         [
529         AC_LANG_PROGRAM(
530         [#include "ptime.h"],
531         [int q = PTime::IsDaylightSaving();])
532         ],
533         [       AC_MSG_RESULT(yes) 
534                 ac_cv_lib_pwlib="yes" 
535         ],
536         [       AC_MSG_RESULT(no) 
537                 ac_cv_lib_pwlib="no" 
538         ]
539         )
540
541    LIBS="${saved_libs}"
542    CPPFLAGS="${saved_cppflags}"
543
544    if test "${ac_cv_lib_pwlib}" = "yes"; then
545       PWLIB_LIB="-l{PLATFORM_PWLIB}"
546       if test "${PWLIB_DIR}" != ""; then
547          PWLIB_LIB="-L${PWLIB_DIR}/lib ${PWLIB_LIB}"
548          PWLIB_INCLUDE="-I${PWLIB_DIR}/include"
549       fi
550         PBX_PWLIB=1
551         AC_DEFINE([HAVE_PWLIB], 1, [Define if your system has the pwlib libraries.])
552    elif test ! -z "${PWLIB_MANDATORY}"; then
553       echo "***"
554       echo "*** The PWLIB installation on this system appears to be broken."
555       echo "*** Either correct the installation, or run configure"
556       echo "*** including --without-pwlib"
557       exit 1
558    fi
559 fi
560
561 AC_LANG_PUSH(C++)
562
563 if test "${USE_QT}" != "no"; then
564    echo -n "checking for QDate in -lqt... "
565    saved_libs="${LIBS}"
566    saved_cppflags="${CPPFLAGS}"
567    if test "x${QT_DIR}" != "x"; then
568       LIBS="${LIBS} -L${QT_DIR}/lib"
569       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
570    fi
571    LIBS="${LIBS} -lqt"
572    qtlib="qt"
573    AC_LINK_IFELSE(
574         [
575                 AC_LANG_PROGRAM(
576                 [#include <qt3/qdatetime.h>],
577                 [QDate date();])
578         ],
579         [ac_cv_lib_qt_qt_date="yes"],
580         [ac_cv_lib_qt_qt_date="no"])
581    LIBS="${saved_libs}"
582    CPPFLAGS="${saved_cppflags}"
583         
584    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
585       saved_libs="${LIBS}"
586       saved_cppflags="${CPPFLAGS}"
587       if test "x${QT_DIR}" != "x"; then
588          LIBS="${LIBS} -L${QT_DIR}/lib"
589          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
590       fi
591       LIBS="${LIBS} -lqt-mt"
592       qtlib="qt-mt"     
593       AC_LINK_IFELSE(
594                 [
595                         AC_LANG_PROGRAM(
596                         [#include <qt3/qdatetime.h>],
597                         [QDate date();])
598                 ],
599                 [ac_cv_lib_qt_qt_date="yes"],
600                 [ac_cv_lib_qt_qt_date="no"])
601       LIBS="${saved_libs}"
602       CPPFLAGS="${saved_cppflags}"
603    fi   
604
605    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
606       AC_MSG_RESULT(yes) 
607    else
608       AC_MSG_RESULT(no) 
609    fi
610         
611    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
612       QT_LIB="-l${qtlib}"
613       if test "${QT_DIR}" != ""; then
614          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
615          QT_INCLUDE="-I${QT_DIR}/include"
616       fi
617       PBX_QT=1
618       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
619       AC_PATH_TOOL(QTMOC, moc, No)
620    elif test ! -z "${QT_MANDATORY}"; 
621    then
622       echo "***"
623       echo "*** The Qt installation on this system appears to be broken."
624       echo "*** Either correct the installation, or run configure"
625       echo "*** including --without-qt."
626       exit 1
627    fi
628 fi
629
630 AC_LANG_POP
631
632 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
633
634 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
635
636 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
637
638 AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
639
640 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
641 if test "${PBX_FREETDS}" != "0";
642 then
643     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
644     *0.63*)
645         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
646         ;;
647     *0.62*)
648         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
649         ;;
650     *)
651         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
652         ;;
653     esac
654 fi
655
656 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
657
658 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
659
660 if test "${PBX_OSTYPE}" != "Linux" ; then
661   tonezone_extra="-lm"
662 fi
663
664 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}])
665
666 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
667
668 AC_LANG_PUSH(C++)
669
670 if test "${USE_VPB}" != "no"; then
671    echo -n "checking for vpb_open in -lvpb... "
672    saved_libs="${LIBS}"
673    saved_cppflags="${CPPFLAGS}"
674    if test "x${VPB_DIR}" != "x"; then
675       if test -d ${VPB_DIR}/lib; then
676          vpblibdir=${VPB_DIR}/lib
677       else
678          vpblibdir=${VPB_DIR}
679       fi
680       LIBS="${LIBS} -L${vpblibdir}"
681       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
682    fi
683    LIBS="${LIBS} -lvpb -lpthread"
684    AC_LINK_IFELSE(
685         [
686         AC_LANG_PROGRAM(
687         [#include <vpbapi.h>],
688         [int q = vpb_open(0,0);])
689         ],
690         [       AC_MSG_RESULT(yes) 
691                 ac_cv_lib_vpb_vpb_open="yes" 
692         ],
693         [       AC_MSG_RESULT(no) 
694                 ac_cv_lib_vpb_vpb_open="no" 
695         ]
696         )
697    LIBS="${saved_libs}"
698    CPPFLAGS="${saved_cppflags}"
699    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
700         VPB_LIB="-lvpb"
701         if test "${VPB_DIR}" != ""; then
702            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
703            VPB_INCLUDE="-I${VPB_DIR}/include"
704         fi
705         PBX_VPB=1
706         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
707    elif test ! -z "${VPB_MANDATORY}"; then
708       echo "***"
709       echo "*** The VoiceTronix (vpb) installation on this system appears to be broken."
710       echo "*** Either correct the installation, or run configure"
711       echo "*** including --without-vpb."
712       exit 1
713    fi
714 fi
715
716 AC_LANG_POP
717
718 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
719
720 if test "${USE_ZAPTEL}" != "no"; then
721    echo -n "checking for zt_transcode_header in zaptel.h... "
722    saved_cppflags="${CPPFLAGS}"
723    if test "x${ZAPTEL_DIR}" != "x"; then
724       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
725    fi
726    AC_COMPILE_IFELSE(
727         [
728         AC_LANG_PROGRAM(
729         [#include <zaptel/zaptel.h>],
730         [struct zt_transcode_header test;])
731         ],
732         [       AC_MSG_RESULT(yes) 
733                 ac_cv_zaptel_h="yes" 
734         ],
735         [       AC_MSG_RESULT(no) 
736                 ac_cv_zaptel_h="no" 
737         ]
738         )
739    CPPFLAGS="${saved_cppflags}"
740    if test "${ac_cv_zaptel_h}" = "yes"; then
741         if test "${ZAPTEL_DIR}" != ""; then
742            ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
743         fi
744         PBX_ZAPTEL=1
745         AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
746    elif test ! -z "${ZAPTEL_MANDATORY}"; 
747    then
748       echo "***"
749       echo "*** The Zaptel installation on this system appears to be broken."
750       echo "*** Either correct the installation, or run configure"
751       echo "*** including --without-zaptel."
752       exit 1
753    fi
754 fi
755
756 EDITLINE_LIB=""
757 if test "x$TERMCAP_LIB" != "x" ; then
758   EDITLINE_LIB="$TERMCAP_LIB"
759 elif test "x$TINFO_LIB" != "x" ; then
760   EDITLINE_LIB="$TINFO_LIB"
761 elif test "x$CURSES_LIB" != "x" ; then
762   EDITLINE_LIB="$CURSES_LIB"
763 elif test "x$NCURSES_LIB" != "x" ; then
764   EDITLINE_LIB="$NCURSES_LIB"
765 else
766   echo "*** termcap support not found"
767   exit 1
768 fi
769 AC_SUBST(EDITLINE_LIB)
770
771 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
772 AC_SUBST(PBX_H323)
773
774 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
775                                    #include <linux/version.h>
776                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
777                                    #include <linux/compiler.h>
778                                    #endif
779                                    ])
780 AC_SUBST(PBX_IXJUSER)
781
782 PBX_GTK=0
783 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
784 if test ! "x${GTKCONFIG}" = xNo; then
785    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
786    GTK_LIB=$(${GTKCONFIG} --libs gthread)
787    PBX_GTK=1
788    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
789 fi
790 AC_SUBST(PBX_GTK)
791 AC_SUBST(GTK_INCLUDE)
792 AC_SUBST(GTK_LIB)
793
794 PBX_CURL=0
795 AC_PATH_TOOL([CURL], [curl-config], No)
796 if test ! x"${CURL}" = xNo; then
797 # check for version
798    CURLLIB=$(${CURL} --libs)
799    PBX_CURL=1
800    AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
801 fi
802 AC_SUBST(PBX_CURL)
803 AC_SUBST(CURLLIB)
804
805 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
806 AC_OUTPUT
807
808 echo
809 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
810 echo "            .\$7\$7..          .7\$\$7:.    "
811 echo "          .\$\$:.                 ,\$7.7   "
812 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
813 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
814 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
815 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
816 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
817 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
818 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
819 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
820 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
821 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
822 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
823 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
824 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
825 echo " \$\$\$\$\$                        \$\$\$       "
826 echo "  \$\$\$\$7.                       \$\$  (TM)     "
827 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
828 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
829 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
830 echo
831
832 echo "Package configured for: "
833 echo " OS type  : $PBX_OSTYPE"
834 echo " Host CPU : $host_cpu"
835 if test "x${crossCompile}" = xYes; then
836    echo ""
837    echo " Cross Compilation = YES"
838    echo " Target            = ${host}"
839 fi