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