diff --git a/ChangeLog b/ChangeLog index 7e6d7b60f..05cd2c438 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-08-05 Alexey Shchepin + + * src/aclocal.m4: Updated to check for openssl library (thanks to + AV) + * src/configure.ac: Likewise + * src/configure: Likewise + * src/Makefile.in: Likewise + * src/tls/Makefile.in: Likewise + 2004-08-03 Alexey Shchepin * src/web/ejabberd_web_admin.erl: Added user's roster page diff --git a/src/Makefile.in b/src/Makefile.in index b6eaa886c..32c91dc33 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,19 +1,14 @@ # $Id$ CC = @CC@ -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ @ERLANG_CFLAGS@ @EXPAT_CFLAGS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ @ERLANG_LIBS@ @EXPAT_LIBS@ prefix = @prefix@ -INCLUDES = @ERLANG_CFLAGS@ @EXPAT_CFLAGS@ - -LIBDIRS = @ERLANG_LIBS@ @EXPAT_LIBS@ - -SUBDIRS = @mod_irc@ @mod_pubsub@ @mod_muc@ @eldap@ @web@ stringprep - +SUBDIRS = @mod_irc@ @mod_pubsub@ @mod_muc@ @eldap@ @web@ stringprep @tls@ ERLSHLIBS = expat_erl.so DESTDIR = @@ -43,7 +38,7 @@ mostlyclean-recursive maintainer-clean-recursive: $(ERLSHLIBS): %.so: %.c - gcc -Wall $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LIBDIRS) \ + gcc -Wall $(CFLAGS) $(LDFLAGS) $(LIBS) \ $(subst ../,,$(subst .so,.c,$@)) \ -lexpat \ -lerl_interface \ diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 75c80e976..59911d01c 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -1,6 +1,6 @@ AC_DEFUN(AM_WITH_EXPAT, [ AC_ARG_WITH(expat, - [ --with-expat=PREFIX path to expat library], + [ --with-expat=PREFIX prefix where EXPAT is installed], , with_expat=no) EXPAT_CFLAGS= @@ -110,9 +110,8 @@ AC_DEFUN([AM_ICONV], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). - AC_ARG_WITH([libiconv-prefix], -[ --with-libiconv-prefix=DIR Search for libiconv in DIR/include and DIR/lib], [ +[ --with-libiconv-prefix=PREFIX prefix where libiconv is installed], [ for dir in `echo "$withval" | tr : ' '`; do if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi if test -d $dir/include; then CFLAGS="$CFLAGS -I$dir/include"; fi @@ -193,3 +192,41 @@ size_t iconv(); fi AC_SUBST(LIBICONV) ]) + +dnl +AC_DEFUN(AM_WITH_OPENSSL, +[ AC_ARG_WITH(openssl, + [ --with-openssl=PREFIX prefix where OPENSSL is installed ]) + +if test x"$tls" != x; then + if test "x$with_openssl" == x; then + ssl_prefix=/usr + else + ssl_prefix=$with_openssl + fi + SSL_CFLAGS="-I$ssl_prefix/include/openssl" + SSL_LIBS="-L$ssl_prefix/lib" + AC_CHECK_LIB(ssl, SSL_new, [ have_openssl=yes ], [ have_openssl=no ], "-lcrypto") + if test x"$have_openssl" = xyes; then + AC_CHECK_HEADERS(openssl/ssl.h, have_openssl_h=yes) + if test x"$have_openssl_h" = xyes; then + with_openssl=yes + SSL_LIBS="$SSL_LIBS -lssl -lcrypto" + else + unset SSL_LIBS + unset SSL_CFLAGS + with_openssl=no + AC_MSG_ERROR([openssl library cannot be found. Install openssl or disable `tls' module (--disable-tls).]) + fi + fi + echo -n openssl support ..... : $with_openssl + if test x"$with_openssl" != xno; then + echo , libs: $SSL_LIBS, includes: $SSL_CFLAGS + else + echo "" + fi +fi +AC_SUBST(SSL_LIBS) +AC_SUBST(SSL_CFLAGS) +]) +dnl diff --git a/src/configure b/src/configure index bc4660c5f..9d8281402 100755 --- a/src/configure +++ b/src/configure @@ -830,13 +830,15 @@ Optional Features: --enable-mod_muc enable mod_muc (default: yes) --enable-eldap enable eldap (default: yes) --enable-web enable web (default: yes) + --enable-tls enable tls (default: yes) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-erlang=PREFIX path to erlc and erl - --with-libiconv-prefix=DIR Search for libiconv in DIR/include and DIR/lib - --with-expat=PREFIX path to expat library + --with-libiconv-prefix=PREFIX prefix where libiconv is installed + --with-expat=PREFIX prefix where EXPAT is installed + --with-openssl=PREFIX prefix where OPENSSL is installed Some influential environment variables: CC C compiler command @@ -2235,7 +2237,6 @@ echo "$as_me: error: erlang program was not properly executed, (conftest.out was - # Check whether --with-libiconv-prefix or --without-libiconv-prefix was given. if test "${with_libiconv_prefix+set}" = set; then withval="$with_libiconv_prefix" @@ -3090,9 +3091,6 @@ echo "$as_me: error: Could not find expat.h" >&2;} - - - # Checks for typedefs, structures, and compiler characteristics. echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 @@ -3610,7 +3608,6 @@ fi - mod_pubsub= make_mod_pubsub= echo "$as_me:$LINENO: checking whether build mod_pubsub" >&5 @@ -3721,8 +3718,243 @@ echo "${ECHO_T}$mr_enable_web" >&6 +tls= +make_tls= +echo "$as_me:$LINENO: checking whether build tls" >&5 +echo $ECHO_N "checking whether build tls... $ECHO_C" >&6 +# Check whether --enable-tls or --disable-tls was given. +if test "${enable_tls+set}" = set; then + enableval="$enable_tls" + mr_enable_tls="$enableval" +else + mr_enable_tls=yes +fi; +if test "$mr_enable_tls" = yes; then +tls=tls +make_tls=tls/Makefile +fi +echo "$as_me:$LINENO: result: $mr_enable_tls" >&5 +echo "${ECHO_T}$mr_enable_tls" >&6 + + + + + +ac_config_files="$ac_config_files Makefile $make_mod_irc $make_mod_muc $make_mod_pubsub $make_eldap $make_web stringprep/Makefile $make_tls" + +#openssl + +# Check whether --with-openssl or --without-openssl was given. +if test "${with_openssl+set}" = set; then + withval="$with_openssl" + +fi; + +if test x"$tls" != x; then + if test "x$with_openssl" == x; then + ssl_prefix=/usr + else + ssl_prefix=$with_openssl + fi + SSL_CFLAGS="-I$ssl_prefix/include/openssl" + SSL_LIBS="-L$ssl_prefix/lib" + echo "$as_me:$LINENO: checking for SSL_new in -lssl" >&5 +echo $ECHO_N "checking for SSL_new in -lssl... $ECHO_C" >&6 +if test "${ac_cv_lib_ssl_SSL_new+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lssl "-lcrypto" $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char SSL_new (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +SSL_new (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ssl_SSL_new=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_ssl_SSL_new=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_SSL_new" >&5 +echo "${ECHO_T}$ac_cv_lib_ssl_SSL_new" >&6 +if test $ac_cv_lib_ssl_SSL_new = yes; then + have_openssl=yes +else + have_openssl=no +fi + + if test x"$have_openssl" = xyes; then + +for ac_header in openssl/ssl.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + have_openssl_h=yes +fi + +done + + if test x"$have_openssl_h" = xyes; then + with_openssl=yes + SSL_LIBS="$SSL_LIBS -lssl -lcrypto" + else + unset SSL_LIBS + unset SSL_CFLAGS + with_openssl=no + { { echo "$as_me:$LINENO: error: openssl library cannot be found. Install openssl or disable \`tls' module (--disable-tls)." >&5 +echo "$as_me: error: openssl library cannot be found. Install openssl or disable \`tls' module (--disable-tls)." >&2;} + { (exit 1); exit 1; }; } + fi + fi + echo -n openssl support ..... : $with_openssl + if test x"$with_openssl" != xno; then + echo , libs: $SSL_LIBS, includes: $SSL_CFLAGS + else + echo "" + fi +fi + -ac_config_files="$ac_config_files Makefile $make_mod_irc $make_mod_muc $make_mod_pubsub $make_eldap $make_web stringprep/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -4227,6 +4459,7 @@ do "$make_eldap" ) CONFIG_FILES="$CONFIG_FILES $make_eldap" ;; "$make_web" ) CONFIG_FILES="$CONFIG_FILES $make_web" ;; "stringprep/Makefile" ) CONFIG_FILES="$CONFIG_FILES stringprep/Makefile" ;; + "$make_tls" ) CONFIG_FILES="$CONFIG_FILES $make_tls" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; @@ -4335,6 +4568,10 @@ s,@eldap@,$eldap,;t t s,@make_eldap@,$make_eldap,;t t s,@web@,$web,;t t s,@make_web@,$make_web,;t t +s,@tls@,$tls,;t t +s,@make_tls@,$make_tls,;t t +s,@SSL_LIBS@,$SSL_LIBS,;t t +s,@SSL_CFLAGS@,$SSL_CFLAGS,;t t CEOF _ACEOF diff --git a/src/configure.ac b/src/configure.ac index 9f2a2c72c..c59d78365 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -15,9 +15,6 @@ AM_ICONV #locating libexpat AM_WITH_EXPAT - - - # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -25,19 +22,21 @@ AC_C_CONST AC_FUNC_MALLOC AC_HEADER_STDC - AC_MOD_ENABLE(mod_pubsub, yes) AC_MOD_ENABLE(mod_irc, yes) AC_MOD_ENABLE(mod_muc, yes) AC_MOD_ENABLE(eldap, yes) AC_MOD_ENABLE(web, yes) +AC_MOD_ENABLE(tls, yes) - AC_CONFIG_FILES([Makefile $make_mod_irc $make_mod_muc $make_mod_pubsub $make_eldap $make_web - stringprep/Makefile]) + stringprep/Makefile + $make_tls]) +#openssl +AM_WITH_OPENSSL AC_OUTPUT diff --git a/src/tls/Makefile.in b/src/tls/Makefile.in new file mode 100644 index 000000000..df7667ff1 --- /dev/null +++ b/src/tls/Makefile.in @@ -0,0 +1,41 @@ +# $Id$ + +CC = @CC@ +CFLAGS = @CFLAGS@ @SSL_CFLAGS@ @ERLANG_CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ @SSL_LIBS@ @ERLANG_LIBS@ + +SUBDIRS = + +ERLSHLIBS = ../tls_drv.so + +OUTDIR = .. +EFLAGS = -I .. -pz .. +OBJS = \ + $(OUTDIR)/tls.beam + +all: $(OBJS) $(ERLSHLIBS) + +$(OUTDIR)/%.beam: %.erl + erlc -W $(EFLAGS) -o $(OUTDIR) $< + +#all: $(ERLSHLIBS) +# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt + +$(ERLSHLIBS): ../%.so: %.c + $(CC) -Wall $(CFLAGS) $(LDFLAGS) $(LIBS) \ + $(subst ../,,$(subst .so,.c,$@)) \ + -lerl_interface @LIBICONV@ \ + -lei \ + -o $@ -fpic -shared \ + +clean: + rm -f $(OBJS) $(ERLSHLIBS) + +distclean: clean + rm -f Makefile + +TAGS: + etags *.erl +