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