| 227 |
dpurdie |
1 |
# -*- mode: perl; tabs: 8; indent-width: 4; show-tabs: yes; -*-
|
|
|
2 |
#
|
|
|
3 |
# Module name : GCC
|
|
|
4 |
# Module type : Makefile system
|
|
|
5 |
# Compiler(s) : ANSI C
|
|
|
6 |
# Environment(s): GCC
|
|
|
7 |
#
|
|
|
8 |
# Description:
|
|
|
9 |
# GCC C/C++ toolset
|
|
|
10 |
#
|
|
|
11 |
#............................................................................#
|
|
|
12 |
|
|
|
13 |
use strict;
|
|
|
14 |
use warnings;
|
|
|
15 |
|
| 4034 |
dpurdie |
16 |
our $ScmPlatform;
|
|
|
17 |
our $ScmNoToolsTest;
|
|
|
18 |
|
| 227 |
dpurdie |
19 |
##############################################################################
|
|
|
20 |
# Configuration information
|
|
|
21 |
# Cross reference from CrossCompiler Alias to actual paths
|
|
|
22 |
# Structure:
|
|
|
23 |
# Hash reference: Array of toolchain information
|
| 369 |
dpurdie |
24 |
# Mandatory
|
|
|
25 |
# ROOT => Root of compiler
|
|
|
26 |
# BASE => Base for binaries
|
|
|
27 |
# Optional
|
|
|
28 |
# CC_OPTS => Additonal Compiler options
|
| 4034 |
dpurdie |
29 |
# CC_OPTSP => Production Compiler options
|
|
|
30 |
# CC_OPTSD => Debug Compiler options
|
| 369 |
dpurdie |
31 |
# UNCONTROLLED => Boolean to create warning
|
| 3967 |
dpurdie |
32 |
# PACKAGE_ARCH => Packageing architecture
|
|
|
33 |
# VERSION => Version reported by GCC
|
|
|
34 |
# MACHINE => Machine reported by GCC
|
| 4034 |
dpurdie |
35 |
# COMPILER_OPTIONS => Toolset specific compiler initial options
|
|
|
36 |
# This is a comma seperated list
|
| 369 |
dpurdie |
37 |
|
| 227 |
dpurdie |
38 |
my %ToolsetConfig = (
|
|
|
39 |
|
| 369 |
dpurdie |
40 |
'i386-unknown-linux-gnu' => {
|
|
|
41 |
ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/i586-unknown-linux-gnu',
|
|
|
42 |
BASE => 'bin/i586-unknown-linux-gnu-',
|
| 3967 |
dpurdie |
43 |
VERSION => '4.1.1',
|
|
|
44 |
MACHINE => 'i586-unknown-linux-gnu'
|
| 369 |
dpurdie |
45 |
},
|
| 227 |
dpurdie |
46 |
|
| 369 |
dpurdie |
47 |
'arm-9tdmi-linux-gnu' => {
|
|
|
48 |
ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/arm-9tdmi-linux-gnu',
|
| 3967 |
dpurdie |
49 |
BASE => 'bin/arm-9tdmi-linux-gnu-',
|
|
|
50 |
VERSION => '4.1.1',
|
|
|
51 |
MACHINE => 'arm-9tdmi-linux-gnu'
|
| 369 |
dpurdie |
52 |
},
|
| 247 |
dpurdie |
53 |
|
| 369 |
dpurdie |
54 |
'powerpc-603e-linux-gnu' => {
|
|
|
55 |
ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/powerpc-603e-linux-gnu',
|
| 3967 |
dpurdie |
56 |
BASE => 'bin/powerpc-603e-linux-gnu-',
|
|
|
57 |
VERSION => '4.1.1',
|
|
|
58 |
MACHINE => 'powerpc-603e-linux-gnu'
|
| 369 |
dpurdie |
59 |
},
|
| 337 |
dpurdie |
60 |
|
| 369 |
dpurdie |
61 |
'arm-926ejs-linux-gnueabi' => {
|
|
|
62 |
ROOT => '/opt/crosstool/gcc-4.4.3-glibc-2.9/arm-926ejs-linux-gnueabi',
|
|
|
63 |
BASE => 'bin/arm-926ejs-linux-gnueabi-',
|
|
|
64 |
CC_OPTS => '-Wno-psabi',
|
| 3967 |
dpurdie |
65 |
VERSION => '4.4.3',
|
|
|
66 |
MACHINE => 'arm-926ejs-linux-gnueabi'
|
| 369 |
dpurdie |
67 |
},
|
|
|
68 |
|
| 3967 |
dpurdie |
69 |
'i686-linux-gnu' => {
|
|
|
70 |
ROOT => '/usr',
|
|
|
71 |
BASE => 'bin/',
|
|
|
72 |
PACKAGE_ARCH => 'i386',
|
|
|
73 |
VERSION => '4.6',
|
|
|
74 |
MACHINE => 'i686-linux-gnu'
|
|
|
75 |
},
|
|
|
76 |
|
| 4109 |
dpurdie |
77 |
'arm-iwmmxt-linux-gnueabi' => {
|
|
|
78 |
ROOT => '/opt/marvel',
|
|
|
79 |
BASE => 'bin/arm-iwmmxt-linux-gnueabi-',
|
|
|
80 |
VERSION => '4.2.4',
|
|
|
81 |
MACHINE => 'arm-iwmmxt-linux-gnueabi'
|
|
|
82 |
},
|
|
|
83 |
|
|
|
84 |
|
| 227 |
dpurdie |
85 |
#
|
|
|
86 |
# Old (not to be used) version of the embedded toolchain
|
| 4003 |
dpurdie |
87 |
# This was deprecated in favor of gcc-4.1.1-glibc-2.5
|
| 227 |
dpurdie |
88 |
# It is not possible to reproduce old packages using the old compiler
|
|
|
89 |
# This is a known issue
|
|
|
90 |
#
|
| 369 |
dpurdie |
91 |
'i386-unknown-linux-gnu.glibc-2.3.2' => {
|
|
|
92 |
ROOT => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/i386-unknown-linux-gnu',
|
|
|
93 |
BASE => 'bin/i386-unknown-linux-gnu-'
|
|
|
94 |
},
|
| 227 |
dpurdie |
95 |
|
| 369 |
dpurdie |
96 |
'arm-9tdmi-linux-gnu.glibc-2.3.2' => {
|
|
|
97 |
ROOT => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu',
|
|
|
98 |
BASE => 'bin/arm-9tdmi-linux-gnu-'
|
|
|
99 |
},
|
| 227 |
dpurdie |
100 |
|
|
|
101 |
#
|
|
|
102 |
# Not too sure where this is used
|
|
|
103 |
#
|
| 369 |
dpurdie |
104 |
'armv4l-unknown-linux-gcc' => {
|
|
|
105 |
ROOT => '/opt/host/armv4l',
|
|
|
106 |
BASE => 'bin/armv4l-unknown-linux-'
|
|
|
107 |
},
|
| 227 |
dpurdie |
108 |
|
|
|
109 |
#
|
|
|
110 |
# The compiler for the current local machine
|
|
|
111 |
#
|
| 369 |
dpurdie |
112 |
'i386-unknown-linux-gcc' => {
|
|
|
113 |
ROOT => '/usr',
|
|
|
114 |
BASE => 'bin/',
|
|
|
115 |
UNCONTROLLED => 1,
|
| 3967 |
dpurdie |
116 |
PACKAGE_ARCH => 'i386',
|
| 369 |
dpurdie |
117 |
},
|
|
|
118 |
);
|
| 227 |
dpurdie |
119 |
|
|
|
120 |
#
|
|
|
121 |
# Cross reference from GCCTarget to GBE_MACHTYPE for which it can
|
|
|
122 |
# build using the 'native gcc'. This is NOT the preferred mode of operation
|
|
|
123 |
# as the compiler is not as controlled as the cross compilers.
|
|
|
124 |
#
|
|
|
125 |
my %NativeCompilers = (
|
|
|
126 |
'Linux i386' => 'linux_i386',
|
|
|
127 |
);
|
|
|
128 |
|
| 4700 |
alewis |
129 |
my $UseGcov = 0;
|
| 4701 |
alewis |
130 |
my $UseCppcheck = 0;
|
| 4700 |
alewis |
131 |
|
| 227 |
dpurdie |
132 |
##############################################################################
|
|
|
133 |
# ToolsetInit()
|
|
|
134 |
# Runtime initialisation
|
|
|
135 |
#
|
|
|
136 |
##############################################################################
|
|
|
137 |
|
|
|
138 |
ToolsetInit();
|
|
|
139 |
|
|
|
140 |
sub ToolsetInit
|
|
|
141 |
{
|
| 4034 |
dpurdie |
142 |
my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCObjCopy );
|
| 4700 |
alewis |
143 |
my( $GCCFlags, $GCCFlagsP, $GCCFlagsD, $LDFlags );
|
| 3967 |
dpurdie |
144 |
my( $PkgArch);
|
| 4034 |
dpurdie |
145 |
my( $arg_alias, $tools_found, $compiler_tool );
|
| 227 |
dpurdie |
146 |
|
|
|
147 |
#.. Toolset configuration
|
|
|
148 |
#
|
|
|
149 |
$::ScmToolsetVersion = "1.0.0"; # our version
|
|
|
150 |
$::ScmToolsetGenerate = 0; # GEN generate optional
|
|
|
151 |
$::ScmToolsetCompilerPath = 1; # Exports Compiler path to makefile via SCM_COMPILERPATH
|
| 271 |
dpurdie |
152 |
$::ScmToolsetProgDependancies = 0; # handle Prog dependancies myself
|
| 339 |
dpurdie |
153 |
$::ScmToolsetSoName = 1; # Shared library supports SoName
|
| 227 |
dpurdie |
154 |
|
|
|
155 |
#.. Standard.rul requirements
|
|
|
156 |
#
|
|
|
157 |
$::s = "asm";
|
|
|
158 |
$::o = "o";
|
|
|
159 |
$::so = "so";
|
|
|
160 |
$::a = "a";
|
|
|
161 |
$::exe = "";
|
|
|
162 |
|
|
|
163 |
#.. Parse arguments
|
|
|
164 |
#
|
|
|
165 |
foreach $_ ( @::ScmToolsetArgs ) {
|
|
|
166 |
if (/^--Target=(.*)/) { # OS Version
|
|
|
167 |
$GCCTarget = "$1";
|
|
|
168 |
|
|
|
169 |
} elsif (/^--CrossAlias=(.*)/) { # CrossCompiler target-alias
|
|
|
170 |
$arg_alias = $1;
|
|
|
171 |
|
| 4700 |
alewis |
172 |
} elsif (/^--UseGcov/) { # Compile for code coverage
|
|
|
173 |
$UseGcov = 1;
|
|
|
174 |
|
| 4701 |
alewis |
175 |
} elsif (/^--UseCppcheck/) { # Use cppcheck as the lint tool
|
|
|
176 |
$UseCppcheck = 1;
|
|
|
177 |
|
| 4034 |
dpurdie |
178 |
} elsif (/^--CompilerTool=(.*)/) { # CrossCompiler located in package
|
|
|
179 |
$compiler_tool = $1;
|
|
|
180 |
|
| 227 |
dpurdie |
181 |
} else {
|
|
|
182 |
Message( "gcc toolset: unknown option $_ -- ignored\n" );
|
|
|
183 |
}
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
foreach $_ ( @::ScmPlatformArgs ) {
|
|
|
187 |
if (/^--product=(.*)/) { # GBE product
|
|
|
188 |
|
|
|
189 |
} else {
|
|
|
190 |
Message( "gcc toolset: unknown platform argument $_ -- ignored\n" );
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
Error ("TOOLSET/gcc - Target undefined" )
|
|
|
195 |
unless ($GCCTarget);
|
|
|
196 |
|
| 4034 |
dpurdie |
197 |
#
|
|
|
198 |
# If the toolset is not required, then do not process any futher
|
|
|
199 |
# We may not find the compiler
|
|
|
200 |
#
|
|
|
201 |
return
|
|
|
202 |
if ($ScmNoToolsTest);
|
|
|
203 |
|
| 227 |
dpurdie |
204 |
#.. Cross compile support
|
| 4034 |
dpurdie |
205 |
# Compiler provided in package, rather than install on machine
|
| 227 |
dpurdie |
206 |
#
|
| 4034 |
dpurdie |
207 |
if ( $compiler_tool )
|
|
|
208 |
{
|
|
|
209 |
#
|
|
|
210 |
# The GCC toolset will handle a compiler provided within a package
|
|
|
211 |
# Initial requirement was for ANDROID NDKs where the compiler is
|
|
|
212 |
# a part of the NDK and will change.
|
|
|
213 |
#
|
|
|
214 |
# Compilers in packages will have a file in gbe/COMPILERS/<compiler_tool>
|
|
|
215 |
# that contains data specifically designed for this toolset
|
|
|
216 |
#
|
|
|
217 |
Verbose("Locate compiler in package: $compiler_tool");
|
|
|
218 |
my @toolList;
|
|
|
219 |
my $toolPath;
|
|
|
220 |
my $toolPkg;
|
|
|
221 |
for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
|
|
|
222 |
{
|
|
|
223 |
my $tpath = join('/', $entry->{ROOT}, 'gbe', 'COMPILERS' , $compiler_tool);
|
|
|
224 |
if ( -f $tpath )
|
|
|
225 |
{
|
|
|
226 |
push @toolList, $entry->{NAME};
|
|
|
227 |
$toolPath = $tpath;
|
|
|
228 |
$toolPkg = $entry;
|
|
|
229 |
}
|
|
|
230 |
}
|
|
|
231 |
Error ("Multiple packages provide required compiler:", @toolList)
|
|
|
232 |
if ( scalar(@toolList) > 1 );
|
|
|
233 |
Error ("Required compiler not found in any package", "Compiler: $compiler_tool")
|
|
|
234 |
unless ( scalar(@toolList) == 1 );
|
|
|
235 |
|
|
|
236 |
#
|
|
|
237 |
# Process the compiler info file
|
|
|
238 |
# Rip out the data and create a hash of item/values
|
|
|
239 |
# File format:
|
|
|
240 |
# '#' is a line comment
|
|
|
241 |
# item=value
|
|
|
242 |
#
|
|
|
243 |
my %data;
|
|
|
244 |
open (my $DATA, '<', $toolPath ) || Error("Cannot open compiler datafile. $!", "File: $toolPath");
|
|
|
245 |
while ( <$DATA> )
|
|
|
246 |
{
|
|
|
247 |
$_ =~ s~\s+$~~;
|
|
|
248 |
next if ( m~^#~ );
|
|
|
249 |
m~(.*?)\s*=\s*(.*)~;
|
|
|
250 |
$data{$1} = $2;
|
|
|
251 |
}
|
|
|
252 |
close $DATA;
|
|
|
253 |
|
|
|
254 |
#
|
|
|
255 |
# Force this compilers data into the ToolsetConfig hash
|
|
|
256 |
#
|
|
|
257 |
$arg_alias = $compiler_tool;
|
|
|
258 |
%ToolsetConfig = ();
|
|
|
259 |
|
|
|
260 |
$ToolsetConfig{$arg_alias}{ROOT} = join('/', $toolPkg->{ROOT}, $data{ROOT} );
|
|
|
261 |
$ToolsetConfig{$arg_alias}{BASE} = $data{BASE} . '-';
|
|
|
262 |
$ToolsetConfig{$arg_alias}{CC_OPTS} = $data{CFLAGS};
|
|
|
263 |
$ToolsetConfig{$arg_alias}{CC_OPTSP} = $data{CFLAGSP};
|
|
|
264 |
$ToolsetConfig{$arg_alias}{CC_OPTSD} = $data{CFLAGSD};
|
|
|
265 |
$ToolsetConfig{$arg_alias}{VERSION} = $data{VERSION};
|
|
|
266 |
$ToolsetConfig{$arg_alias}{MACHINE} = $data{MACHINE};
|
|
|
267 |
$ToolsetConfig{$arg_alias}{COMPILER_OPTIONS} = $data{COMPILER_OPTIONS};
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
#.. Cross compile support
|
|
|
271 |
#
|
| 227 |
dpurdie |
272 |
# Toolchain=root,[bin]
|
|
|
273 |
#
|
|
|
274 |
if ( $arg_alias )
|
|
|
275 |
{
|
|
|
276 |
if ( exists $ToolsetConfig{ $arg_alias } )
|
|
|
277 |
{
|
| 369 |
dpurdie |
278 |
$GCCToolchain = $ToolsetConfig{ $arg_alias };
|
|
|
279 |
$tools_found = (-d $GCCToolchain->{ROOT});
|
| 227 |
dpurdie |
280 |
Warning ("gcc toolset: CrossPlatform toolchain not found for: $arg_alias",
|
| 369 |
dpurdie |
281 |
"Path: $GCCToolchain->{ROOT}" ) unless $tools_found;
|
| 227 |
dpurdie |
282 |
}
|
|
|
283 |
else
|
|
|
284 |
{
|
|
|
285 |
Error("gcc toolset: CrossPlatform Alias not configured: $arg_alias");
|
|
|
286 |
}
|
| 369 |
dpurdie |
287 |
|
|
|
288 |
Warning ("Uncontrolled toolchain used: $arg_alias")
|
|
|
289 |
if ( exists($GCCToolchain->{UNCONTROLLED}) && $GCCToolchain->{UNCONTROLLED} );
|
| 227 |
dpurdie |
290 |
}
|
|
|
291 |
|
|
|
292 |
#
|
|
|
293 |
# If no Cross compiler toolchain is found (preferred method), then attempt
|
|
|
294 |
# to match a native compiler. Only known targets allow a native build
|
|
|
295 |
#
|
|
|
296 |
unless ( $tools_found )
|
|
|
297 |
{
|
|
|
298 |
if ( exists ( $NativeCompilers{$GCCTarget} ))
|
|
|
299 |
{
|
|
|
300 |
if ( $NativeCompilers{$GCCTarget} eq $::GBE_MACHTYPE )
|
|
|
301 |
{
|
|
|
302 |
$tools_found = 1;
|
| 369 |
dpurdie |
303 |
$GCCToolchain = undef;
|
| 227 |
dpurdie |
304 |
}
|
|
|
305 |
}
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
#
|
|
|
309 |
# Must have a toolset by now, either a cross compiler or Native
|
|
|
310 |
#
|
|
|
311 |
Error ("gcc toolset: Toolchain not found for: $GCCTarget" )
|
|
|
312 |
unless ( $tools_found );
|
|
|
313 |
|
|
|
314 |
|
| 369 |
dpurdie |
315 |
if ( defined $GCCToolchain )
|
| 227 |
dpurdie |
316 |
{
|
|
|
317 |
#
|
| 369 |
dpurdie |
318 |
# Parse GCCToolchain. Potential parts to create
|
|
|
319 |
# GCCRoot - Location to find the effective /usr/include directory
|
|
|
320 |
# GCCBin - Path to the gcc executable
|
|
|
321 |
# GCCAr - Path to the ar executable
|
| 4034 |
dpurdie |
322 |
# GCCFlags - Additional compiler flags. Also Production and Debug
|
| 227 |
dpurdie |
323 |
#
|
| 369 |
dpurdie |
324 |
$GCCRoot = $GCCToolchain->{ROOT};
|
|
|
325 |
$GCCBin = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'gcc';
|
|
|
326 |
$GCCAr = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'ar';
|
| 373 |
dpurdie |
327 |
$GCCObjCopy = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'objcopy';
|
| 369 |
dpurdie |
328 |
$GCCFlags = $GCCToolchain->{CC_OPTS};
|
| 4034 |
dpurdie |
329 |
$GCCFlagsP = $GCCToolchain->{CC_OPTSP};
|
|
|
330 |
$GCCFlagsD = $GCCToolchain->{CC_OPTSD};
|
| 3967 |
dpurdie |
331 |
$PkgArch = $GCCToolchain->{PACKAGE_ARCH};
|
| 227 |
dpurdie |
332 |
}
|
|
|
333 |
else
|
|
|
334 |
{
|
| 373 |
dpurdie |
335 |
$GCCRoot = '/usr';
|
|
|
336 |
$GCCBin = 'gcc';
|
|
|
337 |
$GCCAr = 'ar';
|
|
|
338 |
$GCCObjCopy = 'objcopy';
|
| 227 |
dpurdie |
339 |
}
|
| 4700 |
alewis |
340 |
|
|
|
341 |
#
|
|
|
342 |
# When running under gcov we need to instruct GCC to perform code coverage
|
|
|
343 |
# generation in both C flags and LD flags
|
|
|
344 |
#
|
|
|
345 |
if ( $UseGcov )
|
|
|
346 |
{
|
|
|
347 |
$GCCFlags=$GCCFlags . ' -coverage';
|
|
|
348 |
$LDFlags=$LDFlags . ' -coverage';
|
|
|
349 |
}
|
| 4701 |
alewis |
350 |
|
|
|
351 |
#
|
|
|
352 |
# When running with cppcheck we need to include it in our environment
|
|
|
353 |
#
|
|
|
354 |
if ( $UseCppcheck )
|
|
|
355 |
{
|
|
|
356 |
ToolsetRequire( "cppcheck" );
|
|
|
357 |
PlatformDefine( "CPPCHECK_PLATFORM := unix32" );
|
|
|
358 |
}
|
| 4700 |
alewis |
359 |
|
| 227 |
dpurdie |
360 |
|
|
|
361 |
#.. Define GCC environment
|
|
|
362 |
#
|
|
|
363 |
PlatformDefine( "
|
|
|
364 |
#################################################
|
|
|
365 |
# GCC toolchain definitions
|
|
|
366 |
#
|
|
|
367 |
#..");
|
| 369 |
dpurdie |
368 |
PlatformDefine( "GCC_TARGET := $GCCTarget" );
|
|
|
369 |
PlatformDefine( "GCC_ROOT := $GCCRoot" );
|
|
|
370 |
PlatformDefine( "GCC_CC := $GCCBin" );
|
|
|
371 |
PlatformDefine( "GCC_AR := $GCCAr" );
|
| 373 |
dpurdie |
372 |
PlatformDefine( "GCC_OBJCOPY := $GCCObjCopy" );
|
| 369 |
dpurdie |
373 |
PlatformDefine( "GCC_CFLAGS := $GCCFlags" ) if defined $GCCFlags;
|
| 4034 |
dpurdie |
374 |
PlatformDefine( "GCC_CFLAGSP := $GCCFlagsP" ) if defined $GCCFlagsP;
|
|
|
375 |
PlatformDefine( "GCC_CFLAGSD := $GCCFlagsD" ) if defined $GCCFlagsD;
|
| 4700 |
alewis |
376 |
PlatformDefine( "GCC_LDFLAGS := $LDFlags" ) if defined $LDFlags;
|
| 369 |
dpurdie |
377 |
|
| 227 |
dpurdie |
378 |
#
|
|
|
379 |
# Required since this toolset advertises: ScmToolsetCompilerPath
|
|
|
380 |
#
|
| 369 |
dpurdie |
381 |
PlatformDefine( "SCM_COMPILERPATH := \$\{GCC_CC\}" );
|
| 3967 |
dpurdie |
382 |
|
|
|
383 |
#
|
|
|
384 |
# Sanity checking
|
|
|
385 |
#
|
|
|
386 |
PlatformDefine( "GCC_EVERSION := " . $GCCToolchain->{VERSION} ) if defined $GCCToolchain->{VERSION};
|
|
|
387 |
PlatformDefine( "GCC_EMACHINE := " . $GCCToolchain->{MACHINE} ) if defined $GCCToolchain->{MACHINE};
|
|
|
388 |
|
|
|
389 |
#
|
|
|
390 |
# Option indication of packaging architecture
|
|
|
391 |
# Used by non-embedded systems for packaging. See debian_packager
|
|
|
392 |
#
|
|
|
393 |
PlatformDefine( "PACKAGE_ARCH := $PkgArch" ) if (defined $PkgArch);
|
| 369 |
dpurdie |
394 |
PlatformDefine( "" );
|
| 227 |
dpurdie |
395 |
|
|
|
396 |
#.. Piece the world together
|
|
|
397 |
#
|
| 3967 |
dpurdie |
398 |
Init( 'gcc' );
|
| 227 |
dpurdie |
399 |
ToolsetDefines( "gcc.def" );
|
|
|
400 |
ToolsetRules( "gcc.rul" );
|
|
|
401 |
ToolsetRules( "standard.rul" );
|
|
|
402 |
|
| 4094 |
dpurdie |
403 |
|
|
|
404 |
PlatformDefine( "CTAGS_EXE:= ctags" );
|
|
|
405 |
ToolsetRequire( "exctags" ); # and Exuberant Ctags
|
|
|
406 |
|
| 227 |
dpurdie |
407 |
# Create a standard data structure
|
|
|
408 |
# This is a hash of hashes
|
|
|
409 |
# The first hash is keyed by CompileOption keyword
|
|
|
410 |
# The second hash contains pairs of values to set or remove
|
|
|
411 |
#
|
|
|
412 |
%::ScmToolsetCompilerOptions =
|
|
|
413 |
(
|
|
|
414 |
#
|
|
|
415 |
# Control the thread model to use
|
|
|
416 |
# This will affect the compiler options and the linker options
|
|
|
417 |
#
|
|
|
418 |
'staticprogs' => { 'STATIC_PROGS' , '1' }, # Progams link staticlly
|
|
|
419 |
'no_staticprogs' => { 'STATIC_PROGS' , undef }, # Default
|
| 4034 |
dpurdie |
420 |
'noversiondll' => { 'NO_VERSIONED_DLLS', 1 }, # Matches usage elsewhere
|
| 227 |
dpurdie |
421 |
);
|
|
|
422 |
|
|
|
423 |
#
|
|
|
424 |
# Set default options
|
|
|
425 |
#
|
|
|
426 |
$::ScmCompilerOpts{'STATIC_PROGS'} = undef;
|
| 4034 |
dpurdie |
427 |
$::ScmCompilerOpts{'NO_VERSIONED_DLLS'} = undef;
|
|
|
428 |
|
|
|
429 |
#
|
|
|
430 |
# Process toolset-specfic compiler options
|
|
|
431 |
#
|
|
|
432 |
if ( exists $GCCToolchain->{COMPILER_OPTIONS} )
|
|
|
433 |
{
|
|
|
434 |
CompileOptions('*', split(',',$GCCToolchain->{COMPILER_OPTIONS}) );
|
|
|
435 |
}
|
| 227 |
dpurdie |
436 |
}
|
|
|
437 |
|
| 4094 |
dpurdie |
438 |
###############################################################################
|
|
|
439 |
# ToolsetCTAGS()
|
|
|
440 |
# This subroutine takes the user options and builds the rules
|
|
|
441 |
# required to build the CTAGS database.
|
|
|
442 |
#
|
|
|
443 |
# Arguments:
|
|
|
444 |
# --xxx No arguments currently defined
|
|
|
445 |
#
|
|
|
446 |
# Output:
|
|
|
447 |
# [ctags:]
|
|
|
448 |
# $(EXCTAGS)
|
|
|
449 |
#
|
|
|
450 |
###############################################################################
|
| 227 |
dpurdie |
451 |
|
| 4094 |
dpurdie |
452 |
sub ToolsetCTAGS
|
|
|
453 |
{
|
|
|
454 |
EXCTAGS( @_ );
|
|
|
455 |
}
|
|
|
456 |
|
|
|
457 |
|
| 227 |
dpurdie |
458 |
###############################################################################
|
|
|
459 |
# ToolsetCC( $source, $obj, \@args )
|
|
|
460 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
461 |
# required to compile the source file 'source' to 'obj'
|
|
|
462 |
#
|
|
|
463 |
###############################################################################
|
|
|
464 |
|
|
|
465 |
sub ToolsetCC
|
|
|
466 |
{
|
|
|
467 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
468 |
my( $cflags, $file ) = "";
|
|
|
469 |
|
|
|
470 |
foreach $_ ( @$pArgs ) {
|
|
|
471 |
if (/--Shared$/) { # Building a 'shared' object
|
|
|
472 |
$cflags = "$cflags \$(SHCFLAGS)";
|
|
|
473 |
} else {
|
|
|
474 |
Message( "CC: unknown option $_ -- ignored\n" );
|
|
|
475 |
}
|
|
|
476 |
}
|
|
|
477 |
|
|
|
478 |
MakePrint( "\n\t\$(CC)\n" );
|
|
|
479 |
if ( $cflags )
|
|
|
480 |
{ # object specific CFLAGS
|
|
|
481 |
MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
|
|
|
482 |
MakePrint( "\tCFLAGS +=$cflags\n" );
|
|
|
483 |
}
|
|
|
484 |
|
|
|
485 |
$file = StripExt( $obj ); # Metric working file
|
|
|
486 |
ToolsetGenerate( "\$(OBJDIR)/$file.met" );
|
| 4712 |
alewis |
487 |
|
|
|
488 |
if ( $UseGcov )
|
|
|
489 |
{
|
|
|
490 |
ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
|
|
|
491 |
ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
|
|
|
492 |
}
|
| 227 |
dpurdie |
493 |
}
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
###############################################################################
|
|
|
497 |
# ToolsetCCDepend( $depend, \@sources )
|
|
|
498 |
# This subroutine takes the user options and builds the
|
|
|
499 |
# rule(s) required to build the dependencies for the source
|
|
|
500 |
# files 'sources' to 'depend'.
|
|
|
501 |
#
|
|
|
502 |
###############################################################################
|
|
|
503 |
|
|
|
504 |
sub ToolsetCCDepend
|
|
|
505 |
{
|
|
|
506 |
MakePrint( "\t\$(CCDEPEND)\n" );
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
|
|
|
510 |
###############################################################################
|
|
|
511 |
# ToolsetCXX( $source, $obj, \@args )
|
|
|
512 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
513 |
# required to compile the source file 'source' to 'obj'
|
|
|
514 |
#
|
|
|
515 |
###############################################################################
|
|
|
516 |
|
|
|
517 |
sub ToolsetCXX
|
|
|
518 |
{
|
|
|
519 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
520 |
my( $cflags, $file ) = "";
|
|
|
521 |
|
|
|
522 |
foreach $_ ( @$pArgs ) {
|
|
|
523 |
if (/--Shared$/) { # Building a 'shared' object
|
|
|
524 |
$cflags = "$cflags \$(SHCXXFLAGS)";
|
|
|
525 |
} else {
|
|
|
526 |
Message( "CXX: unknown option $_ -- ignored\n" );
|
|
|
527 |
}
|
|
|
528 |
}
|
|
|
529 |
|
|
|
530 |
MakePrint( "\n\t\$(CXX)\n" );
|
|
|
531 |
if ( $cflags )
|
|
|
532 |
{ # object specific CFLAGS
|
|
|
533 |
MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
|
|
|
534 |
MakePrint( "\tCXXFLAGS +=$cflags\n" );
|
|
|
535 |
}
|
|
|
536 |
|
|
|
537 |
$file = StripExt( $obj ); # Metric working file
|
|
|
538 |
ToolsetGenerate( "\$(OBJDIR)/$file.met" );
|
| 4712 |
alewis |
539 |
|
|
|
540 |
if ( $UseGcov )
|
|
|
541 |
{
|
|
|
542 |
ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
|
|
|
543 |
ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
|
|
|
544 |
}
|
| 227 |
dpurdie |
545 |
}
|
|
|
546 |
|
|
|
547 |
|
|
|
548 |
###############################################################################
|
|
|
549 |
# ToolsetCXXDepend( $depend, \@sources )
|
|
|
550 |
# This subroutine takes the user options and builds the
|
|
|
551 |
# rule(s) required to build the dependencies for the source
|
|
|
552 |
# files 'sources' to 'depend'.
|
|
|
553 |
#
|
|
|
554 |
###############################################################################
|
|
|
555 |
|
|
|
556 |
sub ToolsetCXXDepend
|
|
|
557 |
{
|
| 287 |
dpurdie |
558 |
ToolsetCCDepend();
|
| 227 |
dpurdie |
559 |
}
|
|
|
560 |
|
|
|
561 |
|
|
|
562 |
###############################################################################
|
|
|
563 |
# ToolsetAS( $source, $obj, \@args )
|
|
|
564 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
565 |
# required to compile the source file 'source' to 'obj'
|
|
|
566 |
#
|
|
|
567 |
###############################################################################
|
|
|
568 |
|
|
|
569 |
sub ToolsetAS
|
|
|
570 |
{
|
|
|
571 |
MakePrint( "\n\t\$(AS)\n" );
|
|
|
572 |
}
|
|
|
573 |
|
|
|
574 |
sub ToolsetASDepend
|
|
|
575 |
{
|
|
|
576 |
}
|
|
|
577 |
|
|
|
578 |
|
|
|
579 |
###############################################################################
|
|
|
580 |
# ToolsetAR( $name, \@args, \@objs )
|
|
|
581 |
# This subroutine takes the user options and builds the rules
|
|
|
582 |
# required to build the library 'name'.
|
|
|
583 |
#
|
|
|
584 |
# Arguments:
|
|
|
585 |
# n/a
|
|
|
586 |
#
|
|
|
587 |
# Output:
|
|
|
588 |
# $(BINDIR)/name$.${a}: .... ]
|
|
|
589 |
# $(AR)
|
|
|
590 |
#
|
|
|
591 |
# name_ld += ... Linker command file
|
|
|
592 |
# :
|
|
|
593 |
#
|
|
|
594 |
# name_dp += ... Dependency list
|
|
|
595 |
# :
|
|
|
596 |
#
|
|
|
597 |
###############################################################################
|
|
|
598 |
|
|
|
599 |
sub ToolsetAR
|
|
|
600 |
{
|
|
|
601 |
my( $name, $pArgs, $pObjs ) = @_;
|
|
|
602 |
|
|
|
603 |
#.. Parse arguments
|
|
|
604 |
#
|
|
|
605 |
foreach $_ ( @$pArgs )
|
|
|
606 |
{
|
|
|
607 |
Message( "AR: unknown option $_ -- ignored\n" );
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
#.. Target
|
|
|
611 |
#
|
|
|
612 |
MakePrint( "#.. Library ($name)\n\n" ); # label
|
|
|
613 |
|
|
|
614 |
MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).$::a:\t",
|
|
|
615 |
"", "\\\n\t\t", ".$::o", @$pObjs );
|
|
|
616 |
|
|
|
617 |
#.. Build library rule (just append to standard rule)
|
|
|
618 |
#
|
|
|
619 |
MakePrint( "\n\t\$(AR)\n\n" );
|
|
|
620 |
}
|
|
|
621 |
|
|
|
622 |
|
|
|
623 |
###############################################################################
|
|
|
624 |
# ToolsetARMerge( $name, \@args, \@libs )
|
|
|
625 |
# This subroutine takes the user options and builds the rules
|
|
|
626 |
# required to build the library 'name' by merging the specified
|
|
|
627 |
# libaries
|
|
|
628 |
#
|
|
|
629 |
# Arguments:
|
|
|
630 |
# --xxx No arguments currently defined
|
|
|
631 |
#
|
|
|
632 |
# Output:
|
|
|
633 |
# [ $(LIBDIR)/name$.${a}: .... ]
|
|
|
634 |
# ...
|
|
|
635 |
#
|
|
|
636 |
###############################################################################
|
|
|
637 |
|
|
|
638 |
sub ToolsetARMerge
|
|
|
639 |
{
|
|
|
640 |
MakePrint( "\n\t\$(ARMERGE)\n\n" );
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
|
|
|
644 |
###############################################################################
|
| 289 |
dpurdie |
645 |
# ToolsetSHLD( $name, \@args, \@objs, \@libraries, $ver )
|
| 227 |
dpurdie |
646 |
# This subroutine takes the user options and builds the rules
|
| 339 |
dpurdie |
647 |
# required to link the Shared Library 'name'.
|
| 227 |
dpurdie |
648 |
#
|
|
|
649 |
# Arguments:
|
|
|
650 |
# n/a
|
|
|
651 |
#
|
|
|
652 |
# Output:
|
|
|
653 |
# $(LIBDIR)/name: $(LIBDIR)/shared
|
|
|
654 |
# ln -s $shared $name
|
|
|
655 |
#
|
|
|
656 |
# $(LIBDIR)/name.dep: $(GBE_OBJDIR)
|
|
|
657 |
# $(LIBDIR)/name.dep: $(GBE_LIBDIR)
|
|
|
658 |
# $(LIBDIR)/name.dep: $(GBE_PLATFORM).mk
|
|
|
659 |
# $(SHLDDEPEND)
|
|
|
660 |
#
|
|
|
661 |
# $(LIBDIR)/shared: SHNAME=name
|
|
|
662 |
# $(LIBDIR)/shared: SHBASE=base
|
|
|
663 |
# $(LIBDIR)/shared: $(LIBDIR)/name.dep \
|
|
|
664 |
# $(OBJECTS)
|
|
|
665 |
#
|
|
|
666 |
# ifneq "$(findstring $(IFLAG),23)" ""
|
|
|
667 |
# -include "$(LIBDIR)/name.dep"
|
|
|
668 |
# endif
|
|
|
669 |
#
|
|
|
670 |
# name_ld += ...
|
|
|
671 |
# :
|
|
|
672 |
#
|
|
|
673 |
###############################################################################
|
|
|
674 |
|
|
|
675 |
sub ToolsetSHLD
|
|
|
676 |
{
|
| 289 |
dpurdie |
677 |
my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
|
| 373 |
dpurdie |
678 |
my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
|
| 4034 |
dpurdie |
679 |
my $sosuffix;
|
|
|
680 |
my $noVersionedLib = $::ScmCompilerOpts{'NO_VERSIONED_DLLS'};
|
| 227 |
dpurdie |
681 |
|
| 4034 |
dpurdie |
682 |
|
| 227 |
dpurdie |
683 |
#.. Parse arguments
|
|
|
684 |
#
|
|
|
685 |
foreach $_ ( @$pArgs )
|
|
|
686 |
{
|
|
|
687 |
if (/^--Def=(.*?)(\,(.*))?$/) { # Library definition
|
|
|
688 |
#
|
|
|
689 |
# Locate the Def file.
|
|
|
690 |
# If it is a generate file so it will be in the SRCS hash
|
|
|
691 |
# Otherwise the user will have to use Src to locate the file
|
|
|
692 |
#
|
|
|
693 |
$def = MakeSrcResolve($1);
|
|
|
694 |
$def_pref = '';
|
|
|
695 |
if ( $1 =~ m~\.def$~ ) {
|
|
|
696 |
$def_pref = '--version-script='; # Old def file
|
|
|
697 |
}
|
|
|
698 |
} elsif ( /^--MultiScan/i ) {
|
|
|
699 |
$multi_scan = 1;
|
|
|
700 |
|
|
|
701 |
} elsif ( /^--NoMultiScan/i ) {
|
|
|
702 |
$multi_scan = 0;
|
|
|
703 |
|
| 339 |
dpurdie |
704 |
} elsif ( /^--SoNameSuffix=(.*)/i ) {
|
|
|
705 |
$sosuffix = $1;
|
|
|
706 |
|
| 4034 |
dpurdie |
707 |
} elsif (/^--NoVersionDll/i) {
|
|
|
708 |
$noVersionedLib = 1;
|
|
|
709 |
|
| 227 |
dpurdie |
710 |
} else {
|
|
|
711 |
Message( "SHLD: unknown option $_ -- ignored\n" );
|
|
|
712 |
}
|
|
|
713 |
}
|
|
|
714 |
|
| 4034 |
dpurdie |
715 |
#
|
|
|
716 |
# Determine the 'soname' in none has been provided
|
|
|
717 |
#
|
|
|
718 |
$sosuffix = '.' . $ver
|
|
|
719 |
unless ( defined $sosuffix );
|
|
|
720 |
$sosuffix = ''
|
|
|
721 |
if ( $noVersionedLib );
|
|
|
722 |
|
| 339 |
dpurdie |
723 |
#.. Various library names
|
| 227 |
dpurdie |
724 |
#
|
| 339 |
dpurdie |
725 |
$linkname = "$name\$(GBE_TYPE).$::so";
|
| 4034 |
dpurdie |
726 |
$shared = $noVersionedLib ? $linkname : "$linkname.$ver";
|
| 339 |
dpurdie |
727 |
$soname = "$linkname$sosuffix";
|
| 4034 |
dpurdie |
728 |
|
| 373 |
dpurdie |
729 |
my $shared_path = "\$(LIBDIR)/${shared}";
|
|
|
730 |
my $dbg_path = $shared_path . '.dbg';
|
| 227 |
dpurdie |
731 |
|
|
|
732 |
#.. Cleanup rules
|
|
|
733 |
#
|
|
|
734 |
# map Map file
|
|
|
735 |
# ln Link from LIBDIR to BINDIR
|
|
|
736 |
#
|
| 261 |
dpurdie |
737 |
ToolsetGenerate( "\$(LIBDIR)/${name}.map" );
|
|
|
738 |
ToolsetGenerate( "\$(LIBDIR)/${shared}" );
|
| 339 |
dpurdie |
739 |
ToolsetGenerate( "\$(BINDIR)/${soname}" );
|
| 373 |
dpurdie |
740 |
ToolsetGenerate( $dbg_path );
|
| 227 |
dpurdie |
741 |
|
|
|
742 |
#.. Build rules
|
|
|
743 |
#
|
|
|
744 |
# name Base name
|
|
|
745 |
# shared Library name, includes GBE_TYPE specification
|
|
|
746 |
#
|
|
|
747 |
my ($io) = ToolsetPrinter::New();
|
| 335 |
dpurdie |
748 |
my $dep = $io->SetShldTarget($shared);
|
| 227 |
dpurdie |
749 |
|
|
|
750 |
$io->Label( "Shared library", $name );
|
| 339 |
dpurdie |
751 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
|
| 373 |
dpurdie |
752 |
PackageShlibAddFiles( $name, $dbg_path );
|
| 4034 |
dpurdie |
753 |
|
| 227 |
dpurdie |
754 |
$io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
|
| 339 |
dpurdie |
755 |
$io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
|
|
|
756 |
$io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
|
| 321 |
dpurdie |
757 |
$io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
|
| 227 |
dpurdie |
758 |
$io->Prt( "\\\n\t\t$def" ) if($def);
|
| 373 |
dpurdie |
759 |
$io->Prt( "\n\t\$(SHLD)" );
|
|
|
760 |
$io->Prt( "\n\t\$(call LDSTRIP,$shared_path,$dbg_path)\n\n" );
|
| 321 |
dpurdie |
761 |
|
| 339 |
dpurdie |
762 |
#
|
|
|
763 |
# Create soft links
|
|
|
764 |
# 'Real Name' to its 'Link Name'
|
|
|
765 |
# 'Real Name' to 'SoName' in the BINDIR (for testing I think)
|
|
|
766 |
# 'Real Name' to 'SoName' in the LIBDIR (if different)
|
|
|
767 |
#
|
| 4034 |
dpurdie |
768 |
if ( $shared ne $linkname)
|
|
|
769 |
{
|
|
|
770 |
$io->Label( "Shared library Symbolic Links", $name );
|
|
|
771 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname" );
|
|
|
772 |
$io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
|
|
|
773 |
"\t\t\$(GBE_BINDIR)\\\n" .
|
|
|
774 |
"\t\t\$(LIBDIR)/${shared}\n" .
|
|
|
775 |
"\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n\n" );
|
|
|
776 |
}
|
|
|
777 |
|
|
|
778 |
$io->Label( "Shared library BINDIR Symbolic Links", $name );
|
|
|
779 |
PackageShlibAddFiles( $name, "\$(BINDIR)/$soname" );
|
|
|
780 |
$io->Prt( "\$(BINDIR)/$soname:\t\\\n" .
|
| 339 |
dpurdie |
781 |
"\t\t\$(GBE_BINDIR)\\\n" .
|
|
|
782 |
"\t\t\$(LIBDIR)/${shared}\n" .
|
| 4034 |
dpurdie |
783 |
"\t\$(AA_PRE)(rm -f \$@; ln -s ../\$(LIBDIR)/$shared \$@)\n\n" );
|
| 339 |
dpurdie |
784 |
|
| 4034 |
dpurdie |
785 |
if ( $soname ne $shared )
|
| 339 |
dpurdie |
786 |
{
|
|
|
787 |
$io->Label( "Shared library SoName Symbolic Links", $name );
|
|
|
788 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname" );
|
|
|
789 |
$io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
|
|
|
790 |
"\t\t\$(GBE_LIBDIR)\\\n" .
|
|
|
791 |
"\t\t\$(LIBDIR)/${shared}\n" .
|
|
|
792 |
"\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n" );
|
|
|
793 |
}
|
|
|
794 |
|
| 227 |
dpurdie |
795 |
#.. Linker command file
|
|
|
796 |
#
|
|
|
797 |
# Now the fun part... piecing together a variable $(name_shld)
|
|
|
798 |
# which ends up in the command file.
|
|
|
799 |
#
|
| 339 |
dpurdie |
800 |
$io->Newline();
|
| 227 |
dpurdie |
801 |
$io->SetTag( "${name}_shld" ); # command tag
|
|
|
802 |
$io->SetTerm( "\n" );
|
|
|
803 |
|
|
|
804 |
$io->Label( "Linker commands", $name ); # label
|
|
|
805 |
|
|
|
806 |
# object list
|
|
|
807 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
|
|
|
808 |
|
|
|
809 |
ToolsetLibStd( $pLibs ); # push standard libraries
|
|
|
810 |
|
|
|
811 |
$io->Cmd( "-Wl,$def_pref$def" ) if ($def);
|
|
|
812 |
|
|
|
813 |
$io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
|
|
|
814 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
|
|
|
815 |
$io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
|
|
|
816 |
|
|
|
817 |
$io->Newline();
|
|
|
818 |
|
| 335 |
dpurdie |
819 |
#.. Dependency link,
|
|
|
820 |
# Create a library dependency file
|
|
|
821 |
# Create command file to build applicaton dependency list
|
|
|
822 |
# from the list of dependent libraries
|
|
|
823 |
#
|
|
|
824 |
# Create makefile directives to include the dependency
|
|
|
825 |
# list into the makefile.
|
|
|
826 |
#
|
|
|
827 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${shared}" );
|
| 339 |
dpurdie |
828 |
$io->SHLDDEPEND($name, $soname);
|
| 227 |
dpurdie |
829 |
}
|
|
|
830 |
|
|
|
831 |
|
|
|
832 |
###############################################################################
|
| 271 |
dpurdie |
833 |
# Function : ToolsetLD
|
| 227 |
dpurdie |
834 |
#
|
| 271 |
dpurdie |
835 |
# Description : Takes the user options and builds the rules required to
|
|
|
836 |
# link the program 'name'.
|
| 227 |
dpurdie |
837 |
#
|
| 271 |
dpurdie |
838 |
# Inputs : $name - base name of the program
|
|
|
839 |
# $pArgs - Ref to program arguments
|
|
|
840 |
# $pObjs - Ref to program objects
|
|
|
841 |
# $pLibs - Ref to program library list
|
| 227 |
dpurdie |
842 |
#
|
| 271 |
dpurdie |
843 |
# Returns : Nothing
|
| 227 |
dpurdie |
844 |
#
|
| 271 |
dpurdie |
845 |
# Output: : Rules and recipes to create a program
|
|
|
846 |
# Create program rules and recipes
|
|
|
847 |
# Create linker input script
|
|
|
848 |
# Create library dependency list
|
|
|
849 |
# Include library dependency information
|
| 227 |
dpurdie |
850 |
#
|
|
|
851 |
sub ToolsetLD
|
|
|
852 |
{
|
|
|
853 |
my( $name, $pArgs, $pObjs, $pLibs ) = @_;
|
|
|
854 |
my $static = $::ScmCompilerOpts{'STATIC_PROGS'};
|
|
|
855 |
my $multi_scan;
|
|
|
856 |
|
|
|
857 |
#.. Parse arguments
|
|
|
858 |
#
|
|
|
859 |
foreach $_ ( @$pArgs )
|
|
|
860 |
{
|
|
|
861 |
if ( m/^--Static$/ ) {
|
|
|
862 |
$static = 1;
|
|
|
863 |
|
|
|
864 |
} elsif ( m/^--Shared/ ) {
|
|
|
865 |
$static = 0;
|
|
|
866 |
|
|
|
867 |
} elsif ( /^--MultiScan/i ) {
|
|
|
868 |
$multi_scan = 1;
|
|
|
869 |
|
|
|
870 |
} elsif ( /^--NoMultiScan/i ) {
|
|
|
871 |
$multi_scan = 0;
|
|
|
872 |
|
|
|
873 |
} else {
|
|
|
874 |
Message( "LD: unknown option $_ -- ignored\n" );
|
|
|
875 |
}
|
|
|
876 |
}
|
|
|
877 |
|
| 271 |
dpurdie |
878 |
#.. Names of programs and components
|
|
|
879 |
#
|
|
|
880 |
my $base = "\$(BINDIR)/${name}";
|
|
|
881 |
my $full = $base . $::exe;
|
|
|
882 |
my $map = $base . '.map';
|
|
|
883 |
my $ld = $base . '.ld';
|
| 373 |
dpurdie |
884 |
my $dbg = $base . '.dbg';
|
| 271 |
dpurdie |
885 |
|
| 227 |
dpurdie |
886 |
#.. Cleanup rules
|
|
|
887 |
#
|
| 271 |
dpurdie |
888 |
ToolsetGenerate( $ld );
|
|
|
889 |
ToolsetGenerate( $map );
|
| 373 |
dpurdie |
890 |
ToolsetGenerate( $dbg );
|
| 227 |
dpurdie |
891 |
|
|
|
892 |
#.. Build rules
|
|
|
893 |
#
|
|
|
894 |
my ($io) = ToolsetPrinter::New();
|
| 335 |
dpurdie |
895 |
my $dep = $io->SetLdTarget( $name );
|
| 227 |
dpurdie |
896 |
|
| 271 |
dpurdie |
897 |
$io->Prt( "$full : $dep " );
|
|
|
898 |
$io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
|
| 373 |
dpurdie |
899 |
$io->Prt( "\n\t\$(LD)" );
|
|
|
900 |
$io->Prt( "\n\t\$(call LDSTRIP,$full,$dbg)\n\n" );
|
| 227 |
dpurdie |
901 |
|
| 271 |
dpurdie |
902 |
|
| 227 |
dpurdie |
903 |
#.. Linker command file
|
|
|
904 |
#
|
|
|
905 |
# Now the fun part... piecing together a variable $(name_ld)
|
|
|
906 |
# which ends up in the command file.
|
|
|
907 |
#
|
|
|
908 |
$io->SetTag( "${name}_ld" ); # macro tag
|
|
|
909 |
$io->SetTerm( "\n" );
|
|
|
910 |
|
|
|
911 |
$io->Label( "Linker commands", $name ); # label
|
|
|
912 |
|
|
|
913 |
$io->Cmd( "-static" ) if ($static); # Link as a static program
|
|
|
914 |
|
|
|
915 |
# object list
|
|
|
916 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
|
|
|
917 |
|
|
|
918 |
ToolsetLibStd( $pLibs ); # push standard libraries
|
|
|
919 |
|
|
|
920 |
# library list
|
|
|
921 |
$io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
|
|
|
922 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
|
|
|
923 |
$io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
|
|
|
924 |
|
|
|
925 |
$io->Newline();
|
|
|
926 |
|
| 335 |
dpurdie |
927 |
#.. Dependency link,
|
|
|
928 |
# Create a library dependency file
|
|
|
929 |
# Create command file to build applicaton dependency list
|
|
|
930 |
# from the list of dependent libraries
|
|
|
931 |
#
|
|
|
932 |
# Create makefile directives to include the dependency
|
|
|
933 |
# list into the makefile.
|
|
|
934 |
#
|
|
|
935 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, $base );
|
|
|
936 |
$io->LDDEPEND();
|
| 271 |
dpurdie |
937 |
|
|
|
938 |
#.. Package up the program and other artifacts
|
|
|
939 |
#
|
|
|
940 |
PackageProgAddFiles ( $name, $full );
|
| 373 |
dpurdie |
941 |
PackageProgAddFiles ( $name, $dbg );
|
| 271 |
dpurdie |
942 |
|
| 227 |
dpurdie |
943 |
}
|
|
|
944 |
|
|
|
945 |
|
| 4700 |
alewis |
946 |
###############################################################################
|
|
|
947 |
# Function : ToolsetPreprocessTests
|
|
|
948 |
#
|
|
|
949 |
# Description :
|
|
|
950 |
#
|
|
|
951 |
# Inputs : None
|
|
|
952 |
#
|
|
|
953 |
# Returns : Nothing
|
|
|
954 |
#
|
|
|
955 |
# Output: : Rules and recipes to run before unit tests
|
|
|
956 |
#
|
|
|
957 |
sub ToolsetPreprocessTests
|
|
|
958 |
{
|
|
|
959 |
my ($io) = ToolsetPrinter::New();
|
|
|
960 |
if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
|
|
|
961 |
{
|
| 4701 |
alewis |
962 |
my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
|
|
|
963 |
my $final=$finaldir . '/lcov-final.info';
|
| 4712 |
alewis |
964 |
|
|
|
965 |
ToolsetGenerate( '$(OBJDIR)/lcov-baseline.info' );
|
| 4701 |
alewis |
966 |
|
| 4700 |
alewis |
967 |
my $key;
|
|
|
968 |
my $value;
|
|
|
969 |
while(($key, $value) = each(%::OBJSOURCE))
|
|
|
970 |
{
|
|
|
971 |
$io->Prt("\t" . '$(XX_PRE)rm -f $(OBJDIR)/' . $key . ".gcda\n");
|
|
|
972 |
}
|
| 4701 |
alewis |
973 |
$io->Prt("\t" . '${XX_PRE}$(rm) -f ' . $final . "\n");
|
| 4700 |
alewis |
974 |
$io->Prt("\t" . '${XX_PRE}lcov'
|
|
|
975 |
. ' --capture'
|
|
|
976 |
. ' --initial'
|
|
|
977 |
. ' --base-directory ' . $::Cwd
|
|
|
978 |
. ' --directory $(OBJDIR)'
|
|
|
979 |
. ' --output-file $(OBJDIR)/lcov-baseline.info'
|
|
|
980 |
. "\n");
|
|
|
981 |
}
|
|
|
982 |
}
|
|
|
983 |
|
|
|
984 |
|
|
|
985 |
###############################################################################
|
|
|
986 |
# Function : ToolsetPostprocessTests
|
|
|
987 |
#
|
|
|
988 |
# Description :
|
|
|
989 |
#
|
|
|
990 |
# Inputs : None
|
|
|
991 |
#
|
|
|
992 |
# Returns : Nothing
|
|
|
993 |
#
|
|
|
994 |
# Output: : Rules and recipes to run after the unit tests
|
|
|
995 |
#
|
|
|
996 |
sub ToolsetPostprocessTests
|
|
|
997 |
{
|
|
|
998 |
my ($io) = ToolsetPrinter::New();
|
|
|
999 |
if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
|
|
|
1000 |
{
|
|
|
1001 |
my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
|
|
|
1002 |
my $final=$finaldir . '/lcov-final.info';
|
|
|
1003 |
|
| 4712 |
alewis |
1004 |
ToolsetGenerate( '$(OBJDIR)/lcov-capture.info' );
|
|
|
1005 |
ToolsetGenerate( $final );
|
|
|
1006 |
|
| 4700 |
alewis |
1007 |
$io->Prt("\t" . '$(eval GCDA_COUNT := $(shell find $(OBJDIR) -name "*.gcda"))' . "\n");
|
|
|
1008 |
|
|
|
1009 |
$io->Prt("\t" . '$(XX_PRE)$(mkdir) -p ' . $finaldir . "\n");
|
|
|
1010 |
$io->Prt("\t" . '$(XX_PRE)if [ "$(GCDA_COUNT)" = "" ]; then' . " \\\n");
|
|
|
1011 |
$io->Prt("\t\t" . 'if [ ! -e ' . $final . " ]; then \\\n");
|
|
|
1012 |
$io->Prt("\t\t\t" . '$(cp) $(OBJDIR)/lcov-baseline.info ' . $final . "; \\\n");
|
|
|
1013 |
$io->Prt("\t\t" . 'else' . " \\\n");
|
|
|
1014 |
$io->Prt("\t\t\t" . 'lcov'
|
|
|
1015 |
. ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
|
|
|
1016 |
. ' --add-tracefile ' . $final
|
|
|
1017 |
. ' --output-file $(OBJDIR)/lcov-merge.info'
|
|
|
1018 |
. "; \\\n");
|
|
|
1019 |
$io->Prt("\t\t\t" . '$(rm) -f ' . $final . "; \\\n");
|
|
|
1020 |
$io->Prt("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . "; \\\n");
|
|
|
1021 |
$io->Prt("\t\t" . 'fi' . "; \\\n");
|
|
|
1022 |
$io->Prt("\t" . 'else' . " \\\n");
|
|
|
1023 |
$io->Prt("\t\t" . 'lcov'
|
|
|
1024 |
. ' --capture'
|
|
|
1025 |
. ' --base-directory ' . $::Cwd
|
|
|
1026 |
. ' --directory $(OBJDIR)'
|
|
|
1027 |
. ' --output-file $(OBJDIR)/lcov-capture.info'
|
|
|
1028 |
. "; \\\n");
|
|
|
1029 |
$io->Prt("\t\t" . 'if [ ! -e ' . $final . " ]; then \\\n");
|
|
|
1030 |
$io->Prt("\t\t\t" . 'lcov'
|
|
|
1031 |
. ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
|
|
|
1032 |
. ' --add-tracefile $(OBJDIR)/lcov-capture.info'
|
|
|
1033 |
. ' --output-file ' . $final
|
|
|
1034 |
. "; \\\n");
|
|
|
1035 |
$io->Prt("\t\t" . 'else' . " \\\n");
|
|
|
1036 |
$io->Prt("\t\t\t" . 'lcov'
|
|
|
1037 |
. ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
|
|
|
1038 |
. ' --add-tracefile $(OBJDIR)/lcov-capture.info'
|
|
|
1039 |
. ' --add-tracefile ' . $final
|
|
|
1040 |
. ' --output-file $(OBJDIR)/lcov-merge.info'
|
|
|
1041 |
. "; \\\n");
|
|
|
1042 |
$io->Prt("\t\t\t" . '$(rm) -f ' . $final . "; \\\n");
|
|
|
1043 |
$io->Prt("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . "; \\\n");
|
|
|
1044 |
$io->Prt("\t\t" . 'fi' . "; \\\n");
|
|
|
1045 |
$io->Prt("\t" . 'fi' . " \n");
|
|
|
1046 |
}
|
|
|
1047 |
}
|
|
|
1048 |
|
|
|
1049 |
|
|
|
1050 |
|
|
|
1051 |
###############################################################################
|
|
|
1052 |
# Function : ToolsetCollateTestResults
|
|
|
1053 |
#
|
|
|
1054 |
# Description :
|
|
|
1055 |
#
|
|
|
1056 |
# Inputs : None
|
|
|
1057 |
#
|
|
|
1058 |
# Returns : Nothing
|
|
|
1059 |
#
|
|
|
1060 |
# Output: : Rules and recipes to run after unit test result
|
|
|
1061 |
# postprocessing.
|
|
|
1062 |
#
|
|
|
1063 |
sub ToolsetCollateTestResults
|
|
|
1064 |
{
|
|
|
1065 |
my ($io) = ToolsetPrinter::New();
|
|
|
1066 |
if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
|
|
|
1067 |
{
|
|
|
1068 |
my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
|
|
|
1069 |
my $final=$finaldir . '/lcov-final.info';
|
|
|
1070 |
|
|
|
1071 |
my $reportdir='$(PKGDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
|
|
|
1072 |
my $reportindex=$reportdir . '/index.html';
|
|
|
1073 |
|
|
|
1074 |
$io->Prt('collate_test_results: ' . $reportindex . "\n");
|
|
|
1075 |
$io->Prt($reportindex . ': ' . $final . "\n");
|
|
|
1076 |
$io->Prt("\t" . 'genhtml'
|
|
|
1077 |
. ' --frames'
|
|
|
1078 |
. ' --show-details'
|
|
|
1079 |
. ' --output-directory ' . $reportdir
|
|
|
1080 |
. ' --legend'
|
|
|
1081 |
. ' --demangle-cpp'
|
|
|
1082 |
. ' ' . $final
|
|
|
1083 |
. "\n");
|
|
|
1084 |
}
|
|
|
1085 |
}
|
|
|
1086 |
|
| 4701 |
alewis |
1087 |
|
|
|
1088 |
###############################################################################
|
|
|
1089 |
# ToolsetARLINT( $name, \@args, \@objs )
|
|
|
1090 |
# This subroutine takes the user options and builds the rules
|
|
|
1091 |
# required to lint the static library 'name'.
|
|
|
1092 |
#
|
|
|
1093 |
# Arguments:
|
|
|
1094 |
# --xxx No arguments currently defined
|
|
|
1095 |
#
|
|
|
1096 |
# Output:
|
|
|
1097 |
# [ $(LIBDIR)/name$_lint: .... ]
|
|
|
1098 |
# $(ARLINT)
|
|
|
1099 |
#
|
|
|
1100 |
###############################################################################
|
|
|
1101 |
|
|
|
1102 |
sub ToolsetARLINT
|
|
|
1103 |
{
|
|
|
1104 |
if ( $UseCppcheck )
|
|
|
1105 |
{
|
|
|
1106 |
CppcheckAR( @_ );
|
|
|
1107 |
}
|
|
|
1108 |
}
|
|
|
1109 |
|
|
|
1110 |
|
|
|
1111 |
###############################################################################
|
|
|
1112 |
# ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
|
|
|
1113 |
# This subroutine takes the user options and builds the rules
|
|
|
1114 |
# required to lint the shared library 'name'.
|
|
|
1115 |
#
|
|
|
1116 |
# Arguments:
|
|
|
1117 |
# (none)
|
|
|
1118 |
#
|
|
|
1119 |
# Output:
|
|
|
1120 |
# [ $(LIBDIR)/$name_lint: .... ]
|
|
|
1121 |
# $(SHLIBLINT)
|
|
|
1122 |
#
|
|
|
1123 |
###############################################################################
|
|
|
1124 |
|
|
|
1125 |
sub ToolsetSHLDLINT
|
|
|
1126 |
{
|
|
|
1127 |
if ( $UseCppcheck )
|
|
|
1128 |
{
|
|
|
1129 |
CppcheckSHLD( @_ );
|
|
|
1130 |
}
|
|
|
1131 |
}
|
|
|
1132 |
|
|
|
1133 |
|
|
|
1134 |
###############################################################################
|
|
|
1135 |
# ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
|
|
|
1136 |
# This subroutine takes the user options and builds the rules
|
|
|
1137 |
# required to lint the program 'name'.
|
|
|
1138 |
#
|
|
|
1139 |
# Arguments:
|
|
|
1140 |
# (none)
|
|
|
1141 |
#
|
|
|
1142 |
# Output:
|
|
|
1143 |
# [ $(BINDIR)/$name_lint: .... ]
|
|
|
1144 |
# $(LDLINT)
|
|
|
1145 |
#
|
|
|
1146 |
###############################################################################
|
|
|
1147 |
|
|
|
1148 |
sub ToolsetLDLINT
|
|
|
1149 |
{
|
|
|
1150 |
if ( $UseCppcheck )
|
|
|
1151 |
{
|
|
|
1152 |
CppcheckLD( @_ );
|
|
|
1153 |
}
|
|
|
1154 |
}
|
|
|
1155 |
|
| 227 |
dpurdie |
1156 |
########################################################################
|
|
|
1157 |
#
|
|
|
1158 |
# Push standard "system" libraries. This is a helper function
|
|
|
1159 |
# used within this toolset.
|
|
|
1160 |
#
|
|
|
1161 |
# Arguments:
|
|
|
1162 |
# $plib Reference to library array.
|
|
|
1163 |
#
|
|
|
1164 |
########################################################################
|
|
|
1165 |
|
|
|
1166 |
sub ToolsetLibStd
|
|
|
1167 |
{
|
|
|
1168 |
}
|
|
|
1169 |
|
|
|
1170 |
|
|
|
1171 |
########################################################################
|
|
|
1172 |
#
|
|
|
1173 |
# Generate a linker object recipe. This is a helper function used
|
|
|
1174 |
# within this toolset.
|
|
|
1175 |
#
|
|
|
1176 |
# Arguments:
|
|
|
1177 |
# $io I/O stream
|
|
|
1178 |
#
|
|
|
1179 |
# $target Name of the target
|
|
|
1180 |
#
|
|
|
1181 |
# $obj Library specification
|
|
|
1182 |
#
|
|
|
1183 |
########################################################################
|
|
|
1184 |
|
|
|
1185 |
sub ToolsetObjRecipe
|
|
|
1186 |
{
|
|
|
1187 |
my ($io, $target, $obj) = @_;
|
|
|
1188 |
|
|
|
1189 |
$io->Cmd( "\$(strip $obj).$::o" );
|
|
|
1190 |
}
|
|
|
1191 |
|
|
|
1192 |
|
|
|
1193 |
###############################################################################
|
|
|
1194 |
#
|
|
|
1195 |
# Parse a linker lib list
|
|
|
1196 |
# This is a helper function used within this toolset
|
|
|
1197 |
#
|
|
|
1198 |
# Arguments:
|
|
|
1199 |
# $target Name of the target
|
|
|
1200 |
#
|
|
|
1201 |
# $lib Library specification
|
|
|
1202 |
#
|
|
|
1203 |
# $tag Tag (user specified)
|
|
|
1204 |
#
|
|
|
1205 |
# $dp If building a depend list, the full target name.
|
|
|
1206 |
#
|
|
|
1207 |
###############################################################################
|
|
|
1208 |
|
|
|
1209 |
sub ToolsetLibRecipe
|
|
|
1210 |
{
|
|
|
1211 |
my ($io, $target, $lib, $dp) = @_;
|
|
|
1212 |
|
|
|
1213 |
if ( ! defined($dp) ) { # linker
|
|
|
1214 |
$lib =~ s/^lib//; # .. remove leading 'lib'
|
|
|
1215 |
$io->Cmd( "-l$lib" );
|
|
|
1216 |
|
|
|
1217 |
} else { # depend
|
|
|
1218 |
$io->Cmd( "$dp:\t@(vlib2,$lib,GCC_LIB)" );
|
|
|
1219 |
|
|
|
1220 |
}
|
|
|
1221 |
}
|
|
|
1222 |
|
|
|
1223 |
#.. Successful termination
|
|
|
1224 |
1;
|
|
|
1225 |
|