1 | # Copyright 2001 David Abrahams
|
---|
2 | # Copyright 2002-2006 Rene Rivera
|
---|
3 | # Copyright 2002-2003 Vladimir Prus
|
---|
4 | # Copyright 2005 Reece H. Dunn
|
---|
5 | # Copyright 2006 Ilya Sokolov
|
---|
6 | # Copyright 2007 Roland Schwarz
|
---|
7 | # Copyright 2007 Boris Gubenko
|
---|
8 | #
|
---|
9 | # Distributed under the Boost Software License, Version 1.0.
|
---|
10 | # (See accompanying file LICENSE_1_0.txt or copy at
|
---|
11 | # http://www.boost.org/LICENSE_1_0.txt)
|
---|
12 |
|
---|
13 | import "class" : new ;
|
---|
14 | import common ;
|
---|
15 | import feature ;
|
---|
16 | import fortran ;
|
---|
17 | import generators ;
|
---|
18 | import os ;
|
---|
19 | import pch ;
|
---|
20 | import property ;
|
---|
21 | import property-set ;
|
---|
22 | import rc ;
|
---|
23 | import regex ;
|
---|
24 | import set ;
|
---|
25 | import toolset ;
|
---|
26 | import type ;
|
---|
27 | import unix ;
|
---|
28 |
|
---|
29 |
|
---|
30 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
|
---|
31 | {
|
---|
32 | .debug-configuration = true ;
|
---|
33 | }
|
---|
34 |
|
---|
35 |
|
---|
36 | feature.extend toolset : gcc ;
|
---|
37 | # feature.subfeature toolset gcc : flavor : : optional ;
|
---|
38 |
|
---|
39 | toolset.inherit-generators gcc : unix : unix.link unix.link.dll ;
|
---|
40 | toolset.inherit-flags gcc : unix ;
|
---|
41 | toolset.inherit-rules gcc : unix ;
|
---|
42 |
|
---|
43 | generators.override gcc.prebuilt : builtin.prebuilt ;
|
---|
44 | generators.override gcc.searched-lib-generator : searched-lib-generator ;
|
---|
45 |
|
---|
46 | # Make gcc toolset object files use the "o" suffix on all platforms.
|
---|
47 | type.set-generated-target-suffix OBJ : <toolset>gcc : o ;
|
---|
48 | type.set-generated-target-suffix OBJ : <toolset>gcc <target-os>windows : o ;
|
---|
49 | type.set-generated-target-suffix OBJ : <toolset>gcc <target-os>cygwin : o ;
|
---|
50 |
|
---|
51 |
|
---|
52 | # Initializes the gcc toolset for the given version. If necessary, command may
|
---|
53 | # be used to specify where the compiler is located. The parameter 'options' is a
|
---|
54 | # space-delimited list of options, each one specified as
|
---|
55 | # <option-name>option-value. Valid option names are: cxxflags, linkflags and
|
---|
56 | # linker-type. Accepted linker-type values are aix, darwin, gnu, hpux, osf or
|
---|
57 | # sun and the default value will be selected based on the current OS.
|
---|
58 | # Example:
|
---|
59 | # using gcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ;
|
---|
60 | #
|
---|
61 | # The compiler command to use is detected in three steps:
|
---|
62 | # 1) If an explicit command is specified by the user, it will be used and must
|
---|
63 | # be available.
|
---|
64 | # 2) If only a certain version is specified, it is enforced:
|
---|
65 | # - either the 'g++-VERSION' command must be available
|
---|
66 | # - or the default command 'g++' must be available and match the exact
|
---|
67 | # version.
|
---|
68 | # 3) Without user-provided restrictions use default 'g++'.
|
---|
69 | #
|
---|
70 | rule init ( version ? : command * : options * )
|
---|
71 | {
|
---|
72 | #1): use user-provided command
|
---|
73 | local tool-command = ;
|
---|
74 | if $(command)
|
---|
75 | {
|
---|
76 | tool-command = [ common.get-invocation-command-nodefault gcc : g++ :
|
---|
77 | $(command) ] ;
|
---|
78 | if ! $(tool-command)
|
---|
79 | {
|
---|
80 | import errors ;
|
---|
81 | errors.error toolset gcc initialization:
|
---|
82 | : provided command '$(command)' not found
|
---|
83 | : initialized from [ errors.nearest-user-location ] ;
|
---|
84 | }
|
---|
85 | }
|
---|
86 | #2): enforce user-provided version
|
---|
87 | else if $(version)
|
---|
88 | {
|
---|
89 | tool-command = [ common.get-invocation-command-nodefault gcc :
|
---|
90 | "g++-$(version[1])" ] ;
|
---|
91 |
|
---|
92 | #2.1) fallback: check whether "g++" reports the requested version
|
---|
93 | if ! $(tool-command)
|
---|
94 | {
|
---|
95 | tool-command = [ common.get-invocation-command-nodefault gcc : g++ ]
|
---|
96 | ;
|
---|
97 | if $(tool-command)
|
---|
98 | {
|
---|
99 | local tool-command-string = \"$(tool-command)\" ;
|
---|
100 | tool-command-string = $(tool-command-string:J=" ") ;
|
---|
101 | local tool-version = [ MATCH "^([0-9.]+)" :
|
---|
102 | [ SHELL "$(tool-command-string) -dumpversion" ] ] ;
|
---|
103 | if $(tool-version) != $(version)
|
---|
104 | {
|
---|
105 | # Permit a match betwen a two-digit version specified by the
|
---|
106 | # user (e.g. 4.4) and a 3-digit version reported by gcc.
|
---|
107 | # Since only two digits are present in the binary name
|
---|
108 | # anyway, insisting that user specify the 3-digit version
|
---|
109 | # when configuring Boost.Build, while it is not required on
|
---|
110 | # the command line, would be strange.
|
---|
111 | local stripped = [ MATCH "^([0-9]+\.[0-9]+).*" :
|
---|
112 | $(tool-version) ] ;
|
---|
113 | if $(stripped) != $(version)
|
---|
114 | {
|
---|
115 | import errors ;
|
---|
116 | errors.error toolset gcc initialization:
|
---|
117 | : version '$(version)' requested but
|
---|
118 | 'g++-$(version)' not found and version
|
---|
119 | '$(tool-version)' of default '$(tool-command)'
|
---|
120 | does not match
|
---|
121 | : initialized from [ errors.nearest-user-location ]
|
---|
122 | ;
|
---|
123 | tool-command = ;
|
---|
124 | }
|
---|
125 | # Use full 3-digit version to be compatible with the
|
---|
126 | # 'using gcc ;' case
|
---|
127 | version = $(tool-version) ;
|
---|
128 | }
|
---|
129 | }
|
---|
130 | else
|
---|
131 | {
|
---|
132 | import errors ;
|
---|
133 | errors.error toolset gcc initialization:
|
---|
134 | : version '$(version)' requested but neither
|
---|
135 | 'g++-$(version)' nor default 'g++' found
|
---|
136 | : initialized from [ errors.nearest-user-location ] ;
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|
140 | #3) default: no command and no version specified, try using "g++"
|
---|
141 | else
|
---|
142 | {
|
---|
143 | tool-command = [ common.get-invocation-command-nodefault gcc : g++ ] ;
|
---|
144 | if ! $(tool-command)
|
---|
145 | {
|
---|
146 | import errors ;
|
---|
147 | errors.error toolset gcc initialization:
|
---|
148 | : no command provided, default command 'g++' not found
|
---|
149 | : initialized from [ errors.nearest-user-location ] ;
|
---|
150 | }
|
---|
151 | }
|
---|
152 |
|
---|
153 |
|
---|
154 | # Information about the gcc command...
|
---|
155 | # The command.
|
---|
156 | local command = $(tool-command) ;
|
---|
157 | # The 'command' variable can have multiple elements but when calling the
|
---|
158 | # SHELL builtin we need a single string, and we need to quote elements
|
---|
159 | # with spaces.
|
---|
160 | local command-string = \"$(command)\" ;
|
---|
161 | command-string = $(command-string:J=" ") ;
|
---|
162 | # The root directory of the tool install.
|
---|
163 | local root = [ feature.get-values <root> : $(options) ] ;
|
---|
164 | # The bin directory where to find the command to execute.
|
---|
165 | local bin ;
|
---|
166 | # The compiler flavor.
|
---|
167 | local flavor = [ feature.get-values <flavor> : $(options) ] ;
|
---|
168 | # Autodetect the root and bin dir if not given.
|
---|
169 | if $(command)
|
---|
170 | {
|
---|
171 | bin ?= [ common.get-absolute-tool-path $(command[-1]) ] ;
|
---|
172 | root ?= $(bin:D) ;
|
---|
173 | }
|
---|
174 | # Autodetect the version and flavor if not given.
|
---|
175 | if $(command)
|
---|
176 | {
|
---|
177 | local machine = [ MATCH "^([^ ]+)" :
|
---|
178 | [ SHELL "$(command-string) -dumpmachine" ] ] ;
|
---|
179 | version ?= [ MATCH "^([0-9.]+)" :
|
---|
180 | [ SHELL "$(command-string) -dumpversion" ] ] ;
|
---|
181 | switch $(machine:L)
|
---|
182 | {
|
---|
183 | case *mingw* : flavor ?= mingw ;
|
---|
184 | }
|
---|
185 | }
|
---|
186 |
|
---|
187 | local condition ;
|
---|
188 | if $(flavor)
|
---|
189 | {
|
---|
190 | condition = flavor $(flavor) ;
|
---|
191 | }
|
---|
192 | condition = [ common.check-init-parameters gcc : version $(version)
|
---|
193 | : $(condition) ] ;
|
---|
194 |
|
---|
195 | common.handle-options gcc : $(condition) : $(command) : $(options) ;
|
---|
196 |
|
---|
197 | local linker = [ feature.get-values <linker-type> : $(options) ] ;
|
---|
198 | # TODO: The logic below should actually be keyed on <target-os>.
|
---|
199 | if ! $(linker)
|
---|
200 | {
|
---|
201 | switch [ os.name ]
|
---|
202 | {
|
---|
203 | case OSF : linker = osf ;
|
---|
204 | case HPUX : linker = hpux ;
|
---|
205 | case AIX : linker = aix ;
|
---|
206 | case SOLARIS : linker = sun ;
|
---|
207 | case * : linker = gnu ;
|
---|
208 | }
|
---|
209 | }
|
---|
210 | init-link-flags gcc $(linker) $(condition) ;
|
---|
211 |
|
---|
212 | # If gcc is installed in a non-standard location, we would need to add
|
---|
213 | # LD_LIBRARY_PATH when running programs created with it (for unit-test/run
|
---|
214 | # rules).
|
---|
215 | if $(command)
|
---|
216 | {
|
---|
217 | # On multilib 64-bit boxes, there are both 32-bit and 64-bit libraries
|
---|
218 | # and all must be added to LD_LIBRARY_PATH. The linker will pick the
|
---|
219 | # right onces. Note that we do not provide a clean way to build a 32-bit
|
---|
220 | # binary using a 64-bit compiler, but user can always pass -m32
|
---|
221 | # manually.
|
---|
222 | local lib_path = $(root)/bin $(root)/lib $(root)/lib32 $(root)/lib64 ;
|
---|
223 | if $(.debug-configuration)
|
---|
224 | {
|
---|
225 | ECHO notice: using gcc libraries :: $(condition) :: $(lib_path) ;
|
---|
226 | }
|
---|
227 | toolset.flags gcc.link RUN_PATH $(condition) : $(lib_path) ;
|
---|
228 | }
|
---|
229 |
|
---|
230 | # If we are not using a system gcc installation we should adjust the various
|
---|
231 | # programs as needed to prefer using their installation specific versions.
|
---|
232 | # This is essential for correct use of MinGW and for cross-compiling.
|
---|
233 |
|
---|
234 | local nl = "
|
---|
235 | " ;
|
---|
236 |
|
---|
237 | # - Archive builder.
|
---|
238 | local archiver = [ common.get-invocation-command gcc
|
---|
239 | : [ NORMALIZE_PATH [ MATCH "(.*)[$(nl)]+" :
|
---|
240 | [ SHELL "$(command-string) -print-prog-name=ar" ] ] ]
|
---|
241 | : [ feature.get-values <archiver> : $(options) ]
|
---|
242 | : $(bin)
|
---|
243 | : search-path ] ;
|
---|
244 | toolset.flags gcc.archive .AR $(condition) : $(archiver[1]) ;
|
---|
245 | if $(.debug-configuration)
|
---|
246 | {
|
---|
247 | ECHO notice: using gcc archiver :: $(condition) :: $(archiver[1]) ;
|
---|
248 | }
|
---|
249 |
|
---|
250 | # - Ranlib.
|
---|
251 | local ranlib = [ common.get-invocation-command gcc
|
---|
252 | : [ NORMALIZE_PATH [ MATCH "(.*)[$(nl)]+" :
|
---|
253 | [ SHELL "$(command-string) -print-prog-name=ranlib" ] ] ]
|
---|
254 | : [ feature.get-values <ranlib> : $(options) ]
|
---|
255 | : $(bin)
|
---|
256 | : search-path ] ;
|
---|
257 | toolset.flags gcc.archive .RANLIB $(condition) : $(ranlib[1]) ;
|
---|
258 | if $(.debug-configuration)
|
---|
259 | {
|
---|
260 | ECHO notice: using gcc ranlib :: $(condition) :: $(ranlib[1]) ;
|
---|
261 | }
|
---|
262 |
|
---|
263 | # - Resource compiler.
|
---|
264 | local rc = [ common.get-invocation-command-nodefault gcc : windres :
|
---|
265 | [ feature.get-values <rc> : $(options) ] : $(bin) : search-path ] ;
|
---|
266 | local rc-type = [ feature.get-values <rc-type> : $(options) ] ;
|
---|
267 | rc-type ?= windres ;
|
---|
268 | if ! $(rc)
|
---|
269 | {
|
---|
270 | # If we can not find an RC compiler we fallback to a null one that
|
---|
271 | # creates empty object files. This allows the same Jamfiles to work
|
---|
272 | # across the board. The null RC uses assembler to create the empty
|
---|
273 | # objects, so configure that.
|
---|
274 | rc = [ common.get-invocation-command gcc : as : : $(bin) : search-path ]
|
---|
275 | ;
|
---|
276 | rc-type = null ;
|
---|
277 | }
|
---|
278 | rc.configure $(rc) : $(condition) : <rc-type>$(rc-type) ;
|
---|
279 | }
|
---|
280 |
|
---|
281 | if [ os.name ] = NT
|
---|
282 | {
|
---|
283 | # This causes single-line command invocation to not go through .bat files,
|
---|
284 | # thus avoiding command-line length limitations.
|
---|
285 | # TODO: Set JAMSHELL on specific targets instead of globally.
|
---|
286 | JAMSHELL = % ;
|
---|
287 | }
|
---|
288 |
|
---|
289 | generators.register-c-compiler gcc.compile.c++.preprocess : CPP : PREPROCESSED_CPP : <toolset>gcc ;
|
---|
290 | generators.register-c-compiler gcc.compile.c.preprocess : C : PREPROCESSED_C : <toolset>gcc ;
|
---|
291 | generators.register-c-compiler gcc.compile.c++ : CPP : OBJ : <toolset>gcc ;
|
---|
292 | generators.register-c-compiler gcc.compile.c : C : OBJ : <toolset>gcc ;
|
---|
293 | generators.register-c-compiler gcc.compile.asm : ASM : OBJ : <toolset>gcc ;
|
---|
294 | generators.register-fortran-compiler gcc.compile.fortran : FORTRAN FORTRAN90 : OBJ : <toolset>gcc ;
|
---|
295 |
|
---|
296 | # pch support
|
---|
297 |
|
---|
298 | # The compiler looks for a precompiled header in each directory just before it
|
---|
299 | # looks for the include file in that directory. The name searched for is the
|
---|
300 | # name specified in the #include directive with ".gch" suffix appended. The
|
---|
301 | # logic in gcc-pch-generator will make sure that the BASE_PCH suffix is appended
|
---|
302 | # to the full header name.
|
---|
303 |
|
---|
304 | type.set-generated-target-suffix PCH : <toolset>gcc : gch ;
|
---|
305 |
|
---|
306 | # GCC-specific pch generator.
|
---|
307 | class gcc-pch-generator : pch-generator
|
---|
308 | {
|
---|
309 | import project ;
|
---|
310 | import property-set ;
|
---|
311 | import type ;
|
---|
312 |
|
---|
313 | rule run-pch ( project name ? : property-set : sources + )
|
---|
314 | {
|
---|
315 | # Find the header in sources. Ignore any CPP sources.
|
---|
316 | local header ;
|
---|
317 | for local s in $(sources)
|
---|
318 | {
|
---|
319 | if [ type.is-derived [ $(s).type ] H ]
|
---|
320 | {
|
---|
321 | header = $(s) ;
|
---|
322 | }
|
---|
323 | }
|
---|
324 |
|
---|
325 | # Error handling: base header file name should be the same as the base
|
---|
326 | # precompiled header name.
|
---|
327 | local header-name = [ $(header).name ] ;
|
---|
328 | local header-basename = $(header-name:B) ;
|
---|
329 | if $(header-basename) != $(name)
|
---|
330 | {
|
---|
331 | local location = [ $(project).project-module ] ;
|
---|
332 | import errors : user-error : errors.user-error ;
|
---|
333 | errors.user-error "in" $(location): pch target name '$(name)' should
|
---|
334 | be the same as the base name of header file '$(header-name)' ;
|
---|
335 | }
|
---|
336 |
|
---|
337 | local pch-file = [ generator.run $(project) $(name) : $(property-set)
|
---|
338 | : $(header) ] ;
|
---|
339 |
|
---|
340 | # Return result of base class and pch-file property as
|
---|
341 | # usage-requirements.
|
---|
342 | return
|
---|
343 | [ property-set.create <pch-file>$(pch-file) <cflags>-Winvalid-pch ]
|
---|
344 | $(pch-file)
|
---|
345 | ;
|
---|
346 | }
|
---|
347 |
|
---|
348 | # Calls the base version specifying source's name as the name of the created
|
---|
349 | # target. As a result, the PCH will be named whatever.hpp.gch, and not
|
---|
350 | # whatever.gch.
|
---|
351 | rule generated-targets ( sources + : property-set : project name ? )
|
---|
352 | {
|
---|
353 | name = [ $(sources[1]).name ] ;
|
---|
354 | return [ generator.generated-targets $(sources)
|
---|
355 | : $(property-set) : $(project) $(name) ] ;
|
---|
356 | }
|
---|
357 | }
|
---|
358 |
|
---|
359 | # Note: the 'H' source type will catch both '.h' header and '.hpp' header. The
|
---|
360 | # latter have HPP type, but HPP type is derived from H. The type of compilation
|
---|
361 | # is determined entirely by the destination type.
|
---|
362 | generators.register [ new gcc-pch-generator gcc.compile.c.pch : H : C_PCH : <pch>on <toolset>gcc ] ;
|
---|
363 | generators.register [ new gcc-pch-generator gcc.compile.c++.pch : H : CPP_PCH : <pch>on <toolset>gcc ] ;
|
---|
364 |
|
---|
365 | # Override default do-nothing generators.
|
---|
366 | generators.override gcc.compile.c.pch : pch.default-c-pch-generator ;
|
---|
367 | generators.override gcc.compile.c++.pch : pch.default-cpp-pch-generator ;
|
---|
368 |
|
---|
369 | toolset.flags gcc.compile PCH_FILE <pch>on : <pch-file> ;
|
---|
370 |
|
---|
371 | # Declare flags and action for compilation.
|
---|
372 | toolset.flags gcc.compile OPTIONS <optimization>off : -O0 ;
|
---|
373 | toolset.flags gcc.compile OPTIONS <optimization>speed : -O3 ;
|
---|
374 | toolset.flags gcc.compile OPTIONS <optimization>space : -Os ;
|
---|
375 |
|
---|
376 | toolset.flags gcc.compile OPTIONS <inlining>off : -fno-inline ;
|
---|
377 | toolset.flags gcc.compile OPTIONS <inlining>on : -Wno-inline ;
|
---|
378 | toolset.flags gcc.compile OPTIONS <inlining>full : -finline-functions -Wno-inline ;
|
---|
379 |
|
---|
380 | toolset.flags gcc.compile OPTIONS <warnings>off : -w ;
|
---|
381 | toolset.flags gcc.compile OPTIONS <warnings>on : -Wall ;
|
---|
382 | toolset.flags gcc.compile OPTIONS <warnings>all : -Wall -pedantic ;
|
---|
383 | toolset.flags gcc.compile OPTIONS <warnings-as-errors>on : -Werror ;
|
---|
384 |
|
---|
385 | toolset.flags gcc.compile OPTIONS <debug-symbols>on : -g ;
|
---|
386 | toolset.flags gcc.compile OPTIONS <profiling>on : -pg ;
|
---|
387 |
|
---|
388 | toolset.flags gcc.compile.c++ OPTIONS <rtti>off : -fno-rtti ;
|
---|
389 | toolset.flags gcc.compile.c++ OPTIONS <exception-handling>off : -fno-exceptions ;
|
---|
390 |
|
---|
391 | rule setup-fpic ( targets * : sources * : properties * )
|
---|
392 | {
|
---|
393 | local link = [ feature.get-values link : $(properties) ] ;
|
---|
394 | if $(link) = shared
|
---|
395 | {
|
---|
396 | local target = [ feature.get-values target-os : $(properties) ] ;
|
---|
397 |
|
---|
398 | # This logic will add -fPIC for all compilations:
|
---|
399 | #
|
---|
400 | # lib a : a.cpp b ;
|
---|
401 | # obj b : b.cpp ;
|
---|
402 | # exe c : c.cpp a d ;
|
---|
403 | # obj d : d.cpp ;
|
---|
404 | #
|
---|
405 | # This all is fine, except that 'd' will be compiled with -fPIC even
|
---|
406 | # though it is not needed, as 'd' is used only in exe. However, it is
|
---|
407 | # hard to detect where a target is going to be used. Alternatively, we
|
---|
408 | # can set -fPIC only when main target type is LIB but than 'b' would be
|
---|
409 | # compiled without -fPIC which would lead to link errors on x86-64. So,
|
---|
410 | # compile everything with -fPIC.
|
---|
411 | #
|
---|
412 | # Yet another alternative would be to create a propagated <sharedable>
|
---|
413 | # feature and set it when building shared libraries, but that would be
|
---|
414 | # hard to implement and would increase the target path length even more.
|
---|
415 |
|
---|
416 | # On Windows, fPIC is the default, and specifying -fPIC explicitly leads
|
---|
417 | # to a warning.
|
---|
418 | if ! $(target) in cygwin windows
|
---|
419 | {
|
---|
420 | OPTIONS on $(targets) += -fPIC ;
|
---|
421 | }
|
---|
422 | }
|
---|
423 | }
|
---|
424 |
|
---|
425 | rule setup-address-model ( targets * : sources * : properties * )
|
---|
426 | {
|
---|
427 | local model = [ feature.get-values address-model : $(properties) ] ;
|
---|
428 | if $(model)
|
---|
429 | {
|
---|
430 | local option ;
|
---|
431 | local os = [ feature.get-values target-os : $(properties) ] ;
|
---|
432 | if $(os) = aix
|
---|
433 | {
|
---|
434 | if $(model) = 32
|
---|
435 | {
|
---|
436 | option = -maix32 ;
|
---|
437 | }
|
---|
438 | else
|
---|
439 | {
|
---|
440 | option = -maix64 ;
|
---|
441 | }
|
---|
442 | }
|
---|
443 | else if $(os) = hpux
|
---|
444 | {
|
---|
445 | if $(model) = 32
|
---|
446 | {
|
---|
447 | option = -milp32 ;
|
---|
448 | }
|
---|
449 | else
|
---|
450 | {
|
---|
451 | option = -mlp64 ;
|
---|
452 | }
|
---|
453 | }
|
---|
454 | else
|
---|
455 | {
|
---|
456 | local arch = [ feature.get-values architecture : $(properties) ] ;
|
---|
457 | if $(arch) = power || $(arch) = sparc || $(arch) = x86
|
---|
458 | {
|
---|
459 | if $(model) = 32
|
---|
460 | {
|
---|
461 | option = -m32 ;
|
---|
462 | }
|
---|
463 | else if $(model) = 64
|
---|
464 | {
|
---|
465 | option = -m64 ;
|
---|
466 | }
|
---|
467 | }
|
---|
468 | # For darwin, the model can be 32_64. darwin.jam will handle that
|
---|
469 | # on its own.
|
---|
470 | }
|
---|
471 | OPTIONS on $(targets) += $(option) ;
|
---|
472 | }
|
---|
473 | }
|
---|
474 |
|
---|
475 |
|
---|
476 | # FIXME: this should not use os.name.
|
---|
477 | if ! [ os.name ] in NT OSF HPUX AIX
|
---|
478 | {
|
---|
479 | # OSF does have an option called -soname but it does not seem to work as
|
---|
480 | # expected, therefore it has been disabled.
|
---|
481 | HAVE_SONAME = "" ;
|
---|
482 | SONAME_OPTION = -h ;
|
---|
483 | }
|
---|
484 |
|
---|
485 | # HPUX, for some reason, seems to use '+h' instead of '-h'.
|
---|
486 | if [ os.name ] = HPUX
|
---|
487 | {
|
---|
488 | HAVE_SONAME = "" ;
|
---|
489 | SONAME_OPTION = +h ;
|
---|
490 | }
|
---|
491 |
|
---|
492 | toolset.flags gcc.compile USER_OPTIONS <cflags> ;
|
---|
493 | toolset.flags gcc.compile.c++ USER_OPTIONS <cxxflags> ;
|
---|
494 | toolset.flags gcc.compile.asm USER_OPTIONS <asmflags> ;
|
---|
495 | toolset.flags gcc.compile DEFINES <define> ;
|
---|
496 | toolset.flags gcc.compile INCLUDES <include> ;
|
---|
497 | toolset.flags gcc.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ;
|
---|
498 | toolset.flags gcc.compile.fortran USER_OPTIONS <fflags> ;
|
---|
499 |
|
---|
500 | rule compile.c++.pch ( targets * : sources * : properties * )
|
---|
501 | {
|
---|
502 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
503 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
504 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
505 | }
|
---|
506 |
|
---|
507 | actions compile.c++.pch
|
---|
508 | {
|
---|
509 | "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
|
---|
510 | }
|
---|
511 |
|
---|
512 | rule compile.c.pch ( targets * : sources * : properties * )
|
---|
513 | {
|
---|
514 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
515 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
516 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
517 | }
|
---|
518 |
|
---|
519 | actions compile.c.pch
|
---|
520 | {
|
---|
521 | "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
|
---|
522 | }
|
---|
523 |
|
---|
524 | rule compile.c++.preprocess ( targets * : sources * : properties * )
|
---|
525 | {
|
---|
526 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
527 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
528 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
529 |
|
---|
530 | # Some extensions are compiled as C++ by default. For others, we need to
|
---|
531 | # pass -x c++. We could always pass -x c++ but distcc does not work with it.
|
---|
532 | if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C
|
---|
533 | {
|
---|
534 | LANG on $(<) = "-x c++" ;
|
---|
535 | }
|
---|
536 | DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
|
---|
537 | }
|
---|
538 |
|
---|
539 | rule compile.c.preprocess ( targets * : sources * : properties * )
|
---|
540 | {
|
---|
541 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
542 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
543 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
544 |
|
---|
545 | # If we use the name g++ then default file suffix -> language mapping does
|
---|
546 | # not work. So have to pass -x option. Maybe, we can work around this by
|
---|
547 | # allowing the user to specify both C and C++ compiler names.
|
---|
548 | #if $(>:S) != .c
|
---|
549 | #{
|
---|
550 | LANG on $(<) = "-x c" ;
|
---|
551 | #}
|
---|
552 | DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
|
---|
553 | }
|
---|
554 |
|
---|
555 | rule compile.c++ ( targets * : sources * : properties * )
|
---|
556 | {
|
---|
557 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
558 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
559 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
560 |
|
---|
561 | # Some extensions are compiled as C++ by default. For others, we need to
|
---|
562 | # pass -x c++. We could always pass -x c++ but distcc does not work with it.
|
---|
563 | if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C
|
---|
564 | {
|
---|
565 | LANG on $(<) = "-x c++" ;
|
---|
566 | }
|
---|
567 | DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
|
---|
568 |
|
---|
569 | # Here we want to raise the template-depth parameter value to something
|
---|
570 | # higher than the default value of 17. Note that we could do this using the
|
---|
571 | # feature.set-default rule but we do not want to set the default value for
|
---|
572 | # all toolsets as well.
|
---|
573 | #
|
---|
574 | # TODO: This 'modified default' has been inherited from some 'older Boost
|
---|
575 | # Build implementation' and has most likely been added to make some Boost
|
---|
576 | # library parts compile correctly. We should see what exactly prompted this
|
---|
577 | # and whether we can get around the problem more locally.
|
---|
578 | local template-depth = [ on $(<) return $(TEMPLATE_DEPTH) ] ;
|
---|
579 | if ! $(template-depth)
|
---|
580 | {
|
---|
581 | TEMPLATE_DEPTH on $(<) = 128 ;
|
---|
582 | }
|
---|
583 | }
|
---|
584 |
|
---|
585 | rule compile.c ( targets * : sources * : properties * )
|
---|
586 | {
|
---|
587 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
588 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
589 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
590 |
|
---|
591 | # If we use the name g++ then default file suffix -> language mapping does
|
---|
592 | # not work. So have to pass -x option. Maybe, we can work around this by
|
---|
593 | # allowing the user to specify both C and C++ compiler names.
|
---|
594 | #if $(>:S) != .c
|
---|
595 | #{
|
---|
596 | LANG on $(<) = "-x c" ;
|
---|
597 | #}
|
---|
598 | DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
|
---|
599 | }
|
---|
600 |
|
---|
601 | rule compile.fortran ( targets * : sources * : properties * )
|
---|
602 | {
|
---|
603 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
604 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
605 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
606 | }
|
---|
607 |
|
---|
608 | actions compile.c++ bind PCH_FILE
|
---|
609 | {
|
---|
610 | "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<:W)" "$(>:W)"
|
---|
611 | }
|
---|
612 |
|
---|
613 | actions compile.c bind PCH_FILE
|
---|
614 | {
|
---|
615 | "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
|
---|
616 | }
|
---|
617 |
|
---|
618 | actions compile.c++.preprocess bind PCH_FILE
|
---|
619 | {
|
---|
620 | "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>:W)" -E >"$(<:W)"
|
---|
621 | }
|
---|
622 |
|
---|
623 | actions compile.c.preprocess bind PCH_FILE
|
---|
624 | {
|
---|
625 | "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>)" -E >$(<)
|
---|
626 | }
|
---|
627 |
|
---|
628 | actions compile.fortran
|
---|
629 | {
|
---|
630 | "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
|
---|
631 | }
|
---|
632 |
|
---|
633 | rule compile.asm ( targets * : sources * : properties * )
|
---|
634 | {
|
---|
635 | setup-fpic $(targets) : $(sources) : $(properties) ;
|
---|
636 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
637 | LANG on $(<) = "-x assembler-with-cpp" ;
|
---|
638 | }
|
---|
639 |
|
---|
640 | actions compile.asm
|
---|
641 | {
|
---|
642 | "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
|
---|
643 | }
|
---|
644 |
|
---|
645 | # Class checking that we do not try to use the <runtime-link>static property
|
---|
646 | # while creating or using a shared library, since it is not supported by
|
---|
647 | # gcc/libc.
|
---|
648 | class gcc-linking-generator : unix-linking-generator
|
---|
649 | {
|
---|
650 | rule run ( project name ? : property-set : sources + )
|
---|
651 | {
|
---|
652 | # TODO: Replace this with the use of a target-os property.
|
---|
653 | local no-static-link = ;
|
---|
654 | if [ modules.peek : UNIX ]
|
---|
655 | {
|
---|
656 | switch [ modules.peek : JAMUNAME ]
|
---|
657 | {
|
---|
658 | case * : no-static-link = true ;
|
---|
659 | }
|
---|
660 | }
|
---|
661 |
|
---|
662 | local properties = [ $(property-set).raw ] ;
|
---|
663 | local reason ;
|
---|
664 | if $(no-static-link) && <runtime-link>static in $(properties)
|
---|
665 | {
|
---|
666 | if <link>shared in $(properties)
|
---|
667 | {
|
---|
668 | reason = On gcc, DLLs can not be built with
|
---|
669 | '<runtime-link>static'. ;
|
---|
670 | }
|
---|
671 | else if [ type.is-derived $(self.target-types[1]) EXE ]
|
---|
672 | {
|
---|
673 | for local s in $(sources)
|
---|
674 | {
|
---|
675 | local type = [ $(s).type ] ;
|
---|
676 | if $(type) && [ type.is-derived $(type) SHARED_LIB ]
|
---|
677 | {
|
---|
678 | reason = On gcc, using DLLs together with the
|
---|
679 | '<runtime-link>static' option is not possible. ;
|
---|
680 | }
|
---|
681 | }
|
---|
682 | }
|
---|
683 | }
|
---|
684 | if $(reason)
|
---|
685 | {
|
---|
686 | ECHO warning: $(reason) ;
|
---|
687 | ECHO warning: It is suggested to use '<runtime-link>static' together
|
---|
688 | with '<link>static'. ;
|
---|
689 | }
|
---|
690 | else
|
---|
691 | {
|
---|
692 | return [ unix-linking-generator.run $(project) $(name) :
|
---|
693 | $(property-set) : $(sources) ] ;
|
---|
694 | }
|
---|
695 | }
|
---|
696 | }
|
---|
697 |
|
---|
698 | # The set of permissible input types is different on mingw. So, define two sets
|
---|
699 | # of generators, with mingw generators selected when target-os=windows.
|
---|
700 |
|
---|
701 | local g ;
|
---|
702 | g = [ new gcc-linking-generator gcc.mingw.link
|
---|
703 | : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
|
---|
704 | : EXE
|
---|
705 | : <toolset>gcc <target-os>windows ] ;
|
---|
706 | $(g).set-rule-name gcc.link ;
|
---|
707 | generators.register $(g) ;
|
---|
708 |
|
---|
709 | g = [ new gcc-linking-generator gcc.mingw.link.dll
|
---|
710 | : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
|
---|
711 | : IMPORT_LIB SHARED_LIB
|
---|
712 | : <toolset>gcc <target-os>windows ] ;
|
---|
713 | $(g).set-rule-name gcc.link.dll ;
|
---|
714 | generators.register $(g) ;
|
---|
715 |
|
---|
716 | generators.register
|
---|
717 | [ new gcc-linking-generator gcc.link
|
---|
718 | : LIB OBJ
|
---|
719 | : EXE
|
---|
720 | : <toolset>gcc ] ;
|
---|
721 | generators.register
|
---|
722 | [ new gcc-linking-generator gcc.link.dll
|
---|
723 | : LIB OBJ
|
---|
724 | : SHARED_LIB
|
---|
725 | : <toolset>gcc ] ;
|
---|
726 |
|
---|
727 | generators.override gcc.mingw.link : gcc.link ;
|
---|
728 | generators.override gcc.mingw.link.dll : gcc.link.dll ;
|
---|
729 |
|
---|
730 | # Cygwin is similar to msvc and mingw in that it uses import libraries. While in
|
---|
731 | # simple cases, it can directly link to a shared library, it is believed to be
|
---|
732 | # slower, and not always possible. Define cygwin-specific generators here.
|
---|
733 |
|
---|
734 | g = [ new gcc-linking-generator gcc.cygwin.link
|
---|
735 | : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
|
---|
736 | : EXE
|
---|
737 | : <toolset>gcc <target-os>cygwin ] ;
|
---|
738 | $(g).set-rule-name gcc.link ;
|
---|
739 | generators.register $(g) ;
|
---|
740 |
|
---|
741 | g = [ new gcc-linking-generator gcc.cygwin.link.dll
|
---|
742 | : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
|
---|
743 | : IMPORT_LIB SHARED_LIB
|
---|
744 | : <toolset>gcc <target-os>cygwin ] ;
|
---|
745 | $(g).set-rule-name gcc.link.dll ;
|
---|
746 | generators.register $(g) ;
|
---|
747 |
|
---|
748 | generators.override gcc.cygwin.link : gcc.link ;
|
---|
749 | generators.override gcc.cygwin.link.dll : gcc.link.dll ;
|
---|
750 |
|
---|
751 | # Declare flags for linking.
|
---|
752 | # First, the common flags.
|
---|
753 | toolset.flags gcc.link OPTIONS <debug-symbols>on : -g ;
|
---|
754 | toolset.flags gcc.link OPTIONS <profiling>on : -pg ;
|
---|
755 | toolset.flags gcc.link USER_OPTIONS <linkflags> ;
|
---|
756 | toolset.flags gcc.link LINKPATH <library-path> ;
|
---|
757 | toolset.flags gcc.link FINDLIBS-ST <find-static-library> ;
|
---|
758 | toolset.flags gcc.link FINDLIBS-SA <find-shared-library> ;
|
---|
759 | toolset.flags gcc.link LIBRARIES <library-file> ;
|
---|
760 |
|
---|
761 | toolset.flags gcc.link.dll .IMPLIB-COMMAND <target-os>windows : "-Wl,--out-implib," ;
|
---|
762 | toolset.flags gcc.link.dll .IMPLIB-COMMAND <target-os>cygwin : "-Wl,--out-implib," ;
|
---|
763 |
|
---|
764 | # For <runtime-link>static we made sure there are no dynamic libraries in the
|
---|
765 | # link. On HP-UX not all system libraries exist as archived libraries (for
|
---|
766 | # example, there is no libunwind.a), so, on this platform, the -static option
|
---|
767 | # cannot be specified.
|
---|
768 | if [ os.name ] != HPUX
|
---|
769 | {
|
---|
770 | toolset.flags gcc.link OPTIONS <runtime-link>static : -static ;
|
---|
771 | }
|
---|
772 |
|
---|
773 | # Now, the vendor specific flags.
|
---|
774 | # The parameter linker can be either aix, darwin, gnu, hpux, osf or sun.
|
---|
775 | rule init-link-flags ( toolset linker condition )
|
---|
776 | {
|
---|
777 | switch $(linker)
|
---|
778 | {
|
---|
779 | case aix :
|
---|
780 | # On AIX we *have* to use the native linker.
|
---|
781 | #
|
---|
782 | # Using -brtl, the AIX linker will look for libraries with both the .a
|
---|
783 | # and .so extensions, such as libfoo.a and libfoo.so. Without -brtl, the
|
---|
784 | # AIX linker looks only for libfoo.a. Note that libfoo.a is an archived
|
---|
785 | # file that may contain shared objects and is different from static libs
|
---|
786 | # as on Linux.
|
---|
787 | #
|
---|
788 | # The -bnoipath strips the prepending (relative) path of libraries from
|
---|
789 | # the loader section in the target library or executable. Hence, during
|
---|
790 | # load-time LIBPATH (identical to LD_LIBRARY_PATH) or a hard-coded
|
---|
791 | # -blibpath (*similar* to -lrpath/-lrpath-link) is searched. Without
|
---|
792 | # this option, the prepending (relative) path + library name is
|
---|
793 | # hard-coded in the loader section, causing *only* this path to be
|
---|
794 | # searched during load-time. Note that the AIX linker does not have an
|
---|
795 | # -soname equivalent, this is as close as it gets.
|
---|
796 | #
|
---|
797 | # The -bbigtoc option instrcuts the linker to create a TOC bigger than 64k.
|
---|
798 | # This is neccesary for some submodules such as math, but it does make running
|
---|
799 | # the tests a tad slower.
|
---|
800 | #
|
---|
801 | # The above options are definately for AIX 5.x, and most likely also for
|
---|
802 | # AIX 4.x and AIX 6.x. For details about the AIX linker see:
|
---|
803 | # http://download.boulder.ibm.com/ibmdl/pub/software/dw/aix/es-aix_ll.pdf
|
---|
804 | #
|
---|
805 |
|
---|
806 | toolset.flags $(toolset).link OPTIONS : -Wl,-brtl -Wl,-bnoipath -Wl,-bbigtoc
|
---|
807 | : unchecked ;
|
---|
808 |
|
---|
809 | case darwin :
|
---|
810 | # On Darwin, the -s option to ld does not work unless we pass -static,
|
---|
811 | # and passing -static unconditionally is a bad idea. So, do not pass -s
|
---|
812 | # at all and darwin.jam will use a separate 'strip' invocation.
|
---|
813 | toolset.flags $(toolset).link RPATH $(condition) : <dll-path> :
|
---|
814 | unchecked ;
|
---|
815 | toolset.flags $(toolset).link RPATH_LINK $(condition) : <xdll-path> :
|
---|
816 | unchecked ;
|
---|
817 |
|
---|
818 | case gnu :
|
---|
819 | # Strip the binary when no debugging is needed. We use --strip-all flag
|
---|
820 | # as opposed to -s since icc (intel's compiler) is generally
|
---|
821 | # option-compatible with and inherits from the gcc toolset, but does not
|
---|
822 | # support -s.
|
---|
823 | toolset.flags $(toolset).link OPTIONS $(condition)/<strip>on : -Wl,--strip-all : unchecked ;
|
---|
824 | toolset.flags $(toolset).link RPATH $(condition) : <dll-path> : unchecked ;
|
---|
825 | toolset.flags $(toolset).link RPATH_LINK $(condition) : <xdll-path> : unchecked ;
|
---|
826 | toolset.flags $(toolset).link START-GROUP $(condition) : -Wl,--start-group : unchecked ;
|
---|
827 | toolset.flags $(toolset).link END-GROUP $(condition) : -Wl,--end-group : unchecked ;
|
---|
828 |
|
---|
829 | # gnu ld has the ability to change the search behaviour for libraries
|
---|
830 | # referenced by the -l switch. These modifiers are -Bstatic and
|
---|
831 | # -Bdynamic and change search for -l switches that follow them. The
|
---|
832 | # following list shows the tried variants. Search stops at the first
|
---|
833 | # variant that has a match.
|
---|
834 | #
|
---|
835 | # *nix: -Bstatic -lxxx
|
---|
836 | # libxxx.a
|
---|
837 | #
|
---|
838 | # *nix: -Bdynamic -lxxx
|
---|
839 | # libxxx.so
|
---|
840 | # libxxx.a
|
---|
841 | #
|
---|
842 | # windows (mingw, cygwin) -Bstatic -lxxx
|
---|
843 | # libxxx.a
|
---|
844 | # xxx.lib
|
---|
845 | #
|
---|
846 | # windows (mingw, cygwin) -Bdynamic -lxxx
|
---|
847 | # libxxx.dll.a
|
---|
848 | # xxx.dll.a
|
---|
849 | # libxxx.a
|
---|
850 | # xxx.lib
|
---|
851 | # cygxxx.dll (*)
|
---|
852 | # libxxx.dll
|
---|
853 | # xxx.dll
|
---|
854 | # libxxx.a
|
---|
855 | #
|
---|
856 | # (*) This is for cygwin
|
---|
857 | # Please note that -Bstatic and -Bdynamic are not a guarantee that a
|
---|
858 | # static or dynamic lib indeed gets linked in. The switches only change
|
---|
859 | # search patterns!
|
---|
860 |
|
---|
861 | # On *nix mixing shared libs with static runtime is not a good idea.
|
---|
862 | toolset.flags $(toolset).link FINDLIBS-ST-PFX
|
---|
863 | $(condition)/<runtime-link>shared : -Wl,-Bstatic : unchecked ;
|
---|
864 | toolset.flags $(toolset).link FINDLIBS-SA-PFX
|
---|
865 | $(condition)/<runtime-link>shared : -Wl,-Bdynamic : unchecked ;
|
---|
866 |
|
---|
867 | # On windows allow mixing of static and dynamic libs with static
|
---|
868 | # runtime is not a good idea.
|
---|
869 | toolset.flags $(toolset).link FINDLIBS-ST-PFX
|
---|
870 | $(condition)/<runtime-link>static/<target-os>windows : -Wl,-Bstatic
|
---|
871 | : unchecked ;
|
---|
872 | toolset.flags $(toolset).link FINDLIBS-SA-PFX
|
---|
873 | $(condition)/<runtime-link>static/<target-os>windows : -Wl,-Bdynamic
|
---|
874 | : unchecked ;
|
---|
875 | toolset.flags $(toolset).link OPTIONS
|
---|
876 | $(condition)/<runtime-link>static/<target-os>windows : -Wl,-Bstatic
|
---|
877 | : unchecked ;
|
---|
878 |
|
---|
879 | case hpux :
|
---|
880 | toolset.flags $(toolset).link OPTIONS $(condition)/<strip>on : -Wl,-s :
|
---|
881 | unchecked ;
|
---|
882 | toolset.flags $(toolset).link OPTIONS $(condition)/<link>shared : -fPIC
|
---|
883 | : unchecked ;
|
---|
884 |
|
---|
885 | case osf :
|
---|
886 | # No --strip-all, just -s.
|
---|
887 | toolset.flags $(toolset).link OPTIONS $(condition)/<strip>on : -Wl,-s :
|
---|
888 | unchecked ;
|
---|
889 | toolset.flags $(toolset).link RPATH $(condition) : <dll-path> :
|
---|
890 | unchecked ;
|
---|
891 | # This does not support -R.
|
---|
892 | toolset.flags $(toolset).link RPATH_OPTION $(condition) : -rpath :
|
---|
893 | unchecked ;
|
---|
894 | # -rpath-link is not supported at all.
|
---|
895 |
|
---|
896 | case sun :
|
---|
897 | toolset.flags $(toolset).link OPTIONS $(condition)/<strip>on : -Wl,-s :
|
---|
898 | unchecked ;
|
---|
899 | toolset.flags $(toolset).link RPATH $(condition) : <dll-path> :
|
---|
900 | unchecked ;
|
---|
901 | # Solaris linker does not have a separate -rpath-link, but allows using
|
---|
902 | # -L for the same purpose.
|
---|
903 | toolset.flags $(toolset).link LINKPATH $(condition) : <xdll-path> :
|
---|
904 | unchecked ;
|
---|
905 |
|
---|
906 | # This permits shared libraries with non-PIC code on Solaris.
|
---|
907 | # VP, 2004/09/07: Now that we have -fPIC hardcode in link.dll, the
|
---|
908 | # following is not needed. Whether -fPIC should be hardcoded, is a
|
---|
909 | # separate question.
|
---|
910 | # AH, 2004/10/16: it is still necessary because some tests link against
|
---|
911 | # static libraries that were compiled without PIC.
|
---|
912 | toolset.flags $(toolset).link OPTIONS $(condition)/<link>shared :
|
---|
913 | -mimpure-text : unchecked ;
|
---|
914 |
|
---|
915 | case * :
|
---|
916 | import errors ;
|
---|
917 | errors.user-error $(toolset) initialization: invalid linker '$(linker)'
|
---|
918 | : The value '$(linker)' specified for <linker> is not recognized.
|
---|
919 | : Possible values are 'aix', 'darwin', 'gnu', 'hpux', 'osf' or 'sun'
|
---|
920 | ;
|
---|
921 | }
|
---|
922 | }
|
---|
923 |
|
---|
924 |
|
---|
925 | # Enclose the RPATH variable on 'targets' in double quotes, unless it is already
|
---|
926 | # enclosed in single quotes. This special casing is done because it is common to
|
---|
927 | # pass '$ORIGIN' to linker -- and it has to have single quotes to prevent shell
|
---|
928 | # expansion -- and if we add double quotes then the preventing properties of
|
---|
929 | # single quotes disappear.
|
---|
930 | #
|
---|
931 | rule quote-rpath ( targets * )
|
---|
932 | {
|
---|
933 | local r = [ on $(targets[1]) return $(RPATH) ] ;
|
---|
934 | if ! [ MATCH ('.*') : $(r) ]
|
---|
935 | {
|
---|
936 | r = \"$(r)\" ;
|
---|
937 | }
|
---|
938 | RPATH on $(targets) = $(r) ;
|
---|
939 | }
|
---|
940 |
|
---|
941 | # Declare actions for linking.
|
---|
942 | rule link ( targets * : sources * : properties * )
|
---|
943 | {
|
---|
944 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
945 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
946 | SPACE on $(targets) = " " ;
|
---|
947 | # Serialize execution of the 'link' action, since running N links in
|
---|
948 | # parallel is just slower. For now, serialize only gcc links, it might be a
|
---|
949 | # good idea to serialize all links.
|
---|
950 | JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
|
---|
951 | quote-rpath $(targets) ;
|
---|
952 | }
|
---|
953 |
|
---|
954 | actions link bind LIBRARIES
|
---|
955 | {
|
---|
956 | "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,$(RPATH) -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
|
---|
957 | }
|
---|
958 |
|
---|
959 |
|
---|
960 | # Default value. Mostly for the sake of intel-linux that inherits from gcc, but
|
---|
961 | # does not have the same logic to set the .AR variable. We can put the same
|
---|
962 | # logic in intel-linux, but that is hardly worth the trouble as on Linux, 'ar'
|
---|
963 | # is always available.
|
---|
964 | .AR = ar ;
|
---|
965 | .RANLIB = ranlib ;
|
---|
966 |
|
---|
967 | toolset.flags gcc.archive AROPTIONS <archiveflags> ;
|
---|
968 |
|
---|
969 | rule archive ( targets * : sources * : properties * )
|
---|
970 | {
|
---|
971 | # Always remove archive and start again. Here is the rationale from
|
---|
972 | #
|
---|
973 | # Andre Hentz:
|
---|
974 | #
|
---|
975 | # I had a file, say a1.c, that was included into liba.a. I moved a1.c to
|
---|
976 | # a2.c, updated my Jamfiles and rebuilt. My program was crashing with absurd
|
---|
977 | # errors. After some debugging I traced it back to the fact that a1.o was
|
---|
978 | # *still* in liba.a
|
---|
979 | #
|
---|
980 | # Rene Rivera:
|
---|
981 | #
|
---|
982 | # Originally removing the archive was done by splicing an RM onto the
|
---|
983 | # archive action. That makes archives fail to build on NT when they have
|
---|
984 | # many files because it will no longer execute the action directly and blow
|
---|
985 | # the line length limit. Instead we remove the file in a different action,
|
---|
986 | # just before building the archive.
|
---|
987 | #
|
---|
988 | local clean.a = $(targets[1])(clean) ;
|
---|
989 | TEMPORARY $(clean.a) ;
|
---|
990 | NOCARE $(clean.a) ;
|
---|
991 | LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ;
|
---|
992 | DEPENDS $(clean.a) : $(sources) ;
|
---|
993 | DEPENDS $(targets) : $(clean.a) ;
|
---|
994 | common.RmTemps $(clean.a) : $(targets) ;
|
---|
995 | }
|
---|
996 |
|
---|
997 | # Declare action for creating static libraries.
|
---|
998 | # The letter 'r' means to add files to the archive with replacement. Since we
|
---|
999 | # remove archive, we do not care about replacement, but there is no option "add
|
---|
1000 | # without replacement".
|
---|
1001 | # The letter 'c' suppresses the warning in case the archive does not exists yet.
|
---|
1002 | # That warning is produced only on some platforms, for whatever reasons.
|
---|
1003 | #
|
---|
1004 | actions piecemeal archive
|
---|
1005 | {
|
---|
1006 | "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"
|
---|
1007 | "$(.RANLIB)" "$(<)"
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | rule link.dll ( targets * : sources * : properties * )
|
---|
1011 | {
|
---|
1012 | setup-threading $(targets) : $(sources) : $(properties) ;
|
---|
1013 | setup-address-model $(targets) : $(sources) : $(properties) ;
|
---|
1014 | SPACE on $(targets) = " " ;
|
---|
1015 | JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
|
---|
1016 | quote-rpath $(targets) ;
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | # Differs from 'link' above only by -shared.
|
---|
1020 | actions link.dll bind LIBRARIES
|
---|
1021 | {
|
---|
1022 | "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,$(RPATH) "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | rule setup-threading ( targets * : sources * : properties * )
|
---|
1026 | {
|
---|
1027 | local threading = [ feature.get-values threading : $(properties) ] ;
|
---|
1028 | if $(threading) = multi
|
---|
1029 | {
|
---|
1030 | local target = [ feature.get-values target-os : $(properties) ] ;
|
---|
1031 | local option ;
|
---|
1032 | local libs ;
|
---|
1033 |
|
---|
1034 | switch $(target)
|
---|
1035 | {
|
---|
1036 | case android : # No threading options, everything is in already.
|
---|
1037 | case windows : option = -mthreads ;
|
---|
1038 | case cygwin : option = -mthreads ;
|
---|
1039 | case solaris : option = -pthreads ; libs = rt ;
|
---|
1040 | case beos : # No threading options.
|
---|
1041 | case haiku : option = ;
|
---|
1042 | case *bsd : option = -pthread ; # There is no -lrt on BSD.
|
---|
1043 | case sgi : # gcc on IRIX does not support multi-threading.
|
---|
1044 | case darwin : # No threading options.
|
---|
1045 | case * : option = -pthread ; libs = rt ;
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 | if $(option)
|
---|
1049 | {
|
---|
1050 | OPTIONS on $(targets) += $(option) ;
|
---|
1051 | }
|
---|
1052 | if $(libs)
|
---|
1053 | {
|
---|
1054 | FINDLIBS-SA on $(targets) += $(libs) ;
|
---|
1055 | }
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 |
|
---|
1060 | local rule cpu-flags ( toolset variable : architecture : instruction-set + :
|
---|
1061 | values + : default ? )
|
---|
1062 | {
|
---|
1063 | if $(default)
|
---|
1064 | {
|
---|
1065 | toolset.flags $(toolset) $(variable)
|
---|
1066 | <architecture>$(architecture)/<instruction-set> : $(values) ;
|
---|
1067 | }
|
---|
1068 | toolset.flags $(toolset) $(variable)
|
---|
1069 | <architecture>/<instruction-set>$(instruction-set)
|
---|
1070 | <architecture>$(architecture)/<instruction-set>$(instruction-set)
|
---|
1071 | : $(values) ;
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 |
|
---|
1075 | # Set architecture/instruction-set options.
|
---|
1076 | #
|
---|
1077 | # x86 and compatible
|
---|
1078 | # The 'native' option appeared in gcc 4.2 so we cannot safely use it as default.
|
---|
1079 | # Use i686 instead for 32-bit.
|
---|
1080 | toolset.flags gcc OPTIONS <architecture>x86/<address-model>32/<instruction-set> : -march=i686 ;
|
---|
1081 | cpu-flags gcc OPTIONS : x86 : native : -march=native ;
|
---|
1082 | cpu-flags gcc OPTIONS : x86 : i486 : -march=i486 ;
|
---|
1083 | cpu-flags gcc OPTIONS : x86 : i586 : -march=i586 ;
|
---|
1084 | cpu-flags gcc OPTIONS : x86 : i686 : -march=i686 ;
|
---|
1085 | cpu-flags gcc OPTIONS : x86 : pentium : -march=pentium ;
|
---|
1086 | cpu-flags gcc OPTIONS : x86 : pentium-mmx : -march=pentium-mmx ;
|
---|
1087 | cpu-flags gcc OPTIONS : x86 : pentiumpro : -march=pentiumpro ;
|
---|
1088 | cpu-flags gcc OPTIONS : x86 : pentium2 : -march=pentium2 ;
|
---|
1089 | cpu-flags gcc OPTIONS : x86 : pentium3 : -march=pentium3 ;
|
---|
1090 | cpu-flags gcc OPTIONS : x86 : pentium3m : -march=pentium3m ;
|
---|
1091 | cpu-flags gcc OPTIONS : x86 : pentium-m : -march=pentium-m ;
|
---|
1092 | cpu-flags gcc OPTIONS : x86 : pentium4 : -march=pentium4 ;
|
---|
1093 | cpu-flags gcc OPTIONS : x86 : pentium4m : -march=pentium4m ;
|
---|
1094 | cpu-flags gcc OPTIONS : x86 : prescott : -march=prescott ;
|
---|
1095 | cpu-flags gcc OPTIONS : x86 : nocona : -march=nocona ;
|
---|
1096 | cpu-flags gcc OPTIONS : x86 : core2 : -march=core2 ;
|
---|
1097 | cpu-flags gcc OPTIONS : x86 : conroe : -march=core2 ;
|
---|
1098 | cpu-flags gcc OPTIONS : x86 : conroe-xe : -march=core2 ;
|
---|
1099 | cpu-flags gcc OPTIONS : x86 : conroe-l : -march=core2 ;
|
---|
1100 | cpu-flags gcc OPTIONS : x86 : allendale : -march=core2 ;
|
---|
1101 | cpu-flags gcc OPTIONS : x86 : wolfdale : -march=core2 -msse4.1 ;
|
---|
1102 | cpu-flags gcc OPTIONS : x86 : merom : -march=core2 ;
|
---|
1103 | cpu-flags gcc OPTIONS : x86 : merom-xe : -march=core2 ;
|
---|
1104 | cpu-flags gcc OPTIONS : x86 : kentsfield : -march=core2 ;
|
---|
1105 | cpu-flags gcc OPTIONS : x86 : kentsfield-xe : -march=core2 ;
|
---|
1106 | cpu-flags gcc OPTIONS : x86 : yorksfield : -march=core2 ;
|
---|
1107 | cpu-flags gcc OPTIONS : x86 : penryn : -march=core2 ;
|
---|
1108 | cpu-flags gcc OPTIONS : x86 : corei7 : -march=corei7 ;
|
---|
1109 | cpu-flags gcc OPTIONS : x86 : nehalem : -march=corei7 ;
|
---|
1110 | cpu-flags gcc OPTIONS : x86 : corei7-avx : -march=corei7-avx ;
|
---|
1111 | cpu-flags gcc OPTIONS : x86 : sandy-bridge : -march=corei7-avx ;
|
---|
1112 | cpu-flags gcc OPTIONS : x86 : core-avx-i : -march=core-avx-i ;
|
---|
1113 | cpu-flags gcc OPTIONS : x86 : ivy-bridge : -march=core-avx-i ;
|
---|
1114 | cpu-flags gcc OPTIONS : x86 : haswell : -march=core-avx-i -mavx2 -mfma -mbmi -mbmi2 -mlzcnt ;
|
---|
1115 | cpu-flags gcc OPTIONS : x86 : k6 : -march=k6 ;
|
---|
1116 | cpu-flags gcc OPTIONS : x86 : k6-2 : -march=k6-2 ;
|
---|
1117 | cpu-flags gcc OPTIONS : x86 : k6-3 : -march=k6-3 ;
|
---|
1118 | cpu-flags gcc OPTIONS : x86 : athlon : -march=athlon ;
|
---|
1119 | cpu-flags gcc OPTIONS : x86 : athlon-tbird : -march=athlon-tbird ;
|
---|
1120 | cpu-flags gcc OPTIONS : x86 : athlon-4 : -march=athlon-4 ;
|
---|
1121 | cpu-flags gcc OPTIONS : x86 : athlon-xp : -march=athlon-xp ;
|
---|
1122 | cpu-flags gcc OPTIONS : x86 : athlon-mp : -march=athlon-mp ;
|
---|
1123 | ##
|
---|
1124 | cpu-flags gcc OPTIONS : x86 : k8 : -march=k8 ;
|
---|
1125 | cpu-flags gcc OPTIONS : x86 : opteron : -march=opteron ;
|
---|
1126 | cpu-flags gcc OPTIONS : x86 : athlon64 : -march=athlon64 ;
|
---|
1127 | cpu-flags gcc OPTIONS : x86 : athlon-fx : -march=athlon-fx ;
|
---|
1128 | cpu-flags gcc OPTIONS : x86 : k8-sse3 : -march=k8-sse3 ;
|
---|
1129 | cpu-flags gcc OPTIONS : x86 : opteron-sse3 : -march=opteron-sse3 ;
|
---|
1130 | cpu-flags gcc OPTIONS : x86 : athlon64-sse3 : -march=athlon64-sse3 ;
|
---|
1131 | cpu-flags gcc OPTIONS : x86 : amdfam10 : -march=amdfam10 ;
|
---|
1132 | cpu-flags gcc OPTIONS : x86 : barcelona : -march=barcelona ;
|
---|
1133 | cpu-flags gcc OPTIONS : x86 : bdver1 : -march=bdver1 ;
|
---|
1134 | cpu-flags gcc OPTIONS : x86 : bdver2 : -march=bdver2 ;
|
---|
1135 | cpu-flags gcc OPTIONS : x86 : bdver3 : -march=bdver3 ;
|
---|
1136 | cpu-flags gcc OPTIONS : x86 : btver1 : -march=btver1 ;
|
---|
1137 | cpu-flags gcc OPTIONS : x86 : btver2 : -march=btver2 ;
|
---|
1138 | cpu-flags gcc OPTIONS : x86 : winchip-c6 : -march=winchip-c6 ;
|
---|
1139 | cpu-flags gcc OPTIONS : x86 : winchip2 : -march=winchip2 ;
|
---|
1140 | cpu-flags gcc OPTIONS : x86 : c3 : -march=c3 ;
|
---|
1141 | cpu-flags gcc OPTIONS : x86 : c3-2 : -march=c3-2 ;
|
---|
1142 | ##
|
---|
1143 | cpu-flags gcc OPTIONS : x86 : atom : -march=atom ;
|
---|
1144 | # Sparc
|
---|
1145 | cpu-flags gcc OPTIONS : sparc : v7 : -mcpu=v7 : default ;
|
---|
1146 | cpu-flags gcc OPTIONS : sparc : cypress : -mcpu=cypress ;
|
---|
1147 | cpu-flags gcc OPTIONS : sparc : v8 : -mcpu=v8 ;
|
---|
1148 | cpu-flags gcc OPTIONS : sparc : supersparc : -mcpu=supersparc ;
|
---|
1149 | cpu-flags gcc OPTIONS : sparc : sparclite : -mcpu=sparclite ;
|
---|
1150 | cpu-flags gcc OPTIONS : sparc : hypersparc : -mcpu=hypersparc ;
|
---|
1151 | cpu-flags gcc OPTIONS : sparc : sparclite86x : -mcpu=sparclite86x ;
|
---|
1152 | cpu-flags gcc OPTIONS : sparc : f930 : -mcpu=f930 ;
|
---|
1153 | cpu-flags gcc OPTIONS : sparc : f934 : -mcpu=f934 ;
|
---|
1154 | cpu-flags gcc OPTIONS : sparc : sparclet : -mcpu=sparclet ;
|
---|
1155 | cpu-flags gcc OPTIONS : sparc : tsc701 : -mcpu=tsc701 ;
|
---|
1156 | cpu-flags gcc OPTIONS : sparc : v9 : -mcpu=v9 ;
|
---|
1157 | cpu-flags gcc OPTIONS : sparc : ultrasparc : -mcpu=ultrasparc ;
|
---|
1158 | cpu-flags gcc OPTIONS : sparc : ultrasparc3 : -mcpu=ultrasparc3 ;
|
---|
1159 | # RS/6000 & PowerPC
|
---|
1160 | cpu-flags gcc OPTIONS : power : 403 : -mcpu=403 ;
|
---|
1161 | cpu-flags gcc OPTIONS : power : 505 : -mcpu=505 ;
|
---|
1162 | cpu-flags gcc OPTIONS : power : 601 : -mcpu=601 ;
|
---|
1163 | cpu-flags gcc OPTIONS : power : 602 : -mcpu=602 ;
|
---|
1164 | cpu-flags gcc OPTIONS : power : 603 : -mcpu=603 ;
|
---|
1165 | cpu-flags gcc OPTIONS : power : 603e : -mcpu=603e ;
|
---|
1166 | cpu-flags gcc OPTIONS : power : 604 : -mcpu=604 ;
|
---|
1167 | cpu-flags gcc OPTIONS : power : 604e : -mcpu=604e ;
|
---|
1168 | cpu-flags gcc OPTIONS : power : 620 : -mcpu=620 ;
|
---|
1169 | cpu-flags gcc OPTIONS : power : 630 : -mcpu=630 ;
|
---|
1170 | cpu-flags gcc OPTIONS : power : 740 : -mcpu=740 ;
|
---|
1171 | cpu-flags gcc OPTIONS : power : 7400 : -mcpu=7400 ;
|
---|
1172 | cpu-flags gcc OPTIONS : power : 7450 : -mcpu=7450 ;
|
---|
1173 | cpu-flags gcc OPTIONS : power : 750 : -mcpu=750 ;
|
---|
1174 | cpu-flags gcc OPTIONS : power : 801 : -mcpu=801 ;
|
---|
1175 | cpu-flags gcc OPTIONS : power : 821 : -mcpu=821 ;
|
---|
1176 | cpu-flags gcc OPTIONS : power : 823 : -mcpu=823 ;
|
---|
1177 | cpu-flags gcc OPTIONS : power : 860 : -mcpu=860 ;
|
---|
1178 | cpu-flags gcc OPTIONS : power : 970 : -mcpu=970 ;
|
---|
1179 | cpu-flags gcc OPTIONS : power : 8540 : -mcpu=8540 ;
|
---|
1180 | cpu-flags gcc OPTIONS : power : power : -mcpu=power ;
|
---|
1181 | cpu-flags gcc OPTIONS : power : power2 : -mcpu=power2 ;
|
---|
1182 | cpu-flags gcc OPTIONS : power : power3 : -mcpu=power3 ;
|
---|
1183 | cpu-flags gcc OPTIONS : power : power4 : -mcpu=power4 ;
|
---|
1184 | cpu-flags gcc OPTIONS : power : power5 : -mcpu=power5 ;
|
---|
1185 | cpu-flags gcc OPTIONS : power : powerpc : -mcpu=powerpc ;
|
---|
1186 | cpu-flags gcc OPTIONS : power : powerpc64 : -mcpu=powerpc64 ;
|
---|
1187 | cpu-flags gcc OPTIONS : power : rios : -mcpu=rios ;
|
---|
1188 | cpu-flags gcc OPTIONS : power : rios1 : -mcpu=rios1 ;
|
---|
1189 | cpu-flags gcc OPTIONS : power : rios2 : -mcpu=rios2 ;
|
---|
1190 | cpu-flags gcc OPTIONS : power : rsc : -mcpu=rsc ;
|
---|
1191 | cpu-flags gcc OPTIONS : power : rs64a : -mcpu=rs64 ;
|
---|
1192 | # AIX variant of RS/6000 & PowerPC
|
---|
1193 | toolset.flags gcc AROPTIONS <address-model>64/<target-os>aix : "-X64" ;
|
---|