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