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