Imported Upstream version 1.57.0
[platform/upstream/boost.git] / tools / build / src / tools / qcc.jam
1 #  Copyright (c) 2001 David Abrahams.
2 #  Copyright (c) 2002-2003 Rene Rivera.
3 #  Copyright (c) 2002-2003 Vladimir Prus.
4 #
5 #  Use, modification and distribution is subject to the Boost Software
6 #  License Version 1.0. (See accompanying file LICENSE_1_0.txt or
7 #  http://www.boost.org/LICENSE_1_0.txt)
8
9 import "class" : new ;
10 import common ;
11 import errors ;
12 import feature ;
13 import generators ;
14 import os ;
15 import property ;
16 import set ;
17 import toolset ;
18 import type ;
19 import unix ;
20
21 feature.extend toolset : qcc ;
22
23 toolset.inherit-generators qcc : unix : unix.link unix.link.dll ;
24 generators.override builtin.lib-generator : qcc.prebuilt ;
25 toolset.inherit-flags qcc : unix ;
26 toolset.inherit-rules qcc : unix ;
27
28 # Initializes the qcc toolset for the given version. If necessary, command may
29 # be used to specify where the compiler is located. The parameter 'options' is a
30 # space-delimited list of options, each one being specified as
31 # <option-name>option-value. Valid option names are: cxxflags, linkflags and
32 # linker-type. Accepted values for linker-type are gnu and sun, gnu being the
33 # default.
34 #
35 # Example:
36 #   using qcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ;
37 #
38 rule init ( version ? : command * : options * )
39 {
40     local condition = [ common.check-init-parameters qcc : version $(version) ] ;
41     local command = [ common.get-invocation-command qcc : QCC : $(command) ] ;
42     common.handle-options qcc : $(condition) : $(command) : $(options) ;
43 }
44
45
46 generators.register-c-compiler qcc.compile.c++ : CPP : OBJ : <toolset>qcc ;
47 generators.register-c-compiler qcc.compile.c   : C   : OBJ : <toolset>qcc ;
48 generators.register-c-compiler qcc.compile.asm : ASM : OBJ : <toolset>qcc ;
49
50
51 # Declare flags for compilation.
52 toolset.flags qcc.compile OPTIONS <debug-symbols>on : -gstabs+ ;
53
54 # Declare flags and action for compilation.
55 toolset.flags qcc.compile OPTIONS <optimization>off : -O0 ;
56 toolset.flags qcc.compile OPTIONS <optimization>speed : -O3 ;
57 toolset.flags qcc.compile OPTIONS <optimization>space : -Os ;
58
59 toolset.flags qcc.compile OPTIONS <inlining>off : -Wc,-fno-inline ;
60 toolset.flags qcc.compile OPTIONS <inlining>on : -Wc,-Wno-inline ;
61 toolset.flags qcc.compile OPTIONS <inlining>full : -Wc,-finline-functions -Wc,-Wno-inline ;
62
63 toolset.flags qcc.compile OPTIONS <warnings>off : -w ;
64 toolset.flags qcc.compile OPTIONS <warnings>all : -Wc,-Wall ;
65 toolset.flags qcc.compile OPTIONS <warnings-as-errors>on : -Wc,-Werror ;
66
67 toolset.flags qcc.compile OPTIONS <profiling>on : -p ;
68
69 toolset.flags qcc.compile OPTIONS <cflags> ;
70 toolset.flags qcc.compile.c++ OPTIONS <cxxflags> ;
71 toolset.flags qcc.compile DEFINES <define> ;
72 toolset.flags qcc.compile INCLUDES <include> ;
73
74 toolset.flags qcc.compile OPTIONS <link>shared : -shared ;
75
76 toolset.flags qcc.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ;
77
78
79 rule compile.c++
80 {
81     # Here we want to raise the template-depth parameter value to something
82     # higher than the default value of 17. Note that we could do this using the
83     # feature.set-default rule but we do not want to set the default value for
84     # all toolsets as well.
85     #
86     # TODO: This 'modified default' has been inherited from some 'older Boost
87     # Build implementation' and has most likely been added to make some Boost
88     # library parts compile correctly. We should see what exactly prompted this
89     # and whether we can get around the problem more locally.
90     local template-depth = [ on $(1) return $(TEMPLATE_DEPTH) ] ;
91     if ! $(template-depth)
92     {
93         TEMPLATE_DEPTH on $(1) = 128 ;
94     }
95 }
96
97 actions compile.c++
98 {
99     "$(CONFIG_COMMAND)" -Wc,-ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
100 }
101
102 actions compile.c
103 {
104     "$(CONFIG_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
105 }
106
107 actions compile.asm
108 {
109     "$(CONFIG_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
110 }
111
112
113 # The class checking that we do not try to use the <runtime-link>static property
114 # while creating or using a shared library, since it is not supported by qcc/
115 # /libc.
116 #
117 class qcc-linking-generator : unix-linking-generator
118 {
119     rule generated-targets ( sources + : property-set : project name ? )
120     {
121         if <runtime-link>static in [ $(property-set).raw ]
122         {
123             local m ;
124             if [ id ] = "qcc.link.dll"
125             {
126                 m = "on qcc, DLL can't be build with <runtime-link>static" ;
127             }
128             if ! $(m)
129             {
130                 for local s in $(sources)
131                 {
132                     local type = [ $(s).type ] ;
133                     if $(type) && [ type.is-derived $(type) SHARED_LIB ]
134                     {
135                         m = "on qcc, using DLLS together with the <runtime-link>static options is not possible " ;
136                     }
137                 }
138             }
139             if $(m)
140             {
141                 errors.user-error $(m) : "It is suggested to use"
142                     "<runtime-link>static together with <link>static." ;
143             }
144         }
145
146         return [ unix-linking-generator.generated-targets
147             $(sources) : $(property-set) : $(project) $(name) ] ;
148     }
149 }
150
151 generators.register [ new qcc-linking-generator qcc.link : LIB OBJ : EXE
152     : <toolset>qcc ] ;
153
154 generators.register [ new qcc-linking-generator qcc.link.dll : LIB OBJ
155     : SHARED_LIB : <toolset>qcc ] ;
156
157 generators.override qcc.prebuilt : builtin.prebuilt ;
158 generators.override qcc.searched-lib-generator : searched-lib-generator ;
159
160
161 # Declare flags for linking.
162 # First, the common flags.
163 toolset.flags qcc.link OPTIONS <debug-symbols>on : -gstabs+ ;
164 toolset.flags qcc.link OPTIONS <profiling>on : -p ;
165 toolset.flags qcc.link OPTIONS <linkflags> ;
166 toolset.flags qcc.link LINKPATH <library-path> ;
167 toolset.flags qcc.link FINDLIBS-ST <find-static-library> ;
168 toolset.flags qcc.link FINDLIBS-SA <find-shared-library> ;
169 toolset.flags qcc.link LIBRARIES <library-file> ;
170
171 toolset.flags qcc.link FINDLIBS-SA : m ;
172
173 # For <runtime-link>static we made sure there are no dynamic libraries in the
174 # link.
175 toolset.flags qcc.link OPTIONS <runtime-link>static : -static ;
176
177 # Assuming this is just like with gcc.
178 toolset.flags qcc.link RPATH : <dll-path> : unchecked ;
179 toolset.flags qcc.link RPATH_LINK : <xdll-path> : unchecked ;
180
181
182 # Declare actions for linking.
183 #
184 rule link ( targets * : sources * : properties * )
185 {
186     SPACE on $(targets) = " " ;
187     # Serialize execution of the 'link' action, since running N links in
188     # parallel is just slower. For now, serialize only qcc links while it might
189     # be a good idea to serialize all links.
190     JAM_SEMAPHORE on $(targets) = <s>qcc-link-semaphore ;
191 }
192
193 actions link bind LIBRARIES
194 {
195     "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS)
196 }
197
198
199 # Always remove archive and start again. Here is the rationale from Andre Hentz:
200 # I had a file, say a1.c, that was included into liba.a. I moved a1.c to a2.c,
201 # updated my Jamfiles and rebuilt. My program was crashing with absurd errors.
202 # After some debugging I traced it back to the fact that a1.o was *still* in
203 # liba.a
204 RM = [ common.rm-command ] ;
205 if [ os.name ] = NT
206 {
207     RM = "if exist \"$(<[1])\" DEL \"$(<[1])\""  ;
208 }
209
210
211 # Declare action for creating static libraries. The 'r' letter means to add
212 # files to the archive with replacement. Since we remove the archive, we do not
213 # care about replacement, but there is no option to "add without replacement".
214 # The 'c' letter suppresses warnings in case the archive does not exists yet.
215 # That warning is produced only on some platforms, for whatever reasons.
216 #
217 # Use qcc driver to create archive, see
218 #     http://www.qnx.com/developers/docs/6.3.2/neutrino/utilities/q/qcc.html
219 actions piecemeal archive
220 {
221     $(RM) "$(<)"
222     "$(CONFIG_COMMAND)" -A "$(<)" "$(>)"
223 }
224
225
226 rule link.dll ( targets * : sources * : properties * )
227 {
228     SPACE on $(targets) = " " ;
229     JAM_SEMAPHORE on $(targets) = <s>qcc-link-semaphore ;
230 }
231
232
233 # Differ from 'link' above only by -shared.
234 #
235 actions link.dll bind LIBRARIES
236 {
237     "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" $(HAVE_SONAME)-Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)"  "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS)
238 }