add support for atomic operations provided by mac osx
[asterisk/asterisk.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2
3 AC_PREREQ(2.59)
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 AC_CANONICAL_TARGET
15
16 # check existence of the package
17 AC_CONFIG_SRCDIR([asterisk.c])
18
19 # specify output header file
20 AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
21
22 AC_COPYRIGHT("Asterisk")
23 AC_REVISION($Revision$)
24
25 case "${host}" in
26      *freebsd*)
27      ac_default_prefix=/usr/local
28      ;;
29      *)
30      ac_default_prefix=/usr
31      if test ${sysconfdir} = '${prefix}/etc'; then
32         sysconfdir=/etc
33      fi
34      if test ${mandir} = '${prefix}/man'; then
35         mandir=/usr/share/man
36      fi
37      ;;
38 esac
39
40 if test ${localstatedir} = '${prefix}/var'; then
41      localstatedir=/var
42 fi
43
44 ### ** Platform.
45 AC_DEFINE_UNQUOTED(PBX_PLATFORM, "${host}",
46 [Define this to be the canonical name (cpu-vendor-os) of your system.])
47 AC_DEFINE_UNQUOTED(PBX_CPU, "${host_cpu}",
48 [Define this to be the name of the CPU of your system.])
49 AC_DEFINE_UNQUOTED(PBX_VENDOR, "${host_vendor}",
50 [Define this to be the name of the vendor of your system.])
51 AC_DEFINE_UNQUOTED(PBX_OS, "${host_os}",
52 [Define this to be the name of the OS of your system.])
53
54 # export some useful defines
55 PBX_PLATFORM=${host}
56 PBX_CPU=${host_cpu}
57 PBX_VENDOR=${host_vendor}
58 PBX_OS=${host_os}
59 AC_SUBST(PBX_PLATFORM)
60 AC_SUBST(PBX_CPU)
61 AC_SUBST(PBX_VENDOR)
62 AC_SUBST(PBX_OS)
63
64 #  check for uname
65 AC_PATH_TOOL([UNAME], [uname], No)
66 if test ! x"${UNAME}" = xNo; then
67    PBX_OSREV=$(${UNAME} -r)
68 fi
69 AC_SUBST(PBX_OSREV)
70
71 # guest OS type
72 case "${host}" in
73   cygwin*|mingw*|windows*|winnt)
74     AC_DEFINE(Win32, 1,
75               [Define according to your operating system type.])
76     PBX_OSTYPE="CYGWIN"
77 # this is ugly - KPF
78   OSISWIN32=1
79   AC_SUBST(OSISWIN32)
80     ;;
81   *linux*)
82     AC_DEFINE(Linux, 1,
83               [Define according to your operating system type.])
84     PBX_OSTYPE="Linux"
85     ;;
86   *netbsd*)
87     AC_DEFINE(NetBSD, 1,
88               [Define according to your operating system type.])
89     PBX_OSTYPE="NetBSD"
90     ;;
91   *freebsd*)
92     AC_DEFINE(FreeBSD, 1,
93               [Define according to your operating system type.])
94     PBX_OSTYPE="FreeBSD"
95     # XXX temporary hack to let FreeBSD use the default paths
96     # for local stuff. We need a better solution.
97     if test x"${CPPFLAGS}" = x; then
98         CPPFLAGS="-I /usr/local/include"
99     fi
100     if test x"${LDFLAGS}" = x; then
101         LDFLAGS="-L /usr/local/lib"
102     fi
103     ;;
104   *openbsd*)
105     AC_DEFINE(OpenBSD, 1,
106               [Define according to your operating system type.])
107     PBX_OSTYPE="OpenBSD"
108     ;;
109   *sun*)
110     AC_DEFINE(SunOS, 1,
111               [Define according to your operating system type.])
112     PBX_OSTYPE="SunOS"
113     ;;
114   *darwin*)
115     AC_DEFINE(Darwin, 1,
116               [Define according to your operating system type.])
117     PBX_OSTYPE="Darwin"
118     ;;
119   *)
120     AC_DEFINE(Unix, 1,
121               [Define according to your operating system type.])
122     PBX_OSTYPE="Unix"
123    ;;
124 esac
125 AC_SUBST(PBX_OSTYPE)
126
127 # This needs to be before any macros that use the C compiler
128 AC_GNU_SOURCE
129
130 AH_TOP(
131 #ifndef ASTERISK_AUTOCONFIG_H
132 #define ASTERISK_AUTOCONFIG_H
133
134 #ifndef MENUSELECT
135 #include "asterisk/buildopts.h"
136 #endif
137
138 #ifndef _REENTRANT
139 #define _REENTRANT
140 #endif
141 )
142
143 AH_BOTTOM(
144 #endif
145 )
146
147 # cross-compile checks
148 if test x"${build}" != x"${host}"; 
149 then
150    AC_CHECK_TOOL(CC, gcc, :)
151    AC_CHECK_TOOL(CXX, g++, :)
152    AC_CHECK_TOOL(RANLIB, ranlib, :)
153    AC_CHECK_TOOL(AR, ar, :)
154
155    if test x"${PBX_OSTYPE}" = xWin32;
156    then
157       AC_CHECK_TOOL(NM, nm, :)
158       AC_CHECK_TOOL(WINDRES, windres, :)
159       AC_CHECK_TOOL(DLLWRAP, dllwrap, :)
160    fi
161    crossCompile="Yes"
162 fi
163
164 # Checks for programs.
165 AC_PROG_CC
166 AC_PROG_CXX
167 AC_PROG_CPP
168 AC_PROG_CXXCPP
169 AC_PROG_AWK
170 AC_PROG_INSTALL
171 AC_PROG_LN_S
172 AC_PROG_RANLIB
173 AST_CHECK_GNU_MAKE
174
175 AC_PATH_PROG([GREP], [grep], :)
176 AC_PATH_PROG([AR], [ar], :)
177 AC_PATH_PROG([FIND], [find], :)
178 AC_PATH_PROG([COMPRESS], [compress], :)
179 AC_PATH_PROG([BASENAME], [basename], :)
180 AC_PATH_PROG([DIRNAME], [dirname], :)
181 AC_PATH_PROG([SHELL], [sh], :)
182 AC_PATH_PROG([LN], [ln], :)
183 AC_PATH_PROG([DOT], [dot], :)
184
185 AC_LANG(C)
186
187 AC_ARG_ENABLE(dev-mode,
188         [  --enable-dev-mode    Turn on developer mode],
189         [case "${enableval}" in
190               y|ye|yes) AST_DEVMODE=yes ;;
191               n|no)  AST_DEVMODE=no ;;
192               *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode)  ;;
193         esac])
194 AC_SUBST(AST_DEVMODE)
195
196 # from here on down, library checking should be done in alphabetical order
197 # by the --with option name, to make things easier for the users :-)
198
199 AST_EXT_LIB([asound], [snd_spcm_init], [alsa/asoundlib.h], [ALSA], [Advanced Linux Sound Architecture], [-lm -ldl])
200 AST_EXT_LIB([curses], [initscr], [curses.h], [CURSES], [curses], [])
201
202 GSM_INTERNAL="yes"
203 GSM_SYSTEM="yes"
204 AC_ARG_WITH([gsm], AC_HELP_STRING([--with-gsm=PATH], [use libgsm files in PATH, or 'internal']), [
205 case ${withval} in
206      n|no)
207      USE_GSM=no
208      ;;
209      y|ye|yes)
210      ;;
211      internal)
212      GSM_SYSTEM="no"
213      ;;
214      *)
215      GSM_DIR="${withval}"
216      GSM_INTERNAL="no"
217      ;;
218 esac
219 ])
220
221 PBX_LIBgsm=0
222
223 if test "${USE_GSM}" != "no"; then
224    if test "${GSM_SYSTEM}" = "yes"; then
225       gsmlibdir=""
226       if test "x${GSM_DIR}" != "x"; then
227          gsmlibdir="-L${GSM_DIR}/lib"
228       fi
229       AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1,
230       [Define to indicate the GSM library]), [], ${gsmlibdir})
231       if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then
232          gsm_LIB="-lgsm"
233          if test "x${GSM_DIR}" != "x"; then
234             gsm_LIB="${gsmlibdir} ${gsm_LIB}"
235             gsm_INCLUDE="-I${GSM_DIR}/include"
236          fi
237          PBX_LIBgsm=1
238          GSM_INTERNAL="no"
239       fi
240    fi
241    if test "${GSM_INTERNAL}" = "yes"; then
242       gsm_LIB="internal"
243       PBX_LIBgsm=1
244    fi
245    if test "x${PBX_LIBgsm}" = "x0"; then
246       echo "***"
247       echo "*** The GSM installation on this system appears to be broken."
248       echo "*** Either correct the installation, or run configure"
249       echo "*** including --without-gsm"
250       exit 1
251    fi
252 fi
253
254 AC_SUBST([gsm_LIB])
255 AC_SUBST([gsm_INCLUDE])
256 AC_SUBST([PBX_LIBgsm])
257
258 AC_LANG_PUSH(C++)
259
260 AC_ARG_WITH([kde], AC_HELP_STRING([--with-kde=PATH],[use KDE files in PATH]),[
261 case ${withval} in
262      n|no)
263      USE_KDE=no
264      ;;
265      y|ye|yes)
266      KDE_MANDATORY="yes"
267      ;;
268      *)
269      KDE_DIR="${withval}"
270      KDE_MANDATORY="yes"
271      ;;
272 esac
273 ])
274
275 PBX_KDE=0
276 if test "${USE_KDE}" != "no"; then
277    echo -n "checking for crashHandler in -lkdecore... "
278    saved_ldflags="${LDFLAGS}"
279    LDFLAGS="-I${KDE_DIR}/include ${LDFLAGS} -L${KDE_DIR}/lib -lkdecore"
280         AC_LINK_IFELSE(
281         [
282                 AC_LANG_PROGRAM(
283                 [#include "kcrash.h"],
284                 [KCrash::defaultCrashHandler(1);])
285         ],
286         [ac_cv_lib_kde_crash="yes"],
287         [ac_cv_lib_kde_crash="no"])
288                 
289         LDFLAGS="${saved_ldflags}"
290         
291         if test "${ac_cv_lib_kde_crash}" = "yes"; then
292                 AC_MSG_RESULT(yes) 
293         else
294                 AC_MSG_RESULT(no) 
295         fi
296         
297         if test "${ac_cv_lib_kde_crash}" = "yes"; then
298                 KDE_LIB="-lkdecore -lkdeui"
299                 if test "${KDE_DIR}" != ""; then
300                         KDE_LIB="-L${KDE_DIR}/lib ${KDE_LIB}"
301                         KDE_INCLUDE="-I${KDE_DIR}/include"
302                         AC_SUBST([KDE_INCLUDE])
303                 fi
304                 AC_SUBST([KDE_LIB])
305                 PBX_KDE=1
306                 AC_DEFINE([HAVE_LIBKDE], 1, [Define if your system has the KDE library])
307    elif test ! -z "${KDE_MANDATORY}"; 
308    then
309       echo "***"
310       echo "*** The KDE installation on this system appears to be broken."
311       echo "*** Either correct the installation, or run configure"
312       echo "*** including --without-kde."
313       exit 1
314    fi
315 fi
316 AC_SUBST([PBX_KDE])
317
318 if test x"${PBX_KDE}" = x1; then
319         AC_PATH_TOOL(KDEINIT, kdeinit, No)
320         if test ! x"${KDEINIT}" = xNo; then
321         KDEDIR=$(${DIRNAME} ${KDEINIT})
322         KDEDIR=$(${DIRNAME} ${KDEDIR})
323         fi
324         AC_SUBST([KDEDIR])
325 fi
326
327 AC_LANG_POP
328
329 AST_EXT_LIB([iksemel], [iks_start_sasl], [iksemel.h], [IKSEMEL], [Iksemel Jabber Library])
330 AST_EXT_LIB([nbs], [nbs_connect], [nbs.h], [NBS], [Network Broadcast Sound])
331 AST_EXT_LIB([ncurses], [initscr], [curses.h], [NCURSES], [ncurses], [])
332
333 AC_ARG_WITH([netsnmp], AC_HELP_STRING([--with-netsnmp=PATH],[use Net-SNMP in PATH]),[
334 case ${withval} in
335      n|no)
336      USE_NETSNMP=no
337      ;;
338      y|ye|yes)
339      NETSNMP_MANDATORY="yes"
340      ;;
341      *)
342      NETSNMP_DIR="${withval}"
343      NETSNMP_MANDATORY="yes"
344      ;;
345 esac
346 ])
347
348 PBX_NETSNMP=0
349 NETSNMP_CONFIG=No
350 if test "${USE_NETSNMP}" != "no"; then  
351    if test "x${NETSNMP_DIR}" != "x"; then
352       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No, [${NETSNMP_DIR}/bin])
353       if test x"${NETSNMP_CONFIG}" = xNo; then
354          echo "***"
355          echo "*** net-snmp-config was not found in the path you specified:"
356          echo "*** ${NETSNMP_DIR}/bin"
357          echo "*** Either correct the installation, or run configure"
358          echo "*** including --without-netsnmp"
359          exit 1
360       fi
361    else
362       AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], No)
363    fi
364 fi
365
366 if test x"${NETSNMP_CONFIG}" != xNo; then
367    NETSNMP_libs=`net-snmp-config --agent-libs`
368    
369    AC_CHECK_LIB([netsnmp], [snmp_register_callback], AC_DEFINE_UNQUOTED([HAVE_NETSNMP], 1,
370    [Define to indicate the Net-SNMP library]), [], ${NETSNMP_libs})
371
372    if test "${ac_cv_lib_netsnmp_snmp_register_callback}" = "yes"; then
373       NETSNMP_LIB="${NETSNMP_libs}"
374       PBX_NETSNMP=1
375    elif test ! -z "${NETSNMP_MANDATORY}";
376    then
377       echo "***"
378       echo "*** The Net-SNMP installation on this system appears to be broken."
379       echo "*** Either correct the installation, or run configure"
380       echo "*** including --without-netsnmp"
381       exit 1
382    fi
383 elif test ! -z "${NETSNMP_MANDATORY}";
384 then
385    echo "***"
386    echo "*** The Net-SNMP installation on this system appears to be broken."
387    echo "*** Either correct the installation, or run configure"
388    echo "*** including --without-netsnmp"
389    exit 1
390 fi
391 AC_SUBST([NETSNMP_LIB])
392 AC_SUBST([PBX_NETSNMP])
393
394 AST_EXT_LIB([newt], [newtBell], [newt.h], [NEWT], [newt])
395 AST_EXT_LIB([odbc], [SQLConnect], [sql.h], [UNIXODBC], [unixODBC])
396 AST_EXT_LIB([ogg], [ogg_sync_init], [], [OGG], [OGG])
397 AST_EXT_LIB([osptk], [OSPPCryptoDecrypt], [osp/osp.h], [OSPTK], [OSP Toolkit], [-lcrypto -lssl])
398
399 PBX_LIBOSS=0
400 AC_CHECK_HEADER([linux/soundcard.h],
401                 [
402                 PBX_LIBOSS=1
403                 AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
404                 ])
405 if test "$PBX_LIBOSS" = "0"; then
406    AC_CHECK_HEADER([sys/soundcard.h],
407                    [
408                    PBX_LIBossaudio=1
409                    AC_DEFINE_UNQUOTED([HAVE_OSS], 1, [Define to indicate the Open Sound System library])
410                    ])
411 fi
412 if test "$PBX_LIBOSS" = "0"; then
413    AST_EXT_LIB([ossaudio], [oss_ioctl_mixer], [soundcard.h], [OSS], [Open Sound System])
414 fi
415
416 AC_SUBST([PBX_LIBOSS])
417
418 AC_ARG_WITH([pq], AC_HELP_STRING([--with-pq=PATH],[use PostgreSQL files in PATH]),[
419 case ${withval} in
420      n|no)
421      USE_PQ=no
422      ;;
423      y|ye|yes)
424      PQ_MANDATORY="yes"
425      ;;
426      *)
427      PQ_DIR="${withval}"
428      PQ_MANDATORY="yes"
429      ;;
430 esac
431 ])
432
433 PBX_LIBpq=0
434 PG_CONFIG=No
435 if test "${USE_PQ}" != "no"; then       
436    if test "x${PQ_DIR}" != "x"; then
437       AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PQ_DIR}/bin])
438       if test x"${PG_CONFIG}" = xNo; then
439          echo "***"
440          echo "*** pg_config was not found in the path you specified:"
441          echo "*** ${PQ_DIR}/bin"
442          echo "*** Either correct the installation, or run configure"
443          echo "*** including --without-pq"
444          exit 1
445       fi
446    else
447       AC_PATH_TOOL([PG_CONFIG], [pg_config], No)
448    fi
449 fi
450
451 if test x"${PG_CONFIG}" != xNo; then
452    PQ_libdir=`pg_config --libdir`
453    PQ_includedir=`pg_config --includedir`
454    
455    AC_CHECK_LIB([pq], [PQexec], AC_DEFINE_UNQUOTED([HAVE_PQ], 1,
456    [Define to indicate the PostgreSQL library]), [], -L${PQ_libdir} -lz)
457
458    if test "${ac_cv_lib_pq_PQexec}" = "yes"; then
459       pq_LIB="-L${PQ_libdir} -lpq -lz"
460       pq_INCLUDE="-I${PQ_includedir}"
461       PBX_LIBpq=1
462    elif test ! -z "${PQ_MANDATORY}";
463    then
464       echo "***"
465       echo "*** The PostgreSQL installation on this system appears to be broken."
466       echo "*** Either correct the installation, or run configure"
467       echo "*** including --without-pq"
468       exit 1
469    fi
470 elif test ! -z "${PQ_MANDATORY}";
471 then
472    echo "***"
473    echo "*** The PostgreSQL installation on this system appears to be broken."
474    echo "*** Either correct the installation, or run configure"
475    echo "*** including --without-pq"
476    exit 1
477 fi
478 AC_SUBST([pq_INCLUDE])
479 AC_SUBST([pq_LIB])
480 AC_SUBST([PBX_LIBpq])
481
482 AST_EXT_LIB([popt], [poptStrerror], [popt.h], [POPT], [popt])
483 AST_EXT_LIB([pri], [pri_call], [libpri.h], [LIBPRI], [ISDN PRI])
484
485 PLATFORM_PTLIB="ptlib_${OSTYPE}_${MACHTYPE}_r"
486
487 AC_ARG_WITH([pwlib], AC_HELP_STRING([--with-pwlib=PATH],[use PWLib files in PATH]),[
488 case ${withval} in
489      n|no)
490      USE_PWLIB=no
491      ;;
492      y|ye|yes)
493      ;;
494      *)
495      PWLIB_DIR="${withval}"
496      ;;
497 esac
498 ])
499 if test "${USE_PWLIB}" != "no"; then
500         echo -n "checking for existence of pwlib... "
501         
502         saved_ldflags="${LDFLAGS}"
503         LDFLAGS="${LDFLAGS} -L${PWLIB_DIR} -l${PLATFORM_PTLIB}"
504         
505         AC_LINK_IFELSE(
506         [
507         AC_LANG_PROGRAM(
508         [#include "${PWDIR_DIR}ptime.h"],
509         [int q = PTime::IsDaylightSaving();])
510         ],
511         [       AC_MSG_RESULT(yes) 
512                 ac_cv_lib_pwlib="yes" 
513         ],
514         [       AC_MSG_RESULT(no) 
515                 ac_cv_lib_pwlib="no" 
516         ]
517         )
518         LDFLAGS="${saved_ldflags}"
519
520         PBX_LIBPWLIB=0
521    
522    if test "${ac_cv_lib_pwlib}" = "yes"; then
523       PWLIB_LIB="-l{PLATFORM_PWLIB}"
524       if test "${PWLIB_DIR}" != ""; then
525          PWLIB_LIB="-L${PWLIB_DIR}/lib ${PWLIB_LIB}"
526                         PWLIB_INCLUDE="-I${PWLIB_DIR}/include"
527                         AC_SUBST([PWLIB_INCLUDE])
528       fi
529         AC_SUBST([PWLIB_LIB])
530         PBX_LIBPWLIB=1
531         AC_DEFINE([HAVE_LIBPWLIB], 1, [Define if your system has the pwlib libraries.])
532    elif test ! -z "${PWLIB_DIR}"; 
533    then
534       echo "***"
535       echo "*** The PWLIB installation on this system appears to be broken."
536       echo "*** Either correct the installation, or run configure"
537       echo "*** including --without-pwlib"
538       exit 1
539    fi
540 fi
541 AC_SUBST([PBX_LIBPWLIB])
542
543 AC_LANG_PUSH(C++)
544
545 AC_ARG_WITH([qt], AC_HELP_STRING([--with-qt=PATH],[use Qt files in PATH]),[
546 case ${withval} in
547      n|no)
548      USE_QT=no
549      ;;
550      y|ye|yes)
551      QT_MANDATORY="yes"
552      ;;
553      *)
554      QT_DIR="${withval}"
555      QT_MANDATORY="yes"
556      ;;
557 esac
558 ])
559
560 PBX_QT=0
561 if test "${USE_QT}" != "no"; then
562    echo -n "checking for QDate in -lqt... "
563    saved_libs="${LIBS}"
564    saved_cppflags="${CPPFLAGS}"
565    if test "x${QT_DIR}" != "x"; then
566       LIBS="${LIBS} -L${QT_DIR}/lib"
567       CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
568    fi
569    LIBS="${LIBS} -lqt"
570    qtlib="qt"
571    AC_LINK_IFELSE(
572         [
573                 AC_LANG_PROGRAM(
574                 [#include <qt3/qdatetime.h>],
575                 [QDate date();])
576         ],
577         [ac_cv_lib_qt_qt_date="yes"],
578         [ac_cv_lib_qt_qt_date="no"])
579    LIBS="${saved_libs}"
580    CPPFLAGS="${saved_cppflags}"
581         
582    if test "${ac_cv_lib_qt_qt_date}" = "no"; then
583       saved_libs="${LIBS}"
584       saved_cppflags="${CPPFLAGS}"
585       if test "x${QT_DIR}" != "x"; then
586          LIBS="${LIBS} -L${QT_DIR}/lib"
587          CPPFLAGS="${CPPFLAGS} -I${QT_DIR}/include"
588       fi
589       LIBS="${LIBS} -lqt-mt"
590       qtlib="qt-mt"     
591       AC_LINK_IFELSE(
592                 [
593                         AC_LANG_PROGRAM(
594                         [#include <qt3/qdatetime.h>],
595                         [QDate date();])
596                 ],
597                 [ac_cv_lib_qt_qt_date="yes"],
598                 [ac_cv_lib_qt_qt_date="no"])
599       LIBS="${saved_libs}"
600       CPPFLAGS="${saved_cppflags}"
601    fi   
602
603    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
604       AC_MSG_RESULT(yes) 
605    else
606       AC_MSG_RESULT(no) 
607    fi
608         
609    if test "${ac_cv_lib_qt_qt_date}" = "yes"; then
610       QT_LIB="-l${qtlib}"
611       if test "${QT_DIR}" != ""; then
612          QT_LIB="-L${QT_DIR}/lib ${QT_LIB}"
613          QT_INCLUDE="-I${QT_DIR}/include"
614          AC_SUBST([QT_INCLUDE])
615       fi
616       AC_SUBST([QT_LIB])
617       PBX_QT=1
618       AC_DEFINE([HAVE_LIBQT], 1, [Define if your system has the Qt library])
619       AC_PATH_TOOL(QTMOC, moc, No)
620    elif test ! -z "${QT_MANDATORY}"; 
621    then
622       echo "***"
623       echo "*** The Qt installation on this system appears to be broken."
624       echo "*** Either correct the installation, or run configure"
625       echo "*** including --without-qt."
626       exit 1
627    fi
628 fi
629 AC_SUBST([PBX_QT])
630
631 AC_LANG_POP
632
633 AST_EXT_LIB([radiusclient-ng], [rc_read_config], [radiusclient-ng.h], [RADIUSCLIENT], [Radius Client])
634 AST_EXT_LIB([speex], [speex_encode], [speex/speex.h], [SPEEX], [Speex], [-lm])
635 AST_EXT_LIB([sqlite], [sqlite_exec], [sqlite.h], [SQLITE], [SQLite])
636 AST_EXT_LIB([ssl], [ssl2_connect], [openssl/ssl.h], [OPENSSL], [OpenSSL], [-lcrypto])
637 AST_EXT_LIB([tds], [tds_version], [tds.h], [FREETDS], [FreeTDS])
638
639 if test "${PBX_LIBFREETDS}" != "0";
640 then
641     case `grep TDS_VERSION_NO ${FREETDS_DIR:-/usr/include}/tdsver.h` in
642     *0.63*)
643         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
644         ;;
645     *0.62*)
646         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
647         ;;
648     *)
649         FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
650         ;;
651     esac
652 fi
653
654 AST_EXT_LIB([termcap], [tgetent], [], [TERMCAP], [Termcap])
655 AST_EXT_LIB([tinfo], [tgetent], [], [TINFO], [Term Info])
656
657 if test "${PBX_OSTYPE}" = "Linux" ; then
658   AST_EXT_LIB([tonezone], [tone_zone_find], [tonezone.h], [TONEZONE], [tonezone])
659 else
660   AST_EXT_LIB([tonezone], [tone_zone_find], [tonezone.h], [TONEZONE], [tonezone], [-lm])
661 fi
662
663 AST_EXT_LIB([vorbis], [vorbis_info_init], [vorbis/codec.h], [VORBIS], [Vorbis], [-lm -lvorbisenc])
664
665 AC_LANG_PUSH(C++)
666
667 AC_ARG_WITH([vpb], AC_HELP_STRING([--with-vpb=PATH],[use vpb files in PATH]),[
668 case ${withval} in
669      n|no)
670      USE_VPB=no
671      ;;
672      y|ye|yes)
673      VPB_MANDATORY="yes"
674      ;;
675      *)
676      VPB_DIR="${withval}"
677      VPB_MANDATORY="yes"
678      ;;
679 esac
680 ])
681 if test "${USE_VPB}" != "no"; then
682    echo -n "checking for vpb_open in -lvpb... "
683    saved_libs="${LIBS}"
684    saved_cppflags="${CPPFLAGS}"
685    if test "x${VPB_DIR}" != "x"; then
686       LIBS="${LIBS} -L${VPB_DIR}/lib"
687       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
688    fi
689    LIBS="${LIBS} -lvpb -lpthread"
690    AC_LINK_IFELSE(
691         [
692         AC_LANG_PROGRAM(
693         [#include <vpbapi.h>],
694         [int q = vpb_open(0,0);])
695         ],
696         [       AC_MSG_RESULT(yes) 
697                 ac_cv_lib_vpb_vpb_open="yes" 
698         ],
699         [       AC_MSG_RESULT(no) 
700                 ac_cv_lib_vpb_vpb_open="no" 
701         ]
702         )
703    LIBS="${saved_libs}"
704    CPPFLAGS="${saved_cppflags}"
705    PBX_LIBvpb=0
706    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
707         VPB_LIB="-lvpb"
708         if test "${VPB_DIR}" != ""; then
709            VPB_LIB="-L${VPB_DIR}/lib ${VPB_LIB}"
710            VPB_INCLUDE="-I${VPB_DIR}/include"
711            AC_SUBST([VPB_INCLUDE])
712         fi
713         AC_SUBST([VPB_LIB])
714         PBX_LIBvpb=1
715         AC_DEFINE([HAVE_LIBVPB], 1, [Define if your system has the VoiceTronix (vpb) libraries.])
716    elif test ! -z "${VPB_MANDATORY}"; 
717    then
718       echo "***"
719       echo "*** The VoiceTronix (vpb) installation on this system appears to be broken."
720       echo "*** Either correct the installation, or run configure"
721       echo "*** including --without-vpb."
722       exit 1
723    fi
724 fi
725 AC_SUBST([PBX_LIBvpb])
726
727 AC_LANG_POP
728
729 AST_EXT_LIB([z], [compress], [zlib.h], [ZLIB], [zlib])
730
731 AC_ARG_WITH([zaptel], AC_HELP_STRING([--with-zaptel=PATH], [use Zaptel files in PATH]), [
732 case ${withval} in
733      n|no)
734      USE_ZAPTEL=no
735      ;;
736      y|ye|yes)
737      ZAPTEL_MANDATORY=yes
738      ;;
739      *)
740      ZAPTEL_DIR="${withval}"
741      ZAPTEL_MANDATORY=yes
742      ;;
743 esac
744 ])
745
746 PBX_ZAPTEL=0
747 if test "${USE_ZAPTEL}" != "no"; then
748    echo -n "checking for zt_transcode_header in zaptel.h... "
749    saved_cppflags="${CPPFLAGS}"
750    if test "x${ZAPTEL_DIR}" != "x"; then
751       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
752    fi
753    AC_COMPILE_IFELSE(
754         [
755         AC_LANG_PROGRAM(
756         [#include <zaptel.h>],
757         [struct zt_transcode_header test;])
758         ],
759         [       AC_MSG_RESULT(yes) 
760                 ac_cv_zaptel_h="yes" 
761         ],
762         [       AC_MSG_RESULT(no) 
763                 ac_cv_zaptel_h="no" 
764         ]
765         )
766    CPPFLAGS="${saved_cppflags}"
767    if test "${ac_cv_zaptel_h}" = "yes"; then
768         if test "${ZAPTEL_DIR}" != ""; then
769            ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
770            AC_SUBST([ZAPTEL_INCLUDE])
771         fi
772         PBX_ZAPTEL=1
773         AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
774    elif test ! -z "${ZAPTEL_MANDATORY}"; 
775    then
776       echo "***"
777       echo "*** The Zaptel installation on this system appears to be broken."
778       echo "*** Either correct the installation, or run configure"
779       echo "*** including --without-zaptel."
780       exit 1
781    fi
782 fi
783
784 AC_SUBST([PBX_ZAPTEL])
785
786 EDITLINE_LIB=""
787 if test "x$TERMCAP_LIB" != "x" ; then
788   EDITLINE_LIB="$TERMCAP_LIB"
789 elif test "x$TINFO_LIB" != "x" ; then
790   EDITLINE_LIB="$TINFO_LIB"
791 elif test "x$CURSES_LIB" != "x" ; then
792   EDITLINE_LIB="$CURSES_LIB"
793 elif test "x$NCURSES_LIB" != "x" ; then
794   EDITLINE_LIB="$NCURSES_LIB"
795 else
796   echo "*** termcap support not found"
797   exit 1
798 fi
799 AC_SUBST(EDITLINE_LIB)
800
801 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
802 AC_SUBST(PBX_H323)
803
804 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
805                                    #include <linux/version.h>
806                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
807                                    #include <linux/compiler.h>
808                                    #endif
809                                    ])
810 AC_SUBST(PBX_IXJUSER)
811
812 PBX_GTK=0
813 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
814 if test ! "x${GTKCONFIG}" = xNo; then
815    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
816    GTK_LIB=$(${GTKCONFIG} --libs gthread)
817    PBX_GTK=1
818    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
819 fi
820 AC_SUBST(PBX_GTK)
821 AC_SUBST(GTK_INCLUDE)
822 AC_SUBST(GTK_LIB)
823
824 PBX_CURL=0
825 AC_PATH_TOOL([CURL], [curl-config], No)
826 if test ! x"${CURL}" = xNo; then
827 # check for version
828    CURLLIB=$(${CURL} --libs)
829    PBX_CURL=1
830    AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
831 fi
832 AC_SUBST(PBX_CURL)
833 AC_SUBST(CURLLIB)
834
835 AC_FUNC_ALLOCA
836 AC_HEADER_DIRENT
837 AC_HEADER_STDC
838 AC_HEADER_SYS_WAIT
839 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])
840
841 AC_SYS_LARGEFILE
842
843 # Checks for typedefs, structures, and compiler characteristics.
844 AC_HEADER_STDBOOL
845 AC_C_CONST
846 AC_TYPE_UID_T
847 AC_C_INLINE
848 AC_TYPE_MODE_T
849 AC_TYPE_OFF_T
850 AC_TYPE_PID_T
851 AC_TYPE_SIZE_T
852 AC_CHECK_MEMBERS([struct stat.st_blksize])
853 AC_HEADER_TIME
854 AC_STRUCT_TM
855 AC_C_VOLATILE
856 AC_CHECK_TYPES([ptrdiff_t])
857
858 # Checks for library functions.
859 AC_FUNC_CHOWN
860 AC_FUNC_CLOSEDIR_VOID
861 AC_FUNC_ERROR_AT_LINE
862 AC_FUNC_FORK
863 AC_FUNC_FSEEKO
864 AC_PROG_GCC_TRADITIONAL
865 AC_FUNC_MALLOC
866 AC_FUNC_MEMCMP
867 AC_FUNC_MKTIME
868 AC_FUNC_MMAP
869 AC_FUNC_REALLOC
870 AC_FUNC_SELECT_ARGTYPES
871 AC_FUNC_SETVBUF_REVERSED
872 AC_TYPE_SIGNAL
873 AC_FUNC_STAT
874 AC_FUNC_STRCOLL
875 AC_FUNC_STRFTIME
876 AC_FUNC_STRNLEN
877 AC_FUNC_STRTOD
878 AC_FUNC_UTIME_NULL
879 AC_FUNC_VPRINTF
880 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])
881
882 echo -n "checking for compiler atomic operations... "
883 AC_LINK_IFELSE(
884 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
885 AC_MSG_RESULT(yes)
886 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
887 AC_MSG_RESULT(no)
888 )
889
890 AC_CHECK_HEADER([libkern/OSAtomic.h],
891                 [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
892
893 AC_CHECK_SIZEOF(int)
894
895 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
896 AC_OUTPUT
897
898 echo
899 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
900 echo "            .\$7\$7..          .7\$\$7:.    "
901 echo "          .\$\$:.                 ,\$7.7   "
902 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
903 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
904 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
905 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
906 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
907 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
908 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
909 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
910 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
911 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
912 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
913 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
914 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
915 echo " \$\$\$\$\$                        \$\$\$       "
916 echo "  \$\$\$\$7.                       \$\$  (TM)     "
917 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
918 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
919 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
920 echo
921
922 echo "Package configured for: "
923 echo " OS type  : $PBX_OSTYPE"
924 echo " Host CPU : $host_cpu"
925 if test "x${crossCompile}" = xYes; then
926    echo ""
927    echo " Cross Compilation = YES"
928    echo " Target            = ${host}"
929 fi