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