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