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