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