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