Subversion Repositories DevTools

Rev

Rev 6177 | 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; -*-
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
227 dpurdie 3
#
4
# Module name   : Makelib.pl
5
# Module type   : Makefile system
6
#
7
# Description:
8
#       This modules builds the primary makefile for each directory,
9
#       used in conjunction with Makelib.pl2.  The produced makefile
10
#       acts as a frontend to platform builds.
11
#
12
# Notes:
13
#
14
#                       *** DO NOT DETAB ***
15
#
16
#       Beware the use of space v's tab characters within the
17
#       makefile generation sessions.
18
#
19
#.........................................................................#
20
 
255 dpurdie 21
require 5.006_001;
227 dpurdie 22
use strict;
23
use warnings;
261 dpurdie 24
use Getopt::Long;
263 dpurdie 25
use JatsError;
227 dpurdie 26
use JatsEnv;
27
use JatsMakeInfo qw(:create);
6133 dpurdie 28
use ToolsetFiles;
227 dpurdie 29
 
30
our $MakelibVersion         = "2.33";           # makelib.pl version
31
 
3967 dpurdie 32
our $ScmRoot;
227 dpurdie 33
our $ScmSrcDir              = "";
34
our $ScmMakelib             = "";
35
our @ScmDepends             = ();
36
our $ScmExpert              = 0;
37
our $ScmAll                 = 0;
38
our $ProjectBase            = "";               # Base of the user's project
39
our $ScmInterface           = "interface";
40
 
41
our @SUBDIRS                = ();
42
our @PLATFORMS              = ();
43
our %PLATFORMARGS           = ();
44
our @DEFINES                = "";
45
our @RULES                  = ();
46
 
47
our %PACKAGE_DIST           = ();
48
 
49
our $ROOTMAKEFILE           = 0;
50
our $PLATFORMINCLUDED       = 0;
51
our @BUILDPLATFORMS         = ();
52
 
263 dpurdie 53
our $GBE_CONFIG;
54
our $GBE_TOOLS;
55
our $GBE_PERL;
227 dpurdie 56
 
57
#.. Running under 'buildlib.pl' ?
331 dpurdie 58
#       This will be the 'require .../makelib.pl' that is present in
59
#       the build.pl files. Yes, its overly complicated, but it was
60
#       the way it was done.
227 dpurdie 61
#
62
unless ( $::ScmBuildlib )
63
{
64
    MakeLibInit();
65
}
66
 
67
sub MakeLibInit
68
{
261 dpurdie 69
    #.. Test environment
70
    #
227 dpurdie 71
    EnvImport( "GBE_BIN" );
72
    EnvImport( "GBE_PERL" );
73
    EnvImport( "GBE_TOOLS" );
74
    EnvImport( "GBE_CONFIG" );
75
    EnvImport( "GBE_MACHTYPE" );
76
 
261 dpurdie 77
    #.. Common stuff
78
    #
227 dpurdie 79
    require "$::GBE_TOOLS/common.pl";
80
 
81
    CommonInit( "makelib " );
82
    Debug( "version:   $MakelibVersion" );
83
 
261 dpurdie 84
    #.. Parse command line
85
    #       makefile.pl  rootdir Makelib.pl [options ...]
86
    #
87
    Verbose ("Command Line: @ARGV");
88
    my $opt_help = 0;
89
    my $result = GetOptions (
90
                "help+"         => \$opt_help,
91
                "interface=s"   => \$::ScmInterface,
92
                );
93
 
94
    MLUsage() if ( $opt_help || !$result );
95
 
96
    #
97
    #   Needs 2 command line arguments
98
    #
227 dpurdie 99
    $::ScmRoot    = StripDrive( ${ARGV[0]} );
279 dpurdie 100
    $::ScmRoot    = '/./' if ( $::ScmRoot eq '/'  );    # Prevent leading '//'
227 dpurdie 101
    $::ProjectBase= $::ScmRoot;
102
    $::ScmMakelib = ${ARGV[1]};
103
 
104
    Debug( "ARGV:      @ARGV" );
105
    Debug( "Root:      $::ScmRoot" );
106
    Debug( "Makelib:   $::ScmMakelib" );
107
 
261 dpurdie 108
    #.. Get the stuff from the platform definition file
109
    #
227 dpurdie 110
    ConfigLoad();
111
 
261 dpurdie 112
    #.. Get the stuff from the package definition file
113
    #
227 dpurdie 114
    require "$::ScmRoot/package.pl"
115
        if ( -f "$::ScmRoot/package.pl" );
116
}
117
 
118
#   MLUsage ---
119
#       Makelib command line usage.
120
#..
121
 
122
sub MLUsage
123
{
261 dpurdie 124
    Error ( "Usage: perl makefile.pl <ROOTDIR> <makelib.pl> [options ...]",
125
            "Valid options:",
126
            "   --help            Display Help",
127
            "   --interface=name  Set interface directory",
128
            );
227 dpurdie 129
}
130
 
131
#-------------------------------------------------------------------------------
132
# Function        : SubDir
133
#
134
# Description     : Recurse into the specified sub directories
135
#                   This is one of the very few directives in a 'makefile.pl'
136
#                   that is processed by this script - all the others are
137
#                   processed by makelib.pl2.
138
#
139
#                   This directive MUST appear before the 'Platform' directive
140
#
141
# Inputs          : List of sub directories to visit
142
#
143
# Returns         : Nothing
144
#
145
sub SubDir
146
{
147
    my( @NewDirs );
148
    Debug( "SubDir(@_)" );
149
    Error ("Directive 'SubDir' not allowed in this context") if ( $::ScmBuildlib  );
150
 
151
    #
152
    #   Support different constructs:
153
    #       'dir1 dir2'
154
    #       'dir1','dir2'
155
    #
156
    @NewDirs = map { split /\s+/ } @_;
157
    @NewDirs = grep { defined $_ } @NewDirs;
158
 
159
    foreach my $ThisDir ( @NewDirs )
160
    {
2450 dpurdie 161
        $ThisDir =~ s~/+$~~;
227 dpurdie 162
        Warning ("SubDir contains a '\\' character: $ThisDir" )
163
            if ( $ThisDir =~ m~\\~);
164
 
165
        if ( grep /^$ThisDir$/, @::SUBDIRS )
166
        {
167
            Warning( "Duplicate SubDir '$ThisDir' -- ignored." );
168
            next;
169
        }
170
        if ( ! ( -e $ThisDir and -d $ThisDir ) )
171
        {
172
            Error( "SubDir(): Subdirectory not found: '$ThisDir'",
173
                   "Current directory: $::Cwd" );
174
        }
175
        if ( ! -f $ThisDir . '/makefile.pl' )
176
        {
177
            Error( "SubDir(): makefile.pl not found in subdirectory: '$ThisDir'",
178
                   "Current directory: $::Cwd" );
179
        }
180
 
181
        push(@::SUBDIRS, $ThisDir);
6133 dpurdie 182
        ToolsetFiles::AddDir($ThisDir, 'SubDir');
227 dpurdie 183
    }
184
}
185
 
186
 
187
#-------------------------------------------------------------------------------
188
# Function        : RootMakefile
189
#
190
# Description     : This function is called from buildlib.pl prior to the
191
#                   generation of the root makefile. The Root Makefile is
192
#                   different to the others in this it does not have any platform
193
#                   specific makefiles associated with it. It is simply used to
194
#                   invoke the makefile in the 'src' subdirectory
195
#
196
# Inputs          : None
197
#
198
# Returns         : Nothing
199
#
200
sub RootMakefile
201
{
202
    Error ("Directive 'RootMakefile' not allowed in this context") if ( $::ScmBuildlib  );
203
    $::ROOTMAKEFILE = 1;
204
}
205
 
206
 
207
sub PackageDist
208
{
209
    my( $name, @elements ) = @_;
210
    Error ("Directive 'PackageDist' not allowed in this context") if ( $::ScmBuildlib  );
211
 
212
    foreach ( @elements ) {
213
        HashJoin( \%::PACKAGE_DIST, $;, $name, "$_" );
214
    }
215
}
216
 
217
 
218
sub Define
219
{
220
    Error ("Directive 'Define' not allowed in this context") if ( $::ScmBuildlib  );
221
    push( @::DEFINES, @_ );
222
}
223
 
224
 
225
sub Defines
226
{
227
    my( $path, $script ) = @_;
228
    my( $line );
229
    Error ("Directive 'Defines' not allowed in this context") if ( $::ScmBuildlib  );
230
 
231
    $script = Exists( $path, $script, "Defines" );
285 dpurdie 232
    open( my $fh, '<' ,$script ) ||
227 dpurdie 233
        Error( "cannot open '$script'" );
285 dpurdie 234
    while (<$fh>) {
227 dpurdie 235
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
236
        push( @::DEFINES, $_ );
237
    }
238
    push( @::ScmDepends, "$script" );           # makefile dependencies
285 dpurdie 239
    close( $fh );
227 dpurdie 240
}
241
 
242
 
243
sub Rule
244
{
245
    Error ("Directive 'Rule' not allowed in this context") if ( $::ScmBuildlib  );
246
    push( @::RULES, @_ );
247
}
248
 
249
 
250
sub Rules
251
{
252
    Error ("Directive 'Rules' not allowed in this context") if ( $::ScmBuildlib  );
253
    my( $path, $script ) = @_;
254
    my( $line );
255
 
256
    $script = Exists( $path, $script, "Rules" );
285 dpurdie 257
    open( my $fh, '<' ,$script ) ||
227 dpurdie 258
        Error( "cannot open '$script'" );
285 dpurdie 259
    while (<$fh>) {
227 dpurdie 260
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
261
        push( @::RULES, $_ );
262
    }
263
    push( @::ScmDepends, "$script" );           # makefile dependencies
285 dpurdie 264
    close( $fh );
227 dpurdie 265
}
266
 
267
#-------------------------------------------------------------------------------
268
# Function        : Platform
269
#
270
# Description     : Within "makelib.pl" the Platform directive is processed
271
#                   in such a manner as to trigger the verification and
272
#                   generation of Makefile and xxxxx.mk files in the tree
273
#                   below the makefile.pl
274
#
275
# Inputs          : A list of platforms for which the body of the makefile.pl
276
#                   are to be processed + GBE_PLATFORM
277
#
278
#                   "*", ...            - A wildcard for all platforms
279
#                                         Options include
280
#                                           --Targets (Not Products)
281
#                                           --Products
282
#                                           --NoPlatformBuilds
283
#                                           !xxx - Exclude a platform
284
#
285
#                   "--NoPlatformBuilds"
286
#
287
#                   "xxx"[, "yyy"]*     - A list of platforms and aliases
288
#
289
#                   "!xxx"              - A platform to be excluded
290
#
291
# Returns         :
292
#
293
sub Platform
294
{
295
    my ( @platforms ) = @_;
285 dpurdie 296
    my $exitVal;
297
    my $platform;
227 dpurdie 298
    my $noplatforms = 0;
299
    my $defplatforms = 0;
300
    my %platforms;
301
 
302
    Debug( "Platform(@_)" );
303
    Error ("Directive 'Platform' not allowed in this context") if ( $::ScmBuildlib  );
304
 
305
    #
306
    #   Import user platform specification (GBE_PLATFORM)
307
    #   Note: This is also used by the Makefile and it cannot be
308
    #         alias expanded or sanitised. Its not really really useful
309
    #
367 dpurdie 310
    #   Only use GBE_PLATFORM if the user has not specified to build ALL makefiles.
227 dpurdie 311
    #
312
    my %filter;
313
    my $filter_present = 0;
314
 
315
    if (  $::ScmAll == 0  )
316
    {
239 dpurdie 317
        $filter{GENERIC} = 1;
227 dpurdie 318
        foreach ( split( ' ', $ENV{ "GBE_PLATFORM" } || '' ) )
319
        {
320
            $filter{$_} = 1;
321
            $filter_present = 1;
322
        }
323
    }
324
 
325
    #
326
    #   Expand out the directive platform list (and optional arguments)
327
    #   Expand wildcards and aliases
328
    #
329
    #   Handle format
330
    #       Platform ('*', '--Options', [!Name]);
331
    #       Platform ('--NoPlatformBuilds' );
332
    #       Platform ('Name', '--Options', [!Name] );
333
    #       Platform ('!Name' );
334
    #
335
    #
6276 dpurdie 336
    if ($::ScmNoBuild)
227 dpurdie 337
    {
6276 dpurdie 338
        @platforms = ();                        # zap list
339
        $noplatforms = 1;
340
    }
341
    elsif ( $platforms[0] && $platforms[0] eq '*' )
342
    {
227 dpurdie 343
        my( $targets, $products );              # options
344
        my( @args );
345
        my( @exclude );
346
 
347
        $targets = $products = 0;
348
 
285 dpurdie 349
        foreach ( @platforms ) {
227 dpurdie 350
            next if ( /^\*$/);
351
            next if ( /^--Targets$/ && ($targets = 1));
352
            next if ( /^--Products$/ && ($products = 1));
353
            next if ( /^--NoPlatformBuilds/ && ($noplatforms = 1));
354
            next if ( /^--/ && push @args, $_ );
355
            next if ( /^!/  && push @exclude, $_ );
356
            Warning( "Platform: unknown option $_ -- ignored\n" );
357
        }
358
 
359
        #
360
        #   Determine the list of platforms to expand the '*' into
361
        #   The result may be modified by optional arguments
362
        #       --Targets           # Expands to all targets
363
        #       --Products          # Expands to all products
364
        #       OtherWise           # Expands to all build platforms
365
        #
366
        @platforms = ();                        # zap list
367
 
368
                                                # 'all' platforms
369
        push( @platforms, @::DEFBUILDPLATFORMS )
370
            unless ( $targets | $products );
371
 
372
        #
373
        #   Expand the '*' into a list of platforms that are NOT products
374
        #
369 dpurdie 375
        if ( $targets && ( %::ScmBuildPlatforms ) )
227 dpurdie 376
        {                                       # targets
377
            foreach my $key (keys %::ScmBuildPlatforms) {
378
                push( @platforms, $key )
369 dpurdie 379
                    if (! ( %::ScmBuildProducts ) ||
227 dpurdie 380
                            ! scalar $::ScmBuildProducts{ $key } );
381
            }
382
        }
383
 
384
        #
385
        #   Expand the '*' into a list of platforms that are 'products'
386
        #
369 dpurdie 387
        if ( $products && ( %::ScmBuildProducts ) )
227 dpurdie 388
        {                                       # products
389
            foreach my $key (keys %::ScmBuildProducts) {
390
                push( @platforms, $key );
391
            }
392
        }
393
 
394
        #
395
        #   Distribute arguments over all expanded platforms
396
        #
397
        if ( @args )
398
        {
399
            my @baseplatforms;
400
            foreach  ( @platforms )
401
            {
402
                push @baseplatforms, $_, @args;
403
            }
404
            @platforms = @baseplatforms;
405
        }
406
 
407
        #
408
        #   Place the excluded platforms at the end of the list
409
        #
410
        push @platforms, ExpandPlatforms( @exclude );
411
 
412
    }
413
    elsif ( scalar @platforms == 1 && $platforms[0] eq "--NoPlatformBuilds" )
414
    {                                           # short-cut
415
        $noplatforms = 1;
416
        @platforms = @::DEFBUILDPLATFORMS;
417
    }
418
    else
419
    {                                           # aliasing
420
        @platforms = ExpandPlatforms( @platforms );
421
        #
422
        #   Process excluded platform lists
423
        #   Migrate excluded platforms to the end of the list
424
        #
425
        my (@include, @exclude);
426
 
427
        foreach ( @platforms )
428
        {
429
            next if ( m/^!/ && push @exclude, $_ );
430
            push @include, $_;
431
        }
432
 
433
        #
434
        #   If no included platforms have been found then assume that the
435
        #   list is an exclusion list and seed the platform list with
436
        #   a set of defualt platforms - like '*'
437
        #
438
        #
439
        @include = @::DEFBUILDPLATFORMS unless @include;
440
        @platforms = ( @include, @exclude );
441
    }
442
 
443
    $platform = "";                             # current platform
444
 
445
    #
446
    #   Process the directives expanded list of platforms
447
    #
448
 
449
    #
450
    #   Generate a HASH of lowercase known platform names
451
    #   This will be used to quickly validate platform names
452
    #
453
    my %lc_platforms;
454
    foreach  ( @::BUILDPLATFORMS )
455
    {
456
        $lc_platforms{ lc($_) } = $_;
457
    }
458
 
459
FILTER:
460
    foreach $_ ( @platforms )
461
    {
462
        if ( ! /^--(.*)/ )
463
        {
464
            $_ =~ s/^\s*//g;                    # leading white space
465
            $_ =~ s/\s*(\n|$)//;                # trailing white space
466
 
467
 
468
            #
469
            #   Remove specific platforms from the list
470
            #
471
            $defplatforms = 1;
472
            if ( m/!(.*)/ )
473
            {
474
                Verbose( "Excluded platform removed: $1" );
475
                delete $platforms{$1};
476
                next FILTER;
477
            }
478
 
479
 
480
            if ( exists $platforms{$_}  )
481
            {
482
                Warning( "duplicate platform '$_' -- ignored." );
483
                $platform = "";
484
                next FILTER;
485
            }
486
 
487
            #
488
            #   validate 'platform'
489
            #   Allow the user to have a bad case match ( Fred == fred == FRED )
490
            #
491
            my $lc_platform = lc($_);
492
            unless ( exists( $lc_platforms{$lc_platform}  ) )
493
            {
494
                Warning( "Platform '$_' not contained within BuildPlatforms -- ignored." )
6276 dpurdie 495
                    unless ( exists( $::ScmBuildMatrix{$_} ));
227 dpurdie 496
                $platform = "";
497
                next FILTER;
498
            }
499
 
500
            $lc_platform = $lc_platforms{$lc_platform};
501
            if ( $_ ne $lc_platform )
502
            {
503
                Warning( "Mixed case usage of platform '$_' -- corrected." );
504
                $_ = $lc_platform;
505
            }
506
 
507
                                                # filter 'platform'
508
            if ( $filter_present  )
509
            {
510
                if ( ! exists $filter{$_} )
511
                {
512
                    Verbose( "GBE_PLATFORM override $_ -- ignored" );
513
                    $platform = "";
514
                    next FILTER;
515
                }
516
            }
517
 
518
            #
519
            #   Platform not filtered out - must be using it.
520
            #
521
            Verbose( "Platform ... $_" );
522
            $platforms{$_} = 1;                 # Add to platform list
523
            $platform = $_;                     # new platform
524
        }
525
 
526
        elsif ( /^--NoPlatformBuilds$/ )
527
        {
528
            $noplatforms = 1;
529
        }
530
 
531
        elsif ( $platform ne "" )
532
        {                                       # other arguments
533
            Verbose( "          .. $_" );
534
 
535
            HashUniqueJoin( \%::PLATFORMARGS, $; , $platform, $1 ) ||
536
                Warning( "Duplicate argument '$platform=$_' -- ignored." );
537
        }
538
    }
539
    #
540
    #   Sort the platforms to ensure that the ordering is consistient throughout
541
    #
542
    @::PLATFORMS = sort keys %platforms;
543
 
544
    #
545
    #   Trap makefiles that don't have any platforms
546
    #   The user 'should' mark these as --NoPlatformBuilds
547
    #
548
    unless ( @::PLATFORMS )
549
    {
550
        Warning( "No platform definitions." )
551
            unless( $noplatforms || $defplatforms);
552
        $noplatforms = 1;
553
    }
554
 
555
#.. Common rules
556
#
557
    my( $file ) = Require( "$::GBE_CONFIG", "Rules", "Common rules " );
558
    push( @::ScmDepends, "$file" );
559
 
560
 
561
#.. Generate primary makefile
562
#
367 dpurdie 563
    $exitVal = Generate( $noplatforms || $::ROOTMAKEFILE );
564
    if ($::ROOTMAKEFILE == 1)
565
    {
566
        Warning ("WARNING: Problem generating Makefile ($exitVal)")
261 dpurdie 567
            if ($exitVal);
227 dpurdie 568
        return ($exitVal);
569
    }
570
 
367 dpurdie 571
    #
572
    #   Not creating the ROOT Makefile
573
    #   Exit the phase. All the work has been done
574
    #
227 dpurdie 575
    Debug( "Platform ExitVal:   $exitVal" );
576
    exit( $exitVal );
577
}
578
 
579
###############################################################################
580
# Private function section.
581
#       The following functions are used INTERNALLY by makelib.pl.
582
#
583
###############################################################################
584
 
585
#-------------------------------------------------------------------------------
586
# Function        : Generate
587
#
588
# Description     : Build makefiles ...
589
#                   Creates the command data files and the per-target .MK files
590
#
591
# Inputs          : $noplatforms    - 1 if this makefile does not have
367 dpurdie 592
#                                       any platforms. Also set for ROOTMAKEFILE
227 dpurdie 593
#
594
# Returns         : $exitVal
595
#
596
sub Generate
597
{
598
    my( $noplatforms ) = @_;
367 dpurdie 599
    my $exitVal = 0;
227 dpurdie 600
 
367 dpurdie 601
    #.. Build all the per-taget makefiles, if any exist
227 dpurdie 602
    #
603
    $exitVal = GeneratePlatforms()
604
        unless ($noplatforms );
605
 
367 dpurdie 606
    #.. Build the common Makefile.gbe
607
    #
227 dpurdie 608
    GenerateMakefile( $noplatforms );
609
    return $exitVal;
610
}
611
 
367 dpurdie 612
#-------------------------------------------------------------------------------
613
# Function        : GeneratePlatforms
227 dpurdie 614
#
367 dpurdie 615
# Description     : Generate all the per-taget makefiles
616
#                   Create all .mk files in the current directory
227 dpurdie 617
#
367 dpurdie 618
#                   Cleanup of unused .mk files is done when the WriteCommonInfo
619
#                   is processed. Makefiles that are no longer used will be purged
6133 dpurdie 620
#                   
621
#                   Invoke makelib.pl2 as
622
#                       perl makefile.pl <root> makelib.pl2 <platform> <interface>
227 dpurdie 623
#
367 dpurdie 624
# Inputs          : None
625
#
626
# Returns         : exitVal
627
#
227 dpurdie 628
sub GeneratePlatforms
629
{
367 dpurdie 630
    my  $exitVal = 0;
631
    my  $exitVal2;
227 dpurdie 632
 
633
    foreach my $platform ( @::PLATFORMS )
634
    {
261 dpurdie 635
        my @CmdLine;
636
        push @CmdLine, $::GBE_PERL, $0, $::ScmRoot;
637
        push @CmdLine, $::ScmMakelib . "2";
638
        push @CmdLine, $platform;
639
        push @CmdLine, "--interface=$::ScmInterface" if ( $::ScmInterface ne "" );
227 dpurdie 640
 
641
        #
642
        #   Insert platform local arguments
643
        #
644
        if ($::PLATFORMARGS{ $platform })
645
        {
261 dpurdie 646
            foreach my $arg (split( /$;/, $::PLATFORMARGS{ $platform } )) {
647
                push @CmdLine,"--arg=$arg";
227 dpurdie 648
            }
649
        }
650
 
261 dpurdie 651
        #
652
        #   Invoke the command
653
        #   Don't use a Shell. Don't need the overhead
654
        #
655
        $exitVal2 = System( '--NoShell', @CmdLine );
227 dpurdie 656
 
261 dpurdie 657
        #
658
        #   Warn on any error
367 dpurdie 659
        #   Overall return code will be set if any platform fails, but we
660
        #   will process all of them first
261 dpurdie 661
        #
662
        if ( $exitVal2 )
663
        {
664
            Warning ("Problem generating $platform.mk in $::Cwd ($exitVal2)");
227 dpurdie 665
            $exitVal = $exitVal2;
666
        }
667
    }
668
 
669
    return $exitVal;
670
}
671
 
672
#-------------------------------------------------------------------------------
673
# Function        : GenerateMakefile
674
#
675
# Description     : Generate the non-platform specific makefile
676
#                   Once upon a time this was a real makefile
4781 dpurdie 677
#                   Now its a simple file and a database as this offers greater
227 dpurdie 678
#                   flexability.
679
#
680
#                   The file, "Makefile.gbe" contains enough info to get to the
681
#                   interface directory.
682
#
683
#                   The "database" is held in the interface directory as
684
#                       Makfile.cfg     - index to locate Makefile_nn.cfg
685
#                       Makefile_nn.cfg - data from a makefile.pl
686
#
687
# Inputs          : $noplatforms        - 1: no platform makefiles in this dir
688
#
689
# Returns         : Nothing
690
#
691
sub GenerateMakefile
692
{
693
    my( $noplatforms ) = @_;
694
    my %platform_info;
695
 
696
    #
697
    #   Determine targets that are limited to either debug or production builds
698
    #   This information may come from several places
699
    #
700
    foreach my $key ( @PLATFORMS )
701
    {
702
        my @args;
703
        UniquePush (\@args, split ( /$;/, $::PLATFORMARGS{$key} ))
704
            if ($::PLATFORMARGS{$key});
705
 
706
        UniquePush (\@args, map { s/^--//; $_} split ( /$;/, $::ScmBuildPlatforms{$key} ))
707
            if($::ScmBuildPlatforms{$key});
708
 
709
        my $hasOnlyProd  =  grep /^OnlyProd/, @args;
710
        my $hasOnlyDebug =  grep /^OnlyDebug/, @args;
711
 
712
        if ( $hasOnlyProd && $hasOnlyDebug )
713
        {
714
            Warning ("Target \"$key\" has both OnlyDebug and OnlyProd options",
715
                     "Both options ignored. Target will be built" );
716
 
717
            $hasOnlyProd = $hasOnlyDebug = 0;
718
        }
719
        $platform_info{$key}{prod}  = 1 unless $hasOnlyDebug;
720
        $platform_info{$key}{debug} = 1 unless $hasOnlyProd;
721
    }
722
 
723
    #
724
    #   Update common information in the Makefile_x.cfg file
725
    #
726
    WriteCommonInfo( \@::SUBDIRS, \%platform_info, $noplatforms, $::ROOTMAKEFILE );
727
 
728
    #
729
    #.. Maintain local information in Makefile.gbe
730
    #   This allows us to locate the interface directory
731
    #
732
    Message "[Control] $::Cwd";
733
    CreateMakeInfo();
734
}
735
 
736
1;
737