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