Subversion Repositories DevTools

Rev

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