Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / build / v2 / tools / intel-win.jam
1 # Copyright Vladimir Prus 2004.
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt
4 # or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 # Importing common is needed because the rules we inherit here depend on it.
7 # That is nasty.
8 import common ;
9 import errors ;
10 import feature ;
11 import intel ;
12 import msvc ;
13 import os ;
14 import toolset ;
15 import generators ;
16 import type ;
17
18 feature.extend-subfeature toolset intel : platform : win ;
19
20 toolset.inherit-generators intel-win <toolset>intel <toolset-intel:platform>win : msvc ;
21 toolset.inherit-flags intel-win : msvc : : YLOPTION ;
22 toolset.inherit-rules intel-win : msvc ;
23
24 # Override default do-nothing generators.
25 generators.override intel-win.compile.c.pch   : pch.default-c-pch-generator   ;
26 generators.override intel-win.compile.c++.pch : pch.default-cpp-pch-generator ;
27 generators.override intel-win.compile.rc : rc.compile.resource ;
28 generators.override intel-win.compile.mc : mc.compile ;
29
30 toolset.flags intel-win.compile PCH_SOURCE <pch>on : <pch-source> ;
31
32 toolset.add-requirements <toolset>intel-win,<runtime-link>shared:<threading>multi ;
33
34 # Initializes the intel toolset for windows
35 rule init ( version ? :     # the compiler version
36             command * :     # the command to invoke the compiler itself
37             options *       # Additional option: <compatibility>
38                             # either 'vc6', 'vc7', 'vc7.1'
39                             # or 'native'(default).
40           )
41 {
42     local compatibility =
43       [ feature.get-values <compatibility> : $(options) ] ;
44     local condition = [  common.check-init-parameters intel-win
45         : version $(version) : compatibility $(compatibility) ] ;
46
47     command = [ common.get-invocation-command intel-win : icl.exe :
48         $(command) ] ;
49
50     common.handle-options intel-win : $(condition) : $(command) : $(options) ;
51
52     local root ;
53     if $(command)
54     {
55         root = [ common.get-absolute-tool-path $(command[-1]) ] ;
56         root = $(root)/ ;
57     }
58
59     local setup ;
60     setup = [ GLOB $(root) : iclvars_*.bat ] ;
61     if ! $(setup)
62     {
63        setup = $(root)/iclvars.bat ;
64     }
65     setup = "call \""$(setup)"\" > nul " ;
66
67     if [ os.name ] = NT
68     {
69         setup = $(setup)"
70 " ;
71     }
72     else
73     {
74         setup = "cmd /S /C "$(setup)" \"&&\" " ;
75     }
76
77     toolset.flags intel-win.compile .CC $(condition) : $(setup)icl ;
78     toolset.flags intel-win.link .LD $(condition) : $(setup)xilink ;
79     toolset.flags intel-win.archive .LD $(condition) : $(setup)xilink /lib ;
80     toolset.flags intel-win.link .MT $(condition) : $(setup)mt -nologo ;
81     toolset.flags intel-win.compile .MC $(condition) : $(setup)mc ;
82     toolset.flags intel-win.compile .RC $(condition) : $(setup)rc ;
83
84     local m = [ MATCH (.).* : $(version) ] ;
85     local major = $(m[1]) ;
86
87     local C++FLAGS ;
88
89     C++FLAGS += /nologo ;
90
91     # Reduce the number of spurious error messages
92     C++FLAGS += /Qwn5 /Qwd985 ;
93
94     # Enable ADL
95     C++FLAGS += -Qoption,c,--arg_dep_lookup ; #"c" works for C++, too
96
97     # Disable Microsoft "secure" overloads in Dinkumware libraries since they
98     # cause compile errors with Intel versions 9 and 10.
99     C++FLAGS += -D_SECURE_SCL=0 ;
100
101     if $(major) > 5
102     {
103         C++FLAGS += /Zc:forScope ;  # Add support for correct for loop scoping.
104     }
105
106     # Add options recognized only by intel7 and above.
107     if $(major) >= 7
108     {
109         C++FLAGS += /Qansi_alias ;
110     }
111
112     if $(compatibility) = vc6
113     {
114         C++FLAGS +=
115           # Emulate VC6
116           /Qvc6
117
118           # No wchar_t support in vc6 dinkum library.  Furthermore, in vc6
119           # compatibility-mode, wchar_t is not a distinct type from unsigned
120           # short.
121           -DBOOST_NO_INTRINSIC_WCHAR_T
122           ;
123     }
124     else
125     {
126         if $(major) > 5
127         {
128             # Add support for wchar_t
129             C++FLAGS += /Zc:wchar_t
130               # Tell the dinkumware library about it.
131               -D_NATIVE_WCHAR_T_DEFINED
132               ;
133         }
134     }
135
136     if $(compatibility) && $(compatibility) != native
137     {
138         C++FLAGS += /Q$(base-vc) ;
139     }
140     else
141     {
142         C++FLAGS +=
143           -Qoption,cpp,--arg_dep_lookup
144           # The following options were intended to disable the Intel compiler's
145           # 'bug-emulation' mode, but were later reported to be causing ICE with
146           # Intel-Win 9.0. It is not yet clear which options can be safely used.
147           # -Qoption,cpp,--const_string_literals
148           # -Qoption,cpp,--new_for_init
149           # -Qoption,cpp,--no_implicit_typename
150           # -Qoption,cpp,--no_friend_injection
151           # -Qoption,cpp,--no_microsoft_bugs
152           ;
153     }
154
155     toolset.flags intel-win CFLAGS $(condition) : $(C++FLAGS) ;
156     # By default, when creating PCH, intel adds 'i' to the explicitly
157     # specified name of the PCH file. Of course, Boost.Build is not
158     # happy when compiler produces not the file it was asked for.
159     # The option below stops this behaviour.
160     toolset.flags intel-win CFLAGS : -Qpchi- ;
161
162     if ! $(compatibility)
163     {
164         # If there's no backend version, assume 10.
165         compatibility = vc10 ;
166     }
167
168     local extract-version = [ MATCH ^vc(.*) : $(compatibility) ] ;
169     if ! $(extract-version)
170     {
171         errors.user-error "Invalid value for compatibility option:"
172             $(compatibility) ;
173     }
174
175     # Depending on the settings, running of tests require some runtime DLLs.
176     toolset.flags intel-win RUN_PATH $(condition) : $(root) ;
177
178     msvc.configure-version-specific intel-win : $(extract-version[1]) : $(condition) ;
179 }
180
181 toolset.flags intel-win.link LIBRARY_OPTION <toolset>intel : "" ;
182
183 toolset.flags intel-win YLOPTION ;
184