9839a85753a5ae418739eeddebf048ff90daf2e3
[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 AST_EXT_LIB([termcap], [tgetent], [], [TERMCAP], [Termcap])
639 AST_EXT_LIB([tinfo], [tgetent], [], [TINFO], [Term Info])
640
641 if test "${PBX_OSTYPE}" = "Linux" ; then
642   AST_EXT_LIB([tonezone], [tone_zone_find], [tonezone.h], [TONEZONE], [tonezone])
643 else
644   AST_EXT_LIB([tonezone], [tone_zone_find], [tonezone.h], [TONEZONE], [tonezone], [-lm])
645 fi
646
647 AST_EXT_LIB([vorbis], [vorbis_info_init], [vorbis/codec.h], [VORBIS], [Vorbis], [-lm -lvorbisenc])
648
649 AC_LANG_PUSH(C++)
650
651 AC_ARG_WITH([vpb], AC_HELP_STRING([--with-vpb=PATH],[use vpb files in PATH]),[
652 case ${withval} in
653      n|no)
654      USE_VPB=no
655      ;;
656      y|ye|yes)
657      VPB_MANDATORY="yes"
658      ;;
659      *)
660      VPB_DIR="${withval}"
661      VPB_MANDATORY="yes"
662      ;;
663 esac
664 ])
665 if test "${USE_VPB}" != "no"; then
666    echo -n "checking for vpb_open in -lvpb... "
667    saved_libs="${LIBS}"
668    saved_cppflags="${CPPFLAGS}"
669    if test "x${VPB_DIR}" != "x"; then
670       LIBS="${LIBS} -L${VPB_DIR}/lib"
671       CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include"
672    fi
673    LIBS="${LIBS} -lvpb -lpthread"
674    AC_LINK_IFELSE(
675         [
676         AC_LANG_PROGRAM(
677         [#include <vpbapi.h>],
678         [int q = vpb_open(0,0);])
679         ],
680         [       AC_MSG_RESULT(yes) 
681                 ac_cv_lib_vpb_vpb_open="yes" 
682         ],
683         [       AC_MSG_RESULT(no) 
684                 ac_cv_lib_vpb_vpb_open="no" 
685         ]
686         )
687    LIBS="${saved_libs}"
688    CPPFLAGS="${saved_cppflags}"
689    PBX_LIBvpb=0
690    if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then
691         VPB_LIB="-lvpb"
692         if test "${VPB_DIR}" != ""; then
693            VPB_LIB="-L${VPB_DIR}/lib ${VPB_LIB}"
694            VPB_INCLUDE="-I${VPB_DIR}/include"
695            AC_SUBST([VPB_INCLUDE])
696         fi
697         AC_SUBST([VPB_LIB])
698         PBX_LIBvpb=1
699         AC_DEFINE([HAVE_LIBVPB], 1, [Define if your system has the VoiceTronix (vpb) libraries.])
700    elif test ! -z "${VPB_MANDATORY}"; 
701    then
702       echo "***"
703       echo "*** The VoiceTronix (vpb) installation on this system appears to be broken."
704       echo "*** Either correct the installation, or run configure"
705       echo "*** including --without-vpb."
706       exit 1
707    fi
708 fi
709 AC_SUBST([PBX_LIBvpb])
710
711 AC_LANG_POP
712
713 AST_EXT_LIB([z], [compress], [zlib.h], [ZLIB], [zlib])
714
715 AC_ARG_WITH([zaptel], AC_HELP_STRING([--with-zaptel=PATH], [use Zaptel files in PATH]), [
716 case ${withval} in
717      n|no)
718      USE_ZAPTEL=no
719      ;;
720      y|ye|yes)
721      ZAPTEL_MANDATORY=yes
722      ;;
723      *)
724      ZAPTEL_DIR="${withval}"
725      ZAPTEL_MANDATORY=yes
726      ;;
727 esac
728 ])
729
730 PBX_ZAPTEL=0
731 if test "${USE_ZAPTEL}" != "no"; then
732    echo -n "checking for zt_transcode_header in zaptel.h... "
733    saved_cppflags="${CPPFLAGS}"
734    if test "x${ZAPTEL_DIR}" != "x"; then
735       CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
736    fi
737    AC_COMPILE_IFELSE(
738         [
739         AC_LANG_PROGRAM(
740         [#include <zaptel.h>],
741         [struct zt_transcode_header test;])
742         ],
743         [       AC_MSG_RESULT(yes) 
744                 ac_cv_zaptel_h="yes" 
745         ],
746         [       AC_MSG_RESULT(no) 
747                 ac_cv_zaptel_h="no" 
748         ]
749         )
750    CPPFLAGS="${saved_cppflags}"
751    if test "${ac_cv_zaptel_h}" = "yes"; then
752         if test "${ZAPTEL_DIR}" != ""; then
753            ZAPTEL_INCLUDE="-I${ZAPTEL_DIR}/include"
754            AC_SUBST([ZAPTEL_INCLUDE])
755         fi
756         PBX_ZAPTEL=1
757         AC_DEFINE([HAVE_ZAPTEL], 1, [Define if your system has the Zaptel headers.])
758    elif test ! -z "${ZAPTEL_MANDATORY}"; 
759    then
760       echo "***"
761       echo "*** The Zaptel installation on this system appears to be broken."
762       echo "*** Either correct the installation, or run configure"
763       echo "*** including --without-zaptel."
764       exit 1
765    fi
766 fi
767
768 AC_SUBST([PBX_ZAPTEL])
769
770 EDITLINE_LIB=""
771 if test "x$TERMCAP_LIB" != "x" ; then
772   EDITLINE_LIB="$TERMCAP_LIB"
773 elif test "x$TINFO_LIB" != "x" ; then
774   EDITLINE_LIB="$TINFO_LIB"
775 elif test "x$CURSES_LIB" != "x" ; then
776   EDITLINE_LIB="$CURSES_LIB"
777 elif test "x$NCURSES_LIB" != "x" ; then
778   EDITLINE_LIB="$NCURSES_LIB"
779 else
780   echo "*** termcap support not found"
781   exit 1
782 fi
783 AC_SUBST(EDITLINE_LIB)
784
785 AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0])
786 AC_SUBST(PBX_H323)
787
788 AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [
789                                    #include <linux/version.h>
790                                    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
791                                    #include <linux/compiler.h>
792                                    #endif
793                                    ])
794 AC_SUBST(PBX_IXJUSER)
795
796 PBX_GTK=0
797 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
798 if test ! "x${GTKCONFIG}" = xNo; then
799    GTK_INCLUDE=$(${GTKCONFIG} --cflags gthread)
800    GTK_LIB=$(${GTKCONFIG} --libs gthread)
801    PBX_GTK=1
802    AC_DEFINE([HAVE_GTK], 1, [Define if your system has the GTK libraries.])
803 fi
804 AC_SUBST(PBX_GTK)
805 AC_SUBST(GTK_INCLUDE)
806 AC_SUBST(GTK_LIB)
807
808 PBX_CURL=0
809 AC_PATH_TOOL([CURL], [curl-config], No)
810 if test ! x"${CURL}" = xNo; then
811 # check for version
812    CURLLIB=$(${CURL} --libs)
813    PBX_CURL=1
814    AC_DEFINE([HAVE_CURL], 1, [Define if your system has the curl libraries.])
815 fi
816 AC_SUBST(PBX_CURL)
817 AC_SUBST(CURLLIB)
818
819 AC_FUNC_ALLOCA
820 AC_HEADER_DIRENT
821 AC_HEADER_STDC
822 AC_HEADER_SYS_WAIT
823 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])
824
825 AC_SYS_LARGEFILE
826
827 # Checks for typedefs, structures, and compiler characteristics.
828 AC_HEADER_STDBOOL
829 AC_C_CONST
830 AC_TYPE_UID_T
831 AC_C_INLINE
832 AC_TYPE_MODE_T
833 AC_TYPE_OFF_T
834 AC_TYPE_PID_T
835 AC_TYPE_SIZE_T
836 AC_CHECK_MEMBERS([struct stat.st_blksize])
837 AC_HEADER_TIME
838 AC_STRUCT_TM
839 AC_C_VOLATILE
840 AC_CHECK_TYPES([ptrdiff_t])
841
842 # Checks for library functions.
843 AC_FUNC_CHOWN
844 AC_FUNC_CLOSEDIR_VOID
845 AC_FUNC_ERROR_AT_LINE
846 AC_FUNC_FORK
847 AC_FUNC_FSEEKO
848 AC_PROG_GCC_TRADITIONAL
849 AC_FUNC_MALLOC
850 AC_FUNC_MEMCMP
851 AC_FUNC_MKTIME
852 AC_FUNC_MMAP
853 AC_FUNC_REALLOC
854 AC_FUNC_SELECT_ARGTYPES
855 AC_FUNC_SETVBUF_REVERSED
856 AC_TYPE_SIGNAL
857 AC_FUNC_STAT
858 AC_FUNC_STRCOLL
859 AC_FUNC_STRFTIME
860 AC_FUNC_STRNLEN
861 AC_FUNC_STRTOD
862 AC_FUNC_UTIME_NULL
863 AC_FUNC_VPRINTF
864 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])
865
866 echo -n "checking for compiler atomic operations... "
867 AC_LINK_IFELSE(
868 AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);]),
869 AC_MSG_RESULT(yes)
870 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
871 AC_MSG_RESULT(no)
872 )
873
874 AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
875 AC_OUTPUT
876
877 echo
878 echo "               .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=..      "
879 echo "            .\$7\$7..          .7\$\$7:.    "
880 echo "          .\$\$:.                 ,\$7.7   "
881 echo "        .\$7.     7\$\$\$\$           .\$\$77  "
882 echo "     ..\$\$.       \$\$\$\$\$            .\$\$\$7 "
883 echo "    ..7\$   .?.   \$\$\$\$\$   .?.       7\$\$\$."
884 echo "   \$.\$.   .\$\$\$7. \$\$\$\$7 .7\$\$\$.      .\$\$\$."
885 echo " .777.   .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7.      \$\$\$,"
886 echo " \$\$\$~      .7\$\$\$\$\$\$\$\$\$\$\$\$\$7.       .\$\$\$."
887 echo ".\$\$7          .7\$\$\$\$\$\$\$7:          ?\$\$\$."
888 echo "\$\$\$          ?7\$\$\$\$\$\$\$\$\$\$I        .\$\$\$7 "
889 echo "\$\$\$       .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$      :\$\$\$. "
890 echo "\$\$\$       \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$    .\$\$\$.  "
891 echo "\$\$\$        \$\$\$   7\$\$\$7  .\$\$\$    .\$\$\$.   "
892 echo "\$\$\$\$             \$\$\$\$7         .\$\$\$.    "
893 echo "7\$\$\$7            7\$\$\$\$        7\$\$\$      "
894 echo " \$\$\$\$\$                        \$\$\$       "
895 echo "  \$\$\$\$7.                       \$\$  (TM)     "
896 echo "   \$\$\$\$\$\$\$.           .7\$\$\$\$\$\$  \$\$      "
897 echo "     \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$      "
898 echo "       \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$.                "
899 echo
900
901 echo "Package configured for: "
902 echo " OS type  : $PBX_OSTYPE"
903 echo " Host CPU : $host_cpu"
904 if test "x${crossCompile}" = xYes; then
905    echo ""
906    echo " Cross Compilation = YES"
907    echo " Target            = ${host}"
908 fi