remove the make version check, and instead, check for the actual bug that
[asterisk/asterisk.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2
3 AC_PREREQ(2.60)
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
15 # check existence of the package
16 AC_CONFIG_SRCDIR([main/asterisk.c])
17
18 # specify output header file
19 AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
20
21 AC_COPYRIGHT("Asterisk")
22 AC_REVISION($Revision$)
23
24 case "${host_os}" in
25      freebsd)
26      ac_default_prefix=/usr/local
27      ;;
28      *)
29      ac_default_prefix=/usr
30      if test ${sysconfdir} = '${prefix}/etc'; then
31         sysconfdir=/etc
32      fi
33      if test ${mandir} = '${prefix}/man'; then
34         mandir=/usr/share/man
35      fi
36      ;;
37 esac
38
39 if test ${localstatedir} = '${prefix}/var'; then
40      localstatedir=/var
41 fi
42
43 BUILD_PLATFORM=${build}
44 BUILD_CPU=${build_cpu}
45 BUILD_VENDOR=${build_vendor}
46 BUILD_OS=${build_os}
47
48 AC_SUBST(BUILD_PLATFORM)
49 AC_SUBST(BUILD_CPU)
50 AC_SUBST(BUILD_VENDOR)
51 AC_SUBST(BUILD_OS)
52
53 HOST_PLATFORM=${host}
54 HOST_CPU=${host_cpu}
55 HOST_VENDOR=${host_vendor}
56 HOST_OS=${host_os}
57
58 AC_SUBST(HOST_PLATFORM)
59 AC_SUBST(HOST_CPU)
60 AC_SUBST(HOST_VENDOR)
61 AC_SUBST(HOST_OS)
62
63 #  check for uname
64 AC_PATH_TOOL([UNAME], [uname], No)
65 if test ! x"${UNAME}" = xNo; then
66    PBX_OSREV=$(${UNAME} -r)
67 fi
68 AC_SUBST(PBX_OSREV)
69
70 # This needs to be before any macros that use the C compiler
71 AC_GNU_SOURCE
72
73 AH_TOP(
74 #ifndef ASTERISK_AUTOCONFIG_H
75 #define ASTERISK_AUTOCONFIG_H
76
77 #ifndef MENUSELECT
78 #include "asterisk/buildopts.h"
79 #endif
80
81 #ifndef _REENTRANT
82 #define _REENTRANT
83 #endif
84 )
85
86 AH_BOTTOM(
87 #endif
88 )
89
90 # cross-compile checks
91 if test "${cross_compiling}" = "yes"; 
92 then
93    AC_CHECK_TOOL(CC, gcc, :)
94    AC_CHECK_TOOL(CXX, g++, :)
95    AC_CHECK_TOOL(LD, ld, :)
96    AC_CHECK_TOOL(RANLIB, ranlib, :)
97    AC_CHECK_TOOL(AR, ar, :)
98 fi
99
100 # Checks for programs.
101 AC_PROG_CC
102 AC_PROG_CXX
103 AC_PROG_CPP
104 AC_PROG_CXXCPP
105 AC_PROG_AWK
106 AC_PROG_INSTALL
107 AC_PROG_LN_S
108 AC_PROG_RANLIB
109 AST_CHECK_GNU_MAKE
110
111 # http://www.mail-archive.com/bug-make@gnu.org/msg02871.html
112 echo 'define A' > testMakefile
113 echo '12345: $(1:.idl=.hh) $(1:.idl=S.h) $(1:.idl=C.h) $(1:.idl=SK.cc) $(1:.idl=DynSK.cc)' >> testMakefile
114 echo 'endef' >> testMakefile
115 echo '$(eval $(call A,01234567890123456789012345678901.idl))' >> testMakefile
116 echo '01234567890123456789012345678901.hh:' >> testMakefile
117 echo '01234567890123456789012345678901S.h:' >> testMakefile
118 echo '01234567890123456789012345678901C.h:' >> testMakefile
119 echo '01234567890123456789012345678901SK.cc:' >> testMakefile
120 echo '01234567890123456789012345678901DynSK.cc:' >> testMakefile
121 $GNU_MAKE -r -f testMakefile 2&>1 > /dev/null
122 if test "$?" != "0" ; then
123   rm -f testMakefile
124   AC_MSG_NOTICE(********** ERROR **********)
125   AC_MSG_NOTICE(Your version of GNU Make contains a bug that will cause the Asterisk build)
126   AC_MSG_NOTICE(system to not funciton properly.  This bug is known to be fixed in version)
127   AC_MSG_NOTICE(3.81 as well as versions of 3.80 that contain backported bug fixes.  You)
128   AC_MSG_NOTICE(must update GNU make to build Asterisk.)
129   AC_MSG_NOTICE(***************************)
130   exit 1
131 fi
132 rm -f testMakefile
133
134 AC_PATH_PROG([GREP], [grep], :)
135 AC_PATH_PROG([AR], [ar], :)
136 AC_PATH_PROG([FIND], [find], :)
137 AC_PATH_PROG([COMPRESS], [compress], :)
138 AC_PATH_PROG([BASENAME], [basename], :)
139 AC_PATH_PROG([DIRNAME], [dirname], :)
140 AC_PATH_PROG([SHELL], [sh], :)
141 AC_PATH_PROG([LN], [ln], :)
142 AC_PATH_PROG([DOT], [dot], :)
143
144 AC_LANG(C)
145
146 AC_ARG_ENABLE(dev-mode,
147         [  --enable-dev-mode    Turn on developer mode],
148         [case "${enableval}" in
149               y|ye|yes) AST_DEVMODE=yes ;;
150               n|no)  AST_DEVMODE=no ;;
151               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
152         esac])
153 AC_SUBST(AST_DEVMODE)
154
155 # package option names should be in alphabetical order
156 # by the --with option name, to make things easier for the users :-)
157
158 AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
159 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
160 AST_EXT_LIB_SETUP([GNUTLS], [GNU TLS support (used for iksemel only)], [gnutls])
161 AST_EXT_LIB_SETUP([GSM], [GSM], [gsm], [, or 'internal'])
162 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
163 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
164 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
165 AST_EXT_LIB_SETUP([KDE], [KDE], [kde])
166 AST_EXT_LIB_SETUP([MISDN], [mISDN User Library], [misdn])
167 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
168 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
169 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
170 AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
171 AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [odbc])
172 AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
173 AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
174 AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
175 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
176 AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
177 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
178 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
179 AST_EXT_LIB_SETUP([QT], [Qt], [qt])
180 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
181 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
182 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
183 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
184 AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL], [ssl])
185 AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds])
186 AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap])
187 AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
188 AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
189 AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
190 AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
191 AST_EXT_LIB_SETUP([ZLIB], [zlib], [z])
192 AST_EXT_LIB_SETUP([ZAPTEL], [Zaptel], [zaptel])
193
194 # check for basic system features and functionality before
195 # checking for package libraries
196
197 AC_FUNC_ALLOCA
198 AC_HEADER_DIRENT
199 AC_HEADER_STDC
200 AC_HEADER_SYS_WAIT
201 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])
202
203 AC_SYS_LARGEFILE
204
205 # Checks for typedefs, structures, and compiler characteristics.
206 AC_HEADER_STDBOOL
207 AC_C_CONST
208 AC_TYPE_UID_T
209 AC_C_INLINE
210 AC_TYPE_MODE_T
211 AC_TYPE_OFF_T
212 AC_TYPE_PID_T
213 AC_TYPE_SIZE_T
214 AC_CHECK_MEMBERS([struct stat.st_blksize])
215 AC_HEADER_TIME
216 AC_STRUCT_TM
217 AC_C_VOLATILE
218 AC_CHECK_TYPES([ptrdiff_t])
219
220 # Checks for library functions.
221 AC_FUNC_CHOWN
222 AC_FUNC_CLOSEDIR_VOID
223 AC_FUNC_ERROR_AT_LINE
224 AST_FUNC_FORK
225 AC_FUNC_FSEEKO
226 AC_PROG_GCC_TRADITIONAL
227 # XXX: these are commented out until we determine whether it matters if our malloc()
228 # acts exactly like glibc's or not
229 # AC_FUNC_MALLOC
230 # AC_FUNC_REALLOC
231 AC_FUNC_MEMCMP
232 AC_FUNC_MKTIME
233 AC_FUNC_MMAP
234 AC_FUNC_SELECT_ARGTYPES
235 AC_FUNC_SETVBUF_REVERSED
236 AC_TYPE_SIGNAL
237 AC_FUNC_STAT
238 AC_FUNC_STRCOLL
239 AC_FUNC_STRFTIME
240 AC_FUNC_STRNLEN
241 AC_FUNC_STRTOD
242 AC_FUNC_UTIME_NULL
243 AC_FUNC_VPRINTF
244 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])
245
246 AC_MSG_CHECKING(checking for compiler atomic operations)
247 AC_LINK_IFELSE(
248 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
249 AC_MSG_RESULT(yes)
250 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
251 AC_MSG_RESULT(no)
252 )
253
254 AC_MSG_CHECKING(checking for res_ninit)
255 AC_LINK_IFELSE(
256         AC_LANG_PROGRAM([#include <resolv.h>],
257                         [int foo = res_ninit(NULL);]),
258         AC_MSG_RESULT(yes)
259         AC_DEFINE([HAVE_RES_NINIT], 1, [Define to 1 if your system has the re-entrant resolver functions.]),
260         AC_MSG_RESULT(no)
261 )
262
263 AC_MSG_CHECKING(checking for RTLD_NOLOAD)
264 AC_LINK_IFELSE(
265         AC_LANG_PROGRAM([#include <dlfcn.h>],
266                         [int foo = RTLD_NOLOAD;]),
267         AC_MSG_RESULT(yes)
268         AC_DEFINE([HAVE_RTLD_NOLOAD], 1, [Define to 1 if your system has a dynamic linker that supports RTLD_NOLOAD.]),
269         AC_MSG_RESULT(no)
270 )
271
272 AST_GCC_ATTRIBUTE(pure)
273 AST_GCC_ATTRIBUTE(malloc)
274 AST_GCC_ATTRIBUTE(const)
275 AST_GCC_ATTRIBUTE(unused)
276 AST_GCC_ATTRIBUTE(always_inline)
277
278 AC_CHECK_HEADER([libkern/OSAtomic.h],
279                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
280
281 AC_CHECK_SIZEOF(int)
282
283 # do the package library checks now
284
285 AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl])
286
287 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
288
289 GSM_INTERNAL="yes"
290 AC_SUBST(GSM_INTERNAL)
291 GSM_SYSTEM="yes"
292 if test "${USE_GSM}" != "no"; then
293    if test "${GSM_DIR}" = "internal"; then
294       GSM_SYSTEM="no"
295    elif test "${GSM_DIR}" != ""; then
296       GSM_INTERNAL="no"
297    fi
298    if test "${GSM_SYSTEM}" = "yes"; then
299       gsmlibdir=""
300       if test "x${GSM_DIR}" != "x"; then
301          if test -d ${GSM_DIR}/lib; then
302             gsmlibdir="-L${GSM_DIR}/lib"
303          else
304             gsmlibdir="-L${GSM_DIR}"
305          fi
306       fi
307       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
308       [Define to indicate the GSM library]), [], ${gsmlibdir})
309       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
310          GSM_LIB="-lgsm"
311          if test "x${GSM_DIR}" != "x"; then
312             GSM_LIB="${gsmlibdir} ${GSM_LIB}"
313             GSM_INCLUDE="-I${GSM_DIR}/include"
314          fi
315          PBX_GSM=1
316          GSM_INTERNAL="no"
317       fi
318    fi
319    if test "${GSM_INTERNAL}" = "yes"; then
320       PBX_GSM=1
321    fi
322 fi
323
324 AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h])
325
326 if test "${PBX_IKSEMEL}" = 1; then
327    AST_EXT_LIB_CHECK([GNUTLS], [gnutls], [gnutls_bye])
328    if test "${PBX_GNUTLS}" = 1; then
329       IKSEMEL_LIB="${IKSEMEL_LIB} -lgnutls -lz -lgcrypt -lnsl -lgpg-error"
330    fi
331 fi
332
333 if test "${USE_IMAP_TK}" != "no"; then
334    if test "${IMAP_TK_DIR}" = ""; then
335       IMAP_TK_DIR=`pwd`"/../imap-2004g"
336    fi
337    AC_MSG_CHECKING(checking for UW IMAP Toolkit c-client library)
338    saved_cppflags="${CPPFLAGS}"
339    saved_libs="${LIBS}"
340    if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
341       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
342    fi
343    CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
344    LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
345    AC_LINK_IFELSE(
346         AC_LANG_PROGRAM(
347                 [#include "c-client.h"
348                 void mm_searched (MAILSTREAM *stream,unsigned long number)
349                 {
350                 }
351                 void mm_exists (MAILSTREAM *stream,unsigned long number)
352                 {
353                 }
354                 void mm_expunged (MAILSTREAM *stream,unsigned long number)
355                 {
356                 }
357                 void mm_flags (MAILSTREAM *stream,unsigned long number)
358                 {
359                 }
360                 void mm_notify (MAILSTREAM *stream,char *string,long errflg)
361                 {
362                 }
363                 void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
364                 {
365                 }
366                 void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
367                 {
368                 }
369                 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
370                 {
371                 }
372                 void mm_log (char *string,long errflg)
373                 {
374                 }
375                 void mm_dlog (char *string)
376                 {
377                 }
378                 void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
379                 {
380                 }
381                 void mm_critical (MAILSTREAM *stream)
382                 {
383                 }
384                 void mm_nocritical (MAILSTREAM *stream)
385                 {
386                 }
387                 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
388                 {
389                 }
390                 void mm_fatal (char *string)
391                 {
392                 }],
393                 [
394                 MAILSTREAM *foo = mail_open(NULL, "", 0);
395                 ]
396         ),
397         [ac_cv_imap_tk="yes"],
398         [ac_cv_imap_tk="no"]
399    )
400    if test "${ac_cv_imap_tk}" = "yes"; then
401    AC_LINK_IFELSE(
402       AC_LANG_PROGRAM(
403          [#include "c-client.h"
404          void mm_searched (MAILSTREAM *stream,unsigned long number)
405          {
406          }
407          void mm_exists (MAILSTREAM *stream,unsigned long number)
408          {
409          }
410          void mm_expunged (MAILSTREAM *stream,unsigned long number)
411          {
412          }
413          void mm_flags (MAILSTREAM *stream,unsigned long number)
414          {
415          }
416          void mm_notify (MAILSTREAM *stream,char *string,long errflg)
417          {
418          }
419          void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
420          {
421          }
422          void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
423          {
424          }
425          void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
426          {
427          }
428          void mm_log (char *string,long errflg)
429          {
430          }
431          void mm_dlog (char *string)
432          {
433          }
434          void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
435          {
436          }
437          void mm_critical (MAILSTREAM *stream)
438          {
439          }
440          void mm_nocritical (MAILSTREAM *stream)
441          {
442          }
443          long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
444          {
445          }
446          void mm_fatal (char *string)
447          {
448          }],
449          [
450          long check = mail_expunge_full(NULL, "", 0);
451          ]
452       ),
453       [ac_cv_imap_tk2006="yes"],
454       [ac_cv_imap_tk2006="no"]
455   )
456   fi
457    CPPFLAGS="${saved_cppflags}"
458    LIBS="${saved_libs}"
459    if test "${ac_cv_imap_tk}" = "yes"; then
460       AC_MSG_RESULT(yes) 
461       IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
462       IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
463       PBX_IMAP_TK=1
464       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
465       if test "${ac_cv_imap_tk2006}" = "yes"; then
466          AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.])
467       fi
468    elif test ! -z "${IMAP_TK_MANDATORY}"; then
469       AC_MSG_RESULT(no) 
470       AC_MSG_NOTICE(***)
471       AC_MSG_NOTICE(*** The UW IMAP Toolkit installation on this system appears to be broken.)
472       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
473       AC_MSG_NOTICE(*** including --without-imap.)
474       exit 1
475    else
476       AC_MSG_RESULT(no) 
477    fi
478 fi
479
480 AC_LANG_PUSH(C++)
481
482 if test "${USE_KDE}" != "no"; then
483    AC_MSG_CHECKING(checking for crashHandler in -lkdecore)
484    saved_libs="${LIBS}"
485    saved_cppflags="${CPPFLAGS}"
486    CPPFLAGS="${CPPFLAGS} -I${KDE_DIR}/include"
487    if test -d ${KDE_DIR}/lib; then
488       kdelibdir="${KDE_DIR}/lib"
489    else
490       kdelibdir="${KDE_DIR}"
491    fi
492    LIBS="${LIBS} -L${kdelibdir} -lkdecore"
493
494    AC_LINK_IFELSE(
495         [AC_LANG_PROGRAM(
496                         [#include "kcrash.h"],
497                         [KCrash::defaultCrashHandler(1);])
498         ],
499         [ac_cv_lib_kde_crash="yes"],
500         [ac_cv_lib_kde_crash="no"])
501                 
502    LIBS="${saved_libs}"
503    CPPFLAGS="${saved_cppflags}"
504         
505    if test "${ac_cv_lib_kde_crash}" = "yes"; then
506       AC_MSG_RESULT(yes) 
507       KDE_LIB="-lkdecore -lkdeui"
508       if test "${KDE_DIR}" != ""; then
509          KDE_LIB="-L${kdelibdir} ${KDE_LIB}"
510          KDE_INCLUDE="-I${KDE_DIR}/include"
511       fi
512       PBX_KDE=1
513       AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE libraries.])
514    elif test ! -z "${KDE_MANDATORY}"; then
515       AC_MSG_RESULT(no) 
516       AC_MSG_NOTICE(***)
517       AC_MSG_NOTICE(*** The KDE installation on this system appears to be broken.)
518       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
519       AC_MSG_NOTICE(*** including --without-kde.)
520       exit 1
521    else
522       AC_MSG_RESULT(no) 
523    fi
524 fi
525 if test "${PBX_KDE}" = 1; then
526    AC_PATH_TOOL(KDEINIT, kdeinit, No)
527    if test ! x"${KDEINIT}" = xNo; then
528       KDEDIR=$(${DIRNAME} ${KDEINIT})
529       KDEDIR=$(${DIRNAME} ${KDEDIR})
530    fi
531    AC_SUBST([KDEDIR])
532 fi
533
534 AC_LANG_POP
535
536 AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h])
537
538 if test "${PBX_MISDN}" = 1; then
539    AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread])
540    AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
541 fi
542
543 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
544
545 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
546
547 NETSNMP_CONFIG=No
548 if test "${USE_NETSNMP}" != "no"; then  
549    if test "x${NETSNMP_DIR}" != "x"; then
550       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
551       if test x"${NETSNMP_CONFIG}" = xNo; then
552          AC_MSG_NOTICE(***)
553          AC_MSG_NOTICE(*** net-snmp-config was not found in the path you specified:)
554          AC_MSG_NOTICE(*** ${NETSNMP_DIR}/bin)
555          AC_MSG_NOTICE(*** Either correct the installation, or run configure)
556          AC_MSG_NOTICE(*** including --without-netsnmp)
557          exit 1
558       fi
559    else
560       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
561    fi
562 fi
563 if test x"${NETSNMP_CONFIG}" != xNo; then
564    NETSNMP_libs=`net-snmp-config --agent-libs`
565    
566    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
567    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
568
569    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
570       NETSNMP_LIB="${NETSNMP_libs}"
571       PBX_NETSNMP=1
572    elif test ! -z "${NETSNMP_MANDATORY}";
573    then
574       AC_MSG_NOTICE(***)
575       AC_MSG_NOTICE(*** The Net-SNMP installation on this system appears to be broken.)
576       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
577       AC_MSG_NOTICE(*** including --without-netsnmp)
578       exit 1
579    fi
580 elif test ! -z "${NETSNMP_MANDATORY}";
581 then
582    AC_MSG_NOTICE(***)
583    AC_MSG_NOTICE(*** The Net-SNMP installation on this system appears to be broken.)
584    AC_MSG_NOTICE(*** Either correct the installation, or run configure)
585    AC_MSG_NOTICE(*** including --without-netsnmp)
586    exit 1
587 fi
588
589 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
590
591 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [-lltdl])
592
593 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])
594
595 AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl])
596
597 PBX_OSS=0
598 AC_CHECK_HEADER([linux/soundcard.h],
599                 [
600                 PBX_OSS=1
601                 AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
602                 ])
603 if test "$PBX_OSS" = "0"; then
604    AC_CHECK_HEADER([sys/soundcard.h],
605                    [
606                    PBX_OSS=1
607                    AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
608                    ])
609 fi
610 if test "$PBX_OSS" = "0"; then
611    AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h])
612 fi
613
614 PG_CONFIG=No
615 if test "${USE_PGSQL}" != "no"; then    
616    if test "x${PGSQL_DIR}" != "x"; then
617       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin])
618       if test x"${PG_CONFIG}" = xNo; then
619          AC_MSG_NOTICE(***)
620          AC_MSG_NOTICE(*** pg_config was not found in the path you specified:)
621          AC_MSG_NOTICE(*** ${PGSQL_DIR}/bin)
622          AC_MSG_NOTICE(*** Either correct the installation, or run configure)
623          AC_MSG_NOTICE(*** including --without-postgres)
624          exit 1
625       fi
626    else
627       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
628    fi
629 fi
630 if test "${PG_CONFIG}" != No; then
631    PGSQL_libdir=`pg_config --libdir`
632    PGSQL_includedir=`pg_config --includedir`
633    
634    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1,
635    [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz)
636
637    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
638       PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz -lcrypt"
639       PGSQL_INCLUDE="-I${PGSQL_includedir}"
640       PBX_PGSQL=1
641    elif test ! -z "${PGSQL_MANDATORY}";
642    then
643       AC_MSG_NOTICE(***)
644       AC_MSG_NOTICE(*** The PostgreSQL installation on this system appears to be broken.)
645       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
646       AC_MSG_NOTICE(*** including --without-postgres)
647       exit 1
648    fi
649 elif test ! -z "${PGSQL_MANDATORY}";
650 then
651    AC_MSG_NOTICE(***)
652    AC_MSG_NOTICE(*** The PostgreSQL installation on this system appears to be broken.)
653    AC_MSG_NOTICE(*** Either correct the installation, or run configure)
654    AC_MSG_NOTICE(*** including --without-postgres)
655    exit 1
656 fi
657
658 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
659
660 AST_EXT_LIB_CHECK([PRI], [pri], [pri_call], [libpri.h])
661
662 PLATFORM_PTLIB="ptlib_${OSTYPE}_${MACHTYPE}_r"
663 if test "${USE_PWLIB}" != "no"; then
664    AC_MSG_CHECKING(checking for existence of pwlib)
665         
666    saved_cppflags="${CPPFLAGS}"
667    saved_libs="${LIBS}"
668    LIBS="${LIBS} -L${PWLIB_DIR} -l${PLATFORM_PTLIB}"
669    CPPFLAGS="${CPPFLAGS} -I${PWLIB_DIR}/include"
670         
671    AC_LINK_IFELSE(
672         [
673         AC_LANG_PROGRAM(
674         [#include "ptime.h"],
675         [int q = PTime::IsDaylightSaving();])
676         ],
677         [       AC_MSG_RESULT(yes) 
678                 ac_cv_lib_pwlib="yes" 
679         ],
680         [       AC_MSG_RESULT(no) 
681                 ac_cv_lib_pwlib="no" 
682         ]
683         )
684
685    LIBS="${saved_libs}"
686    CPPFLAGS="${saved_cppflags}"
687
688    if test "${ac_cv_lib_pwlib}" = "yes"; then
689       PWLIB_LIB="-l{PLATFORM_PWLIB}"
690       if test "${PWLIB_DIR}" != ""; then
691          PWLIB_LIB="-L${PWLIB_DIR}/lib ${PWLIB_LIB}"
692          PWLIB_INCLUDE="-I${PWLIB_DIR}/include"
693       fi
694         PBX_PWLIB=1
695         AC_DEFINE([HAVE_PWLIB], 1, [Define if your system has the pwlib libraries.])
696    elif test ! -z "${PWLIB_MANDATORY}"; then
697       AC_MSG_NOTICE(***)
698       AC_MSG_NOTICE(*** The PWLIB installation on this system appears to be broken.)
699       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
700       AC_MSG_NOTICE(*** including --without-pwlib)
701       exit 1
702    fi
703 fi
704
705 AC_LANG_PUSH(C++)
706
707 if test "${USE_QT}" != "no"; then
708    AC_MSG_CHECKING(checking for QDate in -lqt)
709    saved_libs="${LIBS}"
710    saved_cppflags="${CPPFLAGS}"
711    if test "x${QT_DIR}" != "x"; then
712       LIBS="${LIBS} -L${QT_DIR}/lib"
713       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
714    fi
715    LIBS="${LIBS} -lqt"
716    qtlib="qt"
717    AC_LINK_IFELSE(
718         [
719                 AC_LANG_PROGRAM(
720                 [#include <qt3/qdatetime.h>],
721                 [QDate date();])
722         ],
723         [ac_cv_lib_qt_qt_date="yes"],
724         [ac_cv_lib_qt_qt_date="no"])
725    LIBS="${saved_libs}"
726    CPPFLAGS="${saved_cppflags}"
727         
728    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
729       saved_libs="${LIBS}"
730       saved_cppflags="${CPPFLAGS}"
731       if test "x${QT_DIR}" != "x"; then
732          LIBS="${LIBS} -L${QT_DIR}/lib"
733          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
734       fi
735       LIBS="${LIBS} -lqt-mt"
736       qtlib="qt-mt"     
737       AC_LINK_IFELSE(
738                 [
739                         AC_LANG_PROGRAM(
740                         [#include <qt3/qdatetime.h>],
741                         [QDate date();])
742                 ],
743                 [ac_cv_lib_qt_qt_date="yes"],
744                 [ac_cv_lib_qt_qt_date="no"])
745       LIBS="${saved_libs}"
746       CPPFLAGS="${saved_cppflags}"
747    fi   
748
749    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
750       AC_MSG_RESULT(yes) 
751    else
752       AC_MSG_RESULT(no) 
753    fi
754         
755    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
756       QT_LIB="-l${qtlib}"
757       if test "${QT_DIR}" != ""; then
758          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
759          QT_INCLUDE="-I${QT_DIR}/include"
760       fi
761       PBX_QT=1
762       AC_DEFINE([HAVE_QT], 1, [Define if your system has the Qt library])
763       AC_PATH_TOOL(QTMOC, moc, No)
764    elif test ! -z "${QT_MANDATORY}"; 
765    then
766       AC_MSG_NOTICE(***)
767       AC_MSG_NOTICE(*** The Qt installation on this system appears to be broken.)
768       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
769       AC_MSG_NOTICE(*** including --without-qt.)
770       exit 1
771    fi
772 fi
773
774 AC_LANG_POP
775
776 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
777
778 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
779
780 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
781
782 AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto])
783
784 AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
785 if test "${PBX_FREETDS}" != "0";
786 then
787     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
788     *0.63*)
789         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
790         ;;
791     *0.62*)
792         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
793         ;;
794     *)
795         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
796         ;;
797     esac
798 fi
799
800 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
801
802 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
803
804 if test "${host_os}" != "linux-gnu" ; then
805   tonezone_extra="-lm"
806 fi
807
808 AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [zaptel/tonezone.h], [${tonezone_extra}])
809
810 AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc])
811
812 AC_LANG_PUSH(C++)
813
814 if test "${USE_VPB}" != "no"; then
815    AC_MSG_CHECKING(checking for vpb_open in -lvpb)
816    saved_libs="${LIBS}"
817    saved_cppflags="${CPPFLAGS}"
818    if test "x${VPB_DIR}" != "x"; then
819       if test -d ${VPB_DIR}/lib; then
820          vpblibdir=${VPB_DIR}/lib
821       else
822          vpblibdir=${VPB_DIR}
823       fi
824       LIBS="${LIBS} -L${vpblibdir}"
825       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
826    fi
827    LIBS="${LIBS} -lvpb -lpthread"
828    AC_LINK_IFELSE(
829         [
830         AC_LANG_PROGRAM(
831         [#include <vpbapi.h>],
832         [int q = vpb_open(0,0);])
833         ],
834         [       AC_MSG_RESULT(yes) 
835                 ac_cv_lib_vpb_vpb_open="yes" 
836         ],
837         [       AC_MSG_RESULT(no) 
838                 ac_cv_lib_vpb_vpb_open="no" 
839         ]
840         )
841    LIBS="${saved_libs}"
842    CPPFLAGS="${saved_cppflags}"
843    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
844         VPB_LIB="-lvpb"
845         if test "${VPB_DIR}" != ""; then
846            VPB_LIB="-L${vpblibdir}  ${VPB_LIB}"
847            VPB_INCLUDE="-I${VPB_DIR}/include"
848         fi
849         PBX_VPB=1
850         AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.])
851    elif test ! -z "${VPB_MANDATORY}"; then
852       AC_MSG_NOTICE(***)
853       AC_MSG_NOTICE(*** The VoiceTronix (vpb) installation on this system appears to be broken.)
854       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
855       AC_MSG_NOTICE(*** including --without-vpb.)
856       exit 1
857    fi
858 fi
859
860 AC_LANG_POP
861
862 AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h])
863
864 if test "${USE_ZAPTEL}" != "no"; then
865    AC_MSG_CHECKING(checking for zt_transcode_header in zaptel.h)
866    saved_cppflags="${CPPFLAGS}"
867    if test "x${ZAPTEL_DIR}" != "x"; then
868       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
869    fi
870    AC_COMPILE_IFELSE(
871         [
872         AC_LANG_PROGRAM(
873         [#include <zaptel/zaptel.h>],
874         [struct zt_transcode_header test;])
875         ],
876         [       AC_MSG_RESULT(yes) 
877                 ac_cv_zaptel_h="yes" 
878         ],
879         [       AC_MSG_RESULT(no) 
880                 ac_cv_zaptel_h="no" 
881         ]
882         )
883    CPPFLAGS="${saved_cppflags}"
884    if test "${ac_cv_zaptel_h}" = "yes"; then
885         if test "${ZAPTEL_DIR}" != ""; then
886            ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
887         fi
888         PBX_ZAPTEL=1
889         AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
890    elif test ! -z "${ZAPTEL_MANDATORY}"; 
891    then
892       AC_MSG_NOTICE(***)
893       AC_MSG_NOTICE(*** The Zaptel installation on this system appears to be broken.)
894       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
895       AC_MSG_NOTICE(*** including --without-zaptel.)
896       exit 1
897    fi
898 fi
899
900 EDITLINE_LIB=""
901 if test "x$TERMCAP_LIB" != "x" ; then
902   EDITLINE_LIB="$TERMCAP_LIB"
903 elif test "x$TINFO_LIB" != "x" ; then
904   EDITLINE_LIB="$TINFO_LIB"
905 elif test "x$CURSES_LIB" != "x" ; then
906   EDITLINE_LIB="$CURSES_LIB"
907 elif test "x$NCURSES_LIB" != "x" ; then
908   EDITLINE_LIB="$NCURSES_LIB"
909 else
910   AC_MSG_ERROR(*** termcap support not found)
911 fi
912 AC_SUBST(EDITLINE_LIB)
913
914 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
915 AC_SUBST(PBX_H323)
916
917 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
918                                    #include <linux/version.h>
919                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
920                                    #include <linux/compiler.h>
921                                    #endif
922                                    ])
923 AC_SUBST(PBX_IXJUSER)
924
925 PBX_GTK=0
926 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
927 if test ! "x${GTKCONFIG}" = xNo; then
928    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
929    GTK_LIB=$(${GTKCONFIG} --libs gthread)
930    PBX_GTK=1
931    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
932 fi
933 AC_SUBST(PBX_GTK)
934 AC_SUBST(GTK_INCLUDE)
935 AC_SUBST(GTK_LIB)
936
937 PBX_CURL=0
938 AC_PATH_TOOL([CURL], [curl-config], No)
939 if test ! x"${CURL}" = xNo; then
940 # check for version
941    if test "${host_os}" = "SunOS"; then
942       if [[ 0x`curl-config --vernum` -ge 0x70907 ]]; then
943          CURL_INCLUDE=$(${CURL} --cflags)
944          CURL_LIB=$(${CURL} --libs)
945          PBX_CURL=1
946          AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
947       fi
948    else
949       if [[[ 0x`curl-config --vernum` -ge 0x70907 ]]]; then
950          CURL_INCLUDE=$(${CURL} --cflags)
951          CURL_LIB=$(${CURL} --libs)
952          PBX_CURL=1
953          AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
954       fi
955    fi
956 fi
957 AC_SUBST(PBX_CURL)
958 AC_SUBST(CURL_INCLUDE)
959 AC_SUBST(CURL_LIB)
960
961 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
962 AC_OUTPUT
963
964 if test "x${silent}" != "xyes" ; then
965 echo
966 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
967 echo "            .\$7\$7..          .7\$\$7:.    "
968 echo "          .\$\$:.                 ,\$7.7   "
969 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
970 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
971 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
972 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
973 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
974 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
975 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
976 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
977 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
978 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
979 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
980 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
981 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
982 echo " \$\$\$\$\$                        \$\$\$       "
983 echo "  \$\$\$\$7.                       \$\$  (TM)     "
984 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
985 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
986 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
987 echo
988 fi
989
990 AC_MSG_NOTICE(Package configured for: )
991 AC_MSG_NOTICE( OS type  : $host_os)
992 AC_MSG_NOTICE( Host CPU : $host_cpu)
993 if test "${cross_compiling}" = "yes"; then
994    AC_MSG_NOTICE( Cross Compilation = YES)
995 fi