Subversion Repositories DevTools

Rev

Rev 339 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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