Subversion Repositories DevTools

Rev

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