| 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 |
|
|
|
16 |
##############################################################################
|
|
|
17 |
# Configuration information
|
|
|
18 |
# Cross reference from CrossCompiler Alias to actual paths
|
|
|
19 |
# Structure:
|
|
|
20 |
# Hash reference: Array of toolchain information
|
| 369 |
dpurdie |
21 |
# Mandatory
|
|
|
22 |
# ROOT => Root of compiler
|
|
|
23 |
# BASE => Base for binaries
|
|
|
24 |
# Optional
|
|
|
25 |
# CC_OPTS => Additonal Compiler options
|
|
|
26 |
# UNCONTROLLED => Boolean to create warning
|
| 3965 |
dpurdie |
27 |
# PACKAGE_ARCH => Packageing architecture
|
|
|
28 |
# VERSION => Version reported by GCC
|
|
|
29 |
# MACHINE => Machine reported by GCC
|
| 369 |
dpurdie |
30 |
|
| 227 |
dpurdie |
31 |
my %ToolsetConfig = (
|
|
|
32 |
|
| 369 |
dpurdie |
33 |
'i386-unknown-linux-gnu' => {
|
|
|
34 |
ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/i586-unknown-linux-gnu',
|
|
|
35 |
BASE => 'bin/i586-unknown-linux-gnu-',
|
| 3965 |
dpurdie |
36 |
VERSION => '4.1.1',
|
|
|
37 |
MACHINE => 'i586-unknown-linux-gnu'
|
| 369 |
dpurdie |
38 |
},
|
| 227 |
dpurdie |
39 |
|
| 369 |
dpurdie |
40 |
'arm-9tdmi-linux-gnu' => {
|
|
|
41 |
ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/arm-9tdmi-linux-gnu',
|
| 3965 |
dpurdie |
42 |
BASE => 'bin/arm-9tdmi-linux-gnu-',
|
|
|
43 |
VERSION => '4.1.1',
|
|
|
44 |
MACHINE => 'arm-9tdmi-linux-gnu'
|
| 369 |
dpurdie |
45 |
},
|
| 247 |
dpurdie |
46 |
|
| 369 |
dpurdie |
47 |
'powerpc-603e-linux-gnu' => {
|
|
|
48 |
ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/powerpc-603e-linux-gnu',
|
| 3965 |
dpurdie |
49 |
BASE => 'bin/powerpc-603e-linux-gnu-',
|
|
|
50 |
VERSION => '4.1.1',
|
|
|
51 |
MACHINE => 'powerpc-603e-linux-gnu'
|
| 369 |
dpurdie |
52 |
},
|
| 337 |
dpurdie |
53 |
|
| 369 |
dpurdie |
54 |
'arm-926ejs-linux-gnueabi' => {
|
|
|
55 |
ROOT => '/opt/crosstool/gcc-4.4.3-glibc-2.9/arm-926ejs-linux-gnueabi',
|
|
|
56 |
BASE => 'bin/arm-926ejs-linux-gnueabi-',
|
|
|
57 |
CC_OPTS => '-Wno-psabi',
|
| 3965 |
dpurdie |
58 |
VERSION => '4.4.3',
|
|
|
59 |
MACHINE => 'arm-926ejs-linux-gnueabi'
|
| 369 |
dpurdie |
60 |
},
|
|
|
61 |
|
| 3965 |
dpurdie |
62 |
'i686-linux-gnu' => {
|
|
|
63 |
ROOT => '/usr',
|
|
|
64 |
BASE => 'bin/',
|
|
|
65 |
PACKAGE_ARCH => 'i386',
|
|
|
66 |
VERSION => '4.6',
|
|
|
67 |
MACHINE => 'i686-linux-gnu'
|
|
|
68 |
},
|
|
|
69 |
|
| 227 |
dpurdie |
70 |
#
|
|
|
71 |
# Old (not to be used) version of the embedded toolchain
|
|
|
72 |
# This was depricated in favor of gcc-4.1.1-glibc-2.5
|
|
|
73 |
# It is not possible to reproduce old packages using the old compiler
|
|
|
74 |
# This is a known issue
|
|
|
75 |
#
|
| 369 |
dpurdie |
76 |
'i386-unknown-linux-gnu.glibc-2.3.2' => {
|
|
|
77 |
ROOT => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/i386-unknown-linux-gnu',
|
|
|
78 |
BASE => 'bin/i386-unknown-linux-gnu-'
|
|
|
79 |
},
|
| 227 |
dpurdie |
80 |
|
| 369 |
dpurdie |
81 |
'arm-9tdmi-linux-gnu.glibc-2.3.2' => {
|
|
|
82 |
ROOT => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu',
|
|
|
83 |
BASE => 'bin/arm-9tdmi-linux-gnu-'
|
|
|
84 |
},
|
| 227 |
dpurdie |
85 |
|
|
|
86 |
#
|
|
|
87 |
# Not too sure where this is used
|
|
|
88 |
#
|
| 369 |
dpurdie |
89 |
'armv4l-unknown-linux-gcc' => {
|
|
|
90 |
ROOT => '/opt/host/armv4l',
|
|
|
91 |
BASE => 'bin/armv4l-unknown-linux-'
|
|
|
92 |
},
|
| 227 |
dpurdie |
93 |
|
|
|
94 |
#
|
|
|
95 |
# The compiler for the current local machine
|
|
|
96 |
#
|
| 369 |
dpurdie |
97 |
'i386-unknown-linux-gcc' => {
|
|
|
98 |
ROOT => '/usr',
|
|
|
99 |
BASE => 'bin/',
|
|
|
100 |
UNCONTROLLED => 1,
|
| 3965 |
dpurdie |
101 |
PACKAGE_ARCH => 'i386',
|
| 369 |
dpurdie |
102 |
},
|
|
|
103 |
);
|
| 227 |
dpurdie |
104 |
|
|
|
105 |
#
|
|
|
106 |
# Cross reference from GCCTarget to GBE_MACHTYPE for which it can
|
|
|
107 |
# build using the 'native gcc'. This is NOT the preferred mode of operation
|
|
|
108 |
# as the compiler is not as controlled as the cross compilers.
|
|
|
109 |
#
|
|
|
110 |
my %NativeCompilers = (
|
|
|
111 |
'Linux i386' => 'linux_i386',
|
|
|
112 |
);
|
|
|
113 |
|
|
|
114 |
##############################################################################
|
|
|
115 |
# ToolsetInit()
|
|
|
116 |
# Runtime initialisation
|
|
|
117 |
#
|
|
|
118 |
##############################################################################
|
|
|
119 |
|
|
|
120 |
ToolsetInit();
|
|
|
121 |
|
|
|
122 |
sub ToolsetInit
|
|
|
123 |
{
|
| 373 |
dpurdie |
124 |
my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCFlags, $GCCObjCopy );
|
| 3965 |
dpurdie |
125 |
my( $PkgArch);
|
| 227 |
dpurdie |
126 |
my( $arg_alias, $tools_found );
|
|
|
127 |
|
|
|
128 |
#.. Toolset configuration
|
|
|
129 |
#
|
|
|
130 |
$::ScmToolsetVersion = "1.0.0"; # our version
|
|
|
131 |
$::ScmToolsetGenerate = 0; # GEN generate optional
|
|
|
132 |
$::ScmToolsetCompilerPath = 1; # Exports Compiler path to makefile via SCM_COMPILERPATH
|
| 271 |
dpurdie |
133 |
$::ScmToolsetProgDependancies = 0; # handle Prog dependancies myself
|
| 339 |
dpurdie |
134 |
$::ScmToolsetSoName = 1; # Shared library supports SoName
|
| 227 |
dpurdie |
135 |
|
|
|
136 |
#.. Standard.rul requirements
|
|
|
137 |
#
|
|
|
138 |
$::s = "asm";
|
|
|
139 |
$::o = "o";
|
|
|
140 |
$::so = "so";
|
|
|
141 |
$::a = "a";
|
|
|
142 |
$::exe = "";
|
|
|
143 |
|
|
|
144 |
#.. Parse arguments
|
|
|
145 |
#
|
|
|
146 |
foreach $_ ( @::ScmToolsetArgs ) {
|
|
|
147 |
if (/^--Target=(.*)/) { # OS Version
|
|
|
148 |
$GCCTarget = "$1";
|
|
|
149 |
|
|
|
150 |
} elsif (/^--CrossAlias=(.*)/) { # CrossCompiler target-alias
|
|
|
151 |
$arg_alias = $1;
|
|
|
152 |
|
|
|
153 |
} else {
|
|
|
154 |
Message( "gcc toolset: unknown option $_ -- ignored\n" );
|
|
|
155 |
}
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
foreach $_ ( @::ScmPlatformArgs ) {
|
|
|
159 |
if (/^--product=(.*)/) { # GBE product
|
|
|
160 |
|
|
|
161 |
} else {
|
|
|
162 |
Message( "gcc toolset: unknown platform argument $_ -- ignored\n" );
|
|
|
163 |
}
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
Error ("TOOLSET/gcc - Target undefined" )
|
|
|
167 |
unless ($GCCTarget);
|
|
|
168 |
|
|
|
169 |
#.. Cross compile support
|
|
|
170 |
#
|
|
|
171 |
# Toolchain=root,[bin]
|
|
|
172 |
#
|
|
|
173 |
if ( $arg_alias )
|
|
|
174 |
{
|
|
|
175 |
if ( exists $ToolsetConfig{ $arg_alias } )
|
|
|
176 |
{
|
| 369 |
dpurdie |
177 |
$GCCToolchain = $ToolsetConfig{ $arg_alias };
|
|
|
178 |
$tools_found = (-d $GCCToolchain->{ROOT});
|
| 227 |
dpurdie |
179 |
Warning ("gcc toolset: CrossPlatform toolchain not found for: $arg_alias",
|
| 369 |
dpurdie |
180 |
"Path: $GCCToolchain->{ROOT}" ) unless $tools_found;
|
| 227 |
dpurdie |
181 |
}
|
|
|
182 |
else
|
|
|
183 |
{
|
|
|
184 |
Error("gcc toolset: CrossPlatform Alias not configured: $arg_alias");
|
|
|
185 |
}
|
| 369 |
dpurdie |
186 |
|
|
|
187 |
Warning ("Uncontrolled toolchain used: $arg_alias")
|
|
|
188 |
if ( exists($GCCToolchain->{UNCONTROLLED}) && $GCCToolchain->{UNCONTROLLED} );
|
| 227 |
dpurdie |
189 |
}
|
|
|
190 |
|
|
|
191 |
#
|
|
|
192 |
# If no Cross compiler toolchain is found (preferred method), then attempt
|
|
|
193 |
# to match a native compiler. Only known targets allow a native build
|
|
|
194 |
#
|
|
|
195 |
unless ( $tools_found )
|
|
|
196 |
{
|
|
|
197 |
if ( exists ( $NativeCompilers{$GCCTarget} ))
|
|
|
198 |
{
|
|
|
199 |
if ( $NativeCompilers{$GCCTarget} eq $::GBE_MACHTYPE )
|
|
|
200 |
{
|
|
|
201 |
$tools_found = 1;
|
| 369 |
dpurdie |
202 |
$GCCToolchain = undef;
|
| 227 |
dpurdie |
203 |
}
|
|
|
204 |
}
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
#
|
|
|
208 |
# Must have a toolset by now, either a cross compiler or Native
|
|
|
209 |
#
|
|
|
210 |
Error ("gcc toolset: Toolchain not found for: $GCCTarget" )
|
|
|
211 |
unless ( $tools_found );
|
|
|
212 |
|
|
|
213 |
|
| 369 |
dpurdie |
214 |
if ( defined $GCCToolchain )
|
| 227 |
dpurdie |
215 |
{
|
|
|
216 |
#
|
| 369 |
dpurdie |
217 |
# Parse GCCToolchain. Potential parts to create
|
|
|
218 |
# GCCRoot - Location to find the effective /usr/include directory
|
|
|
219 |
# GCCBin - Path to the gcc executable
|
|
|
220 |
# GCCAr - Path to the ar executable
|
|
|
221 |
# GCCFlags - Additional compiler flags
|
| 227 |
dpurdie |
222 |
#
|
| 369 |
dpurdie |
223 |
$GCCRoot = $GCCToolchain->{ROOT};
|
|
|
224 |
$GCCBin = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'gcc';
|
|
|
225 |
$GCCAr = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'ar';
|
| 373 |
dpurdie |
226 |
$GCCObjCopy = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'objcopy';
|
| 369 |
dpurdie |
227 |
$GCCFlags = $GCCToolchain->{CC_OPTS};
|
| 3965 |
dpurdie |
228 |
$PkgArch = $GCCToolchain->{PACKAGE_ARCH};
|
| 227 |
dpurdie |
229 |
}
|
|
|
230 |
else
|
|
|
231 |
{
|
| 373 |
dpurdie |
232 |
$GCCRoot = '/usr';
|
|
|
233 |
$GCCBin = 'gcc';
|
|
|
234 |
$GCCAr = 'ar';
|
|
|
235 |
$GCCObjCopy = 'objcopy';
|
| 227 |
dpurdie |
236 |
}
|
|
|
237 |
|
|
|
238 |
#.. Define GCC environment
|
|
|
239 |
#
|
|
|
240 |
PlatformDefine( "
|
|
|
241 |
#################################################
|
|
|
242 |
# GCC toolchain definitions
|
|
|
243 |
#
|
|
|
244 |
#..");
|
| 369 |
dpurdie |
245 |
PlatformDefine( "GCC_TARGET := $GCCTarget" );
|
|
|
246 |
PlatformDefine( "GCC_ROOT := $GCCRoot" );
|
|
|
247 |
PlatformDefine( "GCC_CC := $GCCBin" );
|
|
|
248 |
PlatformDefine( "GCC_AR := $GCCAr" );
|
| 373 |
dpurdie |
249 |
PlatformDefine( "GCC_OBJCOPY := $GCCObjCopy" );
|
| 369 |
dpurdie |
250 |
PlatformDefine( "GCC_CFLAGS := $GCCFlags" ) if defined $GCCFlags;
|
|
|
251 |
|
| 227 |
dpurdie |
252 |
#
|
|
|
253 |
# Required since this toolset advertises: ScmToolsetCompilerPath
|
|
|
254 |
#
|
| 369 |
dpurdie |
255 |
PlatformDefine( "SCM_COMPILERPATH := \$\{GCC_CC\}" );
|
| 3965 |
dpurdie |
256 |
|
|
|
257 |
#
|
|
|
258 |
# Sanity checking
|
|
|
259 |
#
|
|
|
260 |
PlatformDefine( "GCC_EVERSION := " . $GCCToolchain->{VERSION} ) if defined $GCCToolchain->{VERSION};
|
|
|
261 |
PlatformDefine( "GCC_EMACHINE := " . $GCCToolchain->{MACHINE} ) if defined $GCCToolchain->{MACHINE};
|
|
|
262 |
|
|
|
263 |
#
|
|
|
264 |
# Option indication of packaging architecture
|
|
|
265 |
# Used by non-embedded systems for packaging. See debian_packager
|
|
|
266 |
#
|
|
|
267 |
PlatformDefine( "PACKAGE_ARCH := $PkgArch" ) if (defined $PkgArch);
|
| 369 |
dpurdie |
268 |
PlatformDefine( "" );
|
| 227 |
dpurdie |
269 |
|
|
|
270 |
#.. Piece the world together
|
|
|
271 |
#
|
| 3965 |
dpurdie |
272 |
Init( 'gcc' );
|
| 227 |
dpurdie |
273 |
ToolsetDefines( "gcc.def" );
|
|
|
274 |
ToolsetRules( "gcc.rul" );
|
|
|
275 |
ToolsetRules( "standard.rul" );
|
|
|
276 |
|
|
|
277 |
# Create a standard data structure
|
|
|
278 |
# This is a hash of hashes
|
|
|
279 |
# The first hash is keyed by CompileOption keyword
|
|
|
280 |
# The second hash contains pairs of values to set or remove
|
|
|
281 |
#
|
|
|
282 |
%::ScmToolsetCompilerOptions =
|
|
|
283 |
(
|
|
|
284 |
#
|
|
|
285 |
# Control the thread model to use
|
|
|
286 |
# This will affect the compiler options and the linker options
|
|
|
287 |
#
|
|
|
288 |
'staticprogs' => { 'STATIC_PROGS' , '1' }, # Progams link staticlly
|
|
|
289 |
'no_staticprogs' => { 'STATIC_PROGS' , undef }, # Default
|
|
|
290 |
);
|
|
|
291 |
|
|
|
292 |
#
|
|
|
293 |
# Set default options
|
|
|
294 |
#
|
|
|
295 |
$::ScmCompilerOpts{'STATIC_PROGS'} = undef;
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
###############################################################################
|
|
|
300 |
# ToolsetCC( $source, $obj, \@args )
|
|
|
301 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
302 |
# required to compile the source file 'source' to 'obj'
|
|
|
303 |
#
|
|
|
304 |
###############################################################################
|
|
|
305 |
|
|
|
306 |
sub ToolsetCC
|
|
|
307 |
{
|
|
|
308 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
309 |
my( $cflags, $file ) = "";
|
|
|
310 |
|
|
|
311 |
foreach $_ ( @$pArgs ) {
|
|
|
312 |
if (/--Shared$/) { # Building a 'shared' object
|
|
|
313 |
$cflags = "$cflags \$(SHCFLAGS)";
|
|
|
314 |
} else {
|
|
|
315 |
Message( "CC: unknown option $_ -- ignored\n" );
|
|
|
316 |
}
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
MakePrint( "\n\t\$(CC)\n" );
|
|
|
320 |
if ( $cflags )
|
|
|
321 |
{ # object specific CFLAGS
|
|
|
322 |
MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
|
|
|
323 |
MakePrint( "\tCFLAGS +=$cflags\n" );
|
|
|
324 |
}
|
|
|
325 |
|
|
|
326 |
$file = StripExt( $obj ); # Metric working file
|
|
|
327 |
ToolsetGenerate( "\$(OBJDIR)/$file.met" );
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
###############################################################################
|
|
|
332 |
# ToolsetCCDepend( $depend, \@sources )
|
|
|
333 |
# This subroutine takes the user options and builds the
|
|
|
334 |
# rule(s) required to build the dependencies for the source
|
|
|
335 |
# files 'sources' to 'depend'.
|
|
|
336 |
#
|
|
|
337 |
###############################################################################
|
|
|
338 |
|
|
|
339 |
sub ToolsetCCDepend
|
|
|
340 |
{
|
|
|
341 |
MakePrint( "\t\$(CCDEPEND)\n" );
|
|
|
342 |
}
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
###############################################################################
|
|
|
346 |
# ToolsetCXX( $source, $obj, \@args )
|
|
|
347 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
348 |
# required to compile the source file 'source' to 'obj'
|
|
|
349 |
#
|
|
|
350 |
###############################################################################
|
|
|
351 |
|
|
|
352 |
sub ToolsetCXX
|
|
|
353 |
{
|
|
|
354 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
355 |
my( $cflags, $file ) = "";
|
|
|
356 |
|
|
|
357 |
foreach $_ ( @$pArgs ) {
|
|
|
358 |
if (/--Shared$/) { # Building a 'shared' object
|
|
|
359 |
$cflags = "$cflags \$(SHCXXFLAGS)";
|
|
|
360 |
} else {
|
|
|
361 |
Message( "CXX: unknown option $_ -- ignored\n" );
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
MakePrint( "\n\t\$(CXX)\n" );
|
|
|
366 |
if ( $cflags )
|
|
|
367 |
{ # object specific CFLAGS
|
|
|
368 |
MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
|
|
|
369 |
MakePrint( "\tCXXFLAGS +=$cflags\n" );
|
|
|
370 |
}
|
|
|
371 |
|
|
|
372 |
$file = StripExt( $obj ); # Metric working file
|
|
|
373 |
ToolsetGenerate( "\$(OBJDIR)/$file.met" );
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
|
|
|
377 |
###############################################################################
|
|
|
378 |
# ToolsetCXXDepend( $depend, \@sources )
|
|
|
379 |
# This subroutine takes the user options and builds the
|
|
|
380 |
# rule(s) required to build the dependencies for the source
|
|
|
381 |
# files 'sources' to 'depend'.
|
|
|
382 |
#
|
|
|
383 |
###############################################################################
|
|
|
384 |
|
|
|
385 |
sub ToolsetCXXDepend
|
|
|
386 |
{
|
| 287 |
dpurdie |
387 |
ToolsetCCDepend();
|
| 227 |
dpurdie |
388 |
}
|
|
|
389 |
|
|
|
390 |
|
|
|
391 |
###############################################################################
|
|
|
392 |
# ToolsetAS( $source, $obj, \@args )
|
|
|
393 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
394 |
# required to compile the source file 'source' to 'obj'
|
|
|
395 |
#
|
|
|
396 |
###############################################################################
|
|
|
397 |
|
|
|
398 |
sub ToolsetAS
|
|
|
399 |
{
|
|
|
400 |
MakePrint( "\n\t\$(AS)\n" );
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
sub ToolsetASDepend
|
|
|
404 |
{
|
|
|
405 |
}
|
|
|
406 |
|
|
|
407 |
|
|
|
408 |
###############################################################################
|
|
|
409 |
# ToolsetAR( $name, \@args, \@objs )
|
|
|
410 |
# This subroutine takes the user options and builds the rules
|
|
|
411 |
# required to build the library 'name'.
|
|
|
412 |
#
|
|
|
413 |
# Arguments:
|
|
|
414 |
# n/a
|
|
|
415 |
#
|
|
|
416 |
# Output:
|
|
|
417 |
# $(BINDIR)/name$.${a}: .... ]
|
|
|
418 |
# $(AR)
|
|
|
419 |
#
|
|
|
420 |
# name_ld += ... Linker command file
|
|
|
421 |
# :
|
|
|
422 |
#
|
|
|
423 |
# name_dp += ... Dependency list
|
|
|
424 |
# :
|
|
|
425 |
#
|
|
|
426 |
###############################################################################
|
|
|
427 |
|
|
|
428 |
sub ToolsetAR
|
|
|
429 |
{
|
|
|
430 |
my( $name, $pArgs, $pObjs ) = @_;
|
|
|
431 |
|
|
|
432 |
#.. Parse arguments
|
|
|
433 |
#
|
|
|
434 |
foreach $_ ( @$pArgs )
|
|
|
435 |
{
|
|
|
436 |
Message( "AR: unknown option $_ -- ignored\n" );
|
|
|
437 |
}
|
|
|
438 |
|
|
|
439 |
#.. Target
|
|
|
440 |
#
|
|
|
441 |
MakePrint( "#.. Library ($name)\n\n" ); # label
|
|
|
442 |
|
|
|
443 |
MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).$::a:\t",
|
|
|
444 |
"", "\\\n\t\t", ".$::o", @$pObjs );
|
|
|
445 |
|
|
|
446 |
#.. Build library rule (just append to standard rule)
|
|
|
447 |
#
|
|
|
448 |
MakePrint( "\n\t\$(AR)\n\n" );
|
|
|
449 |
}
|
|
|
450 |
|
|
|
451 |
|
|
|
452 |
###############################################################################
|
|
|
453 |
# ToolsetARMerge( $name, \@args, \@libs )
|
|
|
454 |
# This subroutine takes the user options and builds the rules
|
|
|
455 |
# required to build the library 'name' by merging the specified
|
|
|
456 |
# libaries
|
|
|
457 |
#
|
|
|
458 |
# Arguments:
|
|
|
459 |
# --xxx No arguments currently defined
|
|
|
460 |
#
|
|
|
461 |
# Output:
|
|
|
462 |
# [ $(LIBDIR)/name$.${a}: .... ]
|
|
|
463 |
# ...
|
|
|
464 |
#
|
|
|
465 |
###############################################################################
|
|
|
466 |
|
|
|
467 |
sub ToolsetARMerge
|
|
|
468 |
{
|
|
|
469 |
MakePrint( "\n\t\$(ARMERGE)\n\n" );
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
|
|
|
473 |
###############################################################################
|
| 289 |
dpurdie |
474 |
# ToolsetSHLD( $name, \@args, \@objs, \@libraries, $ver )
|
| 227 |
dpurdie |
475 |
# This subroutine takes the user options and builds the rules
|
| 339 |
dpurdie |
476 |
# required to link the Shared Library 'name'.
|
| 227 |
dpurdie |
477 |
#
|
|
|
478 |
# Arguments:
|
|
|
479 |
# n/a
|
|
|
480 |
#
|
|
|
481 |
# Output:
|
|
|
482 |
# $(LIBDIR)/name: $(LIBDIR)/shared
|
|
|
483 |
# ln -s $shared $name
|
|
|
484 |
#
|
|
|
485 |
# $(LIBDIR)/name.dep: $(GBE_OBJDIR)
|
|
|
486 |
# $(LIBDIR)/name.dep: $(GBE_LIBDIR)
|
|
|
487 |
# $(LIBDIR)/name.dep: $(GBE_PLATFORM).mk
|
|
|
488 |
# $(SHLDDEPEND)
|
|
|
489 |
#
|
|
|
490 |
# $(LIBDIR)/shared: SHNAME=name
|
|
|
491 |
# $(LIBDIR)/shared: SHBASE=base
|
|
|
492 |
# $(LIBDIR)/shared: $(LIBDIR)/name.dep \
|
|
|
493 |
# $(OBJECTS)
|
|
|
494 |
#
|
|
|
495 |
# ifneq "$(findstring $(IFLAG),23)" ""
|
|
|
496 |
# -include "$(LIBDIR)/name.dep"
|
|
|
497 |
# endif
|
|
|
498 |
#
|
|
|
499 |
# name_ld += ...
|
|
|
500 |
# :
|
|
|
501 |
#
|
|
|
502 |
###############################################################################
|
|
|
503 |
|
|
|
504 |
sub ToolsetSHLD
|
|
|
505 |
{
|
| 289 |
dpurdie |
506 |
my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
|
| 373 |
dpurdie |
507 |
my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
|
| 339 |
dpurdie |
508 |
my $sosuffix = '.' . $ver;
|
| 227 |
dpurdie |
509 |
|
|
|
510 |
#.. Parse arguments
|
|
|
511 |
#
|
|
|
512 |
foreach $_ ( @$pArgs )
|
|
|
513 |
{
|
|
|
514 |
if (/^--Def=(.*?)(\,(.*))?$/) { # Library definition
|
|
|
515 |
#
|
|
|
516 |
# Locate the Def file.
|
|
|
517 |
# If it is a generate file so it will be in the SRCS hash
|
|
|
518 |
# Otherwise the user will have to use Src to locate the file
|
|
|
519 |
#
|
|
|
520 |
$def = MakeSrcResolve($1);
|
|
|
521 |
$def_pref = '';
|
|
|
522 |
if ( $1 =~ m~\.def$~ ) {
|
|
|
523 |
$def_pref = '--version-script='; # Old def file
|
|
|
524 |
}
|
|
|
525 |
} elsif ( /^--MultiScan/i ) {
|
|
|
526 |
$multi_scan = 1;
|
|
|
527 |
|
|
|
528 |
} elsif ( /^--NoMultiScan/i ) {
|
|
|
529 |
$multi_scan = 0;
|
|
|
530 |
|
| 339 |
dpurdie |
531 |
} elsif ( /^--SoNameSuffix=(.*)/i ) {
|
|
|
532 |
$sosuffix = $1;
|
|
|
533 |
|
| 227 |
dpurdie |
534 |
} else {
|
|
|
535 |
Message( "SHLD: unknown option $_ -- ignored\n" );
|
|
|
536 |
}
|
|
|
537 |
}
|
|
|
538 |
|
| 339 |
dpurdie |
539 |
#.. Various library names
|
| 227 |
dpurdie |
540 |
#
|
| 339 |
dpurdie |
541 |
$linkname = "$name\$(GBE_TYPE).$::so";
|
|
|
542 |
$shared = "$linkname.$ver";
|
|
|
543 |
$soname = "$linkname$sosuffix";
|
| 373 |
dpurdie |
544 |
|
|
|
545 |
my $shared_path = "\$(LIBDIR)/${shared}";
|
|
|
546 |
my $dbg_path = $shared_path . '.dbg';
|
| 227 |
dpurdie |
547 |
|
|
|
548 |
#.. Cleanup rules
|
|
|
549 |
#
|
|
|
550 |
# map Map file
|
|
|
551 |
# ln Link from LIBDIR to BINDIR
|
|
|
552 |
#
|
| 261 |
dpurdie |
553 |
ToolsetGenerate( "\$(LIBDIR)/${name}.map" );
|
|
|
554 |
ToolsetGenerate( "\$(LIBDIR)/${shared}" );
|
| 339 |
dpurdie |
555 |
ToolsetGenerate( "\$(BINDIR)/${soname}" );
|
| 373 |
dpurdie |
556 |
ToolsetGenerate( $dbg_path );
|
| 227 |
dpurdie |
557 |
|
|
|
558 |
#.. Build rules
|
|
|
559 |
#
|
|
|
560 |
# name Base name
|
|
|
561 |
# shared Library name, includes GBE_TYPE specification
|
|
|
562 |
#
|
|
|
563 |
my ($io) = ToolsetPrinter::New();
|
| 335 |
dpurdie |
564 |
my $dep = $io->SetShldTarget($shared);
|
| 227 |
dpurdie |
565 |
|
|
|
566 |
$io->Label( "Shared library", $name );
|
| 339 |
dpurdie |
567 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
|
| 373 |
dpurdie |
568 |
PackageShlibAddFiles( $name, $dbg_path );
|
| 339 |
dpurdie |
569 |
|
| 227 |
dpurdie |
570 |
$io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
|
| 339 |
dpurdie |
571 |
$io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
|
|
|
572 |
$io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
|
| 321 |
dpurdie |
573 |
$io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
|
| 227 |
dpurdie |
574 |
$io->Prt( "\\\n\t\t$def" ) if($def);
|
| 373 |
dpurdie |
575 |
$io->Prt( "\n\t\$(SHLD)" );
|
|
|
576 |
$io->Prt( "\n\t\$(call LDSTRIP,$shared_path,$dbg_path)\n\n" );
|
| 321 |
dpurdie |
577 |
|
| 339 |
dpurdie |
578 |
#
|
|
|
579 |
# Create soft links
|
|
|
580 |
# 'Real Name' to its 'Link Name'
|
|
|
581 |
# 'Real Name' to 'SoName' in the BINDIR (for testing I think)
|
|
|
582 |
# 'Real Name' to 'SoName' in the LIBDIR (if different)
|
|
|
583 |
#
|
|
|
584 |
$io->Label( "Shared library Symbolic Links", $name );
|
|
|
585 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname" );
|
|
|
586 |
$io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
|
|
|
587 |
"\t\t\$(GBE_BINDIR)\\\n" .
|
|
|
588 |
"\t\t\$(LIBDIR)/${shared}\n" .
|
|
|
589 |
"\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n" .
|
|
|
590 |
"\t\$(AA_PRE)(rm -f \$(BINDIR)/$soname; ln -s ../\$(LIBDIR)/$shared \$(BINDIR)/$soname)\n\n" );
|
|
|
591 |
|
|
|
592 |
if ( $soname ne $shared && $soname ne $linkname)
|
|
|
593 |
{
|
|
|
594 |
$io->Label( "Shared library SoName Symbolic Links", $name );
|
|
|
595 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname" );
|
|
|
596 |
$io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
|
|
|
597 |
"\t\t\$(GBE_LIBDIR)\\\n" .
|
|
|
598 |
"\t\t\$(LIBDIR)/${shared}\n" .
|
|
|
599 |
"\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n" );
|
|
|
600 |
}
|
|
|
601 |
|
| 227 |
dpurdie |
602 |
#.. Linker command file
|
|
|
603 |
#
|
|
|
604 |
# Now the fun part... piecing together a variable $(name_shld)
|
|
|
605 |
# which ends up in the command file.
|
|
|
606 |
#
|
| 339 |
dpurdie |
607 |
$io->Newline();
|
| 227 |
dpurdie |
608 |
$io->SetTag( "${name}_shld" ); # command tag
|
|
|
609 |
$io->SetTerm( "\n" );
|
|
|
610 |
|
|
|
611 |
$io->Label( "Linker commands", $name ); # label
|
|
|
612 |
|
|
|
613 |
# object list
|
|
|
614 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
|
|
|
615 |
|
|
|
616 |
ToolsetLibStd( $pLibs ); # push standard libraries
|
|
|
617 |
|
|
|
618 |
$io->Cmd( "-Wl,$def_pref$def" ) if ($def);
|
|
|
619 |
|
|
|
620 |
$io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
|
|
|
621 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
|
|
|
622 |
$io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
|
|
|
623 |
|
|
|
624 |
$io->Newline();
|
|
|
625 |
|
| 335 |
dpurdie |
626 |
#.. Dependency link,
|
|
|
627 |
# Create a library dependency file
|
|
|
628 |
# Create command file to build applicaton dependency list
|
|
|
629 |
# from the list of dependent libraries
|
|
|
630 |
#
|
|
|
631 |
# Create makefile directives to include the dependency
|
|
|
632 |
# list into the makefile.
|
|
|
633 |
#
|
|
|
634 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${shared}" );
|
| 339 |
dpurdie |
635 |
$io->SHLDDEPEND($name, $soname);
|
| 227 |
dpurdie |
636 |
}
|
|
|
637 |
|
|
|
638 |
|
|
|
639 |
###############################################################################
|
| 271 |
dpurdie |
640 |
# Function : ToolsetLD
|
| 227 |
dpurdie |
641 |
#
|
| 271 |
dpurdie |
642 |
# Description : Takes the user options and builds the rules required to
|
|
|
643 |
# link the program 'name'.
|
| 227 |
dpurdie |
644 |
#
|
| 271 |
dpurdie |
645 |
# Inputs : $name - base name of the program
|
|
|
646 |
# $pArgs - Ref to program arguments
|
|
|
647 |
# $pObjs - Ref to program objects
|
|
|
648 |
# $pLibs - Ref to program library list
|
| 227 |
dpurdie |
649 |
#
|
| 271 |
dpurdie |
650 |
# Returns : Nothing
|
| 227 |
dpurdie |
651 |
#
|
| 271 |
dpurdie |
652 |
# Output: : Rules and recipes to create a program
|
|
|
653 |
# Create program rules and recipes
|
|
|
654 |
# Create linker input script
|
|
|
655 |
# Create library dependency list
|
|
|
656 |
# Include library dependency information
|
| 227 |
dpurdie |
657 |
#
|
|
|
658 |
sub ToolsetLD
|
|
|
659 |
{
|
|
|
660 |
my( $name, $pArgs, $pObjs, $pLibs ) = @_;
|
|
|
661 |
my $static = $::ScmCompilerOpts{'STATIC_PROGS'};
|
|
|
662 |
my $multi_scan;
|
|
|
663 |
|
|
|
664 |
#.. Parse arguments
|
|
|
665 |
#
|
|
|
666 |
foreach $_ ( @$pArgs )
|
|
|
667 |
{
|
|
|
668 |
if ( m/^--Static$/ ) {
|
|
|
669 |
$static = 1;
|
|
|
670 |
|
|
|
671 |
} elsif ( m/^--Shared/ ) {
|
|
|
672 |
$static = 0;
|
|
|
673 |
|
|
|
674 |
} elsif ( /^--MultiScan/i ) {
|
|
|
675 |
$multi_scan = 1;
|
|
|
676 |
|
|
|
677 |
} elsif ( /^--NoMultiScan/i ) {
|
|
|
678 |
$multi_scan = 0;
|
|
|
679 |
|
|
|
680 |
} else {
|
|
|
681 |
Message( "LD: unknown option $_ -- ignored\n" );
|
|
|
682 |
}
|
|
|
683 |
}
|
|
|
684 |
|
| 271 |
dpurdie |
685 |
#.. Names of programs and components
|
|
|
686 |
#
|
|
|
687 |
my $base = "\$(BINDIR)/${name}";
|
|
|
688 |
my $full = $base . $::exe;
|
|
|
689 |
my $map = $base . '.map';
|
|
|
690 |
my $ld = $base . '.ld';
|
| 373 |
dpurdie |
691 |
my $dbg = $base . '.dbg';
|
| 271 |
dpurdie |
692 |
|
| 227 |
dpurdie |
693 |
#.. Cleanup rules
|
|
|
694 |
#
|
| 271 |
dpurdie |
695 |
ToolsetGenerate( $ld );
|
|
|
696 |
ToolsetGenerate( $map );
|
| 373 |
dpurdie |
697 |
ToolsetGenerate( $dbg );
|
| 227 |
dpurdie |
698 |
|
|
|
699 |
#.. Build rules
|
|
|
700 |
#
|
|
|
701 |
my ($io) = ToolsetPrinter::New();
|
| 335 |
dpurdie |
702 |
my $dep = $io->SetLdTarget( $name );
|
| 227 |
dpurdie |
703 |
|
| 271 |
dpurdie |
704 |
$io->Prt( "$full : $dep " );
|
|
|
705 |
$io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
|
| 373 |
dpurdie |
706 |
$io->Prt( "\n\t\$(LD)" );
|
|
|
707 |
$io->Prt( "\n\t\$(call LDSTRIP,$full,$dbg)\n\n" );
|
| 227 |
dpurdie |
708 |
|
| 271 |
dpurdie |
709 |
|
| 227 |
dpurdie |
710 |
#.. Linker command file
|
|
|
711 |
#
|
|
|
712 |
# Now the fun part... piecing together a variable $(name_ld)
|
|
|
713 |
# which ends up in the command file.
|
|
|
714 |
#
|
|
|
715 |
$io->SetTag( "${name}_ld" ); # macro tag
|
|
|
716 |
$io->SetTerm( "\n" );
|
|
|
717 |
|
|
|
718 |
$io->Label( "Linker commands", $name ); # label
|
|
|
719 |
|
|
|
720 |
$io->Cmd( "-static" ) if ($static); # Link as a static program
|
|
|
721 |
|
|
|
722 |
# object list
|
|
|
723 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
|
|
|
724 |
|
|
|
725 |
ToolsetLibStd( $pLibs ); # push standard libraries
|
|
|
726 |
|
|
|
727 |
# library list
|
|
|
728 |
$io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
|
|
|
729 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
|
|
|
730 |
$io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
|
|
|
731 |
|
|
|
732 |
$io->Newline();
|
|
|
733 |
|
| 335 |
dpurdie |
734 |
#.. Dependency link,
|
|
|
735 |
# Create a library dependency file
|
|
|
736 |
# Create command file to build applicaton dependency list
|
|
|
737 |
# from the list of dependent libraries
|
|
|
738 |
#
|
|
|
739 |
# Create makefile directives to include the dependency
|
|
|
740 |
# list into the makefile.
|
|
|
741 |
#
|
|
|
742 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, $base );
|
|
|
743 |
$io->LDDEPEND();
|
| 271 |
dpurdie |
744 |
|
|
|
745 |
#.. Package up the program and other artifacts
|
|
|
746 |
#
|
|
|
747 |
PackageProgAddFiles ( $name, $full );
|
| 373 |
dpurdie |
748 |
PackageProgAddFiles ( $name, $dbg );
|
| 271 |
dpurdie |
749 |
|
| 227 |
dpurdie |
750 |
}
|
|
|
751 |
|
|
|
752 |
|
|
|
753 |
########################################################################
|
|
|
754 |
#
|
|
|
755 |
# Push standard "system" libraries. This is a helper function
|
|
|
756 |
# used within this toolset.
|
|
|
757 |
#
|
|
|
758 |
# Arguments:
|
|
|
759 |
# $plib Reference to library array.
|
|
|
760 |
#
|
|
|
761 |
########################################################################
|
|
|
762 |
|
|
|
763 |
sub ToolsetLibStd
|
|
|
764 |
{
|
|
|
765 |
}
|
|
|
766 |
|
|
|
767 |
|
|
|
768 |
########################################################################
|
|
|
769 |
#
|
|
|
770 |
# Generate a linker object recipe. This is a helper function used
|
|
|
771 |
# within this toolset.
|
|
|
772 |
#
|
|
|
773 |
# Arguments:
|
|
|
774 |
# $io I/O stream
|
|
|
775 |
#
|
|
|
776 |
# $target Name of the target
|
|
|
777 |
#
|
|
|
778 |
# $obj Library specification
|
|
|
779 |
#
|
|
|
780 |
########################################################################
|
|
|
781 |
|
|
|
782 |
sub ToolsetObjRecipe
|
|
|
783 |
{
|
|
|
784 |
my ($io, $target, $obj) = @_;
|
|
|
785 |
|
|
|
786 |
$io->Cmd( "\$(strip $obj).$::o" );
|
|
|
787 |
}
|
|
|
788 |
|
|
|
789 |
|
|
|
790 |
###############################################################################
|
|
|
791 |
#
|
|
|
792 |
# Parse a linker lib list
|
|
|
793 |
# This is a helper function used within this toolset
|
|
|
794 |
#
|
|
|
795 |
# Arguments:
|
|
|
796 |
# $target Name of the target
|
|
|
797 |
#
|
|
|
798 |
# $lib Library specification
|
|
|
799 |
#
|
|
|
800 |
# $tag Tag (user specified)
|
|
|
801 |
#
|
|
|
802 |
# $dp If building a depend list, the full target name.
|
|
|
803 |
#
|
|
|
804 |
###############################################################################
|
|
|
805 |
|
|
|
806 |
sub ToolsetLibRecipe
|
|
|
807 |
{
|
|
|
808 |
my ($io, $target, $lib, $dp) = @_;
|
|
|
809 |
|
|
|
810 |
if ( ! defined($dp) ) { # linker
|
|
|
811 |
$lib =~ s/^lib//; # .. remove leading 'lib'
|
|
|
812 |
$io->Cmd( "-l$lib" );
|
|
|
813 |
|
|
|
814 |
} else { # depend
|
|
|
815 |
$io->Cmd( "$dp:\t@(vlib2,$lib,GCC_LIB)" );
|
|
|
816 |
|
|
|
817 |
}
|
|
|
818 |
}
|
|
|
819 |
|
|
|
820 |
#.. Successful termination
|
|
|
821 |
1;
|
|
|
822 |
|