support ./configure --silent
[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 AC_MSG_CHECKING(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=`pwd`"/../imap-2004g"
340    fi
341    AC_MSG_CHECKING(checking for UW IMAP Toolkit c-client library)
342    saved_cppflags="${CPPFLAGS}"
343    saved_libs="${LIBS}"
344    if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
345       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
346    fi
347    CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
348    LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
349    AC_LINK_IFELSE(
350         AC_LANG_PROGRAM(
351                 [#include "c-client.h"],
352                 [
353                 void mm_searched (MAILSTREAM *stream,unsigned long number)
354                 {
355                 }
356                 void mm_exists (MAILSTREAM *stream,unsigned long number)
357                 {
358                 }
359                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
360                 {
361                 }
362                 void mm_flags (MAILSTREAM *stream,unsigned long number)
363                 {
364                 }
365                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
366                 {
367                 }
368                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
369                 {
370                 }
371                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
372                 {
373                 }
374                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
375                 {
376                 }
377                 void mm_log (char *string,long errflg)
378                 {
379                 }
380                 void mm_dlog (char *string)
381                 {
382                 }
383                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
384                 {
385                 }
386                 void mm_critical (MAILSTREAM *stream)
387                 {
388                 }
389                 void mm_nocritical (MAILSTREAM *stream)
390                 {
391                 }
392                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
393                 {
394                 }
395                 void mm_fatal (char *string)
396                 {
397                 }
398                 int main()
399                 {
400                 MAILSTREAM *foo = mail_open(NULL, "", 0);
401                 }
402                 ]
403         ),
404         [ac_cv_imap_tk="yes"],
405         [ac_cv_imap_tk="no"]
406    )
407    CPPFLAGS="${saved_cppflags}"
408    LIBS="${saved_libs}"
409    if test "${ac_cv_imap_tk}" = "yes"; then
410       AC_MSG_RESULT(yes) 
411       IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
412       IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
413       PBX_IMAP_TK=1
414       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
415    elif test ! -z "${IMAP_TK_MANDATORY}"; then
416       AC_MSG_RESULT(no) 
417       AC_MSG_NOTICE(***)
418       AC_MSG_NOTICE(*** The UW IMAP Toolkit installation on this system appears to be broken.)
419       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
420       AC_MSG_NOTICE(*** including --without-imap.)
421       exit 1
422    else
423       AC_MSG_RESULT(no) 
424    fi
425 fi
426
427 AC_LANG_PUSH(C++)
428
429 if test "${USE_KDE}" != "no"; then
430    AC_MSG_CHECKING(checking for crashHandler in -lkdecore)
431    saved_libs="${LIBS}"
432    saved_cppflags="${CPPFLAGS}"
433    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
434    if test -d ${KDE_DIR}/lib; then
435       kdelibdir="${KDE_DIR}/lib"
436    else
437       kdelibdir="${KDE_DIR}"
438    fi
439    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
440
441    AC_LINK_IFELSE(
442         [AC_LANG_PROGRAM(
443                         [#include "kcrash.h"],
444                         [KCrash::defaultCrashHandler(1);])
445         ],
446         [ac_cv_lib_kde_crash="yes"],
447         [ac_cv_lib_kde_crash="no"])
448                 
449    LIBS="${saved_libs}"
450    CPPFLAGS="${saved_cppflags}"
451         
452    if test "${ac_cv_lib_kde_crash}" = "yes"; then
453       AC_MSG_RESULT(yes) 
454       KDE_LIB="-lkdecore -lkdeui"
455       if test "${KDE_DIR}" != ""; then
456          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
457          KDE_INCLUDE="-I${KDE_DIR}/include"
458       fi
459       PBX_KDE=1
460       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
461    elif test ! -z "${KDE_MANDATORY}"; then
462       AC_MSG_RESULT(no) 
463       AC_MSG_NOTICE(***)
464       AC_MSG_NOTICE(*** The KDE installation on this system appears to be broken.)
465       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
466       AC_MSG_NOTICE(*** including --without-kde.)
467       exit 1
468    else
469       AC_MSG_RESULT(no) 
470    fi
471 fi
472 if test "${PBX_KDE}" = 1; then
473    AC_PATH_TOOL(KDEINIT, kdeinit, No)
474    if test ! x"${KDEINIT}" = xNo; then
475       KDEDIR=$(${DIRNAME} ${KDEINIT})
476       KDEDIR=$(${DIRNAME} ${KDEDIR})
477    fi
478    AC_SUBST([KDEDIR])
479 fi
480
481 AC_LANG_POP
482
483 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
484
485 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
486
487 NETSNMP_CONFIG=No
488 if test "${USE_NETSNMP}" != "no"; then  
489    if test "x${NETSNMP_DIR}" != "x"; then
490       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
491       if test x"${NETSNMP_CONFIG}" = xNo; then
492          AC_MSG_NOTICE(***)
493          AC_MSG_NOTICE(*** net-snmp-config was not found in the path you specified:)
494          AC_MSG_NOTICE(*** ${NETSNMP_DIR}/bin)
495          AC_MSG_NOTICE(*** Either correct the installation, or run configure)
496          AC_MSG_NOTICE(*** including --without-netsnmp)
497          exit 1
498       fi
499    else
500       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
501    fi
502 fi
503 if test x"${NETSNMP_CONFIG}" != xNo; then
504    NETSNMP_libs=`net-snmp-config --agent-libs`
505    
506    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
507    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
508
509    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
510       NETSNMP_LIB="${NETSNMP_libs}"
511       PBX_NETSNMP=1
512    elif test ! -z "${NETSNMP_MANDATORY}";
513    then
514       AC_MSG_NOTICE(***)
515       AC_MSG_NOTICE(*** The Net-SNMP installation on this system appears to be broken.)
516       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
517       AC_MSG_NOTICE(*** including --without-netsnmp)
518       exit 1
519    fi
520 elif test ! -z "${NETSNMP_MANDATORY}";
521 then
522    AC_MSG_NOTICE(***)
523    AC_MSG_NOTICE(*** The Net-SNMP installation on this system appears to be broken.)
524    AC_MSG_NOTICE(*** Either correct the installation, or run configure)
525    AC_MSG_NOTICE(*** including --without-netsnmp)
526    exit 1
527 fi
528
529 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
530
531 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h])
532
533 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
534
535 AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
536
537 PBX_OSS=0
538 AC_CHECK_HEADER([linux/soundcard.h],
539                 [
540                 PBX_OSS=1
541                 AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
542                 ])
543 if test "$PBX_OSS" = "0"; then
544    AC_CHECK_HEADER([sys/soundcard.h],
545                    [
546                    PBX_OSS=1
547                    AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
548                    ])
549 fi
550 if test "$PBX_OSS" = "0"; then
551    AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
552 fi
553
554 PG_CONFIG=No
555 if test "${USE_PGSQL}" != "no"; then    
556    if test "x${PGSQL_DIR}" != "x"; then
557       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
558       if test x"${PG_CONFIG}" = xNo; then
559          AC_MSG_NOTICE(***)
560          AC_MSG_NOTICE(*** pg_config was not found in the path you specified:)
561          AC_MSG_NOTICE(*** ${PGSQL_DIR}/bin)
562          AC_MSG_NOTICE(*** Either correct the installation, or run configure)
563          AC_MSG_NOTICE(*** including --without-postgres)
564          exit 1
565       fi
566    else
567       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
568    fi
569 fi
570 if test "${PG_CONFIG}" != No; then
571    PGSQL_libdir=`pg_config --libdir`
572    PGSQL_includedir=`pg_config --includedir`
573    
574    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
575    [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
576
577    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
578       PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz"
579       PGSQL_INCLUDE="-I${PGSQL_includedir}"
580       PBX_PGSQL=1
581    elif test ! -z "${PGSQL_MANDATORY}";
582    then
583       AC_MSG_NOTICE(***)
584       AC_MSG_NOTICE(*** The PostgreSQL installation on this system appears to be broken.)
585       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
586       AC_MSG_NOTICE(*** including --without-postgres)
587       exit 1
588    fi
589 elif test ! -z "${PGSQL_MANDATORY}";
590 then
591    AC_MSG_NOTICE(***)
592    AC_MSG_NOTICE(*** The PostgreSQL installation on this system appears to be broken.)
593    AC_MSG_NOTICE(*** Either correct the installation, or run configure)
594    AC_MSG_NOTICE(*** including --without-postgres)
595    exit 1
596 fi
597
598 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
599
600 AST_EXT_LIB_CHECK([PRI], [pri], [pri_call], [libpri.h])
601
602 PLATFORM_PTLIB="ptlib_${OSTYPE}_${MACHTYPE}_r"
603 if test "${USE_PWLIB}" != "no"; then
604    AC_MSG_CHECKING(checking for existence of pwlib)
605         
606    saved_cppflags="${CPPFLAGS}"
607    saved_libs="${LIBS}"
608    LIBS="${LIBS} -L${PWLIB_DIR} -l${PLATFORM_PTLIB}"
609    CPPFLAGS="${CPPFLAGS} -I${PWLIB_DIR}/include"
610         
611    AC_LINK_IFELSE(
612         [
613         AC_LANG_PROGRAM(
614         [#include "ptime.h"],
615         [int q = PTime::IsDaylightSaving();])
616         ],
617         [       AC_MSG_RESULT(yes) 
618                 ac_cv_lib_pwlib="yes" 
619         ],
620         [       AC_MSG_RESULT(no) 
621                 ac_cv_lib_pwlib="no" 
622         ]
623         )
624
625    LIBS="${saved_libs}"
626    CPPFLAGS="${saved_cppflags}"
627
628    if test "${ac_cv_lib_pwlib}" = "yes"; then
629       PWLIB_LIB="-l{PLATFORM_PWLIB}"
630       if test "${PWLIB_DIR}" != ""; then
631          PWLIB_LIB="-L${PWLIB_DIR}/lib ${PWLIB_LIB}"
632          PWLIB_INCLUDE="-I${PWLIB_DIR}/include"
633       fi
634         PBX_PWLIB=1
635         AC_DEFINE([HAVE_PWLIB], 1, [Define if your system has the pwlib libraries.])
636    elif test ! -z "${PWLIB_MANDATORY}"; then
637       AC_MSG_NOTICE(***)
638       AC_MSG_NOTICE(*** The PWLIB installation on this system appears to be broken.)
639       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
640       AC_MSG_NOTICE(*** including --without-pwlib)
641       exit 1
642    fi
643 fi
644
645 AC_LANG_PUSH(C++)
646
647 if test "${USE_QT}" != "no"; then
648    AC_MSG_CHECKING(checking for QDate in -lqt)
649    saved_libs="${LIBS}"
650    saved_cppflags="${CPPFLAGS}"
651    if test "x${QT_DIR}" != "x"; then
652       LIBS="${LIBS} -L${QT_DIR}/lib"
653       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
654    fi
655    LIBS="${LIBS} -lqt"
656    qtlib="qt"
657    AC_LINK_IFELSE(
658         [
659                 AC_LANG_PROGRAM(
660                 [#include <qt3/qdatetime.h>],
661                 [QDate date();])
662         ],
663         [ac_cv_lib_qt_qt_date="yes"],
664         [ac_cv_lib_qt_qt_date="no"])
665    LIBS="${saved_libs}"
666    CPPFLAGS="${saved_cppflags}"
667         
668    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
669       saved_libs="${LIBS}"
670       saved_cppflags="${CPPFLAGS}"
671       if test "x${QT_DIR}" != "x"; then
672          LIBS="${LIBS} -L${QT_DIR}/lib"
673          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
674       fi
675       LIBS="${LIBS} -lqt-mt"
676       qtlib="qt-mt"     
677       AC_LINK_IFELSE(
678                 [
679                         AC_LANG_PROGRAM(
680                         [#include <qt3/qdatetime.h>],
681                         [QDate date();])
682                 ],
683                 [ac_cv_lib_qt_qt_date="yes"],
684                 [ac_cv_lib_qt_qt_date="no"])
685       LIBS="${saved_libs}"
686       CPPFLAGS="${saved_cppflags}"
687    fi   
688
689    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
690       AC_MSG_RESULT(yes) 
691    else
692       AC_MSG_RESULT(no) 
693    fi
694         
695    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
696       QT_LIB="-l${qtlib}"
697       if test "${QT_DIR}" != ""; then
698          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
699          QT_INCLUDE="-I${QT_DIR}/include"
700       fi
701       PBX_QT=1
702       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
703       AC_PATH_TOOL(QTMOC, moc, No)
704    elif test ! -z "${QT_MANDATORY}"; 
705    then
706       AC_MSG_NOTICE(***)
707       AC_MSG_NOTICE(*** The Qt installation on this system appears to be broken.)
708       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
709       AC_MSG_NOTICE(*** including --without-qt.)
710       exit 1
711    fi
712 fi
713
714 AC_LANG_POP
715
716 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
717
718 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
719
720 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
721
722 AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
723
724 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
725 if test "${PBX_FREETDS}" != "0";
726 then
727     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
728     *0.63*)
729         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
730         ;;
731     *0.62*)
732         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
733         ;;
734     *)
735         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
736         ;;
737     esac
738 fi
739
740 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
741
742 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
743
744 if test "${PBX_OSTYPE}" != "Linux" ; then
745   tonezone_extra="-lm"
746 fi
747
748 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}])
749
750 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
751
752 AC_LANG_PUSH(C++)
753
754 if test "${USE_VPB}" != "no"; then
755    AC_MSG_CHECKING(checking for vpb_open in -lvpb)
756    saved_libs="${LIBS}"
757    saved_cppflags="${CPPFLAGS}"
758    if test "x${VPB_DIR}" != "x"; then
759       if test -d ${VPB_DIR}/lib; then
760          vpblibdir=${VPB_DIR}/lib
761       else
762          vpblibdir=${VPB_DIR}
763       fi
764       LIBS="${LIBS} -L${vpblibdir}"
765       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
766    fi
767    LIBS="${LIBS} -lvpb -lpthread"
768    AC_LINK_IFELSE(
769         [
770         AC_LANG_PROGRAM(
771         [#include <vpbapi.h>],
772         [int q = vpb_open(0,0);])
773         ],
774         [       AC_MSG_RESULT(yes) 
775                 ac_cv_lib_vpb_vpb_open="yes" 
776         ],
777         [       AC_MSG_RESULT(no) 
778                 ac_cv_lib_vpb_vpb_open="no" 
779         ]
780         )
781    LIBS="${saved_libs}"
782    CPPFLAGS="${saved_cppflags}"
783    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
784         VPB_LIB="-lvpb"
785         if test "${VPB_DIR}" != ""; then
786            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
787            VPB_INCLUDE="-I${VPB_DIR}/include"
788         fi
789         PBX_VPB=1
790         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
791    elif test ! -z "${VPB_MANDATORY}"; then
792       AC_MSG_NOTICE(***)
793       AC_MSG_NOTICE(*** The VoiceTronix (vpb) installation on this system appears to be broken.)
794       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
795       AC_MSG_NOTICE(*** including --without-vpb.)
796       exit 1
797    fi
798 fi
799
800 AC_LANG_POP
801
802 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
803
804 if test "${USE_ZAPTEL}" != "no"; then
805    AC_MSG_CHECKING(checking for zt_transcode_header in zaptel.h)
806    saved_cppflags="${CPPFLAGS}"
807    if test "x${ZAPTEL_DIR}" != "x"; then
808       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
809    fi
810    AC_COMPILE_IFELSE(
811         [
812         AC_LANG_PROGRAM(
813         [#include <zaptel/zaptel.h>],
814         [struct zt_transcode_header test;])
815         ],
816         [       AC_MSG_RESULT(yes) 
817                 ac_cv_zaptel_h="yes" 
818         ],
819         [       AC_MSG_RESULT(no) 
820                 ac_cv_zaptel_h="no" 
821         ]
822         )
823    CPPFLAGS="${saved_cppflags}"
824    if test "${ac_cv_zaptel_h}" = "yes"; then
825         if test "${ZAPTEL_DIR}" != ""; then
826            ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
827         fi
828         PBX_ZAPTEL=1
829         AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
830    elif test ! -z "${ZAPTEL_MANDATORY}"; 
831    then
832       AC_MSG_NOTICE(***)
833       AC_MSG_NOTICE(*** The Zaptel installation on this system appears to be broken.)
834       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
835       AC_MSG_NOTICE(*** including --without-zaptel.)
836       exit 1
837    fi
838 fi
839
840 EDITLINE_LIB=""
841 if test "x$TERMCAP_LIB" != "x" ; then
842   EDITLINE_LIB="$TERMCAP_LIB"
843 elif test "x$TINFO_LIB" != "x" ; then
844   EDITLINE_LIB="$TINFO_LIB"
845 elif test "x$CURSES_LIB" != "x" ; then
846   EDITLINE_LIB="$CURSES_LIB"
847 elif test "x$NCURSES_LIB" != "x" ; then
848   EDITLINE_LIB="$NCURSES_LIB"
849 else
850   AC_MSG_ERROR(*** termcap support not found)
851 fi
852 AC_SUBST(EDITLINE_LIB)
853
854 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
855 AC_SUBST(PBX_H323)
856
857 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
858                                    #include <linux/version.h>
859                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
860                                    #include <linux/compiler.h>
861                                    #endif
862                                    ])
863 AC_SUBST(PBX_IXJUSER)
864
865 PBX_GTK=0
866 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
867 if test ! "x${GTKCONFIG}" = xNo; then
868    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
869    GTK_LIB=$(${GTKCONFIG} --libs gthread)
870    PBX_GTK=1
871    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
872 fi
873 AC_SUBST(PBX_GTK)
874 AC_SUBST(GTK_INCLUDE)
875 AC_SUBST(GTK_LIB)
876
877 PBX_CURL=0
878 AC_PATH_TOOL([CURL], [curl-config], No)
879 if test ! x"${CURL}" = xNo; then
880 # check for version
881    if test $PBX_OSTYPE = "SunOS"; then
882       if [[ 0x`curl-config --vernum` -ge 0x70907 ]]; then
883          CURLLIB=$(${CURL} --libs)
884          PBX_CURL=1
885          AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
886       fi
887    else
888       if [[[ 0x`curl-config --vernum` -ge 0x70907 ]]]; then
889          CURLLIB=$(${CURL} --libs)
890          PBX_CURL=1
891          AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
892       fi
893    fi
894 fi
895 AC_SUBST(PBX_CURL)
896 AC_SUBST(CURLLIB)
897
898 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
899 AC_OUTPUT
900
901 if test "x${silent}" != "xyes" ; then
902 echo
903 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
904 echo "            .\$7\$7..          .7\$\$7:.    "
905 echo "          .\$\$:.                 ,\$7.7   "
906 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
907 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
908 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
909 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
910 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
911 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
912 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
913 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
914 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
915 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
916 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
917 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
918 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
919 echo " \$\$\$\$\$                        \$\$\$       "
920 echo "  \$\$\$\$7.                       \$\$  (TM)     "
921 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
922 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
923 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
924 echo
925 fi
926
927 AC_MSG_NOTICE(Package configured for: )
928 AC_MSG_NOTICE( OS type  : $PBX_OSTYPE)
929 AC_MSG_NOTICE( Host CPU : $host_cpu)
930 if test "x${crossCompile}" = xYes; then
931    AC_MSG_NOTICE()
932    AC_MSG_NOTICE( Cross Compilation = YES)
933    AC_MSG_NOTICE( Target            = ${host})
934 fi