Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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