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