1 | # Copyright (c) 2001 David Abrahams. |
---|
2 | # Copyright (c) 2002-2005 Rene Rivera. |
---|
3 | # Distributed under the Boost Software License, Version 1.0. |
---|
4 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | |
---|
6 | # The following #// line will be used by the regression test table generation |
---|
7 | # program as the column heading for HTML tables. Must not include version number. |
---|
8 | #//<a href="http://gcc.gnu.org/">GNU<br>GCC</a> |
---|
9 | |
---|
10 | # compute directories for invoking GCC |
---|
11 | # |
---|
12 | # The gcc toolset can be user-configured using the following |
---|
13 | # variables: |
---|
14 | # |
---|
15 | # GCC_ROOT_DIRECTORY |
---|
16 | # The directory in which GCC was installed. Defaults to |
---|
17 | # unset. Usually, there is no need to set this variable at |
---|
18 | # all. However, if G++ is not in the path it is usually |
---|
19 | # sufficient to configure this one variable. More fine-grained |
---|
20 | # configuration is available by setting the following: |
---|
21 | # |
---|
22 | # GCC_BIN_DIRECTORY |
---|
23 | # the directory prefix used to find the gcc executables. Defaults to |
---|
24 | # $(GCC_ROOT_DIRECTORY)/bin/, or "" if GCC_ROOT_DIRECTORY is |
---|
25 | # not set. |
---|
26 | # |
---|
27 | # GCC_INCLUDE_DIRECTORY |
---|
28 | # the directory in which to find system includes. Defaults to |
---|
29 | # empty. |
---|
30 | # |
---|
31 | # GCC_STDLIB_DIRECTORY |
---|
32 | # the directory in which to find the standard library |
---|
33 | # objects associated with this build of gcc. Defaults to |
---|
34 | # $(GCC_ROOT_DIRECTORY)/lib. |
---|
35 | # |
---|
36 | # GXX |
---|
37 | # The name by which g++ is invoked. You can also use this in |
---|
38 | # lieu of setting the <cxxflags> property to force options such |
---|
39 | # as "-V3.0.4" into the g++ command line: "-sGXX=g++ -V3.0.4". |
---|
40 | # |
---|
41 | # GCC |
---|
42 | # Similar to GXX, the name by which gcc is invoked for "C" |
---|
43 | # language targets. |
---|
44 | |
---|
45 | # singleton variables... |
---|
46 | set-as-singleton GCC_ROOT_DIRECTORY GCC_BIN_DIRECTORY GCC_INCLUDE_DIRECTORY GCC_STDLIB_DIRECTORY ; |
---|
47 | |
---|
48 | flags gcc GCC_BIN_DIRECTORY : $(GCC_BIN_DIRECTORY) ; |
---|
49 | flags gcc GCC_INCLUDE_DIRECTORY : $(GCC_INCLUDE_DIRECTORY) ; |
---|
50 | flags gcc GCC_STDLIB_DIRECTORY : $(GCC_STDLIB_DIRECTORY) ; |
---|
51 | |
---|
52 | GCC_BIN_DIRECTORY ?= $(GCC_ROOT_DIRECTORY)$(SLASH)bin ; |
---|
53 | GCC_BIN_DIRECTORY ?= "" ; # Don't clobber tool names if GCC_ROOT_DIRECTORY not set |
---|
54 | GCC_STDLIB_DIRECTORY ?= $(GCC_ROOT_DIRECTORY)$(SLASH)lib ; |
---|
55 | |
---|
56 | # Make sure this gets set "on" the target |
---|
57 | flags gcc GCC_BIN_DIR : $(GCC_BIN_DIRECTORY) ; |
---|
58 | |
---|
59 | flags gcc LINKFLAGS <runtime-link>static : -static ; |
---|
60 | flags gcc CFLAGS <debug-symbols>on : -g ; |
---|
61 | flags gcc LINKFLAGS <debug-symbols>on : -g ; |
---|
62 | flags gcc CFLAGS <optimization>off : -O0 ; |
---|
63 | flags gcc CFLAGS <optimization>speed : -O3 ; |
---|
64 | |
---|
65 | # Other optimizations we might want for GCC |
---|
66 | # -fforce-mem -fomit-frame-pointer |
---|
67 | # -foptimize-sibling-calls -finline-functions -ffast-math -finline-limit=10000 |
---|
68 | |
---|
69 | flags gcc CFLAGS <optimization>space : -Os ; |
---|
70 | flags gcc CFLAGS <inlining>off : -fno-inline ; |
---|
71 | flags gcc CFLAGS <inlining>on : -Wno-inline ; |
---|
72 | flags gcc CFLAGS <inlining>full : -finline-functions -Wno-inline ; |
---|
73 | |
---|
74 | flags gcc .GXX : $(GXX) ; |
---|
75 | flags gcc .GCC : $(GCC) ; |
---|
76 | |
---|
77 | # |
---|
78 | # set threading options for various platforms: |
---|
79 | # |
---|
80 | local on-windows ; |
---|
81 | |
---|
82 | if $(NT) |
---|
83 | { |
---|
84 | on-windows = 1 ; |
---|
85 | } |
---|
86 | else if $(UNIX) |
---|
87 | { |
---|
88 | switch $(JAMUNAME) |
---|
89 | { |
---|
90 | case CYGWIN* : |
---|
91 | { |
---|
92 | on-windows = 1 ; |
---|
93 | } |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | flags gcc ON_WINDOWS : $(on-windows) ; |
---|
98 | |
---|
99 | if $(on-windows) |
---|
100 | { |
---|
101 | flags gcc CFLAGS <threading>multi : -mthreads ; |
---|
102 | flags gcc LINKFLAGS <threading>multi : -mthreads ; |
---|
103 | } |
---|
104 | else if $(UNIX) |
---|
105 | { |
---|
106 | switch $(JAMUNAME) |
---|
107 | { |
---|
108 | case SunOS* : |
---|
109 | { |
---|
110 | flags gcc CFLAGS <threading>multi : -pthreads ; |
---|
111 | flags gcc LINKFLAGS <threading>multi : -pthreads ; |
---|
112 | flags gcc FINDLIBS <threading>multi : rt ; |
---|
113 | } |
---|
114 | case BeOS : |
---|
115 | { |
---|
116 | # BeOS has no threading options, don't set anything here. |
---|
117 | } |
---|
118 | case Darwin : |
---|
119 | { |
---|
120 | # MacOS X, doesn't need any threading options set |
---|
121 | # -lpthread is linked to by default. |
---|
122 | # There is no gcc/g++, we need to use cc/c++ instead: |
---|
123 | .GCC ?= cc ; |
---|
124 | .GXX ?= c++ ; |
---|
125 | } |
---|
126 | case *BSD : |
---|
127 | { |
---|
128 | flags gcc CFLAGS <threading>multi : -pthread ; |
---|
129 | flags gcc LINKFLAGS <threading>multi : -pthread ; |
---|
130 | # there is no -lrt on BSD |
---|
131 | } |
---|
132 | case DragonFly : |
---|
133 | { |
---|
134 | flags gcc CFLAGS <threading>multi : -pthread ; |
---|
135 | flags gcc LINKFLAGS <threading>multi : -pthread ; |
---|
136 | # there is no -lrt on BSD - DragonFly is a FreeBSD variant, |
---|
137 | # which anoyingly doesn't say it's a *BSD. |
---|
138 | } |
---|
139 | case IRIX : |
---|
140 | { |
---|
141 | # gcc on IRIX does not support multi-threading, don't set anything here. |
---|
142 | } |
---|
143 | case HP_UX : |
---|
144 | { |
---|
145 | # gcc on HP-UX does not support multi-threading, don't set anything here |
---|
146 | } |
---|
147 | case QNX* : |
---|
148 | { |
---|
149 | # gcc/QCC on QNX is always? in multi-thread mode, don't set anything here |
---|
150 | } |
---|
151 | case * : |
---|
152 | { |
---|
153 | flags gcc CFLAGS <threading>multi : -pthread ; |
---|
154 | flags gcc LINKFLAGS <threading>multi : -pthread ; |
---|
155 | flags gcc FINDLIBS <threading>multi : rt ; |
---|
156 | } |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | # Some possibly supported, or not, linker flags. The support depends on the OS linker. |
---|
161 | # |
---|
162 | flags gcc RPATH_LINK ; |
---|
163 | flags gcc SONAME ; |
---|
164 | |
---|
165 | # Set/reset options for the linker of the platform. |
---|
166 | # |
---|
167 | if $(UNIX) |
---|
168 | { |
---|
169 | switch $(JAMUNAME) |
---|
170 | { |
---|
171 | case SunOS* : |
---|
172 | { |
---|
173 | NO_GNU_LN = true ; # sun seems not to use the GNU linker with gcc |
---|
174 | flags gcc OBJCOPY_FLAGS <debug-symbols>on : "--set-section-flags .debug_str=contents" ; |
---|
175 | } |
---|
176 | case Linux : |
---|
177 | { |
---|
178 | RPATH_LINK = -Wl,-rpath-link, ; |
---|
179 | SONAME = -Wl,-soname, ; |
---|
180 | flags gcc OBJCOPY_FLAGS <debug-symbols>on : "--set-section-flags .debug_str=contents,debug" ; |
---|
181 | } |
---|
182 | case OpenBSD : |
---|
183 | { |
---|
184 | SONAME = -Wl,-soname, ; |
---|
185 | } |
---|
186 | case AIX* : |
---|
187 | { |
---|
188 | NO_GNU_LN = true ; |
---|
189 | IMPLIB_FLAGS = "-Wl,-bI:" ; |
---|
190 | } |
---|
191 | } |
---|
192 | } |
---|
193 | |
---|
194 | |
---|
195 | # Set architecture/instruction-set options. |
---|
196 | # |
---|
197 | # x86 and compatible |
---|
198 | .ARCH = <architecture>x86 <architecture>native ; |
---|
199 | flags gcc CFLAGS <architecture>x86/<instruction-set>default : -mcpu=i386 ; |
---|
200 | flags gcc CFLAGS $(.ARCH)/<instruction-set>i386 : -mcpu=i386 ; |
---|
201 | flags gcc CFLAGS $(.ARCH)/<instruction-set>i486 : -mcpu=i486 ; |
---|
202 | flags gcc CFLAGS $(.ARCH)/<instruction-set>i586 : -mcpu=i586 ; |
---|
203 | flags gcc CFLAGS $(.ARCH)/<instruction-set>i686 : -mcpu=i686 ; |
---|
204 | flags gcc CFLAGS $(.ARCH)/<instruction-set>pentium : -mcpu=pentium ; |
---|
205 | flags gcc CFLAGS $(.ARCH)/<instruction-set>pentium-mmx : -mcpu=pentium-mmx ; |
---|
206 | flags gcc CFLAGS $(.ARCH)/<instruction-set>pentiumpro : -mcpu=pentiumpro ; |
---|
207 | flags gcc CFLAGS $(.ARCH)/<instruction-set>pentium2 : -mcpu=pentium2 ; |
---|
208 | flags gcc CFLAGS $(.ARCH)/<instruction-set>pentium3 : -mcpu=pentium3 ; |
---|
209 | flags gcc CFLAGS $(.ARCH)/<instruction-set>pentium4 : -mcpu=pentium4 ; |
---|
210 | flags gcc CFLAGS $(.ARCH)/<instruction-set>k6 : -mcpu=k6 ; |
---|
211 | flags gcc CFLAGS $(.ARCH)/<instruction-set>k6-2 : -mcpu=k6-2 ; |
---|
212 | flags gcc CFLAGS $(.ARCH)/<instruction-set>k6-3 : -mcpu=k6-3 ; |
---|
213 | flags gcc CFLAGS $(.ARCH)/<instruction-set>athlon : -mcpu=athlon ; |
---|
214 | flags gcc CFLAGS $(.ARCH)/<instruction-set>athlon-tbird : -mcpu=athlon-tbird ; |
---|
215 | flags gcc CFLAGS $(.ARCH)/<instruction-set>athlon-4 : -mcpu=athlon-4 ; |
---|
216 | flags gcc CFLAGS $(.ARCH)/<instruction-set>athlon-xp : -mcpu=athlon-xp ; |
---|
217 | flags gcc CFLAGS $(.ARCH)/<instruction-set>athlon-mp : -mcpu=athlon-mp ; |
---|
218 | # Sparc |
---|
219 | .ARCH = <architecture>sparc <architecture>native ; |
---|
220 | flags gcc CFLAGS <architecture>sparc/<instruction-set>default : -mcpu=v7 ; |
---|
221 | flags gcc CFLAGS $(.ARCH)/<instruction-set>v7 : -mcpu=v7 ; |
---|
222 | flags gcc CFLAGS $(.ARCH)/<instruction-set>cypress : -mcpu=cypress ; |
---|
223 | flags gcc CFLAGS $(.ARCH)/<instruction-set>v8 : -mcpu=v8 ; |
---|
224 | flags gcc CFLAGS $(.ARCH)/<instruction-set>supersparc : -mcpu=supersparc ; |
---|
225 | flags gcc CFLAGS $(.ARCH)/<instruction-set>sparclite : -mcpu=sparclite ; |
---|
226 | flags gcc CFLAGS $(.ARCH)/<instruction-set>hypersparc : -mcpu=hypersparc ; |
---|
227 | flags gcc CFLAGS $(.ARCH)/<instruction-set>sparclite86x : -mcpu=sparclite86x ; |
---|
228 | flags gcc CFLAGS $(.ARCH)/<instruction-set>f930 : -mcpu=f930 ; |
---|
229 | flags gcc CFLAGS $(.ARCH)/<instruction-set>f934 : -mcpu=f934 ; |
---|
230 | flags gcc CFLAGS $(.ARCH)/<instruction-set>sparclet : -mcpu=sparclet ; |
---|
231 | flags gcc CFLAGS $(.ARCH)/<instruction-set>tsc701 : -mcpu=tsc701 ; |
---|
232 | flags gcc CFLAGS $(.ARCH)/<instruction-set>v9 : -mcpu=v9 ; |
---|
233 | flags gcc CFLAGS $(.ARCH)/<instruction-set>ultrasparc : -mcpu=ultrasparc ; |
---|
234 | flags gcc CFLAGS <architecture>sparc/<address-model>64 : -m64 ; |
---|
235 | flags gcc LINKFLAGS <architecture>sparc/<address-model>64 : -m64 ; |
---|
236 | # RS/6000 & PowerPC |
---|
237 | .ARCH = <architecture>power <architecture>native ; |
---|
238 | flags gcc CFLAGS <architecture>power/<address-model>default/<instruction-set>default : -mcpu=common ; |
---|
239 | flags gcc CFLAGS <architecture>power/<address-model>32/<instruction-set>default : -mcpu=common ; |
---|
240 | flags gcc CFLAGS <architecture>power/<address-model>64/<instruction-set>default : -mcpu=powerpc64 ; |
---|
241 | flags gcc CFLAGS $(.ARCH)/<instruction-set>rios : -mcpu=rios ; |
---|
242 | flags gcc CFLAGS $(.ARCH)/<instruction-set>rios1 : -mcpu=rios1 ; |
---|
243 | flags gcc CFLAGS $(.ARCH)/<instruction-set>rsc : -mcpu=rsc ; |
---|
244 | flags gcc CFLAGS $(.ARCH)/<instruction-set>rios2 : -mcpu=rios2 ; |
---|
245 | flags gcc CFLAGS $(.ARCH)/<instruction-set>rs64a : -mcpu=rs64a ; |
---|
246 | flags gcc CFLAGS $(.ARCH)/<instruction-set>403 : -mcpu=403 ; |
---|
247 | flags gcc CFLAGS $(.ARCH)/<instruction-set>505 : -mcpu=505 ; |
---|
248 | flags gcc CFLAGS $(.ARCH)/<instruction-set>601 : -mcpu=601 ; |
---|
249 | flags gcc CFLAGS $(.ARCH)/<instruction-set>602 : -mcpu=602 ; |
---|
250 | flags gcc CFLAGS $(.ARCH)/<instruction-set>603 : -mcpu=603 ; |
---|
251 | flags gcc CFLAGS $(.ARCH)/<instruction-set>603e : -mcpu=603e ; |
---|
252 | flags gcc CFLAGS $(.ARCH)/<instruction-set>604 : -mcpu=604 ; |
---|
253 | flags gcc CFLAGS $(.ARCH)/<instruction-set>604e : -mcpu=604e ; |
---|
254 | flags gcc CFLAGS $(.ARCH)/<instruction-set>620 : -mcpu=620 ; |
---|
255 | flags gcc CFLAGS $(.ARCH)/<instruction-set>630 : -mcpu=630 ; |
---|
256 | flags gcc CFLAGS $(.ARCH)/<instruction-set>740 : -mcpu=740 ; |
---|
257 | flags gcc CFLAGS $(.ARCH)/<instruction-set>7400 : -mcpu=7400 ; |
---|
258 | flags gcc CFLAGS $(.ARCH)/<instruction-set>7450 : -mcpu=7450 ; |
---|
259 | flags gcc CFLAGS $(.ARCH)/<instruction-set>750 : -mcpu=750 ; |
---|
260 | flags gcc CFLAGS $(.ARCH)/<instruction-set>801 : -mcpu=801 ; |
---|
261 | flags gcc CFLAGS $(.ARCH)/<instruction-set>821 : -mcpu=821 ; |
---|
262 | flags gcc CFLAGS $(.ARCH)/<instruction-set>823 : -mcpu=823 ; |
---|
263 | flags gcc CFLAGS $(.ARCH)/<instruction-set>860 : -mcpu=860 ; |
---|
264 | flags gcc CFLAGS $(.ARCH)/<instruction-set>power : -mcpu=power ; |
---|
265 | flags gcc CFLAGS $(.ARCH)/<instruction-set>power2 : -mcpu=power2 ; |
---|
266 | flags gcc CFLAGS $(.ARCH)/<instruction-set>power3 : -mcpu=power3 ; |
---|
267 | flags gcc CFLAGS $(.ARCH)/<instruction-set>power4 : -mcpu=power4 ; |
---|
268 | flags gcc CFLAGS $(.ARCH)/<instruction-set>power5 : -mcpu=power5 ; |
---|
269 | flags gcc CFLAGS $(.ARCH)/<instruction-set>powerpc : -mcpu=powerpc ; |
---|
270 | flags gcc CFLAGS $(.ARCH)/<instruction-set>powerpc64 : -mcpu=powerpc64 ; |
---|
271 | # AIX variant of RS/6000 & PowerPC |
---|
272 | flags gcc CFLAGS <architecture>power/<address-model>32/<object-model>aix : -maix32 ; |
---|
273 | flags gcc LINKFLAGS <architecture>power/<address-model>32/<object-model>aix : -maix32 ; |
---|
274 | flags gcc CFLAGS <architecture>power/<address-model>64/<object-model>aix : -maix64 ; |
---|
275 | flags gcc LINKFLAGS <architecture>power/<address-model>64/<object-model>aix : -maix64 ; |
---|
276 | flags gcc AROPTIONS <architecture>power/<address-model>64/<object-model>aix : "-X 64" ; |
---|
277 | # MIPS-1-2-3-4 |
---|
278 | flags gcc MIPS <architecture>mips1 <architecture>mips2 <architecture>mips3 <architecture>mips4 : TRUE ; |
---|
279 | flags gcc MIPS |
---|
280 | <instruction-set>r2000 <instruction-set>r3000 <instruction-set>r3900 |
---|
281 | <instruction-set>r4000 <instruction-set>r4100 <instruction-set>r4300 |
---|
282 | <instruction-set>r4400 <instruction-set>r4600 <instruction-set>r4650 |
---|
283 | <instruction-set>r5000 <instruction-set>r6000 <instruction-set>r8000 |
---|
284 | <instruction-set>orion |
---|
285 | : TRUE ; |
---|
286 | if $(MIPS) |
---|
287 | { |
---|
288 | flags gcc CFLAGS <architecture>mips1 : -mips1 ; |
---|
289 | flags gcc CFLAGS <architecture>mips2 : -mips2 ; |
---|
290 | flags gcc CFLAGS <architecture>mips3 : -mips3 ; |
---|
291 | flags gcc CFLAGS <architecture>mips4 : -mips4 ; |
---|
292 | flags gcc CFLAGS <instruction-set>r2000 : -mcpu=r2000 ; |
---|
293 | flags gcc CFLAGS <instruction-set>r3000 : -mcpu=r3000 ; |
---|
294 | flags gcc CFLAGS <instruction-set>r3900 : -mcpu=r3900 ; |
---|
295 | flags gcc CFLAGS <instruction-set>r4000 : -mcpu=r4000 ; |
---|
296 | flags gcc CFLAGS <instruction-set>r4100 : -mcpu=r4100 ; |
---|
297 | flags gcc CFLAGS <instruction-set>r4300 : -mcpu=r4300 ; |
---|
298 | flags gcc CFLAGS <instruction-set>r4400 : -mcpu=r4400 ; |
---|
299 | flags gcc CFLAGS <instruction-set>r4600 : -mcpu=r4600 ; |
---|
300 | flags gcc CFLAGS <instruction-set>r4650 : -mcpu=r4650 ; |
---|
301 | flags gcc CFLAGS <instruction-set>r5000 : -mcpu=r5000 ; |
---|
302 | flags gcc CFLAGS <instruction-set>r6000 : -mcpu=r6000 ; |
---|
303 | flags gcc CFLAGS <instruction-set>r8000 : -mcpu=r8000 ; |
---|
304 | flags gcc CFLAGS <instruction-set>orion : -mcpu=orion ; |
---|
305 | # ...addressing model options |
---|
306 | flags gcc ADDRESS_MODEL_INVALID <address-model>16 : TRUE ; |
---|
307 | if $(ADDRESS_MODEL_INVALID) |
---|
308 | { |
---|
309 | EXIT "Error: Invalid addressing model for MIPS architecture (16)." ; |
---|
310 | } |
---|
311 | flags gcc CFLAGS <address-model>default : -mgp32 ; |
---|
312 | flags gcc CFLAGS <address-model>32 : -mgp32 ; |
---|
313 | flags gcc CFLAGS <address-model>64 : -mgp64 -mlong64 ; |
---|
314 | } |
---|
315 | #S390 |
---|
316 | if $(OSPLAT) = 390 || $(OSPLAT) = IA64 |
---|
317 | { |
---|
318 | flags gcc CFLAGS <threading>multi : -D_REENTRANT ; |
---|
319 | } |
---|
320 | |
---|
321 | # |
---|
322 | # define compiler names if not set: |
---|
323 | .GCC ?= gcc ; |
---|
324 | .GXX ?= g++ ; |
---|
325 | |
---|
326 | |
---|
327 | flags gcc CFLAGS <profiling>on : -pg ; |
---|
328 | flags gcc LINKFLAGS <profiling>on : -pg ; |
---|
329 | |
---|
330 | flags gcc C++FLAGS <rtti>off : -fno-rtti ; |
---|
331 | flags gcc C++FLAGS <vtable-thunks>on : -fvtable-thunks ; |
---|
332 | flags gcc C++FLAGS <vtable-thunks>off : -fvtable-thunks=0 ; |
---|
333 | |
---|
334 | flags gcc CFLAGS <cflags> ; |
---|
335 | flags gcc C++FLAGS <cxxflags> ; |
---|
336 | flags gcc DEFINES <define> ; |
---|
337 | flags gcc UNDEFS <undef> ; |
---|
338 | flags gcc HDRS <include> ; |
---|
339 | flags gcc SYSHDRS <sysinclude> ; |
---|
340 | flags gcc LINKFLAGS <linkflags> ; |
---|
341 | flags gcc LINKFLAGS <debug-symbols>off : -s ; |
---|
342 | flags gcc ARFLAGS <arflags> ; |
---|
343 | |
---|
344 | flags gcc STDHDRS : $(GCC_INCLUDE_DIRECTORY) ; |
---|
345 | flags gcc STDLIBPATH : $(GCC_STDLIB_DIRECTORY) ; |
---|
346 | |
---|
347 | if ! $(ARFLAGS) |
---|
348 | { |
---|
349 | flags gcc ARFLAGS : "" ; |
---|
350 | } |
---|
351 | |
---|
352 | if ! $(on-windows) # The compiler complains about -fPIC on NT |
---|
353 | { |
---|
354 | flags gcc CFLAGS <shared-linkable>true : -fPIC ; |
---|
355 | flags gcc LINKFLAGS <shared-linkable>true : -fPIC ; |
---|
356 | } |
---|
357 | |
---|
358 | |
---|
359 | if $(BETOOLS) |
---|
360 | { |
---|
361 | flags gcc LINKFLAGS <target-type>$(SHARED_TYPES) : -nostart ; |
---|
362 | } |
---|
363 | else |
---|
364 | { |
---|
365 | flags gcc LINKFLAGS <target-type>$(SHARED_TYPES) : -shared ; |
---|
366 | } |
---|
367 | |
---|
368 | flags gcc LIBPATH <library-path> ; |
---|
369 | flags gcc NEEDLIBS <library-file> ; |
---|
370 | flags gcc FINDLIBS <find-library> ; |
---|
371 | |
---|
372 | flags gcc DLLVERSION <dllversion> ; |
---|
373 | DLLVERSION = $(DLLVERSION[1]) ; |
---|
374 | DLLVERSION ?= $(BOOST_VERSION) ; |
---|
375 | |
---|
376 | flags gcc TARGET_TYPE <target-type> ; |
---|
377 | |
---|
378 | # allow for "ar" to be part of the compiler distribution, for |
---|
379 | # example in mingw and cygwin |
---|
380 | flags gcc .AR : [ GLOB $(GCC_BIN_DIRECTORY) $(PATH) : ar ar.exe ] ; |
---|
381 | .AR ?= ar ; |
---|
382 | |
---|
383 | # used to manipulate the object files produced by GCC to |
---|
384 | # prevent the merging of debug symbols (which happens to be n^2 slow) |
---|
385 | if ! ( --no-objcopy in $(ARGV) ) |
---|
386 | { |
---|
387 | flags gcc .OBJCOPY : [ GLOB $(GCC_BIN_DIRECTORY) $(PATH) : objcopy ] ; |
---|
388 | } |
---|
389 | |
---|
390 | if ! $(on-windows) |
---|
391 | { |
---|
392 | flags gcc .SET_EXIT : "set -e" ; |
---|
393 | } |
---|
394 | |
---|
395 | # Since GCC doesn't support response files, we want to give it a |
---|
396 | # chance to execute any long commands via spawnvp on NT, where the |
---|
397 | # command-line length limitation can really get in the way. We call |
---|
398 | # this on every target, but it will only take effect for targets we |
---|
399 | # deem spawnable, and that have long command-lines. |
---|
400 | rule gcc-spawn ( targets + ) |
---|
401 | { |
---|
402 | if $(NT) |
---|
403 | { |
---|
404 | JAMSHELL on $(targets) = % ; |
---|
405 | } |
---|
406 | } |
---|
407 | |
---|
408 | #### Link #### |
---|
409 | |
---|
410 | rule Link-action |
---|
411 | { |
---|
412 | _ on $(<) = " " ; |
---|
413 | # if we don't have a GNU linker then we can't pass any GNU-ld specific flags: |
---|
414 | if $(NO_GNU_LN) |
---|
415 | { |
---|
416 | LNOPT on $(<) = ; |
---|
417 | } |
---|
418 | else |
---|
419 | { |
---|
420 | LNOPT on $(<) = "" ; |
---|
421 | } |
---|
422 | # do we use sonames or not? |
---|
423 | if $(DLLVERSION) && $(TARGET_TYPE) in $(SHARED_TYPES) && ( $(OS) = LINUX || $(OS) = OPENBSD || $(OS) = KFREEBSD ) && ! $(NO_GNU_LN) |
---|
424 | { |
---|
425 | OUTTAG on $(<) = ".$(DLLVERSION)" ; |
---|
426 | SOTAG on $(<) = ".$(DLLVERSION)" ; |
---|
427 | ACTION_1 on $(<) = "" ; |
---|
428 | } |
---|
429 | else |
---|
430 | { |
---|
431 | OUTTAG on $(<) = "" ; |
---|
432 | SOTAG on $(<) = ; |
---|
433 | ACTION_1 on $(<) = ; |
---|
434 | } |
---|
435 | |
---|
436 | if [ on $(<) return $(ON_WINDOWS) ] |
---|
437 | { |
---|
438 | # On Win32, choose different image bases for load-time efficiency |
---|
439 | DLL_LINK_FLAGS on $(<) += "-Wl,--enable-auto-image-base" ; |
---|
440 | } |
---|
441 | |
---|
442 | if $(<[2]) && [ on $(<) return $(ON_WINDOWS) ] |
---|
443 | { |
---|
444 | # Allow gcc-nocygwin to avoid this flag |
---|
445 | if ! $(GCC_NO_EXPORT_ALL) |
---|
446 | { |
---|
447 | DLL_LINK_FLAGS on $(<) += "-Wl,--export-all-symbols" ; |
---|
448 | } |
---|
449 | |
---|
450 | # This will appear before the import library name when building a DLL, but |
---|
451 | # will be "multiplied away" otherwise. The --exclude-symbols directive |
---|
452 | # proved to be necessary with some versions of Cygwin. |
---|
453 | DLL_LINK_FLAGS on $(<) += "-Wl,--exclude-symbols,_bss_end__:_bss_start__:_data_end__:_data_start__" ; |
---|
454 | |
---|
455 | # set the link command to generate an import library |
---|
456 | if ! $(NO_GNU_LN) |
---|
457 | { |
---|
458 | IMPLIB_COMMAND on $(<) = "-Wl,--out-implib," ; |
---|
459 | } |
---|
460 | } |
---|
461 | |
---|
462 | DEPENDS $(<) : $(NEEDLIBS) $(NEEDIMPS) ; |
---|
463 | gRUN_LD_LIBRARY_PATH($(<)) += $(STDLIBPATH:T) ; |
---|
464 | |
---|
465 | # Workaround GCC's lack of command-files and NT's line-length limitation. |
---|
466 | gcc-spawn $(<) ; |
---|
467 | gcc-Link-action $(<) : $(>) ; |
---|
468 | |
---|
469 | if $(DLLVERSION) && $(TARGET_TYPE) in $(SHARED_TYPES) && ( $(OS) = LINUX || $(OS) = OPENBSD || $(OS) = KFREEBSD ) && ! $(NO_GNU_LN) |
---|
470 | { |
---|
471 | return "$(<[1]).$(DLLVERSION)" ; |
---|
472 | } |
---|
473 | } |
---|
474 | |
---|
475 | # for gcc, we repeat all libraries so that dependencies are always resolved |
---|
476 | actions gcc-Link-action bind NEEDLIBS NEEDIMPS |
---|
477 | { |
---|
478 | $(.SET_EXIT) |
---|
479 | $(SHELL_SET)$(gSHELL_LIBPATH)=$(LINK_LIBPATH)$(gAPPEND_LD_LIBRARY_PATH) |
---|
480 | $(SHELL_EXPORT)$(gSHELL_LIBPATH) |
---|
481 | "$(.GXX[1]:R=$(GCC_BIN_DIR))" $(.GXX[2-]) "$(DLL_LINK_FLAGS)" "$(IMPLIB_COMMAND)$(<[2])" $(LINKFLAGS) -o "$(<[1])$(OUTTAG)" -L"$(LIBPATH:T)" -L"$(STDLIBPATH:T)" "$(>)" "$(NEEDLIBS)" "$(NEEDLIBS)" "$(IMPLIB_FLAGS)$(NEEDIMPS)" -l$(FINDLIBS) $(LNOPT)$(RPATH_LINK). $(LNOPT)$(SONAME)$(<[1]:D=)$(SOTAG) |
---|
482 | $(ACTION_1)$(LN)$(_)-fs$(_)"$(<[1]:D=)$(OUTTAG)"$(_)"$(<[1])" |
---|
483 | } |
---|
484 | |
---|
485 | #### Cc ##### |
---|
486 | |
---|
487 | rule Cc-action |
---|
488 | { |
---|
489 | gcc-spawn $(<) ; |
---|
490 | _ on $(<) = " " ; |
---|
491 | gcc-Cc-action $(<) : $(>) ; |
---|
492 | } |
---|
493 | |
---|
494 | actions gcc-Cc-action |
---|
495 | { |
---|
496 | $(.SET_EXIT) |
---|
497 | "$(.GCC[1]:R=$(GCC_BIN_DIR))" $(.GCC[2-]) -c -Wall -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) -I"$(HDRS)" -I$(_)"$(STDHDRS)" -I$(_)"$(SYSHDRS)" -o "$(<)" "$(>)" |
---|
498 | "$(.OBJCOPY[1])"$(_)$(OBJCOPY_FLAGS)$(_)"$(<)" |
---|
499 | } |
---|
500 | |
---|
501 | #### C++ #### |
---|
502 | rule C++-action |
---|
503 | { |
---|
504 | gcc-spawn $(<) ; |
---|
505 | _ on $(<) = " " ; |
---|
506 | gcc-C++-action $(<) : $(>) ; |
---|
507 | } |
---|
508 | |
---|
509 | actions gcc-C++-action |
---|
510 | { |
---|
511 | $(.SET_EXIT) |
---|
512 | "$(.GXX[1]:R=$(GCC_BIN_DIR))" $(.GXX[2-]) -c -Wall -ftemplate-depth-255 -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I$(_)"$(STDHDRS)" -I$(_)"$(SYSHDRS)" -o "$(<)" "$(>)" |
---|
513 | "$(.OBJCOPY[1])"$(_)$(OBJCOPY_FLAGS)$(_)"$(<)" |
---|
514 | } |
---|
515 | |
---|
516 | #### Archive #### |
---|
517 | |
---|
518 | rule Archive-action |
---|
519 | { |
---|
520 | gcc-spawn $(<) ; |
---|
521 | gcc-Archive-action $(<) : $(>) ; |
---|
522 | } |
---|
523 | |
---|
524 | actions updated together piecemeal gcc-Archive-action |
---|
525 | { |
---|
526 | "$(.AR[1])" $(AROPTIONS) ru$(ARFLAGS:J=) "$(<)" "$(>)" |
---|
527 | } |
---|