massive rework of configure script, and split of AST_EXT_LIB into separate macros...
[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_LIBOSS=0
449 AC_CHECK_HEADER([linux/soundcard.h],
450                 [
451                 PBX_LIBOSS=1
452                 AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
453                 ])
454 if test "$PBX_LIBOSS" = "0"; then
455    AC_CHECK_HEADER([sys/soundcard.h],
456                    [
457                    PBX_LIBossaudio=1
458                    AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
459                    ])
460 fi
461 if test "$PBX_LIBOSS" = "0"; then
462    AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
463 fi
464 AC_SUBST([PBX_LIBOSS])
465
466 PG_CONFIG=No
467 if test "${USE_PGSQL}" != "no"; then    
468    if test "x${PGSQL_DIR}" != "x"; then
469       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
470       if test x"${PG_CONFIG}" = xNo; then
471          echo "***"
472          echo "*** pg_config was not found in the path you specified:"
473          echo "*** ${PGSQL_DIR}/bin"
474          echo "*** Either correct the installation, or run configure"
475          echo "*** including --without-postgres"
476          exit 1
477       fi
478    else
479       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
480    fi
481 fi
482 if test "${PG_CONFIG}" != No; then
483    PGSQL_libdir=`pg_config --libdir`
484    PGSQL_includedir=`pg_config --includedir`
485    
486    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
487    [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
488
489    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
490       PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
491       PGSQL_INCLUDE="-I${PGSQL_includedir}"
492       PBX_PGSQL=1
493    elif test ! -z "${PGSQL_MANDATORY}";
494    then
495       echo "***"
496       echo "*** The PostgreSQL installation on this system appears to be broken."
497       echo "*** Either correct the installation, or run configure"
498       echo "*** including --without-postgres"
499       exit 1
500    fi
501 elif test ! -z "${PGSQL_MANDATORY}";
502 then
503    echo "***"
504    echo "*** The PostgreSQL installation on this system appears to be broken."
505    echo "*** Either correct the installation, or run configure"
506    echo "*** including --without-postgres"
507    exit 1
508 fi
509
510 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
511
512 AST_EXT_LIB_CHECK([PRI], [pri], [pri_call], [libpri.h])
513
514 PLATFORM_PTLIB="ptlib_${OSTYPE}_${MACHTYPE}_r"
515 if test "${USE_PWLIB}" != "no"; then
516    echo -n "checking for existence of pwlib... "
517         
518    saved_cppflags="${CPPFLAGS}"
519    saved_libs="${LIBS}"
520    LIBS="${LIBS} -L${PWLIB_DIR} -l${PLATFORM_PTLIB}"
521    CPPFLAGS="${CPPFLAGS} -I${PWLIB_DIR}/include"
522         
523    AC_LINK_IFELSE(
524         [
525         AC_LANG_PROGRAM(
526         [#include "ptime.h"],
527         [int q = PTime::IsDaylightSaving();])
528         ],
529         [       AC_MSG_RESULT(yes) 
530                 ac_cv_lib_pwlib="yes" 
531         ],
532         [       AC_MSG_RESULT(no) 
533                 ac_cv_lib_pwlib="no" 
534         ]
535         )
536
537    LIBS="${saved_libs}"
538    CPPFLAGS="${saved_cppflags}"
539
540    if test "${ac_cv_lib_pwlib}" = "yes"; then
541       PWLIB_LIB="-l{PLATFORM_PWLIB}"
542       if test "${PWLIB_DIR}" != ""; then
543          PWLIB_LIB="-L${PWLIB_DIR}/lib ${PWLIB_LIB}"
544          PWLIB_INCLUDE="-I${PWLIB_DIR}/include"
545       fi
546         PBX_PWLIB=1
547         AC_DEFINE([HAVE_PWLIB], 1, [Define if your system has the pwlib libraries.])
548    elif test ! -z "${PWLIB_MANDATORY}"; then
549       echo "***"
550       echo "*** The PWLIB installation on this system appears to be broken."
551       echo "*** Either correct the installation, or run configure"
552       echo "*** including --without-pwlib"
553       exit 1
554    fi
555 fi
556
557 AC_LANG_PUSH(C++)
558
559 if test "${USE_QT}" != "no"; then
560    echo -n "checking for QDate in -lqt... "
561    saved_libs="${LIBS}"
562    saved_cppflags="${CPPFLAGS}"
563    if test "x${QT_DIR}" != "x"; then
564       LIBS="${LIBS} -L${QT_DIR}/lib"
565       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
566    fi
567    LIBS="${LIBS} -lqt"
568    qtlib="qt"
569    AC_LINK_IFELSE(
570         [
571                 AC_LANG_PROGRAM(
572                 [#include <qt3/qdatetime.h>],
573                 [QDate date();])
574         ],
575         [ac_cv_lib_qt_qt_date="yes"],
576         [ac_cv_lib_qt_qt_date="no"])
577    LIBS="${saved_libs}"
578    CPPFLAGS="${saved_cppflags}"
579         
580    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
581       saved_libs="${LIBS}"
582       saved_cppflags="${CPPFLAGS}"
583       if test "x${QT_DIR}" != "x"; then
584          LIBS="${LIBS} -L${QT_DIR}/lib"
585          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
586       fi
587       LIBS="${LIBS} -lqt-mt"
588       qtlib="qt-mt"     
589       AC_LINK_IFELSE(
590                 [
591                         AC_LANG_PROGRAM(
592                         [#include <qt3/qdatetime.h>],
593                         [QDate date();])
594                 ],
595                 [ac_cv_lib_qt_qt_date="yes"],
596                 [ac_cv_lib_qt_qt_date="no"])
597       LIBS="${saved_libs}"
598       CPPFLAGS="${saved_cppflags}"
599    fi   
600
601    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
602       AC_MSG_RESULT(yes) 
603    else
604       AC_MSG_RESULT(no) 
605    fi
606         
607    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
608       QT_LIB="-l${qtlib}"
609       if test "${QT_DIR}" != ""; then
610          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
611          QT_INCLUDE="-I${QT_DIR}/include"
612       fi
613       PBX_QT=1
614       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
615       AC_PATH_TOOL(QTMOC, moc, No)
616    elif test ! -z "${QT_MANDATORY}"; 
617    then
618       echo "***"
619       echo "*** The Qt installation on this system appears to be broken."
620       echo "*** Either correct the installation, or run configure"
621       echo "*** including --without-qt."
622       exit 1
623    fi
624 fi
625
626 AC_LANG_POP
627
628 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
629
630 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
631
632 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
633
634 AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
635
636 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
637 if test "${PBX_FREETDS}" != "0";
638 then
639     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
640     *0.63*)
641         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
642         ;;
643     *0.62*)
644         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
645         ;;
646     *)
647         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
648         ;;
649     esac
650 fi
651
652 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
653
654 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
655
656 if test "${PBX_OSTYPE}" != "Linux" ; then
657   tonezone_extra="-lm"
658 fi
659
660 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}])
661
662 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
663
664 AC_LANG_PUSH(C++)
665
666 if test "${USE_VPB}" != "no"; then
667    echo -n "checking for vpb_open in -lvpb... "
668    saved_libs="${LIBS}"
669    saved_cppflags="${CPPFLAGS}"
670    if test "x${VPB_DIR}" != "x"; then
671       if test -d ${VPB_DIR}/lib; then
672          vpblibdir=${VPB_DIR}/lib
673       else
674          vpblibdir=${VPB_DIR}
675       fi
676       LIBS="${LIBS} -L${vpblibdir}"
677       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
678    fi
679    LIBS="${LIBS} -lvpb -lpthread"
680    AC_LINK_IFELSE(
681         [
682         AC_LANG_PROGRAM(
683         [#include <vpbapi.h>],
684         [int q = vpb_open(0,0);])
685         ],
686         [       AC_MSG_RESULT(yes) 
687                 ac_cv_lib_vpb_vpb_open="yes" 
688         ],
689         [       AC_MSG_RESULT(no) 
690                 ac_cv_lib_vpb_vpb_open="no" 
691         ]
692         )
693    LIBS="${saved_libs}"
694    CPPFLAGS="${saved_cppflags}"
695    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
696         VPB_LIB="-lvpb"
697         if test "${VPB_DIR}" != ""; then
698            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
699            VPB_INCLUDE="-I${VPB_DIR}/include"
700         fi
701         PBX_VPB=1
702         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
703    elif test ! -z "${VPB_MANDATORY}"; then
704       echo "***"
705       echo "*** The VoiceTronix (vpb) installation on this system appears to be broken."
706       echo "*** Either correct the installation, or run configure"
707       echo "*** including --without-vpb."
708       exit 1
709    fi
710 fi
711
712 AC_LANG_POP
713
714 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
715
716 if test "${USE_ZAPTEL}" != "no"; then
717    echo -n "checking for zt_transcode_header in zaptel.h... "
718    saved_cppflags="${CPPFLAGS}"
719    if test "x${ZAPTEL_DIR}" != "x"; then
720       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
721    fi
722    AC_COMPILE_IFELSE(
723         [
724         AC_LANG_PROGRAM(
725         [#include <zaptel/zaptel.h>],
726         [struct zt_transcode_header test;])
727         ],
728         [       AC_MSG_RESULT(yes) 
729                 ac_cv_zaptel_h="yes" 
730         ],
731         [       AC_MSG_RESULT(no) 
732                 ac_cv_zaptel_h="no" 
733         ]
734         )
735    CPPFLAGS="${saved_cppflags}"
736    if test "${ac_cv_zaptel_h}" = "yes"; then
737         if test "${ZAPTEL_DIR}" != ""; then
738            ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
739         fi
740         PBX_ZAPTEL=1
741         AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
742    elif test ! -z "${ZAPTEL_MANDATORY}"; 
743    then
744       echo "***"
745       echo "*** The Zaptel installation on this system appears to be broken."
746       echo "*** Either correct the installation, or run configure"
747       echo "*** including --without-zaptel."
748       exit 1
749    fi
750 fi
751
752 EDITLINE_LIB=""
753 if test "x$TERMCAP_LIB" != "x" ; then
754   EDITLINE_LIB="$TERMCAP_LIB"
755 elif test "x$TINFO_LIB" != "x" ; then
756   EDITLINE_LIB="$TINFO_LIB"
757 elif test "x$CURSES_LIB" != "x" ; then
758   EDITLINE_LIB="$CURSES_LIB"
759 elif test "x$NCURSES_LIB" != "x" ; then
760   EDITLINE_LIB="$NCURSES_LIB"
761 else
762   echo "*** termcap support not found"
763   exit 1
764 fi
765 AC_SUBST(EDITLINE_LIB)
766
767 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
768 AC_SUBST(PBX_H323)
769
770 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
771                                    #include <linux/version.h>
772                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
773                                    #include <linux/compiler.h>
774                                    #endif
775                                    ])
776 AC_SUBST(PBX_IXJUSER)
777
778 PBX_GTK=0
779 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
780 if test ! "x${GTKCONFIG}" = xNo; then
781    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
782    GTK_LIB=$(${GTKCONFIG} --libs gthread)
783    PBX_GTK=1
784    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
785 fi
786 AC_SUBST(PBX_GTK)
787 AC_SUBST(GTK_INCLUDE)
788 AC_SUBST(GTK_LIB)
789
790 PBX_CURL=0
791 AC_PATH_TOOL([CURL], [curl-config], No)
792 if test ! x"${CURL}" = xNo; then
793 # check for version
794    CURLLIB=$(${CURL} --libs)
795    PBX_CURL=1
796    AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
797 fi
798 AC_SUBST(PBX_CURL)
799 AC_SUBST(CURLLIB)
800
801 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
802 AC_OUTPUT
803
804 echo
805 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
806 echo "            .\$7\$7..          .7\$\$7:.    "
807 echo "          .\$\$:.                 ,\$7.7   "
808 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
809 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
810 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
811 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
812 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
813 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
814 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
815 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
816 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
817 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
818 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
819 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
820 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
821 echo " \$\$\$\$\$                        \$\$\$       "
822 echo "  \$\$\$\$7.                       \$\$  (TM)     "
823 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
824 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
825 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
826 echo
827
828 echo "Package configured for: "
829 echo " OS type  : $PBX_OSTYPE"
830 echo " Host CPU : $host_cpu"
831 if test "x${crossCompile}" = xYes; then
832    echo ""
833    echo " Cross Compilation = YES"
834    echo " Target            = ${host}"
835 fi