Subversion Repositories DevTools

Rev

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