| 227 |
dpurdie |
1 |
# -*- mode: perl; indent-width: 4; show-tabs: yes; -*-
|
|
|
2 |
#
|
|
|
3 |
# Module name : Sunworks
|
|
|
4 |
# Module type : Makefile system
|
|
|
5 |
# Compiler(s) : ANSI C
|
|
|
6 |
# Environment(s): CC
|
|
|
7 |
#
|
|
|
8 |
# Description:
|
|
|
9 |
# Sunworks C/C++ toolset
|
|
|
10 |
#
|
|
|
11 |
#.............................................................................
|
|
|
12 |
|
|
|
13 |
use strict;
|
|
|
14 |
use warnings;
|
|
|
15 |
use JatsError;
|
|
|
16 |
|
|
|
17 |
#
|
|
|
18 |
# Table to provide the location of SUNWSPRO_SC
|
|
|
19 |
# This is hardcoded ( not good ) based on build machine
|
|
|
20 |
#
|
| 313 |
dpurdie |
21 |
# Key: StudioIdentifier
|
|
|
22 |
# SunWorkshop6.1 - Solaris8 32 bit builds
|
|
|
23 |
# SunStudio11 - Solaris10 32 bit builds
|
|
|
24 |
# SunStudio12.1 - Solaris10 64 bit builds
|
| 227 |
dpurdie |
25 |
# Key: build machine type
|
|
|
26 |
# Value: Per machine-type data
|
|
|
27 |
#
|
|
|
28 |
# Per machine type data is a hash
|
| 313 |
dpurdie |
29 |
# archiver - Path to archiver
|
| 227 |
dpurdie |
30 |
# compiler - Path to the compiler
|
| 313 |
dpurdie |
31 |
# misalign{32|64} - Path (relative to compiler) to the misalign obj file
|
| 227 |
dpurdie |
32 |
# If not present then misalign not supported
|
|
|
33 |
#
|
| 313 |
dpurdie |
34 |
my $SunProData;
|
|
|
35 |
my $SunMisalignObject;
|
| 227 |
dpurdie |
36 |
my %SunProLocation = (
|
| 313 |
dpurdie |
37 |
'solaris10_sparc32' => { 'SunStudio11' =>
|
|
|
38 |
{ 'compiler' => '/opt/SUNWspro',
|
|
|
39 |
'misalign32' => 'prod/lib/misalign.o',
|
|
|
40 |
'misalign64' => 'prod/lib/v9/misalign.o',
|
|
|
41 |
'archiver' => '/usr/ccs/bin',
|
|
|
42 |
},
|
|
|
43 |
'SunStudio12.1' =>
|
|
|
44 |
{ 'compiler' => '/opt/sunstudio12.1',
|
|
|
45 |
'misalign32' => 'prod/lib/misalign.o', # This one is OK.
|
|
|
46 |
'misalign64' => 'prod/lib/v9/misalign.o', # May cause link errors as the .o file is not PIC
|
|
|
47 |
'archiver' => '/usr/ccs/bin',
|
|
|
48 |
},
|
|
|
49 |
},
|
| 227 |
dpurdie |
50 |
|
| 313 |
dpurdie |
51 |
'solaris10_x86' => { 'SunStudio11' =>
|
|
|
52 |
{ 'compiler' => '/opt/SUNWspro',
|
|
|
53 |
'archiver' => '/usr/ccs/bin',
|
|
|
54 |
},
|
|
|
55 |
'SunStudio12.1' =>
|
|
|
56 |
{ 'compiler' => '/opt/sunstudio12.1',
|
|
|
57 |
'archiver' => '/usr/ccs/bin',
|
|
|
58 |
},
|
|
|
59 |
},
|
| 227 |
dpurdie |
60 |
|
| 313 |
dpurdie |
61 |
'sparc' => { 'SunWorkshop6.1' =>
|
|
|
62 |
{ 'compiler' => '/opt/SUNWspro/WS6U1',
|
|
|
63 |
'misalign32' => 'lib/misalign.o',
|
|
|
64 |
'archiver' => '/usr/ccs/bin',
|
|
|
65 |
},
|
|
|
66 |
}
|
| 227 |
dpurdie |
67 |
);
|
|
|
68 |
|
|
|
69 |
#
|
|
|
70 |
# Globals
|
|
|
71 |
#
|
|
|
72 |
our $GBE_MACHTYPE;
|
|
|
73 |
our $s;
|
|
|
74 |
our $o;
|
|
|
75 |
our $a;
|
|
|
76 |
our $so;
|
|
|
77 |
our $exe;
|
|
|
78 |
our @ScmToolsetArgs;
|
|
|
79 |
our @ScmPlatformArgs;
|
|
|
80 |
|
|
|
81 |
##############################################################################
|
|
|
82 |
# ToolsetInit()
|
|
|
83 |
# Runtime initialisation
|
|
|
84 |
#
|
|
|
85 |
##############################################################################
|
|
|
86 |
|
|
|
87 |
ToolsetInit();
|
|
|
88 |
|
|
|
89 |
my $toolsetccdepend = 0;
|
|
|
90 |
|
|
|
91 |
sub ToolsetInit
|
|
|
92 |
{
|
|
|
93 |
#.. Standard.rul requirements
|
|
|
94 |
#
|
|
|
95 |
$s = 'asm';
|
|
|
96 |
$o = 'o';
|
|
|
97 |
$a = 'a';
|
|
|
98 |
$so = 'so';
|
|
|
99 |
$exe = '';
|
|
|
100 |
|
|
|
101 |
#.. Toolset configuration
|
|
|
102 |
#
|
| 315 |
dpurdie |
103 |
$::ScmToolsetVersion = "1.0.0"; # our version
|
|
|
104 |
$::ScmToolsetGenerate = 0; # GEN generate optional
|
|
|
105 |
$::ScmToolsetProgDependancies = 0; # handle Prog dependancies myself
|
| 339 |
dpurdie |
106 |
$::ScmToolsetSoName = 1; # Shared library supports SoName
|
| 3559 |
dpurdie |
107 |
$::ScmToolsetCompilerPath = 1; # Exports Compiler path to makefile via SCM_COMPILERPATH
|
|
|
108 |
|
| 227 |
dpurdie |
109 |
|
|
|
110 |
my $ScmToolTarget = '';
|
| 313 |
dpurdie |
111 |
my $ScmStudio = '';
|
| 227 |
dpurdie |
112 |
|
|
|
113 |
#
|
|
|
114 |
# Toolset args
|
|
|
115 |
#
|
|
|
116 |
foreach $_ ( @ScmToolsetArgs ) {
|
|
|
117 |
if (/^--Target=(.*)/) { # Target System
|
|
|
118 |
$ScmToolTarget = $1;
|
|
|
119 |
|
| 313 |
dpurdie |
120 |
} elsif ( /^--Studio=(.*)/) {
|
|
|
121 |
$ScmStudio = $1;
|
|
|
122 |
|
| 227 |
dpurdie |
123 |
} else {
|
|
|
124 |
Message( "sunworks toolset: unknown toolset option $_ -- ignored" );
|
|
|
125 |
}
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
#
|
|
|
129 |
# Platform arguments
|
|
|
130 |
#
|
|
|
131 |
foreach $_ ( @ScmPlatformArgs ) {
|
|
|
132 |
if (/^--product=(.*)/) { # GBE product
|
|
|
133 |
|
|
|
134 |
} else {
|
|
|
135 |
Message( "sunworks toolset: unknown platform argument $_ -- ignored" );
|
|
|
136 |
}
|
| 313 |
dpurdie |
137 |
}
|
| 227 |
dpurdie |
138 |
|
| 313 |
dpurdie |
139 |
#
|
|
|
140 |
# Sanity check
|
|
|
141 |
#
|
|
|
142 |
Error ("Internal: Target configuration must specify Studio version")
|
|
|
143 |
unless ( $ScmStudio );
|
|
|
144 |
|
|
|
145 |
Error ("SunWorks compiler not configured for this type of machine",
|
|
|
146 |
"GBE_MACHTYPE: $GBE_MACHTYPE" )
|
|
|
147 |
unless ( exists $SunProLocation{$GBE_MACHTYPE} );
|
|
|
148 |
|
|
|
149 |
Error ("Required SunWorks/Studio not configured for this type of machine",
|
|
|
150 |
"GBE_MACHTYPE: $GBE_MACHTYPE",
|
|
|
151 |
"Sun Studio : $ScmStudio" )
|
|
|
152 |
unless ( exists $SunProLocation{$GBE_MACHTYPE}{$ScmStudio} );
|
|
|
153 |
|
|
|
154 |
#
|
|
|
155 |
# Determine machine / Studio version specific data
|
|
|
156 |
#
|
|
|
157 |
$SunProData = $SunProLocation{$GBE_MACHTYPE}{$ScmStudio};
|
|
|
158 |
|
| 227 |
dpurdie |
159 |
#.. Define environment
|
|
|
160 |
#
|
|
|
161 |
Init( "sunworks" );
|
|
|
162 |
ToolsetDefines( "sunworks.def" );
|
| 313 |
dpurdie |
163 |
ToolsetRules ( "sunworks.rul" );
|
|
|
164 |
ToolsetRules ( "standard.rul" );
|
| 227 |
dpurdie |
165 |
|
|
|
166 |
#.. Cleanup rules
|
|
|
167 |
#
|
|
|
168 |
ToolsetDirTree( "\$(LIBDIR)/SunWS_cache" );
|
|
|
169 |
ToolsetDirTree( "\$(OBJDIR)/SunWS_cache" );
|
|
|
170 |
ToolsetDirTree( "\$(BINDIR)/SunWS_cache" );
|
|
|
171 |
ToolsetDirTree( "./SunWS_cache" );
|
|
|
172 |
|
|
|
173 |
AddLibDir( '*', '/usr/lib', '--NoWarn', '--System' );
|
|
|
174 |
|
|
|
175 |
#.. Extend the CompilerOption directive
|
|
|
176 |
# Create a standard data structure
|
|
|
177 |
# This is a hash of hashes
|
|
|
178 |
# The first hash is keyed by CompileOption keyword
|
|
|
179 |
# The second hash contains pairs of values to set or remove
|
|
|
180 |
#
|
|
|
181 |
%::ScmToolsetCompilerOptions =
|
|
|
182 |
(
|
|
|
183 |
#
|
|
|
184 |
# Control the thread model to use
|
|
|
185 |
# This will affect the compiler options and the linker options
|
|
|
186 |
#
|
|
|
187 |
'multithread' => { 'THREADMODE' , '1' }, # -mt (default)
|
|
|
188 |
'multithread_none' => { 'THREADMODE' , undef }, # (none)
|
|
|
189 |
'no_multithread' => { 'THREADMODE' , undef }, # (none)
|
|
|
190 |
|
|
|
191 |
'no_misalign' => { 'MISALIGN', undef }, # (default)
|
|
|
192 |
'misalign' => { 'MISALIGN', '1' },
|
|
|
193 |
);
|
|
|
194 |
|
|
|
195 |
#
|
|
|
196 |
# Set default options
|
|
|
197 |
#
|
|
|
198 |
$::ScmCompilerOpts{'THREADMODE'} = '1';
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
#
|
| 245 |
dpurdie |
202 |
# Ensure that we know where the compiler and archiver are
|
| 227 |
dpurdie |
203 |
#
|
| 313 |
dpurdie |
204 |
my $sunpro = $SunProData->{compiler};
|
|
|
205 |
ToolsetDefine ( "SUNWSPRO_SC = $sunpro" );
|
|
|
206 |
|
|
|
207 |
my $ar_path = $SunProData->{archiver};
|
|
|
208 |
ToolsetDefine ( "AR_PATH = $ar_path" );
|
|
|
209 |
|
|
|
210 |
#
|
|
|
211 |
# Specify definitions to support 32 and 64 bit compilation
|
|
|
212 |
# Default operation is only intended for existing (solaris8) work
|
|
|
213 |
#
|
|
|
214 |
if ( ($ScmToolTarget =~ m/32$/) )
|
| 227 |
dpurdie |
215 |
{
|
| 313 |
dpurdie |
216 |
ToolsetDefine ( "COMPILE32 = 1" );
|
|
|
217 |
$SunMisalignObject = $SunProData->{'misalign32'};
|
| 227 |
dpurdie |
218 |
}
|
| 313 |
dpurdie |
219 |
elsif ( ($ScmToolTarget =~ m/64$/) )
|
|
|
220 |
{
|
|
|
221 |
ToolsetDefine ( "COMPILE64 = 1" );
|
|
|
222 |
$SunMisalignObject = $SunProData->{'misalign64'};
|
|
|
223 |
}
|
| 227 |
dpurdie |
224 |
else
|
|
|
225 |
{
|
| 313 |
dpurdie |
226 |
$SunMisalignObject = $SunProData->{'misalign32'};
|
| 227 |
dpurdie |
227 |
}
|
|
|
228 |
|
|
|
229 |
#
|
| 313 |
dpurdie |
230 |
# Allow SPARC and X86 compilation options to differ
|
| 227 |
dpurdie |
231 |
#
|
| 313 |
dpurdie |
232 |
my $isa_sparc = ( $GBE_MACHTYPE =~ m/sparc/i ) ? 1 : 0;
|
|
|
233 |
ToolsetDefine ( "ISA_SPARC = 1" ) if ($isa_sparc);
|
| 3559 |
dpurdie |
234 |
|
|
|
235 |
# Required since this toolset advertises: ScmToolsetCompilerPath
|
|
|
236 |
# Used by shell builder
|
|
|
237 |
#
|
|
|
238 |
PlatformDefine( "SCM_COMPILERPATH := \$\{SUNWSPRO_SC\}/bin/cc" );
|
|
|
239 |
PlatformDefine( "" );
|
|
|
240 |
|
| 227 |
dpurdie |
241 |
}
|
|
|
242 |
|
|
|
243 |
##############################################################################
|
|
|
244 |
# ToolsetPreprocess()
|
|
|
245 |
# Process collected data before the makefile is generated
|
|
|
246 |
# This, optional, routine is called from within MakefileGenerate()
|
|
|
247 |
# It allows the toolset to massage any of the collected data before
|
|
|
248 |
# the makefile is created
|
|
|
249 |
#
|
|
|
250 |
##############################################################################
|
|
|
251 |
|
|
|
252 |
sub ToolsetPreprocess
|
|
|
253 |
{
|
|
|
254 |
#
|
|
|
255 |
# If the machine does not support misalignment and the user has requested
|
|
|
256 |
# it, then kill the option - it makes life easier later.
|
|
|
257 |
#
|
| 313 |
dpurdie |
258 |
unless ( $SunMisalignObject )
|
| 227 |
dpurdie |
259 |
{
|
|
|
260 |
if ( $::ScmCompilerOpts{'MISALIGN'} )
|
|
|
261 |
{
|
|
|
262 |
Warning("Platform does not support MISALIGN option. Will be ignored");
|
|
|
263 |
delete $::ScmCompilerOpts{'MISALIGN'};
|
|
|
264 |
}
|
|
|
265 |
}
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
###############################################################################
|
|
|
269 |
# ToolsetCC( $source, $obj, \@args )
|
|
|
270 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
271 |
# required to compile the source file 'source' to 'obj'
|
|
|
272 |
#
|
|
|
273 |
###############################################################################
|
|
|
274 |
|
|
|
275 |
sub ToolsetCC
|
|
|
276 |
{
|
|
|
277 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
278 |
my( $cflags ) = "";
|
|
|
279 |
|
|
|
280 |
Debug( "CC: $source -> $obj" );
|
|
|
281 |
foreach ( @$pArgs ) {
|
|
|
282 |
Debug( "option: $_" );
|
|
|
283 |
if ( /--Shared$/ ) { # Building a 'shared' object
|
|
|
284 |
$cflags = "$cflags \$(SHCFLAGS)";
|
|
|
285 |
Debug( "CC: as shared object" );
|
|
|
286 |
|
|
|
287 |
} else { # unknown option
|
|
|
288 |
Message( "CC: unknown option $_ -- ignored\n" );
|
|
|
289 |
}
|
|
|
290 |
}
|
|
|
291 |
|
|
|
292 |
MakePrint( "\n\t\$(CC)\n" );
|
|
|
293 |
if ( $cflags )
|
|
|
294 |
{ # object specific CFLAGS
|
|
|
295 |
MakePadded( 4, "\$(OBJDIR)/$obj.${o}:" );
|
|
|
296 |
MakePrint( "\tCFLAGS +=$cflags\n" );
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
###############################################################################
|
|
|
302 |
# ToolsetCCDepend( $depend, \@sources )
|
|
|
303 |
# This subroutine takes the user options and builds the
|
|
|
304 |
# rule(s) required to build the dependencies for the source
|
|
|
305 |
# files 'sources' to 'depend'.
|
|
|
306 |
#
|
|
|
307 |
###############################################################################
|
|
|
308 |
|
|
|
309 |
sub ToolsetCCDepend
|
|
|
310 |
{
|
|
|
311 |
MakePrint( "\t\$(CCDEPEND)\n" );
|
|
|
312 |
$toolsetccdepend = 1;
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
###############################################################################
|
|
|
317 |
# ToolsetCXX( $source, $obj, \@args )
|
|
|
318 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
319 |
# required to compile the source file 'source' to 'obj'
|
|
|
320 |
#
|
|
|
321 |
###############################################################################
|
|
|
322 |
|
|
|
323 |
sub ToolsetCXX
|
|
|
324 |
{
|
|
|
325 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
326 |
my( $cflags ) = "";
|
|
|
327 |
|
|
|
328 |
Debug( "CCX: $source -> $obj" );
|
|
|
329 |
foreach ( @$pArgs ) {
|
|
|
330 |
Debug( "option: $_" );
|
|
|
331 |
if ( /--Shared$/ ) { # Building a 'shared' object
|
|
|
332 |
$cflags = "$cflags \$(SHCXXFLAGS)";
|
|
|
333 |
Debug( "CCX: as shared object" );
|
|
|
334 |
|
|
|
335 |
} else {
|
|
|
336 |
Message( "CCX: unknown option $_ -- ignored\n" );
|
|
|
337 |
}
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
MakePrint( "\n\t\$(CXX)\n" );
|
|
|
341 |
if ( $cflags )
|
|
|
342 |
{ # object specific CFLAGS
|
|
|
343 |
MakePadded( 4, "\$(OBJDIR)/$obj.${o}:" );
|
|
|
344 |
MakePrint( "\tCXXFLAGS +=$cflags\n" );
|
|
|
345 |
}
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
|
|
|
349 |
###############################################################################
|
|
|
350 |
# ToolsetCXXDepend( $depend, \@sources )
|
|
|
351 |
# This subroutine takes the user options and builds the
|
|
|
352 |
# rule(s) required to build the dependencies for the source
|
|
|
353 |
# files 'sources' to 'depend'.
|
|
|
354 |
#
|
|
|
355 |
###############################################################################
|
|
|
356 |
|
|
|
357 |
sub ToolsetCXXDepend
|
|
|
358 |
{
|
|
|
359 |
MakePrint( "\t\$(CCDEPEND)\n" )
|
|
|
360 |
if ( $toolsetccdepend == 0 );
|
|
|
361 |
}
|
|
|
362 |
|
|
|
363 |
|
|
|
364 |
###############################################################################
|
|
|
365 |
# ToolsetAS( $source, $obj, \@args )
|
|
|
366 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
367 |
# required to compile the source file 'source' to 'obj'
|
|
|
368 |
#
|
|
|
369 |
###############################################################################
|
|
|
370 |
|
|
|
371 |
sub ToolsetAS
|
|
|
372 |
{
|
|
|
373 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
374 |
|
|
|
375 |
foreach $_ ( @$pArgs ) {
|
|
|
376 |
Message( "CC: unknown option $_ -- ignored\n" );
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
MakePrint( "\n\t\$(AS)\n" );
|
|
|
380 |
}
|
|
|
381 |
|
|
|
382 |
sub ToolsetASDepend
|
|
|
383 |
{
|
|
|
384 |
}
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
###############################################################################
|
|
|
388 |
# ToolsetAR( $name, \@args, \@objs )
|
|
|
389 |
# This subroutine takes the user options and builds the rules
|
|
|
390 |
# required to build the library 'name'.
|
|
|
391 |
#
|
|
|
392 |
# Arguments:
|
|
|
393 |
#
|
|
|
394 |
# Options:
|
|
|
395 |
# n/a
|
|
|
396 |
#
|
|
|
397 |
# Output:
|
|
|
398 |
# [ $(LIBDIR)/name$.${a}: .... ]
|
|
|
399 |
# $(AR)
|
|
|
400 |
#
|
|
|
401 |
###############################################################################
|
|
|
402 |
|
|
|
403 |
sub ToolsetAR
|
|
|
404 |
{
|
|
|
405 |
my( $name, $pArgs, $pObjs ) = @_;
|
|
|
406 |
|
|
|
407 |
#.. Parse arguments
|
|
|
408 |
#
|
|
|
409 |
foreach $_ ( @$pArgs ) {
|
|
|
410 |
Message( "AR: unknown option $_ -- ignored\n" );
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
#.. Standard library builds
|
|
|
414 |
#
|
|
|
415 |
MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).${a}:\t",
|
|
|
416 |
"", "\\\n\t\t", ".${o} ", @$pObjs );
|
|
|
417 |
MakePrint( "\n\t\$(AR)\n\n" );
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
###############################################################################
|
|
|
422 |
# ToolsetARMerge( $name, \@args, \@libs )
|
|
|
423 |
# This subroutine takes the user options and builds the rules
|
|
|
424 |
# required to build the library 'name' by merging the specified
|
|
|
425 |
# libaries
|
|
|
426 |
#
|
|
|
427 |
# Arguments:
|
|
|
428 |
# --xxx No arguments currently defined
|
|
|
429 |
#
|
|
|
430 |
# Output:
|
|
|
431 |
# [ $(LIBDIR)/name$.${a}: .... ]
|
|
|
432 |
# ...
|
|
|
433 |
#
|
|
|
434 |
###############################################################################
|
|
|
435 |
|
|
|
436 |
sub ToolsetARMerge
|
|
|
437 |
{
|
|
|
438 |
MakePrint( "\n\t\$(ARMERGE)\n\n" );
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
|
|
|
442 |
###############################################################################
|
| 289 |
dpurdie |
443 |
# ToolsetSHLD( $name, \@args, \@objs, \@libraries, $ver )
|
| 227 |
dpurdie |
444 |
# This subroutine takes the user options and builds the rules
|
|
|
445 |
# required to link the program 'name'.
|
|
|
446 |
#
|
|
|
447 |
# Arguments:
|
|
|
448 |
# --WithMisalign
|
|
|
449 |
#
|
|
|
450 |
# Output:
|
|
|
451 |
# $(LIBDIR)/name: $(LIBDIR)/shared
|
|
|
452 |
# ln -s $shared $name
|
|
|
453 |
#
|
|
|
454 |
# $(LIBDIR)/name.dep: $(GBE_PLATFORM).mk
|
|
|
455 |
# $(SHLDDEPEND)
|
|
|
456 |
#
|
|
|
457 |
# $(LIBDIR)/shared: SHLIB=name
|
|
|
458 |
# $(LIBDIR)/shared: $(LIBDIR)/name.dep \
|
|
|
459 |
# $(OBJECTS)
|
|
|
460 |
#
|
|
|
461 |
# ifneq "$(findstring $(IFLAG),23)" ""
|
|
|
462 |
# -include "$(LIBDIR)/name.dep"
|
|
|
463 |
# endif
|
|
|
464 |
#
|
|
|
465 |
# name_ld += ...
|
|
|
466 |
# :
|
|
|
467 |
#
|
|
|
468 |
###############################################################################
|
|
|
469 |
|
|
|
470 |
sub ToolsetSHLD
|
|
|
471 |
{
|
| 289 |
dpurdie |
472 |
my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
|
| 339 |
dpurdie |
473 |
my( $linkname, $soname ,$shared, $merge_obj );
|
|
|
474 |
my $sosuffix = '';
|
| 227 |
dpurdie |
475 |
|
|
|
476 |
#.. Parse arguments
|
|
|
477 |
#
|
|
|
478 |
foreach $_ ( @$pArgs )
|
|
|
479 |
{
|
|
|
480 |
if ( m~^--WithMisalign~ ) {
|
| 313 |
dpurdie |
481 |
$merge_obj = $SunMisalignObject;
|
| 227 |
dpurdie |
482 |
|
| 339 |
dpurdie |
483 |
} elsif ( /^--SoNameSuffix=(.*)/i ) {
|
|
|
484 |
$sosuffix = $1;
|
|
|
485 |
|
| 227 |
dpurdie |
486 |
} else {
|
|
|
487 |
Message( "SHLD: unknown option $_ -- ignored\n" );
|
|
|
488 |
}
|
|
|
489 |
}
|
|
|
490 |
|
| 339 |
dpurdie |
491 |
#.. Various library names
|
| 227 |
dpurdie |
492 |
#
|
| 339 |
dpurdie |
493 |
$linkname = "$name\$(GBE_TYPE).$::so";
|
|
|
494 |
$shared = "$linkname.$ver";
|
|
|
495 |
$soname = "$linkname$sosuffix";
|
| 227 |
dpurdie |
496 |
|
|
|
497 |
#.. Cleanup rules
|
|
|
498 |
#
|
|
|
499 |
# map Map file
|
|
|
500 |
# ln Link from LIBDIR to BINDIR
|
|
|
501 |
#
|
| 261 |
dpurdie |
502 |
ToolsetGenerate( "\$(LIBDIR)/${shared}.map" );
|
|
|
503 |
ToolsetGenerate( "\$(LIBDIR)/${shared}" );
|
| 339 |
dpurdie |
504 |
ToolsetGenerate( "\$(BINDIR)/${soname}" );
|
| 227 |
dpurdie |
505 |
ToolsetDirTree( "\$(LIBDIR)/${name}/SunWS_cache" );
|
|
|
506 |
ToolsetDirTree( "\$(OBJDIR)/${name}/SunWS_cache" );
|
|
|
507 |
|
|
|
508 |
#.. Build rules
|
|
|
509 |
#
|
|
|
510 |
# name Base name
|
|
|
511 |
# shared Library name, includes GBE_TYPE specification
|
|
|
512 |
#
|
|
|
513 |
my ($io) = ToolsetPrinter::New();
|
| 339 |
dpurdie |
514 |
my $dep = $io->SetShldTarget($shared);
|
| 227 |
dpurdie |
515 |
|
|
|
516 |
$io->Label( "Shared library", $name );
|
| 339 |
dpurdie |
517 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
|
|
|
518 |
|
| 227 |
dpurdie |
519 |
$io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
|
| 339 |
dpurdie |
520 |
$io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
|
| 335 |
dpurdie |
521 |
$io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
|
| 315 |
dpurdie |
522 |
$io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
|
|
|
523 |
$io->Prt( "\n\t\$(SHLD)\n\n" );
|
| 339 |
dpurdie |
524 |
|
| 227 |
dpurdie |
525 |
|
| 339 |
dpurdie |
526 |
#
|
|
|
527 |
# Create soft links
|
|
|
528 |
# 'Real Name' to its 'Link Name'
|
|
|
529 |
# 'Real Name' to 'SoName' in the BINDIR (for testing I think)
|
|
|
530 |
# 'Real Name' to 'SoName' in the LIBDIR (if different)
|
|
|
531 |
#
|
|
|
532 |
$io->Label( "Shared library Symbolic Links", $name );
|
| 5882 |
dpurdie |
533 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname", 'symlink=1' );
|
| 339 |
dpurdie |
534 |
$io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
|
|
|
535 |
"\t\t\$(GBE_BINDIR)\\\n" .
|
|
|
536 |
"\t\t\$(LIBDIR)/${shared}\n" .
|
| 5882 |
dpurdie |
537 |
"\t\$(AA_PRE)(rm -f \$@; ln -s $shared \$@)\n" .
|
| 339 |
dpurdie |
538 |
"\t\$(AA_PRE)(rm -f \$(BINDIR)/$soname; ln -s ../\$(LIBDIR)/$shared \$(BINDIR)/$soname)\n\n" );
|
| 227 |
dpurdie |
539 |
|
| 339 |
dpurdie |
540 |
if ( $soname ne $shared && $soname ne $linkname)
|
|
|
541 |
{
|
|
|
542 |
$io->Label( "Shared library SoName Symbolic Links", $name );
|
| 5882 |
dpurdie |
543 |
PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname", 'symlink=1' );
|
| 339 |
dpurdie |
544 |
$io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
|
|
|
545 |
"\t\t\$(GBE_LIBDIR)\\\n" .
|
|
|
546 |
"\t\t\$(LIBDIR)/${shared}\n" .
|
| 5882 |
dpurdie |
547 |
"\t\$(AA_PRE)(rm -f \$@; ln -s $shared \$@)\n" );
|
| 339 |
dpurdie |
548 |
}
|
|
|
549 |
|
| 227 |
dpurdie |
550 |
#.. Linker command file
|
|
|
551 |
#
|
|
|
552 |
# Now the fun part... piecing together a variable $(name_shld)
|
|
|
553 |
# which ends up in the command file.
|
|
|
554 |
#
|
| 339 |
dpurdie |
555 |
$io->Newline();
|
|
|
556 |
$io->SetTag( "${name}_shld" ); # command tag
|
| 227 |
dpurdie |
557 |
$io->SetTerm( "\n" );
|
|
|
558 |
|
|
|
559 |
$io->Label( "Linker commands", $name ); # label
|
|
|
560 |
|
|
|
561 |
# object list
|
|
|
562 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
|
|
|
563 |
|
|
|
564 |
if ( $merge_obj )
|
|
|
565 |
{
|
|
|
566 |
$io->PrtLn( "ifdef MISALIGN" );
|
|
|
567 |
$io->Cmd( "\$(SUNWSPRO_SC)/$merge_obj" );
|
|
|
568 |
$io->PrtLn( "endif" );
|
|
|
569 |
}
|
| 339 |
dpurdie |
570 |
|
| 227 |
dpurdie |
571 |
ToolsetLibStd( $pLibs ); # push standard libraries
|
|
|
572 |
|
|
|
573 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
|
|
|
574 |
|
|
|
575 |
$io->Newline();
|
|
|
576 |
|
| 335 |
dpurdie |
577 |
#.. Dependency link,
|
|
|
578 |
# Create a library dependency file
|
|
|
579 |
# Create command file to build applicaton dependency list
|
|
|
580 |
# from the list of dependent libraries
|
|
|
581 |
#
|
|
|
582 |
# Create makefile directives to include the dependency
|
|
|
583 |
# list into the makefile.
|
|
|
584 |
#
|
| 339 |
dpurdie |
585 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${shared}" );
|
|
|
586 |
$io->SHLDDEPEND($name, $soname);
|
| 227 |
dpurdie |
587 |
}
|
|
|
588 |
|
|
|
589 |
|
|
|
590 |
######################################################
|
|
|
591 |
# ToolsetLD( $name, \@args, \@objs, \@libraries )
|
|
|
592 |
# This subroutine takes the user options and builds the rules
|
|
|
593 |
# required to link the program 'name'.
|
|
|
594 |
#
|
|
|
595 |
# Arguments:
|
|
|
596 |
# n/a
|
|
|
597 |
#
|
|
|
598 |
# Output:
|
|
|
599 |
# $(BINDIR)/name:
|
|
|
600 |
# $(BINDIR)/name.dep
|
|
|
601 |
# $(LD)
|
|
|
602 |
# $(BINDIR)/name.dep: $(GBE_PLATFORM).mk
|
|
|
603 |
# $(LDDEPEND)
|
|
|
604 |
#
|
|
|
605 |
# ifeq "$(IFLAG)" "3"
|
|
|
606 |
# -include "$(BINDIR)/name.dep"
|
|
|
607 |
# endif
|
|
|
608 |
#
|
|
|
609 |
# name_ld += ...
|
|
|
610 |
# :
|
|
|
611 |
#
|
|
|
612 |
###############################################################################
|
|
|
613 |
|
|
|
614 |
sub ToolsetLD
|
|
|
615 |
{
|
|
|
616 |
my( $name, $pArgs, $pObjs, $pLibs ) = @_;
|
|
|
617 |
|
|
|
618 |
#.. Parse arguments
|
|
|
619 |
#
|
|
|
620 |
foreach $_ ( @$pArgs )
|
|
|
621 |
{
|
|
|
622 |
Message( "LD: unknown option $_ -- ignored\n" );
|
|
|
623 |
}
|
|
|
624 |
|
| 315 |
dpurdie |
625 |
#.. Names of programs and components
|
|
|
626 |
#
|
|
|
627 |
my $base = "\$(BINDIR)/${name}";
|
|
|
628 |
my $full = $base . $::exe;
|
|
|
629 |
my $map = $base . '.map';
|
|
|
630 |
my $ld = $base . '.ld';
|
|
|
631 |
|
| 227 |
dpurdie |
632 |
#.. Cleanup rules
|
|
|
633 |
#
|
|
|
634 |
# dep Dependency file
|
|
|
635 |
# map Mape file
|
|
|
636 |
#
|
| 315 |
dpurdie |
637 |
ToolsetGenerate( $map );
|
| 227 |
dpurdie |
638 |
|
|
|
639 |
|
| 335 |
dpurdie |
640 |
my ($io) = ToolsetPrinter::New();
|
|
|
641 |
my $dep =$io->SetLdTarget( $name );
|
|
|
642 |
|
| 227 |
dpurdie |
643 |
#.. Build rules
|
|
|
644 |
#
|
|
|
645 |
|
| 315 |
dpurdie |
646 |
$io->Prt( "$full : $dep " );
|
|
|
647 |
$io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
|
|
|
648 |
$io->Prt( "\n\t\$(LD)\n\n" );
|
|
|
649 |
|
|
|
650 |
|
| 227 |
dpurdie |
651 |
#.. Linker command file
|
|
|
652 |
#
|
|
|
653 |
# Now the fun part... piecing together a variable $(name_ld)
|
|
|
654 |
# which ends up in the command file.
|
|
|
655 |
#
|
|
|
656 |
$io->SetTag( "${name}_ld" ); # macro tag
|
|
|
657 |
$io->SetTerm( "\n" );
|
|
|
658 |
|
|
|
659 |
$io->Label( "Linker commands", $name ); # label
|
|
|
660 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe ); # object list
|
|
|
661 |
ToolsetLibStd( $pLibs ); # push standard libraries
|
|
|
662 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe ); # library list
|
|
|
663 |
$io->Newline();
|
|
|
664 |
|
|
|
665 |
#.. Dependency link,
|
| 335 |
dpurdie |
666 |
# Create a library dependency file
|
|
|
667 |
# Create command file to build applicaton dependency list
|
|
|
668 |
# from the list of dependent libraries
|
| 227 |
dpurdie |
669 |
#
|
| 335 |
dpurdie |
670 |
# Create makefile directives to include the dependency
|
|
|
671 |
# list into the makefile.
|
| 227 |
dpurdie |
672 |
#
|
| 335 |
dpurdie |
673 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, $base );
|
|
|
674 |
$io->LDDEPEND(); # standard LDDEPEND rules
|
| 227 |
dpurdie |
675 |
|
|
|
676 |
|
| 315 |
dpurdie |
677 |
#.. Package up the program and other artifacts
|
|
|
678 |
#
|
|
|
679 |
PackageProgAddFiles ( $name, $full );
|
|
|
680 |
|
| 227 |
dpurdie |
681 |
}
|
|
|
682 |
|
|
|
683 |
|
|
|
684 |
########################################################################
|
|
|
685 |
#
|
|
|
686 |
# Push standard "system" libraries. This is a helper function
|
|
|
687 |
# used within this toolset.
|
|
|
688 |
#
|
|
|
689 |
# Arguments:
|
|
|
690 |
# $plib Reference to library array.
|
|
|
691 |
#
|
|
|
692 |
########################################################################
|
|
|
693 |
|
|
|
694 |
sub ToolsetLibStd
|
|
|
695 |
{
|
|
|
696 |
}
|
|
|
697 |
|
|
|
698 |
########################################################################
|
|
|
699 |
#
|
|
|
700 |
# Generate a linker object recipe. This is a helper function used
|
|
|
701 |
# within this toolset.
|
|
|
702 |
#
|
|
|
703 |
# Arguments:
|
|
|
704 |
# $io I/O stream
|
|
|
705 |
#
|
|
|
706 |
# $target Name of the target
|
|
|
707 |
#
|
|
|
708 |
# $obj Library specification
|
|
|
709 |
#
|
|
|
710 |
########################################################################
|
|
|
711 |
|
|
|
712 |
sub ToolsetObjRecipe
|
|
|
713 |
{
|
|
|
714 |
my ($io, $target, $obj) = @_;
|
|
|
715 |
|
|
|
716 |
$io->Cmd( "\$(strip $obj).$::o" );
|
|
|
717 |
}
|
|
|
718 |
|
|
|
719 |
|
|
|
720 |
###############################################################################
|
|
|
721 |
#
|
|
|
722 |
# Parse a linker lib list
|
|
|
723 |
# This is a helper function used within this toolset
|
|
|
724 |
#
|
|
|
725 |
# Arguments:
|
|
|
726 |
# $target Name of the target
|
|
|
727 |
#
|
|
|
728 |
# $lib Library specification
|
|
|
729 |
#
|
|
|
730 |
# $tag Tag (user specified)
|
|
|
731 |
#
|
|
|
732 |
# $dp If building a depend list, the full target name.
|
|
|
733 |
#
|
|
|
734 |
###############################################################################
|
|
|
735 |
|
|
|
736 |
sub ToolsetLibRecipe
|
|
|
737 |
{
|
|
|
738 |
my ($io, $target, $lib, $dp) = @_;
|
|
|
739 |
|
|
|
740 |
if ( ! defined($dp) ) { # linker
|
|
|
741 |
$lib =~ s/^lib//; # .. remove leading 'lib'
|
|
|
742 |
$io->Cmd( "-l $lib" );
|
|
|
743 |
|
|
|
744 |
} else { # depend
|
|
|
745 |
$io->Cmd( "$dp:\t@(vlib2,$lib,CC_LIB)" );
|
|
|
746 |
|
|
|
747 |
}
|
|
|
748 |
}
|
|
|
749 |
#.. Successful termination
|
|
|
750 |
|
|
|
751 |
1;
|