Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / log / build / Jamfile.v2
1 #
2 #          Copyright Andrey Semashev 2007 - 2014.
3 # Distributed under the Boost Software License, Version 1.0.
4 #    (See accompanying file LICENSE_1_0.txt or copy at
5 #          http://www.boost.org/LICENSE_1_0.txt)
6 #
7
8 import common ;
9 import modules ;
10 import os ;
11 import path ;
12 import project ;
13 import feature ;
14 import configure ;
15 import log-architecture ;
16 using mc ;
17
18 local here = [ modules.binding $(__name__) ] ;
19
20 project.push-current [ project.current ] ;
21 project.load [ path.join [ path.make $(here:D) ] ../config/message-compiler ] ;
22 project.pop-current ;
23 project.push-current [ project.current ] ;
24 project.load [ path.join [ path.make $(here:D) ] ../config/x86-ext ] ;
25 project.pop-current ;
26
27 # Windows libs
28 lib psapi ;
29 lib ws2_32 ;
30 lib mswsock ;
31
32 # UNIX libs
33 lib rt ;
34 lib socket ;
35 lib nsl ;
36 lib ipv6 ;
37
38 feature.feature log-api : generic winnt unix ;
39
40 rule check-instruction-set ( properties * )
41 {
42     local result ;
43     local instruction_set = [ feature.get-values "log-instruction-set" : [ log-architecture.deduce-instruction-set $(properties) ] ] ;
44
45     if $(instruction_set) = i386 || $(instruction_set) = i486
46     {
47         if ! $(.annouced-failure)
48         {
49             ECHO Boost.Log is not supported on the specified target CPU and will not be built. At least i586 class CPU is required. ;
50             .annouced-failure = 1 ;
51         }
52         result = <build>no ;
53     }
54
55     return $(result) ;
56 }
57
58 rule select-log-api ( properties * )
59 {
60     local result = <log-api>generic ;
61
62     local target_os = [ feature.get-values "target-os" : $(properties) ] ;
63     switch $(target_os)
64     {
65     case windows :
66         # We have to verify if message compiler is available
67         if ! ( <define>BOOST_LOG_WITHOUT_EVENT_LOG in $(properties) || <define>BOOST_LOG_WITHOUT_EVENT_LOG=1 in $(properties) )
68         {
69             local has_mc = [ configure.builds /boost/message-compiler//test-availability : $(properties) : message-compiler ] ;
70             if $(has_mc)
71             {
72                 result = <log-api>winnt ;
73             }
74         }
75
76     case linux : result = <log-api>unix ;
77     case *bsd : result = <log-api>unix ;
78     case darwin : result = <log-api>unix ;
79     case unix : result = <log-api>unix ;
80     case unixware : result = <log-api>unix ;
81     case cygwin : result = <log-api>unix ;
82     case hpux : result = <log-api>unix ;
83     case solaris : result = <log-api>unix ;
84     case qnx* : result = <log-api>unix ;
85     case sgi : result = <log-api>unix ;
86     case aix : result = <log-api>unix ;
87
88     case * : result = <log-api>generic ;
89     }
90
91     if ! <log-api>winnt in $(result)
92     {
93         result += <define>BOOST_LOG_WITHOUT_EVENT_LOG ;
94     }
95     if <log-api>unix in $(result)
96     {
97         result += <define>BOOST_LOG_USE_NATIVE_SYSLOG ;
98     }
99
100     return $(result) ;
101 }
102
103 rule select-regex-backend ( properties * )
104 {
105     local result = ;
106
107     # Use Boost.Regex backend by default. It produces smaller executables and also has the best performance for small string matching.
108     if ! ( <define>BOOST_LOG_WITHOUT_SETTINGS_PARSERS in $(properties) || <define>BOOST_LOG_WITHOUT_DEFAULT_FACTORIES in $(properties) || <define>BOOST_LOG_USE_STD_REGEX in $(properties) || <define>BOOST_LOG_USE_BOOST_XPRESSIVE in $(properties) )
109     {
110         result = <library>/boost/regex//boost_regex ;
111     }
112
113     return $(result) ;
114 }
115
116 project boost/log
117     : source-location ../src
118     : requirements
119         <conditional>@select-log-api
120         <conditional>@check-instruction-set
121         <conditional>@select-regex-backend
122         <define>BOOST_SPIRIT_USE_PHOENIX_V3=1
123         <define>BOOST_THREAD_DONT_USE_CHRONO=1 # Don't introduce false dependency on Boost.Chrono
124
125         # Disable warnings about using 'insecure' standard C functions
126         <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
127         <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
128         <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
129         <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
130         <toolset>intel-win:<define>_SCL_SECURE_NO_WARNINGS
131         <toolset>intel-win:<define>_SCL_SECURE_NO_DEPRECATE
132         <toolset>intel-win:<define>_CRT_SECURE_NO_WARNINGS
133         <toolset>intel-win:<define>_CRT_SECURE_NO_DEPRECATE
134
135         <toolset>msvc:<cxxflags>/bigobj
136         <toolset>msvc:<cxxflags>/wd4503 # decorated name length exceeded, name was truncated
137         <toolset>msvc:<cxxflags>/wd4456 # declaration of 'A' hides previous local declaration
138         <toolset>msvc:<cxxflags>/wd4459 # declaration of 'A' hides global declaration
139
140         # Disable Intel warnings:
141         # warning #177: function "X" was declared but never referenced
142         # warning #780: using-declaration ignored -- it refers to the current namespace
143         # warning #2196: routine is both "inline" and "noinline"
144         # remark #1782: #pragma once is obsolete. Use #ifndef guard instead.
145         # remark #193: zero used for undefined preprocessing identifier "X"
146         # remark #304: access control not specified ("public" by default)
147         # remark #981: operands are evaluated in unspecified order
148         # remark #1418: external function definition with no prior declaration
149         # Mostly comes from Boost.Phoenix: warning #411: class "X" defines no constructor to initialize the following: reference member "Y"...
150         # warning #734: "X" (declared at line N of "file.hpp"), required for copy that was eliminated, is inaccessible
151         # warning #279: controlling expression is constant
152         <toolset>intel-win:<cxxflags>"/Qwd177,780,2196,1782,193,304,981,1418,411,734,279"
153         <toolset>intel-linux:<cxxflags>"-wd177,780,2196,1782,193,304,981,1418,411,734,279"
154         <toolset>intel-darwin:<cxxflags>"-wd177,780,2196,1782,193,304,981,1418,411,734,279"
155
156         <toolset>darwin:<cxxflags>-ftemplate-depth-1024
157         <toolset>clang:<cxxflags>-ftemplate-depth-1024
158         <toolset>gcc:<cxxflags>-ftemplate-depth-1024
159
160         <toolset>gcc:<cxxflags>-fno-strict-aliasing  # avoids strict aliasing violations in other Boost components
161         <toolset>gcc,<target-os>windows:<linkflags>-Wl,--enable-auto-import
162         <toolset>gcc,<target-os>cygwin:<linkflags>-Wl,--enable-auto-import
163
164         <library>/boost/date_time//boost_date_time
165         <library>/boost/filesystem//boost_filesystem
166         <library>/boost/system//boost_system
167         <threading>single:<define>BOOST_LOG_NO_THREADS
168         <threading>multi:<library>/boost/thread//boost_thread
169
170         <target-os>windows:<library>ws2_32
171         <target-os>windows:<library>mswsock
172
173         <target-os>cygwin:<define>__USE_W32_SOCKETS
174         <target-os>cygwin:<library>ws2_32
175         <target-os>cygwin:<library>mswsock
176
177         <target-os>linux:<library>rt
178         <target-os>linux:<define>_XOPEN_SOURCE=600
179         <target-os>linux:<define>_GNU_SOURCE=1
180
181         <target-os>solaris:<define>_XOPEN_SOURCE=500
182         <target-os>solaris:<define>__EXTENSIONS__
183         <target-os>solaris:<library>socket
184         <target-os>solaris:<library>nsl
185
186         <target-os>hpux,<toolset>gcc:<define>_XOPEN_SOURCE_EXTENDED
187         <target-os>hpux:<library>ipv6
188
189         <target-os>freebsd:<library>rt
190         <target-os>qnxnto:<library>socket
191         <toolset>pgi:<library>rt
192     : usage-requirements
193         <toolset>clang:<cxxflags>-Wno-bind-to-temporary-copy
194         <toolset>clang:<cxxflags>-Wno-unused-function
195     ;
196
197 local BOOST_LOG_COMMON_SRC =
198     attribute_name.cpp
199     attribute_set.cpp
200     attribute_value_set.cpp
201     code_conversion.cpp
202     core.cpp
203     record_ostream.cpp
204     severity_level.cpp
205     global_logger_storage.cpp
206     named_scope.cpp
207     process_name.cpp
208     process_id.cpp
209     thread_id.cpp
210     timer.cpp
211     exceptions.cpp
212     default_attribute_names.cpp
213     default_sink.cpp
214     text_ostream_backend.cpp
215     text_file_backend.cpp
216     text_multifile_backend.cpp
217     syslog_backend.cpp
218     thread_specific.cpp
219     once_block.cpp
220     timestamp.cpp
221     threadsafe_queue.cpp
222     event.cpp
223     trivial.cpp
224     spirit_encoding.cpp
225     format_parser.cpp
226     date_time_format_parser.cpp
227     named_scope_format_parser.cpp
228     unhandled_exception_count.cpp
229     dump.cpp
230     ;
231
232 local BOOST_LOG_COMMON_SSSE3_SRC =
233     dump_ssse3
234     ;
235
236 local BOOST_LOG_COMMON_AVX2_SRC =
237     dump_avx2
238     ;
239
240 rule ssse3-targets-cond ( properties * )
241 {
242     local result = <build>no ;
243
244     if <log-architecture>x86 in [ log-architecture.deduce-architecture $(properties) ]
245     {
246         local has_ssse3 = [ configure.builds /boost/x86-extensions//ssse3 : $(properties) : compiler-supports-ssse3 ] ;
247         if $(has_ssse3)
248         {
249             result = ;
250             if <toolset>gcc in $(properties) || <toolset>clang in $(properties)
251             {
252                 result = <cxxflags>"-march=core2 -msse -msse2 -msse3 -mssse3" ;
253             }
254             else if <toolset>intel in $(properties)
255             {
256                 if <toolset-intel:platform>win in $(properties)
257                 {
258                     result = <cxxflags>"/QxSSSE3" ;
259                 }
260                 else
261                 {
262                     result = <cxxflags>"-march=core2" ;
263                 }
264             }
265             else if <toolset>msvc in $(properties)
266             {
267                 # MSVC doesn't really care about these switches, all SSE intrinsics are always available, but still...
268                 # Also 64 bit MSVC doesn't have the /arch:SSE2 switch as it is the default.
269                 if <log-address-model>32 in [ log-architecture.deduce-address-model $(properties) ]
270                 {
271                     result = <cxxflags>"/arch:SSE2" ;
272                 }
273             }
274         }
275     }
276
277 #    if ! <build>no in $(result)
278 #    {
279 #        ECHO Boost.Log: Using SSSE3 optimized implementation ;
280 #    }
281 #    ECHO $(result) ;
282
283     return $(result) ;
284 }
285
286 for local src in $(BOOST_LOG_COMMON_SSSE3_SRC)
287 {
288     obj $(src)
289         : ## sources ##
290             $(src).cpp
291         : ## requirements ##
292             <conditional>@ssse3-targets-cond
293             <link>shared:<define>BOOST_LOG_DLL
294             <define>BOOST_LOG_BUILDING_THE_LIB=1
295         : ## default-build ##
296         : ## usage-requirements ##
297             <define>BOOST_LOG_USE_SSSE3
298         ;
299 }
300
301
302 rule avx2-targets-cond ( properties * )
303 {
304     local result = <build>no ;
305
306     if <log-architecture>x86 in [ log-architecture.deduce-architecture $(properties) ]
307     {
308         local has_ssse3 = [ configure.builds /boost/x86-extensions//avx2 : $(properties) : compiler-supports-avx2 ] ;
309         if $(has_ssse3)
310         {
311             result = ;
312             if <toolset>gcc in $(properties)
313             {
314                 result = <cxxflags>"-march=core-avx2 -mavx -mavx2 -fabi-version=0" ;
315             }
316             else if <toolset>clang in $(properties)
317             {
318                 result = <cxxflags>"-march=core-avx2 -mavx -mavx2" ;
319             }
320             else if <toolset>intel in $(properties)
321             {
322                 if <toolset-intel:platform>win in $(properties)
323                 {
324                     result = <cxxflags>"/arch:CORE-AVX2" ;
325                 }
326                 else
327                 {
328                     result = <cxxflags>"-march=core-avx2 -fabi-version=0" ;
329                 }
330             }
331             else if <toolset>msvc in $(properties)
332             {
333                 result = <cxxflags>"/arch:AVX" ;
334             }
335         }
336     }
337
338 #    if ! <build>no in $(result)
339 #    {
340 #        ECHO Boost.Log: Using AVX2 optimized implementation ;
341 #    }
342 #    ECHO $(result) ;
343
344     return $(result) ;
345 }
346
347 for local src in $(BOOST_LOG_COMMON_AVX2_SRC)
348 {
349     obj $(src)
350         : ## sources ##
351             $(src).cpp
352         : ## requirements ##
353             <conditional>@avx2-targets-cond
354             <link>shared:<define>BOOST_LOG_DLL
355             <define>BOOST_LOG_BUILDING_THE_LIB=1
356         : ## default-build ##
357         : ## usage-requirements ##
358             <define>BOOST_LOG_USE_AVX2
359         ;
360 }
361
362 alias platform-specific-sources
363     : ## sources ##
364         debug_output_backend.cpp
365         light_rw_mutex.cpp
366     : ## requirements ##
367         <target-os>windows
368     ;
369
370 alias platform-specific-sources ;
371
372 rule select-log-api-specific-sources ( properties * )
373 {
374     local result ;
375
376     if <log-api>winnt in $(properties)
377     {
378         result = <source>simple_event_log.mc ;
379         result += <source>event_log_backend.cpp ;
380         result += <library>psapi ;
381
382         DEPENDS event_log_backend.cpp : simple_event_log.mc ;
383     }
384
385     return $(result) ;
386 }
387
388 lib boost_log
389     : ## sources ##
390         $(BOOST_LOG_COMMON_SRC)
391         $(BOOST_LOG_COMMON_SSSE3_SRC)
392         $(BOOST_LOG_COMMON_AVX2_SRC)
393         platform-specific-sources
394     : ## requirements ##
395         <conditional>@select-log-api-specific-sources
396         <link>shared:<define>BOOST_LOG_DLL
397         <define>BOOST_LOG_BUILDING_THE_LIB=1
398     : ## default-build ##
399     : ## usage-requirements ##
400         <link>shared:<define>BOOST_LOG_DYN_LINK=1
401         <threading>single:<define>BOOST_LOG_NO_THREADS
402         <log-api>generic:<define>BOOST_LOG_WITHOUT_EVENT_LOG
403         <log-api>unix:<define>BOOST_LOG_WITHOUT_EVENT_LOG
404     ;
405
406
407 local BOOST_LOG_SETUP_COMMON_SRC =
408     parser_utils.cpp
409     init_from_stream.cpp
410     init_from_settings.cpp
411     settings_parser.cpp
412     filter_parser.cpp
413     formatter_parser.cpp
414     default_filter_factory.cpp
415     matches_relation_factory.cpp
416     default_formatter_factory.cpp
417     ;
418
419 lib boost_log_setup
420     : ## sources ##
421         $(BOOST_LOG_SETUP_COMMON_SRC)
422     : ## requirements ##
423         <link>shared:<define>BOOST_LOG_DYN_LINK=1
424         <link>shared:<define>BOOST_LOG_SETUP_DLL
425         <define>BOOST_LOG_SETUP_BUILDING_THE_LIB=1
426         <library>boost_log
427     : ## default-build ##
428     : ## usage-requirements ##
429         <link>shared:<define>BOOST_LOG_SETUP_DYN_LINK=1
430         <threading>single:<define>BOOST_LOG_NO_THREADS
431     ;