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