Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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