From fa1a37e649c19915b49fda4e5827ad81b47cfd4e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 13 Jun 2007 01:48:24 +0000 Subject: [PATCH] updated Jamfile to support openssl on windows, added missing files to makefiles and made test_pe_crypto build when encryption is disabled --- Jamfile | 137 ++++++++++++++++++++++++---------------- docs/building.rst | 18 +++--- examples/Jamfile | 7 +- include/Makefile.am | 2 + src/Makefile.am | 3 + test/Jamfile | 10 +-- test/Makefile.am | 5 +- test/test_pe_crypto.cpp | 12 ++++ 8 files changed, 120 insertions(+), 74 deletions(-) diff --git a/Jamfile b/Jamfile index 3b3a8659c..78b192433 100755 --- a/Jamfile +++ b/Jamfile @@ -1,10 +1,10 @@ -#This Jamfile requires boost-build v2 to build. +# This Jamfile requires boost-build v2 to build. +# The version shipped with boost 1.34.0 import modules ; import os ; import errors ; import feature : feature ; -#import pch ; BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ; @@ -19,6 +19,45 @@ if ! $(BOOST_ROOT) use-project /boost : $(BOOST_ROOT) ; +# rule for linking the correct library when using openssl +rule link-openssl ( properties * ) +{ + local result ; + + if sha-1 in $(properties) || pe in $(properties) + { + if [ os.name ] = NT + { + result += ssleay libeay ; + } + else + { + result += crypto ; + } + } + + return $(result) ; +} + +# rule for adding the right source files when using openssl and/or PE +rule use-openssl ( properties * ) +{ + local result ; + + if off in $(properties) + { + result += src/sha1.cpp ; + } + else + { + if pe in $(properties) + { + result += src/pe_crypto.cpp ; + } + } + + return $(result) ; +} feature logging : none default verbose : composite propagated symmetric link-incompatible ; feature.compose default : TORRENT_LOGGING ; @@ -28,12 +67,10 @@ feature dht-support : on off logging : composite propagated symmetric link-incom feature.compose off : TORRENT_DISABLE_DHT ; feature.compose logging : TORRENT_DHT_VERBOSE_LOGGING ; -feature pe-support : on off : composite propagated symmetric ; -feature.compose on : ; -feature.compose off : TORRENT_DISABLE_ENCRYPTION ; - -feature openssl : off on : composite propagated symmetric link-incompatible ; -feature.compose on : TORRENT_USE_OPENSSL ; +feature openssl : pe sha-1 off : composite propagated symmetric link-incompatible ; +feature.compose pe : TORRENT_USE_OPENSSL ; +feature.compose sha-1 : TORRENT_USE_OPENSSL TORRENT_DISABLE_ENCRYPTION ; +feature.compose off : TORRENT_DISABLE_ENCRYPTION ; feature resolve-countries : on off : composite propagated symmetric link-incompatible ; feature.compose off : TORRENT_DISABLE_RESOLVE_COUNTRIES ; @@ -41,7 +78,9 @@ feature.compose off : TORRENT_DISABLE_RESOLVE_COUNTRI feature character-set : ansi unicode : composite propagated link-incompatible ; feature.compose unicode : _UNICODE UNICODE ; -feature zlib : shipped system : composite ; +feature zlib : shipped system : composite propagated link-incompatible ; +feature.compose shipped : ; +feature.compose system : ; feature statistics : off on : composite propagated symmetric link-incompatible ; feature.compose on : TORRENT_STATS ; @@ -49,6 +88,11 @@ feature.compose on : TORRENT_STATS ; feature upnp-logging : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_UPNP_LOGGING ; +lib ssleay : : ssleay32 ; +lib libeay : : libeay32 ; +lib crypto : : crypto ; +lib zlib-target : : z ; + SOURCES = allocate_resources alert @@ -116,18 +160,19 @@ ZLIB_SOURCES = zutil ; -DEFINES = ; -LIBS = ; +local defines ; +local libs ; if [ os.name ] = CYGWIN || [ os.name ] = NT { lib wsock32 : : wsock32 ; lib ws2_32 : : ws2_32 ; - LIBS += ws2_32 wsock32 ; - DEFINES += WIN32_LEAN_AND_MEAN ; - DEFINES += _WIN32_WINNT=0x0500 ; - DEFINES += __USE_W32_SOCKETS ; - DEFINES += WIN32 ; + libs += ws2_32 wsock32 ; + defines += WIN32_LEAN_AND_MEAN ; + defines += _WIN32_WINNT=0x0500 ; + defines += __USE_W32_SOCKETS ; + defines += WIN32 ; + defines += _WIN32 ; SOURCES += file_win ; } else @@ -135,12 +180,7 @@ else SOURCES += file ; } -lib crypt : : crypto ; - -project torrent - - : requirements - +local usage-requirements = ./include ./include/libtorrent shipped:./zlib @@ -148,54 +188,39 @@ project torrent release:NDEBUG BOOST_ALL_NO_LIB _FILE_OFFSET_BITS=64 - BOOST_THREAD_USE_LIB - $(DEFINES) + $(defines) /boost/thread//boost_thread #/static /boost/filesystem//boost_filesystem #/static - multi - -# ======= compiler settings ======= - + @link-openssl + system:zlib-target # these compiler settings just makes the compiler standard conforming msvc:/Zc:wchar_t msvc:/Zc:forScope # disable bogus deprecation warnings on msvc8 msvc:_SCL_SECURE_NO_DEPRECATE msvc:_CRT_SECURE_NO_DEPRECATE - -# this should be defined when libtorrent is built as -# a dll. It will make sure the functions and classes -# are exported (GCC 4 and msvc) - shared:TORRENT_BUILDING_SHARED - - shared:TORRENT_LINKING_SHARED - - : usage-requirements - - ./include - ./include/libtorrent - $(BOOST_ROOT) - release:NDEBUG - BOOST_ALL_NO_LIB - $(DEFINES) - shared:TORRENT_LINKING_SHARED ; -#cpp-pch pch : include/libtorrent/pch.hpp ; - lib torrent - : + + : # sources src/$(SOURCES).cpp - $(LIBS) -# pch - : + $(libs) + + : # requirements + BOOST_THREAD_USE_LIB + multi + shared:TORRENT_BUILDING_SHARED on:src/$(KADEMLIA_SOURCES).cpp logging:src/$(KADEMLIA_SOURCES).cpp shipped:zlib/$(ZLIB_SOURCES).c - system:z - on:src/pe_crypto.cpp - on:crypt - on:crypt - off,off:src/sha1.cpp + @use-openssl + $(usage-requirements) + + : # default build + static + + : # usage requirements + $(usage-requirements) ; diff --git a/docs/building.rst b/docs/building.rst index 61e788c88..44dd86710 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -213,10 +213,16 @@ Build features: | | * ``shipped`` - links against the zlib bundled | | | with the libtorrent package. | +------------------------+----------------------------------------------------+ -| ``pe-support`` | * ``on`` - turns on support for encrypted | +| ``openssl`` | * ``pe`` - turns on support for encrypted | | | connections. requires openssl (libcrypto) | +| | * ``sha-1`` - openssl will be used instead of the | +| | public domain SHA-1 implementation shipped with | +| | libtorrent. ``libcrypto.a`` will be required for | +| | linking. Encryption support is still turned off. | | | * ``off`` - turns off support for encrypted | -| | connections. openssl is not linked in. | +| | connections. openssl is not linked in. The | +| | shipped public domain SHA-1 implementation is | +| | used. | +------------------------+----------------------------------------------------+ | ``link`` | * ``static`` - builds libtorrent as a static | | | library (.a / .lib) | @@ -236,14 +242,6 @@ Build features: | | * ``profile`` - builds libtorrent with profile | | | information. | +------------------------+----------------------------------------------------+ -| ``openssl`` | * ``on`` - openssl will be used instead of the | -| | public domain SHA-1 implementation shipped with | -| | libtorrent. ``crypto.lib`` or ``libcrypto.a`` | -| | will be required for linking. | -| | * ``off`` - the shipped SHA-1 implementation will | -| | be used, and there will be no dependency on | -| | openssl. | -+------------------------+----------------------------------------------------+ | ``character-set`` | This setting will only have an affect on windows. | | | Other platforms are expected to support UTF-8. | | | | diff --git a/examples/Jamfile b/examples/Jamfile index cc5185daa..aaed10c18 100644 --- a/examples/Jamfile +++ b/examples/Jamfile @@ -6,7 +6,10 @@ use-project /torrent : .. ; use-project /boost : $(BOOST_ROOT) ; project client_test - : requirements multi /torrent + : requirements + multi /torrent//torrent + : default-build + static ; exe client_test : client_test.cpp /boost/program_options /boost/regex ; @@ -14,5 +17,3 @@ exe simple_client : simple_client.cpp ; exe dump_torrent : dump_torrent.cpp ; exe make_torrent : make_torrent.cpp ; -#stage . : dump_torrent make_torrent simple_client client_test ; - diff --git a/include/Makefile.am b/include/Makefile.am index 167c36233..010a2b181 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -7,6 +7,7 @@ libtorrent/buffer.hpp \ libtorrent/connection_queue.hpp \ libtorrent/config.hpp \ libtorrent/debug.hpp \ +libtorrent/disk_io_thread.hpp \ libtorrent/entry.hpp \ libtorrent/escape_string.hpp \ libtorrent/extensions.hpp \ @@ -19,6 +20,7 @@ libtorrent/http_stream.hpp \ libtorrent/http_tracker_connection.hpp \ libtorrent/identify_client.hpp \ libtorrent/instantiate_connection.hpp \ +libtorrent/intrusive_ptr_base.hpp \ libtorrent/invariant_check.hpp \ libtorrent/io.hpp \ libtorrent/ip_filter.hpp \ diff --git a/src/Makefile.am b/src/Makefile.am index 5745d0d93..97e74ee25 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,6 +22,7 @@ http_tracker_connection.cpp udp_tracker_connection.cpp \ alert.cpp identify_client.cpp ip_filter.cpp file.cpp metadata_transfer.cpp \ logger.cpp file_pool.cpp ut_pex.cpp lsd.cpp upnp.cpp instantiate_connection.cpp \ socks5_stream.cpp socks4_stream.cpp http_stream.cpp connection_queue.cpp \ +disk_io_thread.cpp \ $(kademlia_sources) noinst_HEADERS = \ @@ -35,6 +36,7 @@ $(top_srcdir)/include/libtorrent/bencode.hpp \ $(top_srcdir)/include/libtorrent/buffer.hpp \ $(top_srcdir)/include/libtorrent/connection_queue.hpp \ $(top_srcdir)/include/libtorrent/debug.hpp \ +$(top_srcdir)/include/libtorrent/disk_io_thread.hpp \ $(top_srcdir)/include/libtorrent/entry.hpp \ $(top_srcdir)/include/libtorrent/escape_string.hpp \ $(top_srcdir)/include/libtorrent/extensions.hpp \ @@ -51,6 +53,7 @@ $(top_srcdir)/include/libtorrent/session_settings.hpp \ $(top_srcdir)/include/libtorrent/http_tracker_connection.hpp \ $(top_srcdir)/include/libtorrent/identify_client.hpp \ $(top_srcdir)/include/libtorrent/instantiate_connection.hpp \ +$(top_srcdir)/include/libtorrent/intrusive_ptr_base.hpp \ $(top_srcdir)/include/libtorrent/invariant_check.hpp \ $(top_srcdir)/include/libtorrent/io.hpp \ $(top_srcdir)/include/libtorrent/ip_filter.hpp \ diff --git a/test/Jamfile b/test/Jamfile index a0d7f5028..05b220738 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,13 +1,15 @@ use-project /torrent : .. ; -exe test_upnp : test_upnp.cpp /torrent : multi verbose on ; +exe test_upnp : test_upnp.cpp /torrent//torrent : multi verbose on ; project - : - requirements multi - /torrent + : requirements + multi + /torrent//torrent main.cpp setup_transfer.cpp + : default-build + static ; test-suite libtorrent : diff --git a/test/Makefile.am b/test/Makefile.am index a0bfc2f92..649707922 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -13,7 +13,7 @@ test_ip_filter_LDADD = $(top_builddir)/src/libtorrent.la test_piece_picker_SOURCES = main.cpp test_piece_picker.cpp test_piece_picker_LDADD = $(top_builddir)/src/libtorrent.la -test_storage_SOURCES = main.cpp test_storage.cpp +test_storage_SOURCES = main.cpp setup_transfer.cpp test_storage.cpp test_storage_LDADD = $(top_builddir)/src/libtorrent.la test_buffer_SOURCES = main.cpp test_buffer.cpp @@ -25,6 +25,9 @@ test_allocate_resources_LDADD = $(top_builddir)/src/libtorrent.la test_metadata_extension_SOURCES = main.cpp setup_transfer.cpp test_metadata_extension.cpp test_metadata_extension_LDADD = $(top_builddir)/src/libtorrent.la +test_swarm_SOURCES = main.cpp setup_transfer.cpp test_swarm.cpp +test_swarm_LDADD = $(top_builddir)/src/libtorrent.la + test_pe_crypto_SOURCES = main.cpp test_pe_crypto.cpp test_pe_crypto_LDADD = $(top_builddir)/src/libtorrent.la $(top_builddir)/test/setup_transfer.o diff --git a/test/test_pe_crypto.cpp b/test/test_pe_crypto.cpp index a7da88edd..859431975 100644 --- a/test/test_pe_crypto.cpp +++ b/test/test_pe_crypto.cpp @@ -40,6 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "test.hpp" +#ifndef TORRENT_DISABLE_ENCRYPTION + void display_pe_policy(libtorrent::pe_settings::enc_policy policy) { using namespace libtorrent; @@ -193,3 +195,13 @@ int test_main() return 0; } +#else + +int test_main() +{ + std::cerr << "PE test not run because it's disabled" << std::endl; + return 0; +} + +#endif +