improved error reporting of file errors (uses boost.system's error_code). Now permiss...
[libtorrent.git] / Jamfile
blob3377e7d67f7353fe242a3044cb97b09fd525e2f3
1 # This Jamfile requires boost-build v2 to build.
2 # The version shipped with boost 1.34.0
4 import modules ;
5 import os ;
6 import errors ;
7 import feature : feature ;
9 BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
10 CXXFLAGS = [ modules.peek : CXXFLAGS ] ;
11 LDFLAGS = [ modules.peek : LDFLAGS ] ;
13 ECHO "BOOST_ROOT =" $(BOOST_ROOT) ;
14 ECHO "OS =" [ os.name ] ;
16 if $(BOOST_ROOT)
18         use-project /boost : $(BOOST_ROOT) ;
21 # rule for linking the correct libraries depending
22 # on features and target-os
23 rule linking ( properties * )
25         local result ;
27         # openssl libraries, if enabled
28         if <openssl>sha-1 in $(properties)
29                 || <openssl>pe in $(properties)
30         {
31                 # exclude gcc from a regular windows build to make mingw
32                 # link against the regular unix library name
34                 if <target-os>windows in $(properties)
35                 {
36                         result += <library>gdi32 ;
37                 }
39                 if <target-os>windows in $(properties) && ! <toolset>gcc in $(properties)
40                 {
41                         result += <library>ssleay32
42                                 <library>libeay32
43                                 <library>advapi32
44                                 <library>user32
45                                 <library>shell32
46                         ;
47                 }
48                 else
49                 {
50                         result += <library>crypto <library>ssl ;
51                 }
52         }
54         if <geoip>shared in $(properties)
55         {
56                 result += <library>GeoIP ;
57         }
59         # socket functions on windows require winsock libraries
60         if <target-os>windows in $(properties)
61                 || <target-os>cygwin in $(properties)
62         {
63                 result += <library>ws2_32
64                         <library>wsock32
65                         <define>WIN32_LEAN_AND_MEAN
66                         <define>_WIN32_WINNT=0x0500
67                         <define>__USE_W32_SOCKETS
68                         <define>WIN32
69                         <define>_WIN32
70                 ;
71         }
73         if <test-coverage>on in $(properties)
74                 && ( <toolset>gcc in $(properties)
75                 || <toolset>darwin in $(properties) )
76         {
77                 result += <cxxflags>-fprofile-arcs <cxxflags>-ftest-coverage ;
78         }
80         # clock_gettime on linux requires librt
81         if <need-librt>yes in $(properties)
82         {
83                 result += <library>librt ;
84         }
86         if <tcmalloc>yes in $(properties)
87         {
88                 result += <library>tcmalloc ;
89         }
91         if <boost>system in $(properties)
92         {
93                 result += <library>boost_filesystem
94                         <library>boost_thread
95                         <library>boost_iostreams
96                         <library>boost_system
97                 ;
98         }
100         if <toolset>gcc in $(properties)
101                 && <target-os>linux in $(properties)
102                 && <variant>debug in $(properties)
103         {
104                 # for backtraces in assertion failures
105                 # which only works on ELF targets with gcc
106                 result += <linkflags>-export-dynamic <cxxflags>-rdynamic ;
107         }
109         if <boost>source in $(properties)
110         {
111                 if <boost-link>static in $(properties)
112                 {
113                         result += <library>/boost/thread//boost_thread/<link>static
114                                 <library>/boost/filesystem//boost_filesystem/<link>static
115                                 <library>/boost/iostreams//boost_iostreams/<link>static
116                                 <library>/boost/system//boost_system/<link>static
117                                 <include>$(BOOST_ROOT)
118                                 <define>BOOST_ALL_NO_LIB
119                                 ;
120                 }
121                 else
122                 {
123                         result += <library>/boost/thread//boost_thread/<link>shared
124                                 <library>/boost/filesystem//boost_filesystem/<link>shared
125                                 <library>/boost/iostreams//boost_iostreams/<link>shared
126                                 <library>/boost/system//boost_system/<link>shared
127                                 <include>$(BOOST_ROOT)
128                                 <define>BOOST_ALL_NO_LIB
129                                 ;
130                 }
131         }
133         if <boost>system in $(properties)
134         {
135                 # on mac the boost headers are installed in
136                 # a directory that isn't automatically accessable
137                 result += <include>/opt/local/include/boost-1_35
138                         <include>/opt/local/include/boost
139                         ;
140         }
142         return $(result) ;
145 # rule for adding the right source files
146 # depending on target-os and features
147 rule building ( properties * )
149         local result ;
151         if ( <target-os>linux in $(properties)
152                 || <target-os>darwin in $(properties) )
153                 && ( <toolset>gcc in $(properties)
154                 || <toolset>darwin in $(properties) )
155         {
156                 result += <source>src/assert.cpp ;
157         }
159         if <geoip>static in $(properties)
160         {
161                 result += <source>src/GeoIP.c ;
162         }
164         if <openssl>off in $(properties)
165         {
166                 result += <source>src/sha1.cpp ;
167         }
168         else
169         {
170                 if <openssl>pe in $(properties)
171                 {
172                         result += <source>src/pe_crypto.cpp ;
173                 }
174         }
176         if <target-os>windows in $(properties)
177         {
178                 result += <source>src/file_win.cpp ;
179         }
180         else
181         {
182                 result += <source>src/file.cpp ;
183         }
185         if <memdebug>on in $(properties)
186         {
187                 result += <source>src/memdebug.cpp ;
188         }
190         return $(result) ;
193 feature tcmalloc : no yes : composite propagated link-incompatible ;
195 feature need-librt : no yes : composite propagated link-incompatible ;
197 feature pool-allocators : on off : composite propagated link-incompatible ;
198 feature.compose <pool-allocators>off : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
200 feature geoip : off static shared : composite propagated link-incompatible ;
201 feature.compose <geoip>off : <define>TORRENT_DISABLE_GEO_IP ;
203 feature bandwidth-limit-logging : off on : composite propagated link-incompatible ;
204 feature.compose <bandwidth-limit-logging>on : <define>TORRENT_VERBOSE_BANDWIDTH_LIMIT ;
206 feature invariant-checks : on off full : composite propagated link-incompatible ;
207 feature.compose <invariant-checks>off : <define>TORRENT_DISABLE_INVARIANT_CHECKS ;
208 feature.compose <invariant-checks>full : <define>TORRENT_EXPENSIVE_INVARIANT_CHECKS ;
210 feature disk-stats : off on : composite propagated link-incompatible ;
211 feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
213 feature memdebug : off on : composite propagated ;
214 feature.compose <memdebug>on : <define>TORRENT_MEMDEBUG ;
216 feature logging : none default errors verbose : composite propagated link-incompatible ;
217 feature.compose <logging>default : <define>TORRENT_LOGGING ;
218 feature.compose <logging>errors : <define>TORRENT_ERROR_LOGGING ;
219 feature.compose <logging>verbose : <define>TORRENT_VERBOSE_LOGGING ;
221 feature dht-support : on off logging : composite propagated link-incompatible ;
222 feature.compose <dht-support>off : <define>TORRENT_DISABLE_DHT ;
223 feature.compose <dht-support>logging : <define>TORRENT_DHT_VERBOSE_LOGGING ;
225 feature openssl : pe sha-1 off : composite propagated link-incompatible ;
226 feature.compose <openssl>pe : <define>TORRENT_USE_OPENSSL ;
227 feature.compose <openssl>sha-1 : <define>TORRENT_USE_OPENSSL <define>TORRENT_DISABLE_ENCRYPTION ;
228 feature.compose <openssl>off : <define>TORRENT_DISABLE_ENCRYPTION ;
230 feature resolve-countries : on off : composite propagated link-incompatible ;
231 feature.compose <resolve-countries>off : <define>TORRENT_DISABLE_RESOLVE_COUNTRIES ;
233 feature character-set : ansi unicode : composite propagated link-incompatible ;
234 feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
236 feature zlib : shipped system : composite propagated link-incompatible ;
238 feature statistics : off on : composite propagated link-incompatible ;
239 feature.compose <statistics>on : <define>TORRENT_STATS ;
241 feature upnp-logging : off on : composite propagated link-incompatible ;
242 feature.compose <upnp-logging>on : <define>TORRENT_UPNP_LOGGING ;
244 feature boost : system source : link-incompatible propagated ;
245 feature boost-link : static shared : composite ;
247 feature debug-iterators : off on : composite propagated link-incompatible ;
248 feature.compose <debug-iterators>on : <define>_SCL_SECURE=1 <define>_GLIBCXX_DEBUG ;
250 feature test-coverage : off on : composite propagated ;
252 # required for openssl on windows
253 lib ssleay32 : : <name>ssleay32 ;
254 lib libeay32 : : <name>libeay32 ;
255 lib advapi32 : : <name>Advapi32 ;
256 lib user32 : : <name>User32 ;
257 lib shell32 : : <name>shell32 ;
258 lib gdi32 : : <name>gdi32 ;
260 local library-search-path = <search>/opt/local/lib <search>/usr/lib <search>/usr/local/lib <search>/sw/lib ;
262 lib boost_filesystem : : <name>boost_filesystem $(library-search-path) ;
263 lib boost_thread : : <name>boost_thread $(library-search-path) ;
264 lib boost_iostreams : : <name>boost_iostreams $(library-search-path) ;
265 lib boost_system : : <name>boost_system $(library-search-path) ;
267 # openssl on linux/bsd/macos etc.
268 lib crypto : : <name>crypto ;
269 lib ssl : : <name>ssl ;
271 # time functions used on linux require librt
272 lib librt : : <name>rt ;
274 lib tcmalloc : : <name>tcmalloc $(library-search-path) ;
276 # libz
277 lib zlib-target : : <name>z ;
279 # socket libraries on windows
280 lib wsock32 : : <name>wsock32 ;
281 lib ws2_32 : : <name>ws2_32 ;
283 SOURCES =
284         alert
285         assert
286         connection_queue
287         create_torrent
288         disk_buffer_holder
289         entry
290         file_storage
291         lazy_bdecode
292         escape_string
293         gzip
294         http_connection
295         http_stream
296         http_parser
297         identify_client
298         ip_filter
299         peer_connection
300         bt_peer_connection
301         web_peer_connection
302         instantiate_connection
303         natpmp
304         piece_picker
305         policy
306         session
307         session_impl
308         socks4_stream
309         socks5_stream
310         stat
311         storage
312         mapped_storage
313         torrent
314         torrent_handle
315         torrent_info
316         tracker_manager
317         http_tracker_connection
318         udp_tracker_connection
319         sha1
320         udp_socket
321         upnp
322         logger
323         file_pool
324         lsd
325         disk_io_thread
326         enum_net
327         broadcast_socket
328         magnet_uri
329         parse_url
331 # -- extensions --
332         metadata_transfer
333         ut_pex
334         ut_metadata
335         smart_ban
336         ;
338 KADEMLIA_SOURCES =
339         kademlia/closest_nodes
340         kademlia/dht_tracker
341         kademlia/node
342         kademlia/refresh
343         kademlia/rpc_manager
344         kademlia/find_data
345         kademlia/node_id
346         kademlia/routing_table
347         kademlia/traversal_algorithm
348         ;
350 ZLIB_SOURCES = 
351         adler32
352         compress
353         crc32
354         deflate
355         gzio
356         infback
357         inffast
358         inflate
359         inftrees
360         trees
361         uncompr
362         zutil
363         ;
365 local usage-requirements = 
366         <include>./include
367         <include>./include/libtorrent
368         <zlib>shipped:<include>./zlib
369         <variant>release:<define>NDEBUG
370         <define>_FILE_OFFSET_BITS=64
371         <define>BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
372         <conditional>@linking
373         <zlib>system:<library>zlib-target
374 # these compiler settings just makes the compiler standard conforming
375         <toolset>msvc:<cxxflags>/Zc:wchar_t
376         <toolset>msvc:<cxxflags>/Zc:forScope
377 # disable bogus deprecation warnings on msvc8
378         <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
379         <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
380 # msvc optimizations
381         <toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
382         <toolset>msvc,<variant>release:<linkflags>/OPT:REF
383 # disable warning C4503: decorated name length exceeded, name was truncated
384         <toolset>msvc:<cxxflags>/wd4503
385 # disable some warnings for gcc
386         <toolset>gcc:<cxxflags>-fno-strict-aliasing
387         <toolset>gcc:<cxxflags>-Wno-missing-braces
388         <boost>system:<cxxflags>$(CXXFLAGS)
389         <boost>system:<linkflags>$(LDFLAGS)
390         ;
392 project torrent ;
394 lib torrent
396         : # sources
397         src/$(SOURCES).cpp
399         : # requirements
400         <define>BOOST_THREAD_USE_LIB
401         <threading>multi
402         <link>shared:<define>TORRENT_BUILDING_SHARED
403         <dht-support>on:<source>src/$(KADEMLIA_SOURCES).cpp
404         <dht-support>logging:<source>src/$(KADEMLIA_SOURCES).cpp
405         <zlib>shipped:<source>zlib/$(ZLIB_SOURCES).c
406         <conditional>@building
407         <boost>system:<cxxflags>$(CXXFLAGS)
408         $(usage-requirements)
410         : # default build
411         <link>static
413         : # usage requirements
414         $(usage-requirements)
415         ;