# This Jamfile requires boost-build v2 to build. # The version shipped with boost 1.34.0 import modules ; import path ; import os ; import errors ; import feature : feature ; import package ; import virtual-target ; BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ; CXXFLAGS = [ modules.peek : CXXFLAGS ] ; LDFLAGS = [ modules.peek : LDFLAGS ] ; ECHO "CXXFLAGS =" $(CXXFLAGS) ; ECHO "LDFLAGS =" $(LDFLAGS) ; ECHO "OS =" [ os.name ] ; if $(BOOST_ROOT) { ECHO "building boost from source directory: " $(BOOST_ROOT) ; use-project /boost : $(BOOST_ROOT) ; alias boost_system : /boost/system//boost_system : : : $(BOOST_ROOT) ; } else { local boost-lib-search-path = /usr/lib /usr/local/lib ; local boost-include-path = /usr/local/include /usr/sfw/include ; # the names are decorated in MacPorts lib boost_system : : darwin boost_system-mt $(boost-lib-search-path) : : $(boost-include-path) ; lib boost_system : : boost_system $(boost-lib-search-path) : : $(boost-include-path) ; } VERSION = 1.2.0 ; # rule for linking the correct libraries depending # on features and target-os rule linking ( properties * ) { local result ; # ssl=openssl => crypto=libcrypto # this match the previous behavior if openssl in $(properties) && ! libcrypto in $(properties) { ECHO "with ssl=openssl the value for crypto must be libcrypto" ; result += no ; } # openssl libraries, if enabled if openssl in $(properties) { # exclude gcc from a regular windows build to make mingw # link against the regular unix library name if windows in $(properties) && ! gcc in $(properties) { result += ssleay32 advapi32 user32 shell32 gdi32 ; } else { result += ssl ; } } if libcrypto in $(properties) { # exclude gcc from a regular windows build to make mingw # link against the regular unix library name if windows in $(properties) && ! gcc in $(properties) { # it should be possible to cleanup this list, but this is safe for now result += libeay32 advapi32 user32 shell32 gdi32 ; } else { result += crypto ; } } if on in $(properties) { result += /libsimulator//simulator ; } if windows in $(properties) && ( on in $(properties) || production in $(properties) || debug in $(properties) || debug in $(properties) || on in $(properties) ) { result += dbghelp ; } # gcrypt libraries, if enabled if libgcrypt in $(properties) { result += gcrypt ; } if windows in $(properties) || cygwin in $(properties) { # socket functions on windows require winsock libraries result += ws2_32 wsock32 iphlpapi WIN32_LEAN_AND_MEAN __USE_W32_SOCKETS WIN32 _WIN32 ; # when DHT is enabled, we need ed25519 which in turn # needs entropy if ! off in $(properties) { result += advapi32 ; } # default to windows vista if default in $(properties) { result += _WIN32_WINNT=0x0600 ; } } if beos in $(properties) { result += netkit gcc ; } if solaris in $(properties) { result += libsocket libnsl ; } if on in $(properties) { result += libiconv ; } if ( gcc in $(properties) || clang in $(properties) ) && linux in $(properties) && ( on in $(properties) || production in $(properties) || debug in $(properties) || debug in $(properties) || on in $(properties) ) { # for backtraces in assertion failures # which only works on ELF targets with gcc result += -export-dynamic -rdynamic ; } if static in $(properties) { if shared in $(properties) { # if libtorrent is being built as a shared library # but we're linking against boost statically, we still # need to make boost think it's being built as a shared # library, so that it properly exports its symbols result += BOOST_ALL_DYN_LINK ; result += boost_system/static/BOOST_ALL_DYN_LINK ; } else { result += boost_system/static ; } if gcc in $(properties) && ! windows in $(properties) && shared in $(properties) { result += on ; } } else if shared in $(properties) { result += boost_system/shared ; } else { result += boost_system ; } result += BOOST_ALL_NO_LIB BOOST_MULTI_INDEX_DISABLE_SERIALIZATION BOOST_SYSTEM_NO_DEPRECATED ; return $(result) ; } rule warnings ( properties * ) { local result ; if off in $(properties) { return $(result) ; } if clang in $(properties) || darwin in $(properties) { result += -Weverything ; result += -Wno-documentation ; result += -Wno-c++98-compat-pedantic ; result += -Wno-padded ; result += -Wno-global-constructors ; result += -Wno-c++98-compat ; result += -Wno-exit-time-destructors ; result += -Wno-documentation-unknown-command ; result += -Wno-disabled-macro-expansion ; result += -Wno-unused-command-line-argument ; result += -Wno-error=implicit-fallthrough ; result += -Wno-c++11-long-long ; result += -Wno-variadic-macros ; # enable these warnings again, once the other ones are dealt with result += -Wno-weak-vtables ; result += -Wno-sign-compare ; result += -Wno-sign-conversion ; result += -Wno-conversion ; } if gcc in $(properties) { result += -Wall ; result += -Wextra ; result += -Wpedantic ; # result += -Wmisleading-indentation ; result += -Wparentheses ; result += -Wvla ; result += -Wc++11-compat ; result += -Wno-format-zero-length ; result += -Wno-long-long ; # enable these warnings again, once the other ones are dealt with result += -Wno-sign-compare ; result += -Wno-unused-variable ; } if msvc in $(properties) { # disable warning C4503: decorated name length exceeded, name was truncated result += /wd4503 ; # enable these warnings again, once the other ones are dealt with # disable warning C4389: signed/unsigned mismatch result += /wd4389 ; result += /wd4245 ; result += /wd4018 ; # disable warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data result += /wd4244 ; # disable warning C4512: assignment operator could not be generated result += /wd4512 ; # disable warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' result += /wd4251 ; # disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' result += /wd4275 ; # disable warning C4373: virtual function overrides, previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers result += /wd4373 ; } return $(result) ; } # rule for adding the right source files # depending on target-os and features rule building ( properties * ) { local result ; if msvc in $(properties) { # allow larger .obj files (with more sections) result += /bigobj ; } if ( debug in $(properties) && ( clang in $(properties) || gcc in $(properties) || darwin in $(properties) ) ) { result += -ftrapv ; } if ( production in $(properties) || on in $(properties) ) { result += src/assert.cpp ; } if on in $(properties) { result += src/pe_crypto.cpp ; } if built-in in $(properties) && ! windows in $(properties) && ! darwin in $(properties) { result += src/sha1.cpp ; if on in $(properties) { result += src/sha512.cpp ; } } if ( darwin in $(properties) || gcc in $(properties) || clang in $(properties) || clang-darwin in $(properties) ) && shared in $(properties) # on GCC, enabling debugging in libstdc++ # breaks the ABI and its ability to appear # in shared object interfaces, so when it's # enabled, just export everything (since we're) # probably not a production build anyway && ! on in $(properties) { # hide non-external symbols result += -fvisibility=hidden ; result += -fvisibility-inlines-hidden ; if ( gcc in $(properties) ) { result += -Wl,-Bsymbolic ; } } return $(result) ; } rule tag ( name : type ? : property-set ) { name = [ virtual-target.add-prefix-and-suffix $(name) : $(type) : $(property-set) ] ; if $(type) = SHARED_LIB && ( ! ( [ $(property-set).get ] in windows cygwin ) ) { name = $(name).$(VERSION) ; } return $(name) ; } feature ipv6 : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_USE_IPV6=0 ; feature sanitize : off address bounds undefined thread rtc : composite propagated link-incompatible ; # sanitize is a clang and GCC feature feature.compose bounds : -fsanitize=bounds -fsanitize-undefined-trap-on-error -fsanitize=bounds -fsanitize-undefined-trap-on-error ; feature.compose undefined : -fsanitize=undefined -fsanitize=undefined ; feature.compose thread : -fsanitize=thread -fsanitize=thread ; feature.compose address : -fsanitize=address -fsanitize=address ; # RTC (runtime check) is an msvc feature feature.compose rtc : /RTCc /RTCsu ; feature file-leak-logging : off on : composite propagated ; feature.compose on : TORRENT_DEBUG_FILE_LEAKS=1 ; feature i2p : on off : composite propagated ; feature.compose on : TORRENT_USE_I2P=1 ; feature.compose off : TORRENT_USE_I2P=0 ; feature iconv : auto on off : composite propagated ; feature.compose on : TORRENT_USE_ICONV=1 ; feature.compose off : TORRENT_USE_ICONV=0 ; feature memory-optimization : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_OPTIMIZE_MEMORY_USAGE ; feature asserts : off on production system : composite propagated ; feature.compose on : TORRENT_USE_ASSERTS=1 ; feature.compose production : TORRENT_USE_ASSERTS=1 TORRENT_PRODUCTION_ASSERTS=1 ; feature.compose system : TORRENT_USE_ASSERTS=1 TORRENT_USE_SYSTEM_ASSERTS=1 ; feature windows-version : default vista win7 xp : composite propagated link-incompatible ; feature.compose vista : _WIN32_WINNT=0x0600 ; feature.compose win7 : _WIN32_WINNT=0x0601 ; feature.compose xp : _WIN32_WINNT=0x0501 ; feature extensions : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_EXTENSIONS ; feature asio-debugging : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_ASIO_DEBUGGING ; feature picker-debugging : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_DEBUG_REFCOUNTS ; feature simulator : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_BUILD_SIMULATOR ; # deprecated use allocator=pool instead feature pool-allocators : on off debug : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_POOL_ALLOCATOR ; feature.compose debug : TORRENT_DISABLE_POOL_ALLOCATOR TORRENT_DEBUG_BUFFERS ; feature allocator : pool system debug : composite propagated ; feature.compose system : TORRENT_DISABLE_POOL_ALLOCATOR ; feature.compose debug : TORRENT_DISABLE_POOL_ALLOCATOR TORRENT_DEBUG_BUFFERS ; feature piece-allocator : valloc memalign posix_memalign : composite propagated ; feature.compose memalign : TORRENT_USE_MEMALIGN=1 ; feature.compose posix_memalign : TORRENT_USE_POSIX_MEMALIGN=1 ; feature invariant-checks : off on full : composite propagated link-incompatible ; feature.compose on : TORRENT_USE_INVARIANT_CHECKS=1 ; feature.compose full : TORRENT_USE_INVARIANT_CHECKS=1 TORRENT_EXPENSIVE_INVARIANT_CHECKS ; feature disk-stats : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_DISK_STATS ; feature utp-log : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_UTP_LOG_ENABLE ; feature simulate-slow-read : off on : composite propagated ; feature.compose on : TORRENT_SIMULATE_SLOW_READ ; feature logging : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_LOGGING ; feature dht : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_DHT ; feature encryption : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_ENCRYPTION ; feature mutable-torrents : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_MUTABLE_TORRENTS ; feature crypto : built-in libcrypto libgcrypt : composite propagated ; feature.compose libcrypto : TORRENT_USE_LIBCRYPTO ; feature.compose libgcrypt : TORRENT_USE_LIBGCRYPT ; feature ssl : off openssl : composite propagated ; feature.compose openssl : TORRENT_USE_OPENSSL OPENSSL_NO_SSL2 ; feature character-set : unicode ansi : composite propagated link-incompatible ; feature.compose unicode : _UNICODE UNICODE ; feature deprecated-functions : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_NO_DEPRECATE ; feature boost-link : default static shared : propagated composite ; feature debug-iterators : off on : composite propagated link-incompatible ; feature.compose on : _SCL_SECURE=1 _GLIBCXX_DEBUG _GLIBCXX_DEBUG_PEDANTIC ; feature fpic : off on : composite propagated link-incompatible ; feature.compose on : -fPIC ; feature.compose off : darwin:-mdynamic-no-pic ; feature profile-calls : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_PROFILE_CALLS=1 ; # controls whether or not to export some internal # libtorrent functions. Used for unit testing feature export-extra : off on : composite propagated ; # export some internal libtorrent functions # in order to me able to unit test them. # this is off by default to keep the export # symbol table reasonably small feature.compose on : TORRENT_EXPORT_EXTRA ; # this is a trick to get filename paths to targets to become shorter # making it possible to build on windows, especially mingw seems particular # for release builds, disable optimizations as they bump GCC over the edge of # allowed memory usage on travis-ci variant test_release : release : production on full shared off on on multi on ; variant test_debug : debug : on on debug full shared on on multi on ; variant test_barebones : debug : off off off off shared off off on on multi on ; variant test_arm : debug : off off off off off off on on ; # required for openssl on windows lib ssleay32 : : ssleay32 ; lib libeay32 : : libeay32 ; lib advapi32 : : advapi32 ; lib user32 : : user32 ; lib shell32 : : shell32 ; lib gdi32 : : gdi32 ; lib dbghelp : : dbghelp ; # required for networking on beos lib netkit : : net /boot/system/lib shared ; lib gcc : : gcc static ; # when using iconv lib libiconv : : iconv shared /usr/local/lib ; # openssl on linux/bsd/macos etc. lib gcrypt : : gcrypt shared /usr/local/lib : : /usr/local/include ; lib crypto : : crypto shared ; lib ssl : : ssl shared crypto ; lib libsocket : : libnsl socket shared /usr/sfw/lib shared ; lib libnsl : : nsl shared /usr/sfw/lib shared ; # socket libraries on windows lib wsock32 : : wsock32 shared ; lib ws2_32 : : ws2_32 shared ; lib iphlpapi : : iphlpapi shared ; SOURCES = alert alert_manager allocator announce_entry assert bandwidth_limit bandwidth_manager bandwidth_queue_entry bdecode bitfield block_cache bloom_filter chained_buffer choker close_reason cpuid crc32c create_torrent disk_buffer_holder disk_buffer_pool disk_io_job disk_io_thread disk_io_thread_pool disk_job_pool entry error_code file_storage escape_string string_util file fingerprint gzip hasher hex http_connection http_stream http_parser identify_client ip_filter ip_notifier ip_voter merkle peer_connection platform_util bt_peer_connection web_connection_base web_peer_connection http_seed_connection peer_connection_handle i2p_stream instantiate_connection natpmp packet_buffer piece_picker peer_list proxy_base puff random read_resume_data receive_buffer resolve_links session session_handle session_impl session_call settings_pack sha1_hash socket_io socket_type socks5_stream stat storage torrent torrent_handle torrent_info torrent_peer torrent_peer_allocator torrent_status time tracker_manager http_tracker_connection udp_tracker_connection timestamp_history udp_socket upnp utf8 utp_socket_manager utp_stream file_pool lsd enum_net broadcast_socket magnet_uri parse_url ConvertUTF xml_parse version peer_class peer_class_set part_file stat_cache request_blocks session_stats performance_counters resolver session_settings proxy_settings file_progress ffs # -- extensions -- ut_pex ut_metadata smart_ban ; KADEMLIA_SOURCES = dht_state dht_storage dht_tracker msg node node_entry refresh rpc_manager find_data node_id routing_table traversal_algorithm dos_blocker get_peers item get_item put_data ed25519 ; ED25519_SOURCES = add_scalar fe ge key_exchange keypair sc sign verify ; local usage-requirements = ./include ./include/libtorrent /usr/sfw/include # freebsd doesn't seem to include this automatically # and iconv.h is installed there /usr/local/include release:NDEBUG _FILE_OFFSET_BITS=64 BOOST_EXCEPTION_DISABLE # enable cancel support in asio BOOST_ASIO_ENABLE_CANCELIO # make sure asio uses std::chrono BOOST_ASIO_HAS_STD_CHRONO @linking # these compiler settings just makes the compiler standard conforming msvc:/Zc:wchar_t msvc:/Zc:forScope # msvc optimizations msvc,release:/OPT:ICF=5 msvc,release:/OPT:REF # disable bogus deprecation warnings on msvc8 msvc:_SCL_SECURE_NO_DEPRECATE msvc:_CRT_SECURE_NO_DEPRECATE $(CXXFLAGS) $(LDFLAGS) ; project torrent ; lib torrent : # sources src/$(SOURCES).cpp : # requirements ./ed25519/src multi TORRENT_BUILDING_LIBRARY shared:TORRENT_BUILDING_SHARED BOOST_NO_DEPRECATED shared:BOOST_SYSTEM_SOURCE on:src/kademlia/$(KADEMLIA_SOURCES).cpp on:ed25519/src/$(ED25519_SOURCES).cpp on:src/hasher512.cpp on:src/lazy_bdecode.cpp debug:on debug:on @building @warnings $(CXXFLAGS) @tag $(usage-requirements) : # default build multi : # usage requirements $(usage-requirements) shared:TORRENT_LINKING_SHARED ; headers = [ path.glob-tree include/libtorrent : *.hpp ] ; package.install install : libtorrent : : torrent : $(headers) ;