From f1e87114b219ed9a26f7c637e6291f5e90e10af6 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 8 Jun 2007 22:55:33 +0000 Subject: [PATCH] fixed #68 --- configure.in | 28 ++++++++++++++++ include/Makefile.am | 1 + m4/check_ssl.m4 | 78 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 m4/check_ssl.m4 diff --git a/configure.in b/configure.in index 09f73c768..28e22ee1c 100644 --- a/configure.in +++ b/configure.in @@ -139,6 +139,34 @@ case "$dht" in esac AM_CONDITIONAL(USE_DHT, test "x$dht" != "xoff") +dnl encryption support. +AC_ARG_WITH( + [encryption], + AS_HELP_STRING([--with-encryption=on|off],[Specify how to use encryption support. Default is on.]), + [[encryption=$withval]], + [[encryption=on]] +) + +dnl Check the value for the --with-encryption switch +AC_MSG_CHECKING([how to use encryption]) +case "$encryption" in + "on") + AC_MSG_RESULT(on) + CHECK_SSL() + AC_DEFINE(TORRENT_USE_OPENSSL,,[define to use openssl with libtorrent]) + + ;; + "off") + AC_MSG_RESULT(off) + AC_DEFINE(TORRENT_DISABLE_ENCRYPTION,,[define not to use encryption support]) + ;; + *) + AC_MSG_RESULT() + AC_MSG_ERROR([Unknown encryption option "$encryption". Use either "on" or "off".]) + ;; +esac +AM_CONDITIONAL(USE_ENCRYPTION, test "x$encryption" != "xoff") + dnl the user can choose which zlib to use AC_ARG_WITH( [zlib], diff --git a/include/Makefile.am b/include/Makefile.am index c6ff1e919..cd2d727d5 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -58,6 +58,7 @@ libtorrent/utf8.hpp \ libtorrent/xml_parse.hpp \ libtorrent/variant_stream.hpp \ libtorrent/version.hpp \ +libtorrent/time.hpp \ libtorrent/aux_/allocate_resources_impl.hpp \ libtorrent/aux_/session_impl.hpp \ libtorrent/extensions/metadata_transfer.hpp \ diff --git a/m4/check_ssl.m4 b/m4/check_ssl.m4 new file mode 100644 index 000000000..43a6cf005 --- /dev/null +++ b/m4/check_ssl.m4 @@ -0,0 +1,78 @@ +##### http://autoconf-archive.cryp.to/check_ssl.html +# +# SYNOPSIS +# +# CHECK_SSL +# +# DESCRIPTION +# +# This macro will check various standard spots for OpenSSL including +# a user-supplied directory. The user uses '--with-ssl' or +# '--with-ssl=/path/to/ssl' as arguments to configure. +# +# If OpenSSL is found the include directory gets added to CFLAGS and +# CXXFLAGS as well as '-DHAVE_SSL', '-lssl' & '-lcrypto' get added to +# LIBS, and the libraries location gets added to LDFLAGS. Finally +# 'HAVE_SSL' gets set to 'yes' for use in your Makefile.in I use it +# like so (valid for gmake): +# +# HAVE_SSL = @HAVE_SSL@ +# ifeq ($(HAVE_SSL),yes) +# SRCS+= @srcdir@/my_file_that_needs_ssl.c +# endif +# +# For bsd 'bmake' use: +# +# .if ${HAVE_SSL} == "yes" +# SRCS+= @srcdir@/my_file_that_needs_ssl.c +# .endif +# +# LAST MODIFICATION +# +# 2003-01-28 +# +# COPYLEFT +# +# Copyright (c) 2003 Mark Ethan Trostler +# +# Copying and distribution of this file, with or without +# modification, are permitted in any medium without royalty provided +# the copyright notice and this notice are preserved. + +AC_DEFUN([CHECK_SSL], +[ +dnl AC_MSG_CHECKING(if ssl is wanted) +dnl AC_ARG_WITH(ssl, +dnl [ --with-ssl enable ssl [will check /usr/local/ssl +dnl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr ] +dnl ], +dnl [ AC_MSG_RESULT(yes) + for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do + ssldir="$dir" + if test -f "$dir/include/openssl/ssl.h"; then + found_ssl="yes"; + CFLAGS="$CFLAGS -I$ssldir/include/openssl -DHAVE_SSL"; + CXXFLAGS="$CXXFLAGS -I$ssldir/include/openssl -DHAVE_SSL"; + break; + fi + if test -f "$dir/include/ssl.h"; then + found_ssl="yes"; + CFLAGS="$CFLAGS -I$ssldir/include/ -DHAVE_SSL"; + CXXFLAGS="$CXXFLAGS -I$ssldir/include/ -DHAVE_SSL"; + break + fi + done + if test x_$found_ssl != x_yes; then + AC_MSG_ERROR(Cannot find ssl libraries) + else + printf "OpenSSL found in $ssldir\n"; + LIBS="$LIBS -lssl -lcrypto"; + LDFLAGS="$LDFLAGS -L$ssldir/lib"; + HAVE_SSL=yes + fi + AC_SUBST(HAVE_SSL) +dnl ], +dnl [ +dnl AC_MSG_RESULT(no) +dnl ]) +])dnl