2010-10-15 16:24:17 +02:00
|
|
|
AC_DEFUN([AM_WITH_ZLIB],
|
2006-01-19 03:17:31 +01:00
|
|
|
[ AC_ARG_WITH(zlib,
|
2008-07-15 10:45:05 +02:00
|
|
|
[AC_HELP_STRING([--with-zlib=PREFIX], [prefix where zlib is installed])])
|
2006-01-19 03:17:31 +01:00
|
|
|
|
2009-01-19 12:16:44 +01:00
|
|
|
if test x"$ejabberd_zlib" != x; then
|
2006-01-19 03:17:31 +01:00
|
|
|
ZLIB_CFLAGS=
|
|
|
|
ZLIB_LIBS=
|
|
|
|
if test x"$with_zlib" != x; then
|
|
|
|
ZLIB_CFLAGS="-I$with_zlib/include"
|
|
|
|
ZLIB_LIBS="-L$with_zlib/lib"
|
|
|
|
fi
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2006-01-19 03:17:31 +01:00
|
|
|
AC_CHECK_LIB(z, gzgets,
|
|
|
|
[ ZLIB_LIBS="$ZLIB_LIBS -lz"
|
|
|
|
zlib_found=yes ],
|
|
|
|
[ zlib_found=no ],
|
|
|
|
"$ZLIB_LIBS")
|
|
|
|
if test $zlib_found = no; then
|
2009-01-19 12:16:44 +01:00
|
|
|
AC_MSG_ERROR([Could not find development files of zlib library. Install them or disable `ejabberd_zlib' with: --disable-ejabberd_zlib])
|
2006-01-19 03:17:31 +01:00
|
|
|
fi
|
|
|
|
zlib_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS $ZLIB_CFLAGS"
|
2007-03-10 17:27:17 +01:00
|
|
|
zlib_save_CPPFLAGS="$CFLAGS"
|
|
|
|
CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS"
|
2006-01-19 03:17:31 +01:00
|
|
|
AC_CHECK_HEADERS(zlib.h, , zlib_found=no)
|
|
|
|
if test $zlib_found = no; then
|
2009-01-19 12:16:44 +01:00
|
|
|
AC_MSG_ERROR([Could not find zlib.h. Install it or disable `ejabberd_zlib' with: --disable-ejabberd_zlib])
|
2006-01-19 03:17:31 +01:00
|
|
|
fi
|
|
|
|
CFLAGS="$zlib_save_CFLAGS"
|
2007-03-10 17:27:17 +01:00
|
|
|
CPPFLAGS="$zlib_save_CPPFLAGS"
|
2006-01-19 03:17:31 +01:00
|
|
|
|
|
|
|
AC_SUBST(ZLIB_CFLAGS)
|
|
|
|
AC_SUBST(ZLIB_LIBS)
|
2009-01-19 12:16:44 +01:00
|
|
|
fi
|
2006-01-19 03:17:31 +01:00
|
|
|
])
|
|
|
|
|
2010-10-15 16:24:17 +02:00
|
|
|
AC_DEFUN([AM_WITH_PAM],
|
2007-10-01 12:33:03 +02:00
|
|
|
[ AC_ARG_WITH(pam,
|
2008-07-15 10:45:05 +02:00
|
|
|
[AC_HELP_STRING([--with-pam=PREFIX], [prefix where PAM is installed])])
|
2009-01-19 12:16:44 +01:00
|
|
|
if test x"$pam" != x; then
|
2007-10-01 12:33:03 +02:00
|
|
|
PAM_CFLAGS=
|
|
|
|
PAM_LIBS=
|
|
|
|
if test x"$with_pam" != x; then
|
|
|
|
PAM_CFLAGS="-I$with_pam/include"
|
|
|
|
PAM_LIBS="-L$with_pam/lib"
|
|
|
|
fi
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2007-10-01 12:33:03 +02:00
|
|
|
AC_CHECK_LIB(pam, pam_start,
|
|
|
|
[ PAM_LIBS="$PAM_LIBS -lpam"
|
|
|
|
pam_found=yes ],
|
|
|
|
[ pam_found=no ],
|
|
|
|
"$PAM_LIBS")
|
|
|
|
if test $pam_found = no; then
|
2009-01-19 12:16:44 +01:00
|
|
|
AC_MSG_ERROR([Could not find development files of PAM library. Install them or disable `pam' with: --disable-pam])
|
2007-10-01 12:33:03 +02:00
|
|
|
fi
|
|
|
|
pam_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS $PAM_CFLAGS"
|
|
|
|
pam_save_CPPFLAGS="$CPPFLAGS"
|
|
|
|
CPPFLAGS="$CPPFLAGS $PAM_CFLAGS"
|
|
|
|
AC_CHECK_HEADERS(security/pam_appl.h, , pam_found=no)
|
|
|
|
if test $pam_found = no; then
|
2009-01-19 12:16:44 +01:00
|
|
|
AC_MSG_ERROR([Could not find security/pam_appl.h. Install it or disable `pam' with: --disable-pam])
|
2007-10-01 12:33:03 +02:00
|
|
|
fi
|
|
|
|
CFLAGS="$pam_save_CFLAGS"
|
|
|
|
CPPFLAGS="$pam_save_CPPFLAGS"
|
|
|
|
|
|
|
|
AC_SUBST(PAM_CFLAGS)
|
|
|
|
AC_SUBST(PAM_LIBS)
|
2009-01-19 12:16:44 +01:00
|
|
|
fi
|
2007-10-01 12:33:03 +02:00
|
|
|
])
|
|
|
|
|
2010-10-15 16:24:17 +02:00
|
|
|
AC_DEFUN([AM_WITH_ERLANG],
|
2003-10-17 21:15:38 +02:00
|
|
|
[ AC_ARG_WITH(erlang,
|
2008-07-15 10:45:05 +02:00
|
|
|
[AC_HELP_STRING([--with-erlang=PREFIX], [path to erlc and erl])])
|
2003-10-17 21:15:38 +02:00
|
|
|
|
2007-02-19 12:06:28 +01:00
|
|
|
AC_PATH_TOOL(ERLC, erlc, , $with_erlang:$with_erlang/bin:$PATH)
|
|
|
|
AC_PATH_TOOL(ERL, erl, , $with_erlang:$with_erlang/bin:$PATH)
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2006-04-23 17:35:14 +02:00
|
|
|
if test "z$ERLC" = "z" || test "z$ERL" = "z"; then
|
2003-10-17 21:15:38 +02:00
|
|
|
AC_MSG_ERROR([erlang not found])
|
|
|
|
fi
|
2008-01-15 12:11:27 +01:00
|
|
|
|
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
cat >>conftest.erl <<_EOF
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
-module(conftest).
|
|
|
|
-author('alexey@sevcom.net').
|
2005-12-06 20:32:50 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
-export([[start/0]]).
|
2005-12-06 20:32:50 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
start() ->
|
2005-12-06 20:32:50 +01:00
|
|
|
EIDirS = code:lib_dir("erl_interface") ++ "\n",
|
|
|
|
EILibS = libpath("erl_interface") ++ "\n",
|
2008-06-20 14:49:39 +02:00
|
|
|
EXMPPDir = code:lib_dir("exmpp"),
|
|
|
|
case EXMPPDir of
|
|
|
|
{error, bad_name} -> exit("exmpp not found");
|
|
|
|
_ -> ok
|
|
|
|
end,
|
|
|
|
EXMPPDirS = EXMPPDir ++ "\n",
|
2005-12-06 20:32:50 +01:00
|
|
|
RootDirS = code:root_dir() ++ "\n",
|
2010-11-22 16:20:40 +01:00
|
|
|
file:write_file("conftest.out", list_to_binary(EIDirS ++ EILibS ++ ssldef() ++ EXMPPDirS ++ RootDirS)),
|
2005-12-06 20:32:50 +01:00
|
|
|
halt().
|
|
|
|
|
2010-11-22 16:20:40 +01:00
|
|
|
ssldef() ->
|
|
|
|
OTP = (catch erlang:system_info(otp_release)),
|
|
|
|
if
|
|
|
|
OTP >= "R14" -> "-DSSL40\n";
|
|
|
|
OTP >= "R12" -> "-DSSL39\n";
|
|
|
|
true -> "\n"
|
|
|
|
end.
|
|
|
|
|
2005-12-06 20:32:50 +01:00
|
|
|
%% return physical architecture based on OS/Processor
|
|
|
|
archname() ->
|
|
|
|
ArchStr = erlang:system_info(system_architecture),
|
|
|
|
case os:type() of
|
|
|
|
{win32, _} -> "windows";
|
|
|
|
{unix,UnixName} ->
|
|
|
|
Specs = string:tokens(ArchStr,"-"),
|
|
|
|
Cpu = case lists:nth(2,Specs) of
|
|
|
|
"pc" -> "x86";
|
|
|
|
_ -> hd(Specs)
|
|
|
|
end,
|
|
|
|
atom_to_list(UnixName) ++ "-" ++ Cpu;
|
|
|
|
_ -> "generic"
|
|
|
|
end.
|
|
|
|
|
|
|
|
%% Return arch-based library path or a default value if this directory
|
|
|
|
%% does not exist
|
|
|
|
libpath(App) ->
|
|
|
|
PrivDir = code:priv_dir(App),
|
|
|
|
ArchDir = archname(),
|
|
|
|
LibArchDir = filename:join([[PrivDir,"lib",ArchDir]]),
|
|
|
|
case file:list_dir(LibArchDir) of
|
|
|
|
%% Arch lib dir exists: We use it
|
|
|
|
{ok, _List} -> LibArchDir;
|
|
|
|
%% Arch lib dir does not exist: Return the default value
|
|
|
|
%% ({error, enoent}):
|
|
|
|
_Error -> code:lib_dir("erl_interface") ++ "/lib"
|
|
|
|
end.
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
_EOF
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
if ! $ERLC conftest.erl; then
|
|
|
|
AC_MSG_ERROR([could not compile sample program])
|
|
|
|
fi
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
if ! $ERL -s conftest -noshell; then
|
|
|
|
AC_MSG_ERROR([could not run sample program])
|
|
|
|
fi
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
if ! test -f conftest.out; then
|
|
|
|
AC_MSG_ERROR([erlang program was not properly executed, (conftest.out was not produced)])
|
|
|
|
fi
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2005-12-06 20:32:50 +01:00
|
|
|
# First line
|
2003-10-17 21:15:38 +02:00
|
|
|
ERLANG_EI_DIR=`cat conftest.out | head -n 1`
|
2005-12-06 20:32:50 +01:00
|
|
|
# Second line
|
|
|
|
ERLANG_EI_LIB=`cat conftest.out | head -n 2 | tail -n 1`
|
|
|
|
# Third line
|
2010-11-22 16:20:40 +01:00
|
|
|
ERLANG_SSLVER=`cat conftest.out | head -n 3 | tail -n 1`
|
|
|
|
# Fourth line
|
|
|
|
ERLANG_EXMPP=`cat conftest.out | head -n 4 | tail -n 1`
|
2008-01-15 12:11:27 +01:00
|
|
|
# End line
|
2003-10-17 21:15:38 +02:00
|
|
|
ERLANG_DIR=`cat conftest.out | tail -n 1`
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
ERLANG_CFLAGS="-I$ERLANG_EI_DIR/include -I$ERLANG_DIR/usr/include"
|
2005-12-06 20:32:50 +01:00
|
|
|
ERLANG_LIBS="-L$ERLANG_EI_LIB -lerl_interface -lei"
|
2008-01-15 12:11:27 +01:00
|
|
|
|
2003-10-17 21:15:38 +02:00
|
|
|
AC_SUBST(ERLANG_CFLAGS)
|
|
|
|
AC_SUBST(ERLANG_LIBS)
|
2010-11-22 16:20:40 +01:00
|
|
|
AC_SUBST(ERLANG_SSLVER)
|
2008-06-20 14:49:39 +02:00
|
|
|
AC_SUBST(ERLANG_EXMPP)
|
2003-10-17 21:15:38 +02:00
|
|
|
AC_SUBST(ERLC)
|
|
|
|
AC_SUBST(ERL)
|
|
|
|
])
|
|
|
|
|
2010-10-15 16:24:17 +02:00
|
|
|
AC_DEFUN([AC_MOD_ENABLE],
|
2003-10-17 21:15:38 +02:00
|
|
|
[
|
|
|
|
$1=
|
|
|
|
make_$1=
|
|
|
|
AC_MSG_CHECKING([whether build $1])
|
|
|
|
AC_ARG_ENABLE($1,
|
2008-07-15 10:45:05 +02:00
|
|
|
[AC_HELP_STRING([--enable-$1], [enable $1 (default: $2)])],
|
2003-10-17 21:15:38 +02:00
|
|
|
[mr_enable_$1="$enableval"],
|
|
|
|
[mr_enable_$1=$2])
|
2005-05-23 22:27:17 +02:00
|
|
|
if test "$mr_enable_$1" = "yes"; then
|
2003-10-17 21:15:38 +02:00
|
|
|
$1=$1
|
|
|
|
make_$1=$1/Makefile
|
|
|
|
fi
|
|
|
|
AC_MSG_RESULT($mr_enable_$1)
|
|
|
|
AC_SUBST($1)
|
|
|
|
AC_SUBST(make_$1)
|
|
|
|
|
|
|
|
])
|
|
|
|
|
2004-08-05 22:46:24 +02:00
|
|
|
dnl <openssl>
|
2010-10-15 16:24:17 +02:00
|
|
|
AC_DEFUN([AM_WITH_OPENSSL],
|
2004-08-05 22:46:24 +02:00
|
|
|
[ AC_ARG_WITH(openssl,
|
2008-07-15 10:45:05 +02:00
|
|
|
[AC_HELP_STRING([--with-openssl=PREFIX], [prefix where OPENSSL is installed])])
|
2004-09-26 22:46:43 +02:00
|
|
|
unset SSL_LIBS;
|
|
|
|
unset SSL_CFLAGS;
|
|
|
|
have_openssl=no
|
2004-08-05 22:46:24 +02:00
|
|
|
if test x"$tls" != x; then
|
2004-09-26 22:46:43 +02:00
|
|
|
for ssl_prefix in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
|
|
|
|
printf "looking for openssl in $ssl_prefix...\n"
|
2007-03-10 17:27:17 +01:00
|
|
|
SSL_CFLAGS="-I$ssl_prefix/include"
|
2004-09-26 22:46:43 +02:00
|
|
|
SSL_LIBS="-L$ssl_prefix/lib -lcrypto"
|
|
|
|
AC_CHECK_LIB(ssl, SSL_new, [ have_openssl=yes ], [ have_openssl=no ], [ $SSL_LIBS $SSL_CFLAGS ])
|
|
|
|
if test x"$have_openssl" = xyes; then
|
2004-11-05 22:14:31 +01:00
|
|
|
save_CPPFLAGS=$CPPFLAGS
|
2007-03-10 17:27:17 +01:00
|
|
|
CPPFLAGS="-I$ssl_prefix/include $CPPFLAGS"
|
2004-11-05 22:14:31 +01:00
|
|
|
AC_CHECK_HEADERS(openssl/ssl.h, have_openssl_h=yes)
|
|
|
|
CPPFLAGS=$save_CPPFLAGS
|
2004-09-26 22:46:43 +02:00
|
|
|
if test x"$have_openssl_h" = xyes; then
|
|
|
|
have_openssl=yes
|
|
|
|
printf "openssl found in $ssl_prefix\n";
|
|
|
|
SSL_LIBS="-L$ssl_prefix/lib -lssl -lcrypto"
|
2007-03-10 17:27:17 +01:00
|
|
|
CPPFLAGS="-I$ssl_prefix/include $CPPFLAGS"
|
2004-11-05 22:14:31 +01:00
|
|
|
SSL_CFLAGS="-DHAVE_SSL"
|
2004-09-26 22:46:43 +02:00
|
|
|
break
|
|
|
|
fi
|
2007-11-29 18:22:34 +01:00
|
|
|
else
|
|
|
|
# Clear this from the autoconf cache, so in the next pass of
|
|
|
|
# this loop with different -L arguments, it will test again.
|
|
|
|
unset ac_cv_lib_ssl_SSL_new
|
2004-09-26 22:46:43 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
if test x${have_openssl} != xyes; then
|
2009-01-19 12:16:44 +01:00
|
|
|
AC_MSG_ERROR([Could not find development files of OpenSSL library. Install them or disable `tls' with: --disable-tls])
|
2004-08-05 22:46:24 +02:00
|
|
|
fi
|
|
|
|
AC_SUBST(SSL_LIBS)
|
|
|
|
AC_SUBST(SSL_CFLAGS)
|
2004-09-26 22:46:43 +02:00
|
|
|
fi
|
2004-08-05 22:46:24 +02:00
|
|
|
])
|
|
|
|
dnl <openssl/>
|