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