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