# 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 "BOOST_ROOT =" $(BOOST_ROOT) ; ECHO "CXXFLAGS =" $(CXXFLAGS) ; ECHO "LDFLAGS =" $(LDFLAGS) ; ECHO "OS =" [ os.name ] ; if $(BOOST_ROOT) { use-project /boost : $(BOOST_ROOT) ; } VERSION = 1.1.0 ; rule coverage ( properties * ) { local result ; if gcc in $(properties) || darwin in $(properties) || clang in $(properties) { result += -fprofile-arcs -ftest-coverage ; if gcc in $(properties) || darwin in $(properties) { result += -lgcov ; } else { result += --coverage ; } } return $(result) ; } # rule for linking the correct libraries depending # on features and target-os rule linking ( properties * ) { local result ; # 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) { result += ssleay32 libeay32 advapi32 user32 shell32 gdi32 ; } else { result += crypto ssl z ; } if linux in $(properties) { # linker library on linux, required when using openssl result += dl ; } } # dbghelp doesn't appear to exist in mingw if windows in $(properties) && ! gcc in $(properties) && ( debug in $(properties) || on in $(properties) || production in $(properties) || on in $(properties) ) { result += dbghelp ; } # gcrypt libraries, if enabled if gcrypt in $(properties) { # on mac os x, adding the /opt/local/include path # would include openssl headers incompatible with # the system library. Only add this include path # if we're not using openssl (which we're most # likely not if we're using libgcrypt) result += gcrypt /opt/local/include ; } if shared in $(properties) { result += GeoIP ; } # socket functions on windows require winsock libraries if windows in $(properties) || cygwin in $(properties) { 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 ; } } if beos in $(properties) { result += netkit gcc ; } if solaris in $(properties) { result += libsocket libnsl ; } # clock_gettime on linux requires librt if yes in $(properties) { result += librt ; } if on in $(properties) { result += libiconv ; } if yes in $(properties) { result += tcmalloc ; } if gcc in $(properties) && linux in $(properties) && ( debug in $(properties) || on in $(properties) || production in $(properties) || on in $(properties) ) { # for backtraces in assertion failures # which only works on ELF targets with gcc result += -export-dynamic -rdynamic ; } if source in $(properties) { 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//boost_system/static/BOOST_ALL_DYN_LINK ; result += /boost/chrono//boost_chrono/static/BOOST_ALL_DYN_LINK ; result += /boost/random//boost_random/static/BOOST_ALL_DYN_LINK ; } else { result += /boost/system//boost_system/static ; result += /boost/chrono//boost_chrono/static ; result += /boost/random//boost_random/static ; } if gcc in $(properties) && shared in $(properties) { result += on ; } } else { result += /boost/system//boost_system/shared ; result += /boost/chrono//boost_chrono/shared ; result += /boost/random//boost_random/shared ; } result += $(BOOST_ROOT) BOOST_ALL_NO_LIB BOOST_MULTI_INDEX_DISABLE_SERIALIZATION ; } else { result += boost_system ; result += boost_chrono ; result += boost_random ; # on mac the boost headers are installed in # a directory that isn't automatically accessable # on open indiana, boost is install at /usr/g++/include result += /opt/local/include/boost-1_35 /opt/local/include /usr/g++/include ; } return $(result) ; } # rule for adding the right source files # depending on target-os and features rule building ( properties * ) { local result ; if shared in $(properties) && on in $(properties) { # 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 result += TORRENT_EXPORT_EXTRA ; } if ( debug in $(properties) && ( clang in $(properties) || gcc in $(properties) || darwin in $(properties) ) ) { result += -ftrapv ; } if ( debug in $(properties) || on in $(properties) ) { result += src/assert.cpp ; } if openssl in $(properties) { result += src/asio_ssl.cpp ; } if tommath in $(properties) { result += src/mpi.c ; } if static in $(properties) { result += src/GeoIP.c ; } if off in $(properties) || tommath in $(properties) { result += src/sha1.cpp ; } if ! ( off in $(properties) ) { result += src/pe_crypto.cpp ; } if ( darwin in $(properties) || gcc in $(properties) || clang in $(propertoes) || clang-darwin in $(propertoes) ) && 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 # use ms-compat because boost.asio (as of 1.47.0 # appears to have some types not fully exported) 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 tcmalloc : no yes : composite propagated link-incompatible ; feature ipv6 : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_USE_IPV6=0 ; feature sanitize : off address undefined thread rtc : composite propagated link-incompatible ; # sanitize is a clang and GCC feature feature.compose address : -fsanitize=address -fsanitize-undefined-trap-on-error -fsanitize=address ; feature.compose undefined : -fsanitize=undefined -fsanitize=undefined ; feature.compose thread : -fsanitize=thread -fsanitize=thread ; # RTC (runtime check) is an msvc feature feature.compose rtc : /RTCc /RTCsu ; feature need-librt : no yes : composite propagated link-incompatible ; feature fiemap : off on : composite propagated ; feature.compose on : HAVE_LINUX_FIEMAP_H ; 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 valgrind : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_USE_VALGRIND=1 ; feature full-stats : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_FULL_STATS ; feature memory-optimization : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_OPTIMIZE_MEMORY_USAGE ; feature asserts : auto on off production system : composite propagated ; feature.compose on : TORRENT_RELEASE_ASSERTS=1 ; feature.compose production : TORRENT_PRODUCTION_ASSERTS=1 TORRENT_RELEASE_ASSERTS=1 ; feature.compose off : TORRENT_USE_ASSERTS=0 ; feature.compose system : TORRENT_USE_SYSTEM_ASSERTS=1 ; feature windows-version : xp vista win7 : composite propagated link-incompatible ; feature.compose xp : _WIN32_WINNT=0x0501 ; feature.compose vista : _WIN32_WINNT=0x0600 ; feature.compose win7 : _WIN32_WINNT=0x0601 ; 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 ; # 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 geoip : off static shared : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_GEO_IP ; feature bandwidth-limit-logging : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_VERBOSE_BANDWIDTH_LIMIT ; feature invariant-checks : on off full : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_INVARIANT_CHECKS ; feature.compose full : TORRENT_EXPENSIVE_INVARIANT_CHECKS ; feature request-log : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_REQUEST_LOGGING ; feature disk-stats : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_DISK_STATS ; feature simulate-slow-read : off on : composite propagated ; feature.compose on : TORRENT_SIMULATE_SLOW_READ ; feature logging : none default errors verbose : composite propagated link-incompatible ; feature.compose default : TORRENT_LOGGING ; feature.compose errors : TORRENT_ERROR_LOGGING ; feature.compose verbose : TORRENT_VERBOSE_LOGGING ; feature dht : on off logging : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_DHT ; feature.compose logging : TORRENT_DHT_VERBOSE_LOGGING ; feature encryption : tommath off openssl gcrypt : composite propagated link-incompatible ; feature.compose openssl : TORRENT_USE_OPENSSL ; feature.compose gcrypt : TORRENT_USE_GCRYPT ; feature.compose tommath : TORRENT_USE_TOMMATH ; feature.compose off : TORRENT_DISABLE_ENCRYPTION ; feature resolve-countries : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_RESOLVE_COUNTRIES ; 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 statistics : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_STATS ; feature upnp-logging : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_UPNP_LOGGING ; feature boost : system source : link-incompatible propagated ; feature boost-link : static shared : composite ; feature debug-iterators : off on : composite propagated link-incompatible ; feature.compose on : _SCL_SECURE=1 _GLIBCXX_DEBUG ; feature test-coverage : off on : composite propagated ; feature.compose on : @coverage ; 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 ; # 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 ; local boost-library-search-path = /opt/local/lib /usr/lib /usr/local/lib /sw/lib /usr/g++/lib ; lib boost_system : : darwin boost_system-mt $(boost-library-search-path) ; lib boost_system : : solaris boost_system $(boost-library-search-path) ; lib boost_system : : boost_system ; lib boost_chrono : : darwin boost_chrono-mt $(boost-library-search-path) ; lib boost_chrono : : solaris boost_chrono $(boost-library-search-path) ; lib boost_chrono : : boost_chrono ; lib boost_random : : darwin boost_random-mt $(boost-library-search-path) ; lib boost_random : : solaris boost_random $(boost-library-search-path) ; lib boost_random : : boost_random ; # openssl on linux/bsd/macos etc. lib gcrypt : : gcrypt shared /opt/local/lib ; lib z : : shared z /usr/lib ; lib crypto : : crypto /usr/lib z ; lib ssl : : ssl shared crypto /opt/local/lib ; lib dl : : shared dl ; lib aio : : shared aio ; # time functions used on linux require librt lib librt : : rt shared ; lib libsocket : : libnsl socket shared /usr/sfw/lib shared ; lib libnsl : : nsl shared /usr/sfw/lib shared ; lib tcmalloc : : tcmalloc shared ; # GeoIP shared library lib GeoIP : : GeoIP shared ; # socket libraries on windows lib wsock32 : : wsock32 shared ; lib ws2_32 : : ws2_32 shared ; lib iphlpapi : : iphlpapi shared ; SOURCES = alert alert_manager allocator asio assert bandwidth_limit bandwidth_manager bandwidth_queue_entry block_cache bloom_filter chained_buffer connection_queue crc32c create_torrent disk_buffer_holder disk_buffer_pool disk_io_job disk_job_pool entry error_code file_storage lazy_bdecode escape_string string_util file gzip hasher http_connection http_stream http_parser identify_client ip_filter ip_voter peer_connection platform_util bt_peer_connection web_connection_base web_peer_connection http_seed_connection i2p_stream instantiate_connection natpmp packet_buffer piece_picker policy proxy_base puff random rss session session_impl session_call settings_pack socket_io socket_type socks5_stream stat storage torrent torrent_handle torrent_info torrent_peer torrent_peer_allocator time tracker_manager http_tracker_connection udp_tracker_connection sha1 tailqueue timestamp_history udp_socket upnp utf8 utp_socket_manager utp_stream logger file_pool lsd disk_buffer_pool disk_io_thread enum_net broadcast_socket magnet_uri parse_url ConvertUTF thread xml_parse peer_class peer_class_set part_file stat_cache request_blocks session_stats performance_counters resolver # -- extensions -- metadata_transfer ut_pex ut_metadata lt_trackers smart_ban ; KADEMLIA_SOURCES = dht_tracker node refresh rpc_manager find_data node_id routing_table traversal_algorithm logging dos_blocker get_peers item get_item ; ED25519_SOURCES = add_scalar fe ge key_exchange keypair sc seed sha512 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 debug:TORRENT_DEBUG _FILE_OFFSET_BITS=64 BOOST_EXCEPTION_DISABLE # enable cancel support in asio BOOST_ASIO_ENABLE_CANCELIO @linking # 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 # msvc optimizations msvc,release:/OPT:ICF=5 msvc,release:/OPT:REF # disable warning C4503: decorated name length exceeded, name was truncated msvc:/wd4503 # disable warning C4275: non-dll interface class 'x' used as base for dll-interface struct 'y' msvc:/wd4275 # disable warning C4251: 'x' needs to have dll-interface to be used by clients of class 'y' msvc:/wd4251 # disable some warnings for gcc gcc:-fno-strict-aliasing gcc:-Wno-missing-braces # assert on integer overflow system:$(CXXFLAGS) system:$(LDFLAGS) # this works around a bug in asio in boost-1.39 BOOST_ASIO_HASH_MAP_BUCKETS=1021 # make sure asio symbols are properly exported # and imported shared:BOOST_ASIO_DYN_LINK BOOST_ASIO_SEPARATE_COMPILATION @tag ; project torrent ; lib torrent : # sources src/$(SOURCES).cpp : # requirements ./ed25519/src multi shared:TORRENT_BUILDING_SHARED BOOST_NO_DEPRECATED # on windows, when linking statically against asio # but producing a DLL, everything inside the DLL needs # to declare the symbol as being exported shared:BOOST_ASIO_SOURCE shared:BOOST_SYSTEM_SOURCE on:src/kademlia/$(KADEMLIA_SOURCES).cpp logging:src/kademlia/$(KADEMLIA_SOURCES).cpp on:ed25519/src/$(ED25519_SOURCES).cpp logging:ed25519/src/$(ED25519_SOURCES).cpp @building system:$(CXXFLAGS) $(usage-requirements) : # default build static multi : # usage requirements $(usage-requirements) shared:TORRENT_LINKING_SHARED ; headers = [ path.glob-tree include/libtorrent : *.hpp ] ; package.install install : libtorrent on : : torrent : $(headers) ;