Subversion Repositories DevTools

Rev

Rev 4700 | Rev 4712 | 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; 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
 
4034 dpurdie 16
our $ScmPlatform;
17
our $ScmNoToolsTest;
18
 
227 dpurdie 19
##############################################################################
20
#   Configuration information
21
#   Cross reference from CrossCompiler Alias to actual paths
22
#   Structure:
23
#   Hash reference: Array of toolchain information
369 dpurdie 24
#       Mandatory
25
#          ROOT             => Root of compiler
26
#          BASE             => Base for binaries
27
#       Optional
28
#          CC_OPTS          => Additonal Compiler options
4034 dpurdie 29
#          CC_OPTSP         => Production Compiler options
30
#          CC_OPTSD         => Debug Compiler options
369 dpurdie 31
#          UNCONTROLLED     => Boolean to create warning
3967 dpurdie 32
#          PACKAGE_ARCH     => Packageing architecture
33
#          VERSION          => Version reported by GCC
34
#          MACHINE          => Machine reported by GCC
4034 dpurdie 35
#          COMPILER_OPTIONS => Toolset specific compiler initial options
36
#                              This is a comma seperated list
369 dpurdie 37
 
227 dpurdie 38
my %ToolsetConfig = (
39
 
369 dpurdie 40
    'i386-unknown-linux-gnu'    => {
41
        ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/i586-unknown-linux-gnu',
42
        BASE => 'bin/i586-unknown-linux-gnu-',
3967 dpurdie 43
       VERSION      => '4.1.1',
44
       MACHINE      => 'i586-unknown-linux-gnu'
369 dpurdie 45
    },
227 dpurdie 46
 
369 dpurdie 47
    'arm-9tdmi-linux-gnu'       => {
48
        ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/arm-9tdmi-linux-gnu',
3967 dpurdie 49
        BASE => 'bin/arm-9tdmi-linux-gnu-',
50
        VERSION      => '4.1.1',
51
        MACHINE      => 'arm-9tdmi-linux-gnu'
369 dpurdie 52
        },
247 dpurdie 53
 
369 dpurdie 54
    'powerpc-603e-linux-gnu'    => {
55
       ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/powerpc-603e-linux-gnu',
3967 dpurdie 56
       BASE => 'bin/powerpc-603e-linux-gnu-',
57
       VERSION      => '4.1.1',
58
       MACHINE      => 'powerpc-603e-linux-gnu'
369 dpurdie 59
    },
337 dpurdie 60
 
369 dpurdie 61
    'arm-926ejs-linux-gnueabi'  => {
62
       ROOT => '/opt/crosstool/gcc-4.4.3-glibc-2.9/arm-926ejs-linux-gnueabi',
63
       BASE => 'bin/arm-926ejs-linux-gnueabi-',
64
       CC_OPTS => '-Wno-psabi',
3967 dpurdie 65
       VERSION      => '4.4.3',
66
       MACHINE      => 'arm-926ejs-linux-gnueabi'
369 dpurdie 67
    },
68
 
3967 dpurdie 69
    'i686-linux-gnu'    => {
70
       ROOT         => '/usr',
71
       BASE         => 'bin/',
72
       PACKAGE_ARCH => 'i386',
73
       VERSION      => '4.6',
74
       MACHINE      => 'i686-linux-gnu'
75
    },
76
 
4109 dpurdie 77
    'arm-iwmmxt-linux-gnueabi'  => {
78
       ROOT => '/opt/marvel',
79
       BASE => 'bin/arm-iwmmxt-linux-gnueabi-',
80
       VERSION      => '4.2.4',
81
       MACHINE      => 'arm-iwmmxt-linux-gnueabi'
82
    },
83
 
84
 
227 dpurdie 85
    #
86
    #   Old (not to be used) version of the embedded toolchain
4003 dpurdie 87
    #   This was deprecated in favor of gcc-4.1.1-glibc-2.5
227 dpurdie 88
    #   It is not possible to reproduce old packages using the old compiler
89
    #   This is a known issue
90
    #
369 dpurdie 91
    'i386-unknown-linux-gnu.glibc-2.3.2' => {
92
       ROOT => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/i386-unknown-linux-gnu',
93
       BASE => 'bin/i386-unknown-linux-gnu-'
94
    },
227 dpurdie 95
 
369 dpurdie 96
    'arm-9tdmi-linux-gnu.glibc-2.3.2' => {
97
       ROOT => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu',
98
       BASE => 'bin/arm-9tdmi-linux-gnu-'
99
    },
227 dpurdie 100
 
101
    #
102
    #   Not too sure where this is used
103
    #
369 dpurdie 104
    'armv4l-unknown-linux-gcc' => {
105
       ROOT => '/opt/host/armv4l',
106
       BASE => 'bin/armv4l-unknown-linux-'
107
    },
227 dpurdie 108
 
109
    #
110
    #   The compiler for the current local machine
111
    #
369 dpurdie 112
    'i386-unknown-linux-gcc' => {
113
       ROOT => '/usr',
114
       BASE => 'bin/',
115
       UNCONTROLLED => 1,
3967 dpurdie 116
       PACKAGE_ARCH => 'i386',
369 dpurdie 117
    },
118
);
227 dpurdie 119
 
120
#
121
#   Cross reference from GCCTarget to GBE_MACHTYPE for which it can
122
#   build using the 'native gcc'. This is NOT the preferred mode of operation
123
#   as the compiler is not as controlled as the cross compilers.
124
#
125
my %NativeCompilers = (
126
    'Linux i386'       => 'linux_i386',
127
    );
128
 
4700 alewis 129
my $UseGcov = 0;
4701 alewis 130
my $UseCppcheck = 0;
4700 alewis 131
 
227 dpurdie 132
##############################################################################
133
#   ToolsetInit()
134
#       Runtime initialisation
135
#
136
##############################################################################
137
 
138
ToolsetInit();
139
 
140
sub ToolsetInit
141
{
4034 dpurdie 142
    my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCObjCopy );
4700 alewis 143
    my( $GCCFlags,  $GCCFlagsP, $GCCFlagsD, $LDFlags );
3967 dpurdie 144
    my( $PkgArch);
4034 dpurdie 145
    my( $arg_alias, $tools_found, $compiler_tool );
227 dpurdie 146
 
147
#.. Toolset configuration
148
#
149
    $::ScmToolsetVersion = "1.0.0";             # our version
150
    $::ScmToolsetGenerate = 0;                  # GEN generate optional
151
    $::ScmToolsetCompilerPath = 1;              # Exports Compiler path to makefile via SCM_COMPILERPATH
271 dpurdie 152
    $::ScmToolsetProgDependancies = 0;          # handle Prog dependancies myself
339 dpurdie 153
    $::ScmToolsetSoName = 1;                    # Shared library supports SoName
227 dpurdie 154
 
155
#.. Standard.rul requirements
156
#
157
    $::s = "asm";
158
    $::o = "o";
159
    $::so = "so";
160
    $::a = "a";
161
    $::exe = "";
162
 
163
#.. Parse arguments
164
#
165
    foreach $_ ( @::ScmToolsetArgs ) {
166
        if (/^--Target=(.*)/) {                 # OS Version
167
            $GCCTarget = "$1";
168
 
169
        } elsif (/^--CrossAlias=(.*)/) {        # CrossCompiler target-alias
170
            $arg_alias = $1;
171
 
4700 alewis 172
        } elsif (/^--UseGcov/) {                # Compile for code coverage
173
            $UseGcov = 1;
174
 
4701 alewis 175
        } elsif (/^--UseCppcheck/) {            # Use cppcheck as the lint tool
176
            $UseCppcheck = 1;
177
 
4034 dpurdie 178
        } elsif (/^--CompilerTool=(.*)/) {      # CrossCompiler located in package
179
            $compiler_tool = $1;
180
 
227 dpurdie 181
        } else {
182
            Message( "gcc toolset: unknown option $_ -- ignored\n" );
183
        }
184
    }
185
 
186
    foreach $_ ( @::ScmPlatformArgs ) {
187
        if (/^--product=(.*)/) {                # GBE product
188
 
189
        } else {
190
            Message( "gcc toolset: unknown platform argument $_ -- ignored\n" );
191
        }
192
    }
193
 
194
    Error ("TOOLSET/gcc - Target undefined" )
195
        unless ($GCCTarget);
196
 
4034 dpurdie 197
    #
198
    #   If the toolset is not required, then do not process any futher
199
    #   We may not find the compiler
200
    #
201
    return
202
        if ($ScmNoToolsTest);
203
 
227 dpurdie 204
#.. Cross compile support
4034 dpurdie 205
#   Compiler provided in package, rather than install on machine
227 dpurdie 206
#
4034 dpurdie 207
if ( $compiler_tool  )
208
{
209
    #
210
    #   The GCC toolset will handle a compiler provided within a package
211
    #   Initial requirement was for ANDROID NDKs where the compiler is
212
    #   a part of the NDK and will change.
213
    #
214
    #   Compilers in packages will have a file in gbe/COMPILERS/<compiler_tool>
215
    #   that contains data specifically designed for this toolset
216
    #
217
    Verbose("Locate compiler in package: $compiler_tool");
218
    my @toolList;
219
    my $toolPath;
220
    my $toolPkg;
221
    for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
222
    {
223
        my $tpath = join('/', $entry->{ROOT}, 'gbe', 'COMPILERS' , $compiler_tool);
224
        if ( -f $tpath  )
225
        {
226
            push @toolList, $entry->{NAME};
227
            $toolPath = $tpath;
228
            $toolPkg = $entry;
229
        }
230
    }
231
    Error ("Multiple packages provide required compiler:", @toolList)
232
        if ( scalar(@toolList) > 1 );
233
    Error ("Required compiler not found in any package", "Compiler: $compiler_tool")
234
        unless ( scalar(@toolList) == 1 );
235
 
236
    #
237
    #   Process the compiler info file
238
    #   Rip out the data and create a hash of item/values
239
    #   File format:
240
    #       '#' is a line comment
241
    #       item=value
242
    #
243
    my %data;
244
    open (my $DATA, '<', $toolPath ) || Error("Cannot open compiler datafile. $!", "File: $toolPath");
245
    while ( <$DATA> )
246
    {
247
        $_ =~ s~\s+$~~;
248
        next if ( m~^#~ );
249
        m~(.*?)\s*=\s*(.*)~;
250
        $data{$1} = $2;
251
    }
252
    close $DATA;
253
 
254
    #
255
    #   Force this compilers data into the ToolsetConfig hash
256
    #
257
    $arg_alias = $compiler_tool;
258
    %ToolsetConfig = ();
259
 
260
    $ToolsetConfig{$arg_alias}{ROOT} = join('/', $toolPkg->{ROOT}, $data{ROOT} );
261
    $ToolsetConfig{$arg_alias}{BASE} = $data{BASE} . '-';
262
    $ToolsetConfig{$arg_alias}{CC_OPTS} = $data{CFLAGS};
263
    $ToolsetConfig{$arg_alias}{CC_OPTSP} = $data{CFLAGSP};
264
    $ToolsetConfig{$arg_alias}{CC_OPTSD} = $data{CFLAGSD};
265
    $ToolsetConfig{$arg_alias}{VERSION} = $data{VERSION};
266
    $ToolsetConfig{$arg_alias}{MACHINE} = $data{MACHINE};
267
    $ToolsetConfig{$arg_alias}{COMPILER_OPTIONS} = $data{COMPILER_OPTIONS};
268
}
269
 
270
#.. Cross compile support
271
#
227 dpurdie 272
#   Toolchain=root,[bin]
273
#
274
    if ( $arg_alias )
275
    {
276
        if ( exists $ToolsetConfig{ $arg_alias } )
277
        {
369 dpurdie 278
            $GCCToolchain = $ToolsetConfig{ $arg_alias };
279
            $tools_found = (-d $GCCToolchain->{ROOT});
227 dpurdie 280
            Warning ("gcc toolset: CrossPlatform toolchain not found for: $arg_alias",
369 dpurdie 281
                     "Path: $GCCToolchain->{ROOT}" ) unless $tools_found;
227 dpurdie 282
        }
283
        else
284
        {
285
            Error("gcc toolset: CrossPlatform Alias not configured: $arg_alias");
286
        }
369 dpurdie 287
 
288
        Warning ("Uncontrolled toolchain used: $arg_alias")
289
            if ( exists($GCCToolchain->{UNCONTROLLED}) && $GCCToolchain->{UNCONTROLLED} );
227 dpurdie 290
    }
291
 
292
    #
293
    #   If no Cross compiler toolchain is found (preferred method), then attempt
294
    #   to match a native compiler. Only known targets allow a native build
295
    #
296
    unless ( $tools_found )
297
    {
298
        if ( exists ( $NativeCompilers{$GCCTarget} ))
299
        {
300
            if ( $NativeCompilers{$GCCTarget} eq $::GBE_MACHTYPE )
301
            {
302
                $tools_found = 1;
369 dpurdie 303
                $GCCToolchain = undef;
227 dpurdie 304
            }
305
        }
306
    }
307
 
308
    #
309
    #   Must have a toolset by now, either a cross compiler or Native
310
    #
311
    Error ("gcc toolset: Toolchain not found for: $GCCTarget" )
312
        unless ( $tools_found );
313
 
314
 
369 dpurdie 315
    if ( defined $GCCToolchain )
227 dpurdie 316
    {
317
        #
369 dpurdie 318
        #   Parse GCCToolchain. Potential parts to create
319
        #       GCCRoot     - Location to find the effective /usr/include directory
320
        #       GCCBin      - Path to the gcc executable
321
        #       GCCAr       - Path to the ar executable
4034 dpurdie 322
        #       GCCFlags    - Additional compiler flags. Also Production and Debug
227 dpurdie 323
        #
369 dpurdie 324
        $GCCRoot = $GCCToolchain->{ROOT};
325
        $GCCBin = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'gcc';
326
        $GCCAr =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'ar';
373 dpurdie 327
        $GCCObjCopy =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'objcopy';
369 dpurdie 328
        $GCCFlags = $GCCToolchain->{CC_OPTS};
4034 dpurdie 329
        $GCCFlagsP = $GCCToolchain->{CC_OPTSP};
330
        $GCCFlagsD = $GCCToolchain->{CC_OPTSD};
3967 dpurdie 331
        $PkgArch = $GCCToolchain->{PACKAGE_ARCH};
227 dpurdie 332
    }
333
    else
334
    {
373 dpurdie 335
        $GCCRoot = '/usr';
336
        $GCCBin = 'gcc';
337
        $GCCAr = 'ar';
338
        $GCCObjCopy =  'objcopy';
227 dpurdie 339
    }
4700 alewis 340
 
341
    #
342
    #   When running under gcov we need to instruct GCC to perform code coverage
343
    #   generation in both C flags and LD flags
344
    #
345
    if ( $UseGcov )
346
    {
347
        $GCCFlags=$GCCFlags . ' -coverage';
348
        $LDFlags=$LDFlags . ' -coverage';
349
    }
4701 alewis 350
 
351
    #
352
    #   When running with cppcheck we need to include it in our environment
353
    #
354
    if ( $UseCppcheck )
355
    {
356
        ToolsetRequire( "cppcheck" );
357
        PlatformDefine( "CPPCHECK_PLATFORM := unix32" );
358
        PlatformDefine( "CPPCHECK_DEFINES := -U_MSC_VER -U_MOS_ -U_WIN32_WCE -U_WIN32_WINNT -U_SUPRO_C -U__SUNPRO_CC" );
359
    }
4700 alewis 360
 
227 dpurdie 361
 
362
#.. Define GCC environment
363
#
364
    PlatformDefine( "
365
#################################################
366
# GCC toolchain definitions 
367
#
368
#..");
369 dpurdie 369
    PlatformDefine( "GCC_TARGET         := $GCCTarget" );
370
    PlatformDefine( "GCC_ROOT           := $GCCRoot" );
371
    PlatformDefine( "GCC_CC             := $GCCBin" );
372
    PlatformDefine( "GCC_AR             := $GCCAr" );
373 dpurdie 373
    PlatformDefine( "GCC_OBJCOPY        := $GCCObjCopy" );
369 dpurdie 374
    PlatformDefine( "GCC_CFLAGS         := $GCCFlags" ) if defined $GCCFlags;
4034 dpurdie 375
    PlatformDefine( "GCC_CFLAGSP        := $GCCFlagsP" ) if defined $GCCFlagsP;
376
    PlatformDefine( "GCC_CFLAGSD        := $GCCFlagsD" ) if defined $GCCFlagsD;
4700 alewis 377
    PlatformDefine( "GCC_LDFLAGS        := $LDFlags" ) if defined $LDFlags;
369 dpurdie 378
 
227 dpurdie 379
    #
380
    #   Required since this toolset advertises: ScmToolsetCompilerPath
381
    #
369 dpurdie 382
    PlatformDefine( "SCM_COMPILERPATH   := \$\{GCC_CC\}" );
3967 dpurdie 383
 
384
    #
385
    #   Sanity checking
386
    #
387
    PlatformDefine( "GCC_EVERSION       := " . $GCCToolchain->{VERSION} ) if defined $GCCToolchain->{VERSION};
388
    PlatformDefine( "GCC_EMACHINE       := " . $GCCToolchain->{MACHINE} ) if defined $GCCToolchain->{MACHINE};
389
 
390
    #
391
    #   Option indication of packaging architecture
392
    #   Used by non-embedded systems for packaging. See debian_packager
393
    #
394
    PlatformDefine( "PACKAGE_ARCH       := $PkgArch" ) if (defined $PkgArch);
369 dpurdie 395
    PlatformDefine( "" );
227 dpurdie 396
 
397
#.. Piece the world together
398
#
3967 dpurdie 399
    Init( 'gcc' );
227 dpurdie 400
    ToolsetDefines( "gcc.def" );
401
    ToolsetRules( "gcc.rul" );
402
    ToolsetRules( "standard.rul" );
403
 
4094 dpurdie 404
 
405
    PlatformDefine( "CTAGS_EXE:= ctags" );
406
    ToolsetRequire( "exctags" );                # and Exuberant Ctags
407
 
227 dpurdie 408
#   Create a standard data structure
409
#   This is a hash of hashes
410
#       The first hash is keyed by CompileOption keyword
411
#       The second hash contains pairs of values to set or remove
412
#
413
    %::ScmToolsetCompilerOptions =
414
    (
415
        #
416
        #   Control the thread model to use
417
        #   This will affect the compiler options and the linker options
418
        #
419
        'staticprogs'        => { 'STATIC_PROGS' , '1' },      # Progams link staticlly
420
        'no_staticprogs'     => { 'STATIC_PROGS' , undef },    # Default
4034 dpurdie 421
        'noversiondll'       => { 'NO_VERSIONED_DLLS', 1 },    # Matches usage elsewhere
227 dpurdie 422
    );
423
 
424
    #
425
    #   Set default options
426
    #
427
    $::ScmCompilerOpts{'STATIC_PROGS'} = undef;
4034 dpurdie 428
    $::ScmCompilerOpts{'NO_VERSIONED_DLLS'} = undef;
429
 
430
    #
431
    #   Process toolset-specfic compiler options
432
    #
433
    if ( exists $GCCToolchain->{COMPILER_OPTIONS} )
434
    {
435
        CompileOptions('*', split(',',$GCCToolchain->{COMPILER_OPTIONS}) );
436
    }
227 dpurdie 437
}
438
 
4094 dpurdie 439
###############################################################################
440
#   ToolsetCTAGS()
441
#       This subroutine takes the user options and builds the rules
442
#       required to build the CTAGS database.
443
#
444
#   Arguments:
445
#       --xxx                   No arguments currently defined
446
#
447
#   Output:
448
#       [ctags:]
449
#           $(EXCTAGS)
450
#
451
###############################################################################
227 dpurdie 452
 
4094 dpurdie 453
sub ToolsetCTAGS
454
{
455
    EXCTAGS( @_ );
456
}
457
 
458
 
227 dpurdie 459
###############################################################################
460
#   ToolsetCC( $source, $obj, \@args )
461
#       This subroutine takes the user options and builds the rule(s)
462
#       required to compile the source file 'source' to 'obj'
463
#
464
###############################################################################
465
 
466
sub ToolsetCC
467
{
468
    my( $source, $obj, $pArgs ) = @_;
469
    my( $cflags, $file ) = "";
470
 
471
    foreach $_ ( @$pArgs ) {
472
        if (/--Shared$/) {                      # Building a 'shared' object
473
            $cflags  = "$cflags \$(SHCFLAGS)";
474
        } else {
475
            Message( "CC: unknown option $_ -- ignored\n" );
476
        }
477
    }
478
 
479
    MakePrint( "\n\t\$(CC)\n" );
480
    if ( $cflags )
481
    {                                           # object specific CFLAGS
482
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
483
        MakePrint( "\tCFLAGS +=$cflags\n" );
484
    }
485
 
486
    $file = StripExt( $obj );                   # Metric working file
487
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
488
}
489
 
490
 
491
###############################################################################
492
#   ToolsetCCDepend( $depend, \@sources )
493
#       This subroutine takes the user options and builds the
494
#       rule(s) required to build the dependencies for the source
495
#       files 'sources' to 'depend'.
496
#
497
###############################################################################
498
 
499
sub ToolsetCCDepend
500
{
501
    MakePrint( "\t\$(CCDEPEND)\n" );
502
}
503
 
504
 
505
###############################################################################
506
#   ToolsetCXX( $source, $obj, \@args )
507
#       This subroutine takes the user options and builds the rule(s)
508
#       required to compile the source file 'source' to 'obj'
509
#
510
###############################################################################
511
 
512
sub ToolsetCXX
513
{
514
    my( $source, $obj, $pArgs ) = @_;
515
    my( $cflags, $file ) = "";
516
 
517
    foreach $_ ( @$pArgs ) {
518
        if (/--Shared$/) {                      # Building a 'shared' object
519
            $cflags  = "$cflags \$(SHCXXFLAGS)";
520
        } else {
521
            Message( "CXX: unknown option $_ -- ignored\n" );
522
        }
523
    }
524
 
525
    MakePrint( "\n\t\$(CXX)\n" );
526
    if ( $cflags )
527
    {                                           # object specific CFLAGS
528
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
529
        MakePrint( "\tCXXFLAGS +=$cflags\n" );
530
    }
531
 
532
    $file = StripExt( $obj );                   # Metric working file
533
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
534
}
535
 
536
 
537
###############################################################################
538
#   ToolsetCXXDepend( $depend, \@sources )
539
#       This subroutine takes the user options and builds the
540
#       rule(s) required to build the dependencies for the source
541
#       files 'sources' to 'depend'.
542
#
543
###############################################################################
544
 
545
sub ToolsetCXXDepend
546
{
287 dpurdie 547
    ToolsetCCDepend();
227 dpurdie 548
}
549
 
550
 
551
###############################################################################
552
#   ToolsetAS( $source, $obj, \@args )
553
#       This subroutine takes the user options and builds the rule(s)
554
#       required to compile the source file 'source' to 'obj'
555
#
556
###############################################################################
557
 
558
sub ToolsetAS
559
{
560
    MakePrint( "\n\t\$(AS)\n" );
561
}
562
 
563
sub ToolsetASDepend
564
{
565
}
566
 
567
 
568
###############################################################################
569
#   ToolsetAR( $name, \@args, \@objs )
570
#       This subroutine takes the user options and builds the rules
571
#       required to build the library 'name'.
572
#
573
#   Arguments:
574
#       n/a
575
#
576
#   Output:
577
#       $(BINDIR)/name$.${a}:   .... ]
578
#           $(AR)
579
#
580
#       name_ld += ...  Linker command file
581
#           :
582
#
583
#       name_dp += ...  Dependency list
584
#           :
585
#
586
###############################################################################
587
 
588
sub ToolsetAR
589
{
590
    my( $name, $pArgs, $pObjs ) = @_;
591
 
592
#.. Parse arguments
593
#
594
    foreach $_ ( @$pArgs )
595
    {
596
        Message( "AR: unknown option $_ -- ignored\n" );
597
    }
598
 
599
#.. Target
600
#
601
    MakePrint( "#.. Library ($name)\n\n" );     # label
602
 
603
    MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).$::a:\t",
604
        "", "\\\n\t\t", ".$::o", @$pObjs );
605
 
606
#.. Build library rule (just append to standard rule)
607
#
608
    MakePrint( "\n\t\$(AR)\n\n" );
609
}
610
 
611
 
612
###############################################################################
613
#   ToolsetARMerge( $name, \@args, \@libs )
614
#       This subroutine takes the user options and builds the rules
615
#       required to build the library 'name' by merging the specified
616
#       libaries
617
#
618
#   Arguments:
619
#       --xxx                   No arguments currently defined
620
#
621
#   Output:
622
#       [ $(LIBDIR)/name$.${a}:   .... ]
623
#           ...
624
#
625
###############################################################################
626
 
627
sub ToolsetARMerge
628
{
629
    MakePrint( "\n\t\$(ARMERGE)\n\n" );
630
}
631
 
632
 
633
###############################################################################
289 dpurdie 634
#   ToolsetSHLD( $name, \@args, \@objs, \@libraries, $ver )
227 dpurdie 635
#       This subroutine takes the user options and builds the rules
339 dpurdie 636
#       required to link the Shared Library 'name'.
227 dpurdie 637
#
638
#   Arguments:
639
#   n/a
640
#
641
#   Output:
642
#       $(LIBDIR)/name:     $(LIBDIR)/shared
643
#           ln -s $shared $name
644
#
645
#       $(LIBDIR)/name.dep: $(GBE_OBJDIR)
646
#       $(LIBDIR)/name.dep: $(GBE_LIBDIR)
647
#       $(LIBDIR)/name.dep: $(GBE_PLATFORM).mk
648
#           $(SHLDDEPEND)
649
#
650
#       $(LIBDIR)/shared:   SHNAME=name
651
#       $(LIBDIR)/shared:   SHBASE=base
652
#       $(LIBDIR)/shared:   $(LIBDIR)/name.dep  \
653
#           $(OBJECTS)
654
#                           
655
#       ifneq "$(findstring $(IFLAG),23)" ""
656
#       -include            "$(LIBDIR)/name.dep"
657
#       endif
658
#
659
#       name_ld += ...
660
#           :
661
#
662
###############################################################################
663
 
664
sub ToolsetSHLD
665
{
289 dpurdie 666
    my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
373 dpurdie 667
    my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
4034 dpurdie 668
    my $sosuffix;
669
    my $noVersionedLib = $::ScmCompilerOpts{'NO_VERSIONED_DLLS'};
227 dpurdie 670
 
4034 dpurdie 671
 
227 dpurdie 672
#.. Parse arguments
673
#
674
    foreach $_ ( @$pArgs )
675
    {
676
        if (/^--Def=(.*?)(\,(.*))?$/) {         # Library definition
677
            #
678
            #   Locate the Def file.
679
            #   If it is a generate file so it will be in the SRCS hash
680
            #   Otherwise the user will have to use Src to locate the file
681
            #
682
            $def = MakeSrcResolve($1);
683
            $def_pref = '';
684
            if ( $1 =~ m~\.def$~ ) {
685
                $def_pref = '--version-script='; # Old def file
686
            }
687
        } elsif ( /^--MultiScan/i ) {
688
            $multi_scan = 1;
689
 
690
        } elsif ( /^--NoMultiScan/i ) {
691
            $multi_scan = 0;
692
 
339 dpurdie 693
        } elsif ( /^--SoNameSuffix=(.*)/i ) {
694
            $sosuffix = $1;
695
 
4034 dpurdie 696
        } elsif (/^--NoVersionDll/i) {
697
            $noVersionedLib = 1;
698
 
227 dpurdie 699
        } else {
700
            Message( "SHLD: unknown option $_ -- ignored\n" );
701
        }
702
    }
703
 
4034 dpurdie 704
    #
705
    # Determine the 'soname' in none has been provided
706
    #
707
    $sosuffix = '.' . $ver
708
        unless ( defined $sosuffix );
709
    $sosuffix = ''
710
        if ( $noVersionedLib );
711
 
339 dpurdie 712
#.. Various library names
227 dpurdie 713
#
339 dpurdie 714
    $linkname = "$name\$(GBE_TYPE).$::so";
4034 dpurdie 715
    $shared = $noVersionedLib ? $linkname : "$linkname.$ver";
339 dpurdie 716
    $soname = "$linkname$sosuffix";
4034 dpurdie 717
 
373 dpurdie 718
    my $shared_path = "\$(LIBDIR)/${shared}";
719
    my $dbg_path =  $shared_path . '.dbg';
227 dpurdie 720
 
721
#.. Cleanup rules
722
#
723
#   map     Map file
724
#   ln      Link from LIBDIR to BINDIR
725
#
261 dpurdie 726
    ToolsetGenerate( "\$(LIBDIR)/${name}.map" );
727
    ToolsetGenerate( "\$(LIBDIR)/${shared}" );
339 dpurdie 728
    ToolsetGenerate( "\$(BINDIR)/${soname}" );
373 dpurdie 729
    ToolsetGenerate( $dbg_path );
227 dpurdie 730
 
731
#.. Build rules
732
#
733
#   name        Base name
734
#   shared      Library name, includes GBE_TYPE specification
735
#
736
    my ($io) = ToolsetPrinter::New();
335 dpurdie 737
    my $dep = $io->SetShldTarget($shared);
227 dpurdie 738
 
739
    $io->Label( "Shared library", $name );
339 dpurdie 740
    PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
373 dpurdie 741
    PackageShlibAddFiles( $name, $dbg_path );
4034 dpurdie 742
 
227 dpurdie 743
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
339 dpurdie 744
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
745
    $io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
321 dpurdie 746
    $io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
227 dpurdie 747
    $io->Prt( "\\\n\t\t$def" ) if($def);
373 dpurdie 748
    $io->Prt( "\n\t\$(SHLD)" );
749
    $io->Prt( "\n\t\$(call LDSTRIP,$shared_path,$dbg_path)\n\n" );
321 dpurdie 750
 
339 dpurdie 751
#
752
#   Create soft links
753
#       'Real Name' to its 'Link Name'
754
#       'Real Name' to 'SoName' in the BINDIR (for testing I think)
755
#       'Real Name' to 'SoName' in the LIBDIR (if different)
756
#
4034 dpurdie 757
    if ( $shared ne $linkname)
758
    {
759
        $io->Label( "Shared library Symbolic Links", $name );
760
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname" );
761
        $io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
762
                  "\t\t\$(GBE_BINDIR)\\\n" .
763
                  "\t\t\$(LIBDIR)/${shared}\n" .
764
                  "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n\n" );
765
    }
766
 
767
    $io->Label( "Shared library BINDIR Symbolic Links", $name );
768
    PackageShlibAddFiles( $name, "\$(BINDIR)/$soname" );
769
    $io->Prt( "\$(BINDIR)/$soname:\t\\\n" .
339 dpurdie 770
              "\t\t\$(GBE_BINDIR)\\\n" .
771
              "\t\t\$(LIBDIR)/${shared}\n" .
4034 dpurdie 772
              "\t\$(AA_PRE)(rm -f \$@; ln -s ../\$(LIBDIR)/$shared \$@)\n\n" );
339 dpurdie 773
 
4034 dpurdie 774
    if ( $soname ne $shared )
339 dpurdie 775
    {
776
        $io->Label( "Shared library SoName Symbolic Links", $name );
777
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname" );
778
        $io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
779
                  "\t\t\$(GBE_LIBDIR)\\\n" .
780
                  "\t\t\$(LIBDIR)/${shared}\n" .
781
                  "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n" );
782
    }
783
 
227 dpurdie 784
#.. Linker command file
785
#
786
#       Now the fun part... piecing together a variable $(name_shld)
787
#       which ends up in the command file.
788
#
339 dpurdie 789
    $io->Newline();
227 dpurdie 790
    $io->SetTag( "${name}_shld" );              # command tag
791
    $io->SetTerm( "\n" );
792
 
793
    $io->Label( "Linker commands", $name );     # label
794
 
795
                                                # object list
796
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
797
 
798
    ToolsetLibStd( $pLibs );                    # push standard libraries
799
 
800
    $io->Cmd( "-Wl,$def_pref$def" ) if ($def);
801
 
802
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
803
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
804
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
805
 
806
    $io->Newline();
807
 
335 dpurdie 808
    #.. Dependency link,
809
    #   Create a library dependency file
810
    #       Create command file to build applicaton dependency list
811
    #       from the list of dependent libraries
812
    #
813
    #       Create makefile directives to include the dependency
814
    #       list into the makefile.
815
    #
816
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${shared}" );
339 dpurdie 817
    $io->SHLDDEPEND($name, $soname);
227 dpurdie 818
}
819
 
820
 
821
###############################################################################
271 dpurdie 822
# Function        : ToolsetLD
227 dpurdie 823
#
271 dpurdie 824
# Description     : Takes the user options and builds the rules required to
825
#                   link the program 'name'.
227 dpurdie 826
#
271 dpurdie 827
# Inputs          : $name           - base name of the program
828
#                   $pArgs          - Ref to program arguments
829
#                   $pObjs          - Ref to program objects
830
#                   $pLibs          - Ref to program library list
227 dpurdie 831
#
271 dpurdie 832
# Returns         : Nothing
227 dpurdie 833
#
271 dpurdie 834
# Output:         : Rules and recipes to create a program
835
#                       Create program rules and recipes
836
#                       Create linker input script
837
#                       Create library dependency list
838
#                       Include library dependency information
227 dpurdie 839
#
840
sub ToolsetLD
841
{
842
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
843
    my $static = $::ScmCompilerOpts{'STATIC_PROGS'};
844
    my $multi_scan;
845
 
846
#.. Parse arguments
847
#
848
    foreach $_ ( @$pArgs )
849
    {
850
        if ( m/^--Static$/ ) {
851
            $static = 1;
852
 
853
        } elsif ( m/^--Shared/ ) {
854
            $static = 0;
855
 
856
        } elsif ( /^--MultiScan/i ) {
857
            $multi_scan = 1;
858
 
859
        } elsif ( /^--NoMultiScan/i ) {
860
            $multi_scan = 0;
861
 
862
        } else {
863
            Message( "LD: unknown option $_ -- ignored\n" );
864
        }
865
    }
866
 
271 dpurdie 867
#.. Names of programs and components
868
#
869
    my $base = "\$(BINDIR)/${name}";
870
    my $full = $base . $::exe;
871
    my $map  = $base . '.map';
872
    my $ld  =  $base . '.ld';
373 dpurdie 873
    my $dbg =  $base . '.dbg';
271 dpurdie 874
 
227 dpurdie 875
#.. Cleanup rules
876
#
271 dpurdie 877
    ToolsetGenerate( $ld );
878
    ToolsetGenerate( $map );
373 dpurdie 879
    ToolsetGenerate( $dbg );
227 dpurdie 880
 
881
#.. Build rules
882
#
883
    my ($io) = ToolsetPrinter::New();
335 dpurdie 884
    my $dep = $io->SetLdTarget( $name );
227 dpurdie 885
 
271 dpurdie 886
    $io->Prt( "$full : $dep " );
887
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
373 dpurdie 888
    $io->Prt( "\n\t\$(LD)" );
889
    $io->Prt( "\n\t\$(call LDSTRIP,$full,$dbg)\n\n" );
227 dpurdie 890
 
271 dpurdie 891
 
227 dpurdie 892
#.. Linker command file
893
#
894
#       Now the fun part... piecing together a variable $(name_ld)
895
#       which ends up in the command file.
896
#
897
    $io->SetTag( "${name}_ld" );                # macro tag
898
    $io->SetTerm( "\n" );
899
 
900
    $io->Label( "Linker commands", $name );     # label
901
 
902
    $io->Cmd( "-static" ) if ($static);         # Link as a static program
903
 
904
                                                # object list
905
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
906
 
907
    ToolsetLibStd( $pLibs );                    # push standard libraries
908
 
909
                                                # library list
910
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
911
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
912
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
913
 
914
    $io->Newline();
915
 
335 dpurdie 916
    #.. Dependency link,
917
    #   Create a library dependency file
918
    #       Create command file to build applicaton dependency list
919
    #       from the list of dependent libraries
920
    #
921
    #       Create makefile directives to include the dependency
922
    #       list into the makefile.
923
    #
924
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, $base );
925
    $io->LDDEPEND();
271 dpurdie 926
 
927
#.. Package up the program and other artifacts
928
#
929
    PackageProgAddFiles ( $name, $full );
373 dpurdie 930
    PackageProgAddFiles ( $name, $dbg );
271 dpurdie 931
 
227 dpurdie 932
}
933
 
934
 
4700 alewis 935
###############################################################################
936
# Function        : ToolsetPreprocessTests
937
#
938
# Description     : 
939
#
940
# Inputs          : None
941
#
942
# Returns         : Nothing
943
#
944
# Output:         : Rules and recipes to run before unit tests
945
#
946
sub ToolsetPreprocessTests
947
{
948
    my ($io) = ToolsetPrinter::New();
949
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
950
    {
4701 alewis 951
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
952
        my $final=$finaldir . '/lcov-final.info';
953
 
4700 alewis 954
        my $key;
955
        my $value;
956
        while(($key, $value) = each(%::OBJSOURCE))
957
        {
958
            Verbose("$key ==> $value");
959
            $io->Prt("\t" . '$(XX_PRE)rm -f $(OBJDIR)/' . $key . ".gcda\n");
960
        }
4701 alewis 961
        $io->Prt("\t" . '${XX_PRE}$(rm) -f ' . $final . "\n");
4700 alewis 962
        $io->Prt("\t" . '${XX_PRE}lcov'
963
                      . ' --capture'
964
                      . ' --initial'
965
                      . ' --base-directory ' . $::Cwd
966
                      . ' --directory $(OBJDIR)'
967
                      . ' --output-file $(OBJDIR)/lcov-baseline.info' 
968
                      . "\n"); 
969
    }
970
}
971
 
972
 
973
###############################################################################
974
# Function        : ToolsetPostprocessTests
975
#
976
# Description     : 
977
#
978
# Inputs          : None
979
#
980
# Returns         : Nothing
981
#
982
# Output:         : Rules and recipes to run after the unit tests
983
#
984
sub ToolsetPostprocessTests
985
{
986
    my ($io) = ToolsetPrinter::New();
987
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
988
    {
989
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
990
        my $final=$finaldir . '/lcov-final.info';
991
 
992
        $io->Prt("\t" . '$(eval GCDA_COUNT := $(shell find $(OBJDIR) -name "*.gcda"))' . "\n");
993
 
994
        $io->Prt("\t" . '$(XX_PRE)$(mkdir) -p ' . $finaldir . "\n");
995
        $io->Prt("\t" . '$(XX_PRE)if [ "$(GCDA_COUNT)" = "" ]; then' . " \\\n");
996
        $io->Prt("\t\t" . 'if [ ! -e ' . $final . " ]; then \\\n");
997
        $io->Prt("\t\t\t" . '$(cp) $(OBJDIR)/lcov-baseline.info ' . $final . "; \\\n");
998
        $io->Prt("\t\t" . 'else' . " \\\n");
999
        $io->Prt("\t\t\t" . 'lcov'
1000
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1001
                          . ' --add-tracefile ' . $final
1002
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1003
                          . "; \\\n"); 
1004
        $io->Prt("\t\t\t" . '$(rm) -f ' . $final . "; \\\n");
1005
        $io->Prt("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . "; \\\n");
1006
        $io->Prt("\t\t" . 'fi' . "; \\\n");
1007
        $io->Prt("\t" . 'else' . " \\\n");
1008
        $io->Prt("\t\t" . 'lcov'
1009
                        . ' --capture'
1010
                        . ' --base-directory ' . $::Cwd
1011
                        . ' --directory $(OBJDIR)'
1012
                        . ' --output-file $(OBJDIR)/lcov-capture.info' 
1013
                        . "; \\\n"); 
1014
        $io->Prt("\t\t" . 'if [ ! -e ' . $final . " ]; then \\\n");
1015
        $io->Prt("\t\t\t" . 'lcov'
1016
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1017
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
1018
                          . ' --output-file ' .  $final
1019
                          . "; \\\n"); 
1020
        $io->Prt("\t\t" . 'else' . " \\\n");
1021
        $io->Prt("\t\t\t" . 'lcov'
1022
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1023
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
1024
                          . ' --add-tracefile ' . $final
1025
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1026
                          . "; \\\n"); 
1027
        $io->Prt("\t\t\t" . '$(rm) -f ' . $final . "; \\\n");
1028
        $io->Prt("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . "; \\\n");
1029
        $io->Prt("\t\t" . 'fi' . "; \\\n");
1030
        $io->Prt("\t" . 'fi' . " \n");
1031
    }
1032
}
1033
 
1034
 
1035
 
1036
###############################################################################
1037
# Function        : ToolsetCollateTestResults
1038
#
1039
# Description     : 
1040
#
1041
# Inputs          : None
1042
#
1043
# Returns         : Nothing
1044
#
1045
# Output:         : Rules and recipes to run after unit test result 
1046
#                   postprocessing.
1047
#
1048
sub ToolsetCollateTestResults
1049
{
1050
    my ($io) = ToolsetPrinter::New();
1051
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1052
    {
1053
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1054
        my $final=$finaldir . '/lcov-final.info';
1055
 
1056
        my $reportdir='$(PKGDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1057
        my $reportindex=$reportdir . '/index.html';
1058
 
1059
        $io->Prt('collate_test_results: ' . $reportindex . "\n");
1060
        $io->Prt($reportindex . ': ' . $final . "\n");
1061
        $io->Prt("\t" . 'genhtml'
1062
                      . ' --frames'
1063
                      . ' --show-details'
1064
                      . ' --output-directory ' . $reportdir
1065
                      . ' --legend'
1066
                      . ' --demangle-cpp'
1067
                      . ' ' . $final
1068
                      . "\n");
1069
    }
1070
}
1071
 
4701 alewis 1072
 
1073
###############################################################################
1074
#   ToolsetARLINT( $name, \@args, \@objs )
1075
#       This subroutine takes the user options and builds the rules
1076
#       required to lint the static library 'name'.
1077
#
1078
#   Arguments:
1079
#       --xxx                   No arguments currently defined
1080
#
1081
#   Output:
1082
#       [ $(LIBDIR)/name$_lint:   .... ]
1083
#           $(ARLINT)
1084
#
1085
###############################################################################
1086
 
1087
sub ToolsetARLINT
1088
{
1089
    if ( $UseCppcheck )
1090
    {
1091
        CppcheckAR( @_ );
1092
    }
1093
}
1094
 
1095
 
1096
###############################################################################
1097
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
1098
#       This subroutine takes the user options and builds the rules
1099
#       required to lint the shared library 'name'.
1100
#
1101
#   Arguments:
1102
#       (none)
1103
#
1104
#   Output:
1105
#       [ $(LIBDIR)/$name_lint:   .... ]
1106
#           $(SHLIBLINT)
1107
#
1108
###############################################################################
1109
 
1110
sub ToolsetSHLDLINT
1111
{
1112
    if ( $UseCppcheck )
1113
    {
1114
        CppcheckSHLD( @_ );
1115
    }
1116
}
1117
 
1118
 
1119
###############################################################################
1120
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
1121
#       This subroutine takes the user options and builds the rules
1122
#       required to lint the program 'name'.
1123
#
1124
#   Arguments:
1125
#       (none)
1126
#
1127
#   Output:
1128
#       [ $(BINDIR)/$name_lint:   .... ]
1129
#           $(LDLINT)
1130
#
1131
###############################################################################
1132
 
1133
sub ToolsetLDLINT
1134
{
1135
    if ( $UseCppcheck )
1136
    {
1137
        CppcheckLD( @_ );
1138
    }
1139
}
1140
 
227 dpurdie 1141
########################################################################
1142
#
1143
#   Push standard "system" libraries. This is a helper function
1144
#   used within this toolset.
1145
#
1146
#   Arguments:
1147
#       $plib       Reference to library array.
1148
#
1149
########################################################################
1150
 
1151
sub ToolsetLibStd
1152
{
1153
}
1154
 
1155
 
1156
########################################################################
1157
#
1158
#   Generate a linker object recipe.  This is a helper function used 
1159
#   within this toolset.
1160
#
1161
#   Arguments:
1162
#       $io         I/O stream
1163
#
1164
#       $target     Name of the target
1165
#
1166
#       $obj        Library specification
1167
#
1168
########################################################################
1169
 
1170
sub ToolsetObjRecipe
1171
{
1172
    my ($io, $target, $obj) = @_;
1173
 
1174
    $io->Cmd( "\$(strip $obj).$::o" );
1175
}
1176
 
1177
 
1178
###############################################################################
1179
#
1180
#   Parse a linker lib list
1181
#   This is a helper function used within this toolset
1182
#
1183
#   Arguments:
1184
#       $target     Name of the target
1185
#
1186
#       $lib        Library specification
1187
#
1188
#       $tag        Tag (user specified)
1189
#
1190
#       $dp         If building a depend list, the full target name.
1191
#
1192
###############################################################################
1193
 
1194
sub ToolsetLibRecipe
1195
{
1196
    my ($io, $target, $lib, $dp) = @_;
1197
 
1198
    if ( ! defined($dp) ) {                     # linker
1199
        $lib =~ s/^lib//;                       # .. remove leading 'lib'
1200
        $io->Cmd( "-l$lib" );
1201
 
1202
    } else {                                    # depend
1203
        $io->Cmd( "$dp:\t@(vlib2,$lib,GCC_LIB)" );
1204
 
1205
    }
1206
}
1207
 
1208
#.. Successful termination
1209
1;
1210