]> git.ipfire.org Git - thirdparty/freeswitch.git/blame - configure.in
FS-4729 try this patch clean
[thirdparty/freeswitch.git] / configure.in
CommitLineData
4da77ea5
AM
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
8ef2aa54
MJ
4# Must change all of the below together
5# For a release, set revision for that tagged release as well and uncomment
a330febb 6AC_INIT([freeswitch], [1.3.0], BUG-REPORT-ADDRESS)
8ef2aa54 7AC_SUBST(SWITCH_VERSION_MAJOR, [1])
a330febb 8AC_SUBST(SWITCH_VERSION_MINOR, [3])
a1177a79 9AC_SUBST(SWITCH_VERSION_MICRO, [0])
a330febb
KR
10AC_SUBST(SWITCH_VERSION_REVISION, [])
11AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, [])
8ef2aa54
MJ
12
13AC_CONFIG_FILES([src/include/switch_version.h.in:src/include/switch_version.h.template])
7a5bc3b7 14
e8b9a4f7 15AC_CONFIG_AUX_DIR(build/config)
4da77ea5
AM
16AM_INIT_AUTOMAKE(libfreeswitch,0.1)
17AC_CONFIG_SRCDIR([src/switch.c])
42e78242 18AC_CONFIG_HEADER([src/include/switch_private.h])
4062b636 19AC_CONFIG_HEADER([libs/xmlrpc-c/xmlrpc_amconfig.h])
42e78242 20
a642381f 21AC_PREFIX_DEFAULT(/usr/local/freeswitch)
94206d80
MJ
22# AC_PREFIX_DEFAULT does not get expanded until too late so we need to do this to use prefix in this script
23if test "x$prefix" = "xNONE" ; then
24 prefix='/usr/local/freeswitch'
25fi
55b3e6cb 26
31d1e20f
BW
27AC_CANONICAL_HOST
28
55b3e6cb
MJ
29# Absolute source/build directory
30switch_srcdir=`(cd $srcdir && pwd)`
31switch_builddir=`pwd`
32AC_SUBST(switch_srcdir)
33AC_SUBST(switch_builddir)
34
b552cb3a 35# Where to install the modules
2bcd991b 36AC_ARG_WITH([modinstdir],
5ccac21d
MJ
37 [AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: $prefix/mod)])], [modulesdir="$withval"], [modulesdir="${prefix}/mod"])
38AC_SUBST(modulesdir)
39AC_DEFINE_UNQUOTED([SWITCH_MOD_DIR],"${modulesdir}",[where to install the modules to])
1481d37f 40
88aa159b
MJ
41if test "$localstatedir" = "\${prefix}/var" ; then
42 rundir="$prefix/run"
7ae3f5b7 43 logdir="${prefix}/log"
88aa159b
MJ
44else
45 rundir="$localstatedir/run/freeswitch"
7ae3f5b7 46 logdir="$localstatedir/log/freeswitch"
88aa159b 47fi
107f9135
MJ
48# Where to put pidfile
49AC_ARG_WITH([rundir],
88aa159b 50 [AS_HELP_STRING([--with-rundir=DIR], [Put pidfile into this location (default: $prefix/run)])], [runtimedir="$withval"], [runtimedir="$rundir"])
5ccac21d
MJ
51AC_SUBST(runtimedir)
52AC_DEFINE_UNQUOTED([SWITCH_RUN_DIR],"${runtimedir}",[where to put pidfile to])
53
7ae3f5b7
MOC
54AC_ARG_WITH([logfiledir],
55 [AS_HELP_STRING([--with-logfiledir=DIR], [Put logfiles into this location (default: $localstatedir/log)])], [logfiledir="$withval"], [logfiledir="$logdir"])
5ccac21d
MJ
56AC_SUBST(logfiledir)
57AC_DEFINE_UNQUOTED([SWITCH_LOG_DIR],"${logfiledir}",[where to put log files])
107f9135 58
7ae3f5b7
MOC
59AC_ARG_WITH([dbdir],
60 [AS_HELP_STRING([--with-dbdir=DIR], [Put database files into this location (default: $prefix/db)])], [dbdir="$withval"], [dbdir="$prefix/db"])
5ccac21d
MJ
61AC_SUBST(dbdir)
62AC_DEFINE_UNQUOTED([SWITCH_DB_DIR],"${dbdir}",[where to put db files])
63
7ae3f5b7
MOC
64AC_ARG_WITH([htdocsdir],
65 [AS_HELP_STRING([--with-htdocsdir=DIR], [Put html files into this location (default: $prefix/htdocs)])], [htdocsdir="$withval"], [htdocsdir="$prefix/htdocs"])
89ae5f47
MJ
66AC_SUBST(htdocsdir)
67AC_DEFINE_UNQUOTED([SWITCH_HTDOCS_DIR],"${htdocsdir}",[where to put htdocs files])
68
7ae3f5b7
MOC
69AC_ARG_WITH([soundsdir],
70 [AS_HELP_STRING([--with-soundsdir=DIR], [Put sound files into this location (default: $prefix/sounds)])], [soundsdir="$withval"], [soundsdir="$prefix/sounds"])
d1c60899
MJ
71AC_SUBST(soundsdir)
72AC_DEFINE_UNQUOTED([SWITCH_SOUNDS_DIR],"${soundsdir}",[where to put sounds files])
73
7ae3f5b7
MOC
74AC_ARG_WITH([grammardir],
75 [AS_HELP_STRING([--with-grammardir=DIR], [Put grammar files into this location (default: $prefix/grammar)])], [grammardir="$withval"], [grammardir="$prefix/grammar"])
89ae5f47
MJ
76AC_SUBST(grammardir)
77AC_DEFINE_UNQUOTED([SWITCH_GRAMMAR_DIR],"${grammardir}",[where to put grammar files])
78
7ae3f5b7 79AC_ARG_WITH([scriptdir],
023818bc 80 [AS_HELP_STRING([--with-scriptdir=DIR], [Put script files into this location (default: $prefix/scripts)])], [scriptdir="$withval"], [scriptdir="$prefix/scripts"])
5ccac21d
MJ
81AC_SUBST(scriptdir)
82AC_DEFINE_UNQUOTED([SWITCH_SCRIPT_DIR],"${scriptdir}",[where to put script files])
107f9135 83
7ae3f5b7
MOC
84AC_ARG_WITH([recordingsdir],
85 [AS_HELP_STRING([--with-recordingsdir=DIR], [Put recordings files into this location (default: $prefix/recordings)])], [recordingsdir="$withval"], [recordingsdir="$prefix/recordings"])
c064a2a5
MJ
86AC_SUBST(recordingsdir)
87AC_DEFINE_UNQUOTED([SWITCH_RECORDINGS_DIR],"${recordingsdir}",[where to put recording files])
88
911e4a09
MJ
89if test "$sysconfdir" = "\${prefix}/etc" ; then
90 confdir="$prefix/conf"
91else
92 confdir="$sysconfdir"
93fi
94
5ccac21d
MJ
95sysconfdir="$confdir"
96
911e4a09 97AC_SUBST(confdir)
7da7790b 98AC_DEFINE_UNQUOTED([SWITCH_CONF_DIR],"${confdir}",[directory for configuration files])
911e4a09 99
8b3f71cc
MJ
100AC_SUBST(libdir)
101AC_SUBST(bindir)
102AC_SUBST(includedir)
103
f20ba4d1 104AC_ARG_WITH([pkgconfigdir],
78472897 105 [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])],
f20ba4d1
SK
106 [case "${withval}" in
107 yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;;
108 *) pkgconfigdir="${withval}" ;;
109 esac
110 ],
111 [pkgconfigdir="${libdir}/pkgconfig"]
112)
113AC_SUBST([pkgconfigdir])
114
6bc48b70
MJ
115#Set default language
116AC_LANG_C
4da77ea5
AM
117# Checks for programs.
118AC_PROG_CC
80eec6e5 119AC_PROG_CXX
40f18d30
MJ
120
121#check if the g++ compiler works
122AC_CACHE_CHECK([whether the C++ compiler works], [ac_cv_sys_cxx_works], [
123 AC_LANG_PUSH([C++])
124 AC_COMPILE_IFELSE([int main() { }], [ac_cv_sys_cxx_works=yes],
125 [ac_cv_sys_cxx_works=no])
126 AC_LANG_POP([C++])
127 ])
128[ if [ "x$ac_cv_sys_cxx_works" = "xno" ]; then ]
129 AC_MSG_FAILURE([The C++ compiler does not work. Please (re)install the C++ compiler])
130[ fi ]
131
bac1e3fd 132AC_PROG_AWK
4da77ea5 133AC_PROG_MAKE_SET
4da77ea5 134AC_PROG_INSTALL
3de6a7e9
MJ
135
136#override some default libtool behavior and invoke AC_PROG_LIBTOOL (see http://lists.gnu.org/archive/html/libtool/2007-03/msg00000.html)
137m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
138m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
139m4_defun([_LT_AC_LANG_RC_CONFIG], [:])
5b3f19fb 140AM_PROG_CC_C_O
bac1e3fd 141AC_PROG_LIBTOOL
4da77ea5 142
6bc48b70
MJ
143#Check for compiler vendor
144AX_COMPILER_VENDOR
145
146# Optimize
147AC_ARG_ENABLE(optimization,
148[AC_HELP_STRING([--enable-optimization],[Set if you want us to add max optimising compiler flags])],[enable_optimizer="$enableval"],[enable_optimizer="no"])
149
150if test "${enable_optimizer}" = "yes" ; then
151 AC_DEFINE([OPTIMZER],[],[Enable Optimization.])
152 AX_CC_MAXOPT
153fi
154
294b0779
MJ
155AX_PATH_LIBGNUTLS()
156
55b3e6cb 157# set defaults for use on all platforms
3f5c2bed
MJ
158SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include -I${switch_builddir}/src/include -I${switch_srcdir}/libs/libteletone/src"
159SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include -I${switch_builddir}/src/include -I${switch_srcdir}/libs/libteletone/src"
1953ac5c 160SWITCH_AM_LDFLAGS="-lm"
55b3e6cb
MJ
161
162#set SOLINK variable based on compiler and host
163if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
164 SOLINK="-Bdynamic -dy -G"
165elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
166 case "$host" in
5e7986bf
MJ
167 *darwin10.*)
168 SOLINK="-dynamic -force-flat-namespace"
169 ;;
6ae16d15 170 *darwin*)
55b3e6cb
MJ
171 SOLINK="-dynamic -bundle -force-flat-namespace"
172 ;;
872c349f
MB
173 *-solaris2*)
174 SOLINK="-shared -Xlinker"
175 ;;
55b3e6cb
MJ
176 *)
177 SOLINK="-shared -Xlinker -x"
178 ;;
179 esac
180else
181 AC_ERROR([Please update configure.in with SOLINK values for your compiler])
182fi
6bc48b70 183
55b3e6cb
MJ
184# set DYNAMIC_LIB_EXTEN
185# we should really be using libtool so we don't need to do this
6bc48b70 186case "$host" in
55b3e6cb
MJ
187 *cygwin* | *mingw*)
188 DYNAMIC_LIB_EXTEN="dll"
189 ;;
190 *)
191 DYNAMIC_LIB_EXTEN="so"
192 ;;
6bc48b70 193esac
55b3e6cb 194
4a77854b
SK
195##
196# detect libtool major version,
197# set libtool library extension based on this
198# to work around some brokeness when using 'la' with libtool-1.5
199#
200AC_MSG_CHECKING([libtool major version])
201libtool="${switch_builddir}/libtool"
df33a43a 202LIBTOOL_MAJOR_VERSION="`$libtool --version 2>/dev/null| sed -e 's/([[^)]]*)//g;s/^[[^0-9]]*//;s/[[- ]].*//g;q'| awk 'BEGIN { FS = "." } { print $1 }' `"
0c0a4a53 203if test -z "$LIBTOOL_MAJOR_VERSION" ; then
751c2894 204 LIBTOOL_MAJOR_VERSION="`sed -n -e '/^VERSION/{s/^.*=\"\{0,1\}\([[0-9]]\{1,\}\)\..*/\1/;p;}' ${switch_srcdir}/build/config/ltmain.sh`"
0c0a4a53
SK
205fi
206if test -z "$LIBTOOL_MAJOR_VERSION" ; then
207 AC_MSG_ERROR([Failed to detect your libtool version, please open a bug report on http://jira.freeswitch.org/])
208fi
4a77854b 209AC_MSG_RESULT([${LIBTOOL_MAJOR_VERSION}])
02141e30
MJ
210
211LIBTOOL_LIB_EXTEN="$DYNAMIC_LIB_EXTEN"
212
4a77854b 213if test "${LIBTOOL_MAJOR_VERSION}" = "2" ; then
02141e30
MJ
214 LIBTOOL_LIB_EXTEN="la"
215fi
4a77854b
SK
216AC_MSG_RESULT([using libtool library extension... ${LIBTOOL_LIB_EXTEN}])
217
02141e30 218
0f6a6c31 219# Enable 64 bit build
6d45f5f5 220AC_ARG_ENABLE(64,
0f6a6c31 221[AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"])
6d45f5f5 222
55b3e6cb
MJ
223# tweak compiler specific flags
224if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
225 APR_ADDTO(SWITCH_AM_CFLAGS, -KPIC)
226 APR_ADDTO(SWITCH_AM_CFLAGS, -DPIC)
99913ce3
MJ
227 APR_ADDTO(SWITCH_AM_CFLAGS, -erroff=E_END_OF_LOOP_CODE_NOT_REACHED)
228 APR_ADDTO(SWITCH_AM_CFLAGS, -errtags=yes)
2343708a 229 APR_ADDTO(SWITCH_AM_CFLAGS, -D__FUNCTION__=__func__ )
230 APR_ADDTO(SWITCH_AM_CFLAGS, -mt)
99913ce3 231 APR_ADDTO(SWITCH_AM_CXXFLAGS, -errtags=yes)
514bde18
MJ
232 APR_ADDTO(SWITCH_AM_CXXFLAGS, -KPIC)
233 APR_ADDTO(SWITCH_AM_CXXFLAGS, -DPIC)
f32f6f24 234 APR_ADDTO(SWITCH_AM_CXXFLAGS, "-features=extensions")
2343708a 235 APR_ADDTO(SWITCH_AM_CXXFLAGS, -D__FUNCTION__=__func__)
236 APR_ADDTO(SWITCH_AM_CXXFLAGS, -mt)
f32f6f24 237
55b3e6cb 238 APR_ADDTO(SWITCH_AM_LDFLAGS, -R${prefix}/lib)
6d45f5f5
MJ
239 if test "${enable_64}" = "yes"; then
240 APR_ADDTO(SWITCH_AM_CFLAGS, -m64)
5b2d20bf
MJ
241 APR_ADDTO(SWITCH_AM_CXXFLAGS, -m64)
242 APR_ADDTO(SWITCH_AM_LDFLAGS, -m64)
1953ac5c 243 LIBS="$LIBS -m64"
6d45f5f5 244 fi
55b3e6cb
MJ
245elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
246 APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC)
514bde18 247 APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC)
44ef8650 248 APR_ADDTO(SWITCH_AM_CFLAGS, -Werror)
1953ac5c 249 if test "${enable_64}" = "yes"; then
5e7986bf 250 case "$host" in
7803a752 251 *darwin10.*|*darwin9.*|*darwin8.*)
5e7986bf
MJ
252 APR_ADDTO(CFLAGS, -arch x86_64)
253 APR_ADDTO(LDFLAGS, -arch x86_64)
254 APR_ADDTO(CXXFLAGS, -arch x86_64)
255 ;;
7803a752
MJ
256 *)
257 LIBS="$LIBS -m64"
258 ;;
5e7986bf 259 esac
1953ac5c 260 fi
55b3e6cb
MJ
261fi
262
ffe2ad4b
MJ
263#
264# gcc visibility cflag checks
265#
266AC_ARG_ENABLE([visibility],
267 [AS_HELP_STRING([--disable-visibility], [Disable or enable API visibility support (default: use if available)])],
268 [enable_visibility="${enableval}"],
269 [enable_visibility="detect"]
270)
271HAVE_VISIBILITY="no"
272
273if test "x${enable_visibility}" != "xno" ; then
274
275 case "${ax_cv_c_compiler_vendor}" in
276 gnu)
277 save_CFLAGS="${CFLAGS}"
278 CFLAGS="${CFLAGS} -fvisibility=hidden"
279 AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])
280 AC_COMPILE_IFELSE(
281 [AC_LANG_PROGRAM(
282 [int foo __attribute__ ((visibility("default")));],
283 [;]
284 )],
285
286 [AC_MSG_RESULT([yes])
287 APR_ADDTO([SWITCH_AM_CFLAGS], [-fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
288 APR_ADDTO([SWITCH_AM_CXXFLAGS], [-fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
289 HAVE_VISIBILITY="yes"],
290
291 [AC_MSG_RESULT([no])]
292 )
293 CFLAGS="${save_CFLAGS}"
294 ;;
295
900907a2 296 sun)
96114867
SK
297 # save_CFLAGS="${CFLAGS}"
298 # CFLAGS="${CFLAGS} -xldscope=hidden"
299 # AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden])
300 # AC_COMPILE_IFELSE(
301 # [AC_LANG_PROGRAM(
302 # [int foo __attribute__ ((visibility("default")));],
303 # [;]
304 # )],
305 #
306 # [AC_MSG_RESULT([yes])
307 # APR_ADDTO([SWITCH_AM_CFLAGS], [-xldscope=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
308 # APR_ADDTO([SWITCH_AM_CXXFLAGS], [-xldscope=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
309 # HAVE_VISIBILITY="yes"],
310 #
311 # [AC_MSG_RESULT([no])]
312 # )
313 # CFLAGS="${save_CFLAGS}"
900907a2
MJ
314 ;;
315
ffe2ad4b
MJ
316 *)
317 if test "x${enable_visibility}" = "xyes" ; then
900907a2 318 AC_MSG_ERROR([Non-GNU / SUN compilers are currently unsupported])
ffe2ad4b 319 else
900907a2 320 AC_MSG_WARN([Non-GNU / SUN compilers are currently unsupported])
ffe2ad4b
MJ
321 fi
322 ;;
323 esac
324
325 #
326 # visibility explicitly requested but not supported by this compiler => error
327 #
328 if test "x${enable_visibility}" = "xyes" -a "x${HAVE_VISIBILITY}" = "xno" ; then
329 AC_MSG_ERROR([API visibility not supported by this compiler])
330 fi
331fi
332
fcd2a7b0
SK
333# Enable debugging (default: on)
334# (rename option if the default is changed)
2faabff7 335AC_ARG_ENABLE(debug,
fcd2a7b0 336[AC_HELP_STRING([--disable-debug],[build without debug information])],[enable_debug="$enableval"],[enable_debug="yes"])
2faabff7
AM
337
338if test "${enable_debug}" = "yes"; then
339 AC_DEFINE([DEBUG],[],[Enable extra debugging.])
554f476c 340 saved_CFLAGS="$CFLAGS"
44ea66c2 341 CFLAGS=
2faabff7 342 AX_CFLAGS_WARN_ALL_ANSI
02c7a3ac 343 SWITCH_ANSI_CFLAGS=$CFLAGS
554f476c 344 CFLAGS="$saved_CFLAGS"
2faabff7
AM
345
346 if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
347 APR_ADDTO(SWITCH_AM_CFLAGS, -g -ggdb)
37845b42 348 export DEBUG_CFLAGS="-g -ggdb"
2faabff7
AM
349 fi
350
351fi
352
59ba5a15
MJ
353AC_ARG_ENABLE(cpp,
354[AC_HELP_STRING([--disable-cpp],[build without cpp code])],[enable_cpp="$enableval"],[enable_cpp="yes"])
355
356AM_CONDITIONAL([ENABLE_CPP],[test "${enable_cpp}" = "yes"])
357
a8b87ffe
AM
358AC_ARG_ENABLE(srtp,
359[AC_HELP_STRING([--disable-srtp],[build without srtp support])],[enable_srtp="$enableval"],[enable_srtp="yes"])
360
361AM_CONDITIONAL([ENABLE_SRTP],[test "${enable_srtp}" = "yes"])
362
861bd209
BW
363AC_ARG_ENABLE(zrtp,
364 [AS_HELP_STRING([--enable-zrtp], [Compile with zrtp Support])],,[enable_zrtp="no"])
365if test "x$enable_zrtp" = "xyes" ; then
393b63b7 366 LIBS="-lpthread $LIBS"
861bd209
BW
367 APR_ADDTO(SWITCH_AM_CFLAGS, -DENABLE_ZRTP)
368fi
ae67ecce 369
c4d13331
MJ
370PA_LIBS=
371
372PKG_CHECK_MODULES(JACK, jack, have_jack=yes, have_jack=no)
373if test "x$have_jack" = "xyes" ; then
374PA_LIBS+=$JACK_LIBS
375fi
376
ae67ecce 377AC_CHECK_LIB(asound, snd_pcm_open, have_alsa=yes, have_alsa=no)
1911a262 378if test "x$have_alsa" = "xyes" ; then
c4d13331 379PA_LIBS+=-lasound
ae67ecce 380fi
c4d13331
MJ
381
382AC_SUBST(PA_LIBS)
ae67ecce 383
861bd209
BW
384AM_CONDITIONAL([ENABLE_ZRTP],[test "x$enable_zrtp" != "xno"])
385
a4a52620
SK
386AM_CONDITIONAL([WANT_DEBUG],[test "${enable_debug}" = "yes"])
387
cd788c1a
MJ
388AC_ARG_ENABLE(core-odbc-support,
389 [AS_HELP_STRING([--enable-core-odbc-support], [Compile with ODBC Support])],,[enable_core_odbc_support="no"])
390AX_LIB_ODBC
391if test "$ac_cv_found_odbc" = "yes" ; then
392 enable_core_odbc_support="yes"
393fi
ffc8e81b
TC
394if test "x$enable_core_odbc_support" != "xno"; then
395 AC_CHECK_LIB([odbc], [SQLDisconnect],, AC_MSG_ERROR([no usable libodbc; please install unixodbc devel package or equivalent]))
396fi
397
5cb354dd
EG
398AC_ARG_ENABLE(core-pgsql-support,
399 [AS_HELP_STRING([--enable-core-pgsql-support], [Compile with PGSQL Support])],,[enable_core_pgsql_support="no"])
400
401if test x"$enable_core_pgsql_support" = x"yes" ; then
402
403AC_PATH_PROG([PG_CONFIG], [pg_config], [no])
404if test "$PG_CONFIG" != "no"; then
405 AC_MSG_CHECKING([for PostgreSQL libraries])
5cb354dd
EG
406 POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`"
407 POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags` -L`$PG_CONFIG --libdir` -lpq"
408 POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'`
1fe96ac3
EG
409 POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.[0-9]+#\1#'`
410 POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL [0-9]+.([0-9]+).[0-9]+#\1#'`
411 POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL [0-9]+.[0-9]+.([0-9]+)#\1#'`
5cb354dd 412 AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available])
1fe96ac3
EG
413 AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against])
414 AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
415 AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against])
416 AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against])
5cb354dd
EG
417 AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent]))
418 AC_MSG_RESULT([yes])
5cb354dd
EG
419 SWITCH_AM_CXXFLAGS="$POSTGRESQL_CXXFLAGS $SWITCH_AM_CXXFLAGS"
420 SWITCH_AM_LDFLAGS="$POSTGRESQL_LDFLAGS $SWITCH_AM_LDFLAGS"
421else
422 AC_MSG_RESULT([no])
423 AC_MSG_FAILURE([Unabled to find pg_config in PATH. Is PostgreSQL installed?])
424fi
cd788c1a 425
5cb354dd 426fi
25c725c2
AM
427
428AC_ARG_ENABLE(timerfd-wrapper,
429[AC_HELP_STRING([--enable-timerfd-wrapper],[timerfd is in the kernel but not in your libc])],[enable_timer_fd_wrapper="$enableval"],[enable_timer_fd_wrapper="no"])
d28b2391
AM
430AM_CONDITIONAL([ENABLE_TIMERFD_WRAPPER],[test "x$enable_timer_fd_wrapper" != "xno"])
431
432
b544f60b 433AC_CHECK_LIB(z, inflateReset, have_libz=yes, AC_MSG_ERROR([no usable zlib; please install zlib devel package or equivalent]))
da195caa
MJ
434if test "x$have_libz" = "xyes" ; then
435APR_ADDTO(SWITCH_AM_LDFLAGS, -lz)
436fi
437
b544f60b
KR
438AC_CHECK_LIB(jpeg, jpeg_std_error,, AC_MSG_ERROR([no usable libjpeg; please install libjpeg devel package or equivalent]))
439
b017931c
MJ
440AC_CHECK_LIB(resolv, res_init, have_libresolv=yes, have_libresolv=no)
441if test "x$have_libresolv" = "xyes" ; then
442APR_ADDTO(SWITCH_AM_LDFLAGS, -lresolv)
443fi
444
3ec59cdb 445ESL_LDFLAGS=
a48da3b4
SK
446PLATFORM_CORE_LDFLAGS=
447PLATFORM_CORE_LIBS=
55b3e6cb
MJ
448# tweak platform specific flags
449case "$host" in
5e7986bf
MJ
450 *darwin10.*)
451 APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX)
452 APR_ADDTO(CFLAGS, -pipe -no-cpp-precomp)
453 APR_ADDTO(LDFLAGS, -pipe -bind_at_load)
454 APR_ADDTO(CXXFLAGS, -pipe)
455 APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC)
456 if test "x$enable_core_odbc_support" != "xno"; then
a48da3b4 457 APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation])
5e7986bf 458 fi
cdabd564 459 APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl])
5e7986bf 460 ;;
6ae16d15 461 *darwin*)
55b3e6cb
MJ
462 APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX)
463 APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC)
9a9ba4c3 464 if test "x$enable_core_odbc_support" != "xno"; then
a48da3b4 465 APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation])
9a9ba4c3 466 fi
cdabd564 467 APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl])
55b3e6cb
MJ
468 ;;
469 *-solaris2*)
cb1cb69e 470 APR_ADDTO(SWITCH_AM_CFLAGS, -DPATH_MAX=2048 -D__EXTENSIONS__)
54a9eba4 471 APR_ADDTO(SWITCH_AM_LDFLAGS, -lsendfile -lresolv -lsocket -lnsl -luuid)
bb33c4e7 472 APR_ADDTO(ESL_LDFLAGS, -lnsl -lsocket)
a48da3b4 473 APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt -lsendfile -lresolv -lsocket -lnsl -luuid])
55b3e6cb 474 ;;
f0b58efb
MJ
475 *bsd*)
476 APR_ADDTO(SWITCH_AM_CFLAGS, -I/usr/local/include)
041e3bf0 477 APR_ADDTO([PLATFORM_CORE_LIBS], [-lcrypt -lrt])
a48da3b4
SK
478 ;;
479 *linux*)
480 APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt])
f0b58efb 481 ;;
55b3e6cb
MJ
482esac
483
514bde18
MJ
484APR_REMOVEFROM(SWITCH_AM_CXXFLAGS, -std=c99)
485
55b3e6cb 486AC_SUBST(SWITCH_AM_CFLAGS)
02c7a3ac 487AC_SUBST(SWITCH_ANSI_CFLAGS)
514bde18 488AC_SUBST(SWITCH_AM_CXXFLAGS)
55b3e6cb 489AC_SUBST(SWITCH_AM_LDFLAGS)
3ec59cdb 490AC_SUBST(ESL_LDFLAGS)
a48da3b4
SK
491AC_SUBST(PLATFORM_CORE_LDFLAGS)
492AC_SUBST(PLATFORM_CORE_LIBS)
6bc48b70
MJ
493AC_SUBST(SOLINK)
494AC_SUBST(DYNAMIC_LIB_EXTEN)
02141e30 495AC_SUBST(LIBTOOL_LIB_EXTEN)
6bc48b70 496
4da77ea5
AM
497# Checks for header files.
498AC_HEADER_DIRENT
499AC_HEADER_STDC
6b6c83a7 500AC_CHECK_HEADERS([sys/types.h sys/resource.h sched.h wchar.h sys/filio.h sys/ioctl.h sys/select.h netdb.h execinfo.h])
56008e2b 501
56008e2b
AM
502if test x"$ac_cv_header_wchar_h" = xyes; then
503 HAVE_WCHAR_H_DEFINE=1
504else
505 HAVE_WCHAR_H_DEFINE=0
506fi
507AC_SUBST(HAVE_WCHAR_H_DEFINE)
4da77ea5 508
6b6c83a7
JL
509# Needed by Abyss on Solaris:
510
511if test x"$ac_cv_header_sys_filio_h" = xyes; then
512 HAVE_SYS_FILIO_H_DEFINE=1
513else
514 HAVE_SYS_FILIO_H_DEFINE=0
515fi
516AC_SUBST(HAVE_SYS_FILIO_H_DEFINE)
517
518# Needed by Abyss on Solaris:
519
520if test x"$ac_cv_header_sys_ioctl_h" = xyes; then
521 HAVE_SYS_IOCTL_H_DEFINE=1
522else
523 HAVE_SYS_IOCTL_H_DEFINE=0
524fi
525AC_SUBST(HAVE_SYS_IOCTL_H_DEFINE)
526
527if test x"$ac_cv_header_sys_select_h" = xyes; then
528 HAVE_SYS_SELECT_H_DEFINE=1
529else
530 HAVE_SYS_SELECT_H_DEFINE=0
531fi
532AC_SUBST(HAVE_SYS_SELECT_H_DEFINE)
533
4da77ea5
AM
534# Checks for typedefs, structures, and compiler characteristics.
535AC_C_CONST
536AC_C_INLINE
537AC_TYPE_SIZE_T
538AC_HEADER_TIME
539AC_STRUCT_TM
540
541# Checks for library functions.
542AC_PROG_GCC_TRADITIONAL
543AC_FUNC_MALLOC
544AC_TYPE_SIGNAL
545AC_FUNC_STRFTIME
d91f67d0 546AC_CHECK_FUNCS([gethostname vasprintf mmap mlock mlockall usleep getifaddrs timerfd_create getdtablesize posix_openpt])
ea5c0c21 547AC_CHECK_FUNCS([sched_setscheduler setpriority setrlimit setgroups initgroups])
4062b636 548AC_CHECK_FUNCS([wcsncmp setgroups asprintf setenv pselect gettimeofday localtime_r gmtime_r strcasecmp stricmp _stricmp])
b382c0a4 549
8bcf3b4f
SK
550# Check availability and return type of strerror_r
551# (NOTE: apr-1-config sets -D_GNU_SOURCE at build-time, need to run the check with it too)
552save_CPPFLAGS="$CPPFLAGS"
553CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
554AC_FUNC_STRERROR_R
555CPPFLAGS="$save_CPPFLAGS"
556
ea5c0c21
MJ
557AX_HAVE_CPU_SET
558
eb9f9fb2 559AC_CHECK_LIB(rt, clock_gettime, [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])])
d314f254 560AC_CHECK_LIB(rt, clock_getres, [AC_DEFINE(HAVE_CLOCK_GETRES, 1, [Define if you have clock_getres()])])
eb9f9fb2 561AC_CHECK_LIB(rt, clock_nanosleep, [AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define if you have clock_nanosleep()])])
4062b636 562AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
eb9f9fb2 563
d91f67d0
AM
564AC_CHECK_FILE(/dev/ptmx, [AC_DEFINE(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx])])
565AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY, 1, [Define if you have openpty()])])
566
bf988471 567AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[
21159328
MJ
568#include <sys/types.h>
569#include <time.h>])
570
bf988471 571AC_CHECK_MEMBERS([struct tm.tm_zone],,,[
21159328
MJ
572#include <sys/types.h>
573#include <time.h>])
574
b382c0a4
MJ
575AC_CHECK_DECL([RLIMIT_MEMLOCK],
576 [AC_DEFINE([HAVE_RLIMIT_MEMLOCK],[1],[RLIMIT_MEMLOCK constant for setrlimit])],,
577 [#ifdef HAVE_SYS_RESOURCE_H
578 #include <sys/resource.h>
579 #endif])
580
581AC_CHECK_DECL([SCHED_RR],
582 [AC_DEFINE([HAVE_SCHED_RR],[1],[SCHED_RR constant for sched_setscheduler])],,
583 [#ifdef HAVE_SCHED_H
584 #include <sched.h>
585 #endif])
586
817439d7
AM
587AC_CHECK_DECL([SCHED_FIFO],
588 [AC_DEFINE([HAVE_SCHED_FIFO],[1],[SCHED_FIFO constant for sched_setscheduler])],,
589 [#ifdef HAVE_SCHED_H
590 #include <sched.h>
591 #endif])
592
b382c0a4
MJ
593#
594# use mlockall only on linux (for now; if available)
595#
596if test "x${ac_cv_func_mlockall}" = "xyes"; then
597 AC_MSG_CHECKING([whether to use mlockall])
598 case "$host" in
599 *-linux-*)
600 AC_DEFINE([USE_MLOCKALL],[1],[Enable mlockall support])
601 AC_MSG_RESULT([yes])
602 USE_MLOCKALL=yes
603 ;;
604 *-freebsd*)
883de14f
JL
605 APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC)
606 APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC)
b382c0a4
MJ
607 AC_MSG_RESULT([no, broken for non-root users])
608 ;;
609 *)
610 AC_MSG_RESULT([no])
611 ;;
612 esac
613
614 #
615 # setrlimit prerequisites
616 #
617 if test "x${USE_MLOCKALL}" = "xyes" -a \
618 "x${ac_cv_func_setrlimit}" = "xyes" -a \
619 "x${ac_cv_have_decl_RLIMIT_MEMLOCK}" = "xyes"
620 then
621 AC_DEFINE([USE_SETRLIMIT],[1],[Use setrlimit to disable mlock limit for non-root users])
622 fi
623fi
624
625#
626# sched_setcheduler + round-robin scheduler prerequisites
627#
628if test "x${ac_cv_func_sched_setscheduler}" = "xyes" -a \
629 "x${ac_cv_have_decl_SCHED_RR}" = "xyes"
630then
631 AC_DEFINE([USE_SCHED_SETSCHEDULER],[1],[Enable round-robin scheduler using sched_setscheduler])
632fi
4062b636
AM
633#
634# xmlrpc-c checks
635#
636
6b6c83a7 637AC_CHECK_FUNCS(setenv strtoll strtoull strtoq strtouq __strtoll __strtoull)
4062b636
AM
638
639HAVE_LIBWWW_SSL_DEFINE=0
640AC_SUBST(HAVE_LIBWWW_SSL_DEFINE)
641
642DIRECTORY_SEPARATOR="/"
643AC_SUBST(DIRECTORY_SEPARATOR)
644
645va_list_is_array=no
646AC_MSG_CHECKING(whether va_list is an array)
647AC_TRY_COMPILE([
648#include <stdarg.h>
649], [va_list list1, list2; list1 = list2;], ,
650va_list_is_array=yes)
651AC_MSG_RESULT($va_list_is_array)
652if test x"$va_list_is_array" = xyes; then
653 VA_LIST_IS_ARRAY_DEFINE=1
654else
655 VA_LIST_IS_ARRAY_DEFINE=0
656fi
657AC_SUBST(VA_LIST_IS_ARRAY_DEFINE)
658
554f476c 659
4062b636
AM
660AC_MSG_CHECKING(whether compiler has __attribute__)
661AC_TRY_COMPILE(, [int x __attribute__((__unused__));],
662compiler_has_attribute=yes,
663compiler_has_attribute=no)
664AC_MSG_RESULT($compiler_has_attribute)
665if test x"$compiler_has_attribute" = xyes; then
666 ATTR_UNUSED="__attribute__((__unused__))"
667else
668 ATTR_UNUSED=
669fi
670AC_SUBST(ATTR_UNUSED)
671
672
554f476c
MJ
673saved_CFLAGS="$CFLAGS"
674AC_CACHE_CHECK([whether compiler supports -Wdeclaration-after-statement], [ac_cv_gcc_declaration_after_statement], [
675CFLAGS="$CFLAGS -Wdeclaration-after-statement"
676AC_TRY_COMPILE([],[return 0;],[ac_cv_gcc_declaration_after_statement=yes],[ac_cv_gcc_declaration_after_statement=no])
677])
678AC_MSG_RESULT($ac_cv_gcc_declaration_after_statement)
679if test x"$ac_cv_gcc_declaration_after_statement" = xyes; then
680 APR_ADDTO(SWITCH_ANSI_CFLAGS, -Wdeclaration-after-statement)
681fi
682CFLAGS="$saved_CFLAGS"
4da77ea5 683
eb8ff5a0
MOC
684# Tested and fixed lot of modules, but some are untested. Will be added back when the core team decide it ready
685# Untested modules : mod_osp mod_soundtouch mod_sangoma_codec mod_dingaling mod_opal mod_skypopen mod_h323 mod_khomp
686# mod_unimrcp mod_cepstral mod_erlang_event mod_snmp mod_perl mod_java mod_managed
687#
688#saved_CFLAGS="$CFLAGS"
689#AC_CACHE_CHECK([whether compiler supports -Wunused-but-set-variable], [ac_cv_gcc_unused_but_set_variable], [
690#CFLAGS="$CFLAGS -Wunused-but-set-variable"
691#AC_TRY_COMPILE([],[return 0;],[ac_cv_gcc_unused_but_set_variable=yes],[ac_cv_gcc_unused_but_set_variable=no])
692#])
693#AC_MSG_RESULT($ac_cv_gcc_unused_but_set_variable)
694#if test x"$ac_cv_gcc_unused_but_set_variable" = xyes; then
695# APR_ADDTO(SWITCH_ANSI_CFLAGS, -Wunused-but-set-variable)
696#fi
697#CFLAGS="$saved_CFLAGS"
f952719e 698
44cc7d5c 699AC_C_BIGENDIAN(AC_DEFINE([SWITCH_BYTE_ORDER],__BIG_ENDIAN,[Big Endian]),AC_DEFINE([SWITCH_BYTE_ORDER],__LITTLE_ENDIAN,[Little Endian]))
49a0eb29 700
42e78242
MJ
701# Checks for integer size
702AC_CHECK_SIZEOF(char, 1)
703AC_CHECK_SIZEOF(int, 4)
704AC_CHECK_SIZEOF(long, 4)
705AC_CHECK_SIZEOF(short, 2)
706AC_CHECK_SIZEOF(long long, 8)
707AC_TYPE_SIZE_T
708AC_CHECK_TYPE(ssize_t, int)
709
710# Checks for pointer size
711AC_CHECK_SIZEOF(void*, 4)
712
713if test "x$ac_cv_sizeof_voidp" != "x"; then
714 voidp_size=$ac_cv_sizeof_voidp
715else
716 AC_ERROR([Cannot determine size of void*])
717fi
718
719if test "$ac_cv_sizeof_short" = "2"; then
720 short_value=short
721fi
722if test "$ac_cv_sizeof_int" = "4"; then
723 int_value=int
724fi
725
726if test "$ac_cv_sizeof_int" = "8"; then
727 int64_t_fmt='#define SWITCH_INT64_T_FMT "d"'
728 uint64_t_fmt='#define SWITCH_UINT64_T_FMT "u"'
729 int64_value="int"
730 long_value=int
731elif test "$ac_cv_sizeof_long" = "8"; then
732 int64_t_fmt='#define SWITCH_INT64_T_FMT "ld"'
733 uint64_t_fmt='#define SWITCH_UINT64_T_FMT "lu"'
734 int64_value="long"
735 long_value=long
764b7958 736 case "$host" in
f6fe2667 737 *-solaris2*|*apple-darwin*|*-openbsd*)
764b7958
MJ
738 if test "$ac_cv_sizeof_long_long" = "8"; then
739 int64_t_fmt='#define SWITCH_INT64_T_FMT "lld"'
740 uint64_t_fmt='#define SWITCH_UINT64_T_FMT "llu"'
741 int64_value="long long"
742 long_value="long long"
743 fi
744 ;;
745 esac
42e78242
MJ
746elif test "$ac_cv_sizeof_long_long" = "8"; then
747 int64_t_fmt='#define SWITCH_INT64_T_FMT "lld"'
748 uint64_t_fmt='#define SWITCH_UINT64_T_FMT "llu"'
749 int64_value="long long"
750 long_value="long long"
751elif test "$ac_cv_sizeof_longlong" = "8"; then
752 int64_t_fmt='#define SWITCH_INT64_T_FMT "qd"'
753 uint64_t_fmt='#define SWITCH_UINT64_T_FMT "qu"'
754 int64_value="__int64"
755 long_value="__int64"
756else
757 AC_ERROR([could not detect a 64-bit integer type])
758fi
759
760if test "$ac_cv_type_size_t" = "yes"; then
761 size_t_value="size_t"
762else
763 size_t_value="switch_int32_t"
764fi
765
766if test "$ac_cv_type_ssize_t" = "yes"; then
767 ssize_t_value="ssize_t"
768else
769 ssize_t_value="switch_int32_t"
770fi
771
772APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], ssize_t, 8)
773
774if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
775 ssize_t_fmt='#define SWITCH_SSIZE_T_FMT "d"'
776elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
777 ssize_t_fmt='#define SWITCH_SSIZE_T_FMT "ld"'
778else
779 ssize_t_fmt='#error Can not determine the proper size for ssize_t'
780fi
781
782APR_CHECK_SIZEOF_EXTENDED([#include <stddef.h>], size_t, 8)
783
784if test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
785 size_t_fmt='#define SWITCH_SIZE_T_FMT "d"'
786elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
787 size_t_fmt='#define SWITCH_SIZE_T_FMT "ld"'
788else
d90bac38 789 size_t_fmt='#define SWITCH_SIZE_T_FMT "zu"'
42e78242
MJ
790fi
791
792# Basically, we have tried to figure out the correct format strings
793# for SWITCH types which vary between platforms, but we don't always get
794# it right. If you find that we don't get it right for your platform,
795# you can override our decision below.
796# NOTE: borrowed much of this logic from apr.
797case $host in
798 s390*linux*)
799 # uniquely, the 31-bit Linux/s390 uses "unsigned long int"
800 # for size_t rather than "unsigned int":
801 size_t_fmt='#define SWITCH_SIZE_T_FMT "lu"'
802 ssize_t_fmt='#define SWITCH_SSIZE_T_FMT "ld"'
803 ;;
804 *-os2*)
805 size_t_fmt='#define SWITCH_SIZE_T_FMT "lu"'
806 ;;
6d66ecfd
MJ
807 *-openbsd*)
808 size_t_fmt='#define SWITCH_SIZE_T_FMT "ld"'
809 ;;
42e78242
MJ
810 *aix4*|*aix5*)
811 ssize_t_fmt='#define SWITCH_SSIZE_T_FMT "ld"'
812 size_t_fmt='#define SWITCH_SIZE_T_FMT "ld"'
813 ;;
814 *beos*)
815 ssize_t_fmt='#define SWITCH_SSIZE_T_FMT "ld"'
816 size_t_fmt='#define SWITCH_SIZE_T_FMT "ld"'
817 ;;
818 *apple-darwin*)
819 osver=`uname -r`
820 case $osver in
821 [0-7].*)
822 ssize_t_fmt='#define SWITCH_SSIZE_T_FMT "d"'
823 ;;
824 *)
825 ssize_t_fmt='#define SWITCH_SSIZE_T_FMT "ld"'
826 ;;
827 esac
828 size_t_fmt='#define SWITCH_SIZE_T_FMT "lu"'
829 ;;
830esac
831
832AC_SUBST(voidp_size)
833AC_SUBST(short_value)
834AC_SUBST(int_value)
835AC_SUBST(long_value)
836AC_SUBST(int64_value)
837AC_SUBST(size_t_value)
838AC_SUBST(ssize_t_value)
839AC_SUBST(int64_t_fmt)
840AC_SUBST(uint64_t_fmt)
841AC_SUBST(ssize_t_fmt)
842AC_SUBST(size_t_fmt)
42e78242 843
f6fe2667
MJ
844case $host in
845 *-openbsd*)
846 # OpenBSD's gunzip and friends don't like -d because its redundant, only gzip does
847 AC_PATH_PROGS(ZCAT, gzip)
848 ;;
849 *)
850 AC_PATH_PROGS(ZCAT, gunzip gzcat gzip zcat)
851 ;;
852esac
853
50328a66
TC
854AC_PATH_PROGS(BZIP, bzip2)
855AC_PATH_PROGS(XZ, xz)
bc34fb76
MJ
856AC_PATH_PROGS(TAR, gtar tar)
857AC_PATH_PROGS(WGET, wget)
858AC_PATH_PROGS(CURL, curl)
d2cf7f86 859GETLIB="cd $switch_srcdir/libs && ${SHELL} $switch_builddir/build/getlib.sh"
c99d8c9b 860AC_SUBST(GETLIB)
17d52112
MJ
861GETG729="cd $switch_srcdir/libs && ${SHELL} $switch_builddir/build/getg729.sh"
862AC_SUBST(GETG729)
d2cf7f86 863GETSOUNDS="${SHELL} $switch_builddir/build/getsounds.sh"
3d5fcabe 864AC_SUBST(GETSOUNDS)
c99d8c9b 865
bc34fb76 866
493fc648
MJ
867LIBCURL_DEPS=
868
869AC_ARG_WITH(libcurl,
870 AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]),
871 [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
872
e704f021
MP
873AC_CACHE_CHECK([whether to use system libcurl library], [ac_cv_use_system_curl], [
874 LIBCURL_CHECK_CONFIG([yes], [7.13.0], [ac_cv_use_system_curl='yes'], [ac_cv_use_system_curl='no'])
875])
876
493fc648
MJ
877if test "$_libcurl_with" = "no" ; then
878 ac_cv_use_system_curl=no;
879fi
880if test "$_libcurl_with" = "yes" ; then
881 ac_cv_use_system_curl=yes;
882fi
883
36f0a5b8
MJ
884if test "$ac_cv_use_system_curl" = "yes" ; then
885AC_CACHE_CHECK([whether to use system libcurl library], [ac_cv_curl_usable], [
886 AC_CHECK_LIB(curl, Curl_setopt, [ac_cv_curl_usable="yes"], [ac_cv_curl_usable="no"])
887])
888fi
889
890if test "$ac_cv_curl_usable" != "yes" ; then
891 ac_cv_use_system_curl=no;
892fi
893
493fc648
MJ
894if test "$ac_cv_use_system_curl" != "yes" ; then
895 LIBCURL_DEPS='${switch_builddir}/libs/curl/lib/libcurl.la'
896 LIBCURL='${switch_builddir}/libs/curl/lib/libcurl.la'
897 LIBCURL_CPPFLAGS='-I${switch_srcdir}/libs/curl/include'
a7238d0b
AM
898else
899 SWITCH_AM_LDFLAGS="$LIBCURL $SWITCH_AM_LDFLAGS"
493fc648
MJ
900fi
901
a7238d0b
AM
902SWITCH_AM_CFLAGS="$LIBCURL_CPPFLAGS $SWITCH_AM_CFLAGS"
903SWITCH_AM_CXXFLAGS="$LIBCURL_CPPFLAGS $SWITCH_AM_CXXFLAGS"
904
74ed2cef
MJ
905AM_CONDITIONAL([CURL_BUILTIN],[test "${ac_cv_use_system_curl}" != "yes"])
906
f85be6ff
MJ
907AC_SUBST(LIBCURL_DEPS)
908
4d62a1ad 909
c5c13c26 910AC_ARG_ENABLE(core-libedit-support,
2bcd991b 911 [AS_HELP_STRING([--disable-core-libedit-support], [Compile without libedit Support])], [enable_core_libedit_support="$enableval"], [enable_core_libedit_support="yes"])
c5c13c26 912
28213aad
AM
913if test "$enable_core_libedit_support" = "yes" ; then
914 AC_CHECK_LIB(ncurses, tgetent,,
915 [AC_CHECK_LIB(curses, tgetent,,
916 [AC_MSG_ERROR([libtermcap, libcurses or libncurses are required!])] )] )
917fi
918
219a2ecc
AT
919SAC_OPENSSL
920
9d6d8a1c
AT
921if test x$HAVE_OPENSSL = x1; then
922 openssl_CFLAGS="$openssl_CFLAGS -DHAVE_OPENSSL";
1d18b58b 923 APR_ADDTO(SWITCH_AM_CFLAGS, -DHAVE_OPENSSL)
9d6d8a1c
AT
924fi
925
e69fe7e3 926AX_CHECK_JAVA
7df787b7 927
753fa8fb 928
31b743d6
MJ
929AM_CONDITIONAL([HAVE_ODBC],[test "x$enable_core_odbc_support" != "xno"])
930AM_CONDITIONAL([HAVE_LIBEDIT],[test "x$enable_core_libedit_support" != "xno"])
778a82cc 931AM_CONDITIONAL([HAVE_MYSQL],[test "$found_mysql" = "yes"])
49a0eb29 932
e8c88aa1
SK
933#
934# Python checks for mod_python
935#
936AC_ARG_WITH(
937 [python],
938 [AS_HELP_STRING([--with-python], [Use system provided version of python (default: try)])],
939 [with_python="$withval"],
940 [with_python="try"]
941)
942
e8c88aa1
SK
943if test "$with_python" != "no"
944then
2d14539e
SK
945 save_CFLAGS="$CFLAGS"
946 save_LIBS="$LIBS"
947
e8c88aa1
SK
948 if test "$with_python" != "yes" -a "$with_python" != "try" ; then
949 AC_MSG_CHECKING([for python])
950 if test ! -x "$with_python" ; then
951 AC_MSG_ERROR([Specified python does not exist or is not executable: $with_python])
952 fi
953 AC_MSG_RESULT([$with_python])
954 AC_SUBST([PYTHON], ["$with_python"])
955 else
956 AC_PATH_PROG([PYTHON], ["python"], ["no"], ["$PATH:/usr/bin:/usr/local/bin"])
957 fi
958
959 if test "$PYTHON" != "no" ; then
960 AC_MSG_CHECKING([python version])
961 PYTHON_VER="`$PYTHON -V 2>&1 | cut -d' ' -f2`"
962
963 if test -z "$PYTHON_VER" ; then
964 AC_MSG_ERROR([Unable to detect python version])
965 fi
966 AC_MSG_RESULT([$PYTHON_VER])
967
2d14539e 968 AC_MSG_CHECKING([for python distutils])
baf944eb
SK
969 python_result="`$PYTHON -c 'import distutils;' 2>&1`"
970 if test -z "$python_result" ; then
2d14539e 971 python_has_distutils="yes"
baf944eb
SK
972 else
973 python_has_distutils="no"
2d14539e
SK
974 fi
975 AC_MSG_RESULT([$python_has_distutils])
976
baf944eb 977 if test "$python_has_distutils" != "no" ; then
f08ac862
SK
978 AC_MSG_CHECKING([location of site-packages])
979
83680470 980 PYTHON_SITE_DIR="`$PYTHON -c 'from distutils import sysconfig; print(sysconfig.get_python_lib(0));'`"
f08ac862
SK
981
982 if test -z "$PYTHON_SITE_DIR" ; then
983 AC_MSG_ERROR([Unable to detect python site-packages path])
984 elif test ! -d "$PYTHON_SITE_DIR" ; then
985 AC_MSG_ERROR([Path $PYTHON_SITE_DIR returned by python does not exist!])
986 fi
987 AC_MSG_RESULT([$PYTHON_SITE_DIR])
988 AC_SUBST([PYTHON_SITE_DIR], [$PYTHON_SITE_DIR])
989
2d14539e
SK
990 #
991 # python distutils found, get settings from python directly
992 #
93129e32 993 PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; flags = [[\"-I\" + sysconfig.get_python_inc(0), \"-I\" + sysconfig.get_python_inc(1), \" \".join(sysconfig.get_config_var(\"CFLAGS\").split())]]; print(\" \".join(flags));' | sed -e 's/-arch i386//g;s/-arch x86_64//g'`"
83680470
SK
994 PYTHON_LDFLAGS="`$PYTHON -c 'from distutils import sysconfig; libs = sysconfig.get_config_var(\"LIBS\").split() + sysconfig.get_config_var(\"SYSLIBS\").split(); libs.append(\"-lpython\"+sysconfig.get_config_var(\"VERSION\")); print(\" \".join(libs));'`"
995 PYTHON_LIB="`$PYTHON -c 'from distutils import sysconfig; print(\"python\" + sysconfig.get_config_var(\"VERSION\"));'`"
996 PYTHON_LIBDIR="`$PYTHON -c 'from distutils import sysconfig; print(sysconfig.get_config_var(\"LIBDIR\"));'`"
ba892c27
SK
997
998 # handle python being installed into /usr/local
999 AC_MSG_CHECKING([python libdir])
1000 if test -z "`echo $PYTHON_LIBDIR | grep "/usr/lib"`" ; then
1001 PYTHON_LDFLAGS="-L$PYTHON_LIBDIR $PYTHON_LDFLAGS"
1002 LIBS="-L$PYTHON_LIBDIR $LIBS"
1003 fi
1004 AC_MSG_RESULT([$PYTHON_LIBDIR])
e8c88aa1 1005
2d14539e
SK
1006 # check libpython
1007 AC_CHECK_LIB([$PYTHON_LIB], [main], [has_libpython="yes"], [has_libpython="no"])
1008
1009 if test "$has_libpython" = "no" ; then
1010 AS_IF([test "$with_python" = "try"],
1011 [AC_MSG_WARN([$PYTHON_LIB is unusable])],
1012 [AC_MSG_ERROR([$PYTHON_LIB is unusable])]
1013 )
1014 fi
e8c88aa1
SK
1015
1016 # check whether system libpython is usable and has threads support
2d14539e 1017 CFLAGS="$PYTHON_CFLAGS"
e8c88aa1
SK
1018 LIBS="$PYTHON_LDFLAGS"
1019 AC_CHECK_FUNC([PyThread_init_thread], [python_has_threads="yes"], [python_has_threads="no"])
e8c88aa1 1020
2d14539e
SK
1021 if test "$python_has_threads" = "no"; then
1022 AS_IF([test "$with_python" = "try"],
1023 [AC_MSG_WARN([Your python lacks threads support, can not build mod_python])],
1024 [AC_MSG_ERROR([Your python lacks threads support, can not build mod_python])]
1025 )
e8c88aa1
SK
1026 else
1027 AC_MSG_NOTICE([Your python seems OK, do not forget to enable mod_python in modules.conf])
2d14539e 1028 AC_SUBST([PYTHON_CFLAGS], [$PYTHON_CFLAGS])
e8c88aa1
SK
1029 AC_SUBST([PYTHON_LDFLAGS], [$PYTHON_LDFLAGS])
1030 fi
1031 else
2d14539e 1032 AS_IF([test "$with_python" = "try"],
baf944eb
SK
1033 [AC_MSG_WARN([Could not find or use python distutils module: $python_result])],
1034 [AC_MSG_ERROR([Could not find or use python distutils module: $python_result])]
2d14539e 1035 )
e8c88aa1
SK
1036 fi
1037
2d14539e
SK
1038 LIBS="$save_LIBS"
1039 CFLAGS="$save_CFLAGS"
1040
1041 unset python_has_threads
1042 unset python_has_distutils
baf944eb 1043 unset python_result
2d14539e
SK
1044 else
1045 AS_IF([test "$with_python" = "try"],
1046 [AC_MSG_WARN([Could not find python, mod_python will not build, use --with-python to specify the location])],
1047 [AC_MSG_ERROR([Could not find python, use --with-python to specify the location])]
1048 )
e8c88aa1
SK
1049 fi
1050else
1051 AC_MSG_WARN([python support disabled, building mod_python will fail!])
1052fi
1053
ea0316b8
AT
1054CHECK_ERLANG
1055
42e78242 1056AC_CONFIG_FILES([Makefile
7b3d3f7e
AM
1057 build/Makefile
1058 src/Makefile
1059 src/mod/Makefile
aad61cad 1060 src/mod/applications/mod_expr/Makefile
fa9a59a8 1061 src/mod/applications/mod_spandsp/Makefile
dc06a039 1062 src/mod/applications/mod_osp/Makefile
ea181ca4 1063 src/mod/applications/mod_stress/Makefile
a31222ac 1064 src/mod/applications/mod_hash/Makefile
17d52112 1065 src/mod/codecs/mod_com_g729/Makefile
fa511355 1066 src/mod/endpoints/mod_html5/Makefile
59472c23 1067 src/mod/endpoints/mod_portaudio/Makefile
ad4eb5e0 1068 src/mod/endpoints/mod_skinny/Makefile
99e55ae0 1069 src/mod/endpoints/mod_skypopen/Makefile
7b3d3f7e 1070 src/mod/endpoints/mod_sofia/Makefile
59472c23 1071 src/mod/formats/mod_portaudio_stream/Makefile
7b3d3f7e
AM
1072 src/mod/asr_tts/mod_unimrcp/Makefile
1073 src/mod/languages/mod_java/Makefile
9b8392bc 1074 src/mod/languages/mod_lua/Makefile
7b3d3f7e 1075 src/mod/languages/mod_python/Makefile
0c1ae13d 1076 src/mod/languages/mod_spidermonkey/Makefile
7b3d3f7e
AM
1077 src/mod/event_handlers/mod_erlang_event/Makefile
1078 src/include/switch_am_config.h
1079 build/getsounds.sh
1080 build/getlib.sh
17d52112 1081 build/getg729.sh
68b58406 1082 build/freeswitch.pc
7b3d3f7e 1083 build/modmake.rules
7b3d3f7e 1084 libs/xmlrpc-c/xmlrpc_config.h
6b6c83a7
JL
1085 libs/xmlrpc-c/config.mk
1086 libs/xmlrpc-c/srcdir.mk
1087 libs/xmlrpc-c/stamp-h
7b3d3f7e 1088 scripts/gentls_cert])
4da77ea5 1089
a6e9f279 1090AM_CONDITIONAL(ISLINUX, [test `uname -s` = Linux])
db399276 1091AM_CONDITIONAL(ISMAC, [test `uname -s` = Darwin])
a092a55a 1092AM_CONDITIONAL(IS64BITLINUX, [test `uname -m` = x86_64])
a6e9f279 1093
c7753b06
MJ
1094#some vars to sub into the Makefile.am's
1095#LIBS+=> core.log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat core.log;fi;if test "$$error" = "yes";then exit 1;fi
1096LIBTOOL='`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`'
1097TOUCH_TARGET='if test -f "$@";then touch "$@";fi;'
afe7d97f 1098CONF_MODULES='$$(grep -v "\#" $(switch_builddir)/modules.conf | sed -e "s|^.*/||" | sort | uniq )'
b9f2bdfb 1099CONF_DISABLED_MODULES='$$(grep "\#" $(switch_builddir)/modules.conf | grep -v "\#\#" | sed -e "s|^.*/||" | sort | uniq )'
afe7d97f
MJ
1100OUR_MODS='$$(if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods="$$(for i in $$tmp_mods ; do echo $$i-all ; done )"; echo $$mods )'
1101OUR_CLEAN_MODS='$$(if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods="$$(for i in $$tmp_mods ; do echo $$i-clean ; done )"; echo $$mods )'
1102OUR_INSTALL_MODS='$$(if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods="$$(for i in $$tmp_mods ; do echo $$i-install ; done)"; echo $$mods )'
1103OUR_UNINSTALL_MODS='$$(if test -z "$(MODULES)" ; then tmp_mods="$(CONF_MODULES)"; else tmp_mods="$(MODULES)" ; fi ; mods="$$(for i in $$tmp_mods ; do echo $$i-uninstall ; done)"; echo $$mods )'
1104OUR_DISABLED_MODS='$$(tmp_mods="$(CONF_DISABLED_MODULES)"; mods="$$(for i in $$tmp_mods ; do echo $$i-all ; done )"; echo $$mods )'
1105OUR_DISABLED_CLEAN_MODS='$$(tmp_mods="$(CONF_DISABLED_MODULES)"; mods="$$(for i in $$tmp_mods ; do echo $$i-clean ; done )"; echo $$mods )'
1106OUR_DISABLED_INSTALL_MODS='$$(tmp_mods="$(CONF_DISABLED_MODULES)"; mods="$$(for i in $$tmp_mods ; do echo $$i-install ; done)"; echo $$mods )'
1107OUR_DISABLED_UNINSTALL_MODS='$$(tmp_mods="$(CONF_DISABLED_MODULES)"; mods="$$(for i in $$tmp_mods ; do echo $$i-uninstall ; done)"; echo $$mods )'
ed960392
AM
1108
1109AM_MAKEFLAGS='"OUR_MODULES=$(OUR_MODS)" "OUR_CLEAN_MODULES=$(OUR_CLEAN_MODS)" "OUR_INSTALL_MODULES=$(OUR_INSTALL_MODS)" "OUR_UNINSTALL_MODULES=$(OUR_UNINSTALL_MODS)" "OUR_DISABLED_MODULES=$(OUR_DISABLED_MODS)" "OUR_DISABLED_CLEAN_MODULES=$(OUR_DISABLED_CLEAN_MODS)" "OUR_DISABLED_INSTALL_MODULES=$(OUR_DISABLED_INSTALL_MODS)" "OUR_DISABLED_UNINSTALL_MODULES=$(OUR_DISABLED_UNINSTALL_MODS)" `test -n "$(VERBOSE)" || echo -s`'
5f053e18 1110#AM_MAKEFLAGS='`test -n "$(VERBOSE)" || echo -s`'
c7753b06
MJ
1111AC_SUBST(LIBTOOL)
1112AC_SUBST(TOUCH_TARGET)
ed960392 1113AC_SUBST(CONF_DISABLED_MODULES)
5f053e18 1114AC_SUBST(CONF_MODULES)
ed960392 1115
5f053e18
MJ
1116AC_SUBST(OUR_MODS)
1117AC_SUBST(OUR_CLEAN_MODS)
1118AC_SUBST(OUR_INSTALL_MODS)
1119AC_SUBST(OUR_UNINSTALL_MODS)
ed960392
AM
1120AC_SUBST(OUR_DISABLED_MODS)
1121AC_SUBST(OUR_DISABLED_CLEAN_MODS)
1122AC_SUBST(OUR_DISABLED_INSTALL_MODS)
1123AC_SUBST(OUR_DISABLED_UNINSTALL_MODS)
c7753b06
MJ
1124AC_SUBST(AM_MAKEFLAGS)
1125
74fd6fb6 1126ac_configure_args="$ac_configure_args CONFIGURE_CFLAGS='$CFLAGS' CONFIGURE_CXXFLAGS='$CXXFLAGS' CONFIGURE_LDFLAGS='$LDFLAGS' "
452b0bde 1127
40ff9a41
MJ
1128# --prefix='$prefix' --exec_prefix='$exec_prefix' --libdir='$libdir' --libexecdir='$libexecdir' --bindir='$bindir' --sbindir='$sbindir' \
1129# --localstatedir='$localstatedir' --datadir='$datadir'"
8f9ab613 1130
46f6981d 1131# Run configure in all the subdirs
236bfeea
MJ
1132AC_CONFIG_SUBDIRS([libs/srtp])
1133AC_CONFIG_SUBDIRS([libs/sqlite])
1134if test "$enable_core_libedit_support" = "yes" ; then
1135 AC_CONFIG_SUBDIRS([libs/libedit])
1136fi
1137
1138AC_CONFIG_SUBDIRS([libs/pcre])
1139AC_CONFIG_SUBDIRS([libs/apr])
1140AC_CONFIG_SUBDIRS([libs/apr-util])
1141AC_CONFIG_SUBDIRS([libs/ilbc])
1142AC_CONFIG_SUBDIRS([libs/curl])
1143AC_CONFIG_SUBDIRS([libs/iksemel])
1144AC_CONFIG_SUBDIRS([libs/js/nsprpub])
1145AC_CONFIG_SUBDIRS([libs/js])
1146AC_CONFIG_SUBDIRS([libs/libdingaling])
1147AC_CONFIG_SUBDIRS([libs/libsndfile])
1148AC_CONFIG_SUBDIRS([libs/sofia-sip])
1149AC_CONFIG_SUBDIRS([libs/speex])
1150AC_CONFIG_SUBDIRS([libs/portaudio])
1151AC_CONFIG_SUBDIRS([libs/openzap])
1152AC_CONFIG_SUBDIRS([libs/freetdm])
1153AC_CONFIG_SUBDIRS([libs/unimrcp])
1154AC_CONFIG_SUBDIRS([libs/tiff-4.0.2])
1155AC_CONFIG_SUBDIRS([libs/spandsp])
1156AC_CONFIG_SUBDIRS([libs/broadvoice])
1157AC_CONFIG_SUBDIRS([libs/libg722_1])
1158AC_CONFIG_SUBDIRS([libs/silk])
1159AC_CONFIG_SUBDIRS([libs/libcodec2])
1160if test "x${enable_zrtp}" = "xyes"; then
1161 AC_CONFIG_SUBDIRS([libs/libzrtp/projects/gnu])
393b63b7 1162fi
236bfeea 1163AC_CONFIG_SUBDIRS([libs/libwebsockets])
ee3fc89f 1164
f6fe2667
MJ
1165case $host in
1166 *-openbsd*)
1167 # libtool won't link static libs against shared ones on OpenBSD unless we tell it not to be stupid
1168 AC_CONFIG_COMMANDS([hacklibtool], [cp libtool libtool.orig && sed -e "s/deplibs_check_method=.*/deplibs_check_method=pass_all/g" libtool.orig > libtool])
1169 ;;
1170esac
1171
1172
6e81dda1 1173AC_OUTPUT
5ccac21d 1174
1ed00b4d
BW
1175##
1176## Registering for ClueCon
1177##
4ff9b2f1 1178if ! test -f noreg ; then
1ed00b4d
BW
1179echo ""
1180echo ""
1181echo $ECHO_N "Registering you for ClueCon http://www.cluecon.com $ECHO_C" 1>&6
82f77413 1182sleep 1
1ed00b4d 1183echo $ECHO_N ".$ECHO_C" 1>&6
82f77413 1184sleep 1
1ed00b4d 1185echo $ECHO_N ".$ECHO_C" 1>&6
82f77413 1186sleep 1
1ed00b4d 1187echo $ECHO_N ".$ECHO_C" 1>&6
82f77413 1188sleep 1
1ed00b4d 1189echo $ECHO_N ".$ECHO_C" 1>&6
82f77413 1190sleep 1
61172345 1191echo $ECHO_N ".$ECHO_C" 1>&6
82f77413 1192sleep 1
1ed00b4d 1193AC_MSG_RESULT([ See you in August. ;-)])
82f77413 1194sleep 2
1ed00b4d 1195echo ""
17d52112 1196fi
1ed00b4d 1197
5ccac21d
MJ
1198##
1199## Configuration summary
1200##
1201
1202echo
8912b80e 1203echo "-------------------------- FreeSWITCH configuration --------------------------"
5ccac21d
MJ
1204echo ""
1205echo " Locations:"
1206echo " Selected layout: ${layout_name}"
1207echo ""
1208echo " prefix: ${prefix}"
1209echo " exec_prefix: ${exec_prefix}"
1210echo " bindir: ${bindir}"
1211echo " libdir: ${libdir}"
1212echo " modulesdir: ${modulesdir}"
1213echo " sysconfdir: ${sysconfdir}"
1214echo " runtimedir: ${runtimedir}"
1215echo " logfiledir: ${logfiledir}"
1216echo ""
8912b80e 1217echo "------------------------------------------------------------------------------"