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