Subversion Repositories DevTools

Rev

Rev 255 | Rev 263 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 255 Rev 261
Line 19... Line 19...
19
#.........................................................................#
19
#.........................................................................#
20
 
20
 
21
require 5.006_001;
21
require 5.006_001;
22
use strict;
22
use strict;
23
use warnings;
23
use warnings;
-
 
24
use Getopt::Long;
24
use JatsEnv;
25
use JatsEnv;
25
use JatsMakeInfo qw(:create);
26
use JatsMakeInfo qw(:create);
26
 
27
 
27
our $MakelibVersion         = "2.33";           # makelib.pl version
28
our $MakelibVersion         = "2.33";           # makelib.pl version
28
 
29
 
29
our $Generated              = 10;               # Generated error code ..
-
 
30
 
-
 
31
our $ScmRoot                = "";
30
our $ScmRoot                = "";
32
our $ScmSrcDir              = "";
31
our $ScmSrcDir              = "";
33
our $ScmMakelib             = "";
32
our $ScmMakelib             = "";
34
our @ScmDepends             = ();
33
our @ScmDepends             = ();
35
our $ScmForce               = 0;
-
 
36
our $ScmExpert              = 0;
34
our $ScmExpert              = 0;
37
our $ScmAll                 = 0;
35
our $ScmAll                 = 0;
38
our $ProjectBase            = "";               # Base of the user's project
36
our $ProjectBase            = "";               # Base of the user's project
39
our $ScmInterface           = "interface";
37
our $ScmInterface           = "interface";
40
 
38
 
Line 60... Line 58...
60
 
58
 
61
sub MakeLibInit
59
sub MakeLibInit
62
{
60
{
63
    my ( $argc );                               # argument count
61
    my ( $argc );                               # argument count
64
 
62
 
65
#.. Test environment
63
    #.. Test environment
66
#
64
    #
67
    EnvImport( "GBE_BIN" );
65
    EnvImport( "GBE_BIN" );
68
    EnvImport( "GBE_PERL" );
66
    EnvImport( "GBE_PERL" );
69
    EnvImport( "GBE_TOOLS" );
67
    EnvImport( "GBE_TOOLS" );
70
    EnvImport( "GBE_CONFIG" );
68
    EnvImport( "GBE_CONFIG" );
71
    EnvImport( "GBE_MACHTYPE" );
69
    EnvImport( "GBE_MACHTYPE" );
72
 
70
 
73
#.. Common stuff
71
    #.. Common stuff
74
#
72
    #
75
    require "$::GBE_TOOLS/common.pl";
73
    require "$::GBE_TOOLS/common.pl";
76
 
74
 
77
    CommonInit( "makelib " );
75
    CommonInit( "makelib " );
78
    Debug( "version:   $MakelibVersion" );
76
    Debug( "version:   $MakelibVersion" );
79
 
77
 
80
#.. Parse command line
78
    #.. Parse command line
81
#       makefile.pl  rootdir Makelib.pl [options ...]
79
    #       makefile.pl  rootdir Makelib.pl [options ...]
-
 
80
    #
-
 
81
    Verbose ("Command Line: @ARGV");
-
 
82
    my $opt_help = 0;
-
 
83
    my $result = GetOptions (
-
 
84
                "help+"         => \$opt_help,
-
 
85
                "interface=s"   => \$::ScmInterface,
-
 
86
                );
-
 
87
 
-
 
88
    MLUsage() if ( $opt_help || !$result );
82
#
89
 
-
 
90
    #
-
 
91
    #   Needs 2 command line arguments
-
 
92
    #
83
    $::ScmRoot    = StripDrive( ${ARGV[0]} );
93
    $::ScmRoot    = StripDrive( ${ARGV[0]} );
84
    $::ProjectBase= $::ScmRoot;
94
    $::ProjectBase= $::ScmRoot;
85
    $::ScmMakelib = ${ARGV[1]};
95
    $::ScmMakelib = ${ARGV[1]};
86
 
96
 
87
    Debug( "ARGV:      @ARGV" );
97
    Debug( "ARGV:      @ARGV" );
88
    Debug( "Root:      $::ScmRoot" );
98
    Debug( "Root:      $::ScmRoot" );
89
    Debug( "Makelib:   $::ScmMakelib" );
99
    Debug( "Makelib:   $::ScmMakelib" );
90
 
100
 
91
    $argc = 2;
-
 
92
    while ($_ = $ARGV[ $argc++ ])
-
 
93
    {
-
 
94
        last if ( ! /^-/ );                     # end of options
-
 
95
 
-
 
96
        Debug( "option:    $_" );
-
 
97
 
-
 
98
        /^-h$|^-help$|^--help$|^--usage$|^-?$/ && MLUsage();
-
 
99
 
-
 
100
                                                # long arguments
-
 
101
        if (/^--interface=(.*)/) {
-
 
102
            $::ScmInterface = $1;
-
 
103
            Debug( "Interface: $::ScmInterface" );
-
 
104
            next;
-
 
105
        }
-
 
106
 
-
 
107
        if (/^--expert(.*)/) {
-
 
108
            if ($1) {
-
 
109
                $::ScmExpert = $1;
-
 
110
            } else {
-
 
111
                $::ScmExpert = 1;
-
 
112
            }
-
 
113
            Debug( "Expert:    $::ScmExpert" );
-
 
114
            next;
-
 
115
        }
-
 
116
 
-
 
117
        if (/^--all/) {
-
 
118
            $::ScmAll = 1;
-
 
119
            Debug( "All:       $::ScmAll" );
-
 
120
            next;
-
 
121
        }
-
 
122
 
-
 
123
        last if (/^--$/);                       # end of arguments
-
 
124
 
-
 
125
        if (/^-D(.*)/) {
-
 
126
            if ($1) {
-
 
127
                $::ScmDebug = $1;
-
 
128
            } else {
-
 
129
                $::ScmDebug = $ARGV[0];
-
 
130
                $argc++;
-
 
131
            }
-
 
132
            Debug( "ScmDebug:  $::ScmDebug" );
-
 
133
            next;
-
 
134
        }
-
 
135
 
-
 
136
        next if (/^-V/ && ($::ScmVerbose = 1));
-
 
137
 
-
 
138
        next if (/^-F/ && ($::ScmForce   = 1));
-
 
139
 
-
 
140
        if (/^-.*/) {                           # unknown option
-
 
141
            MLUsage( "unknown option '$_'\n\n" );
-
 
142
        }
-
 
143
    }
-
 
144
 
-
 
145
 
-
 
146
#.. Get the stuff from the platform definition file
101
    #.. Get the stuff from the platform definition file
147
#
102
    #
148
    ConfigLoad();
103
    ConfigLoad();
149
 
104
 
150
#.. Get the stuff from the package definition file
105
    #.. Get the stuff from the package definition file
151
#
106
    #
152
    require "$::ScmRoot/package.pl"
107
    require "$::ScmRoot/package.pl"
153
        if ( -f "$::ScmRoot/package.pl" );
108
        if ( -f "$::ScmRoot/package.pl" );
154
}
109
}
155
 
110
 
156
#   MLUsage ---
111
#   MLUsage ---
157
#       Makelib command line usage.
112
#       Makelib command line usage.
158
#..
113
#..
159
 
114
 
160
sub MLUsage
115
sub MLUsage
161
{
116
{
162
    my( $msg ) = @_;
-
 
163
 
-
 
164
    print "makefile $msg\n\n"
-
 
165
        if ( $msg ne "" );
-
 
166
 
-
 
167
    print "Usage: perl makefile.pl <ROOTDIR> <Makelib.pl> [options]\n
117
    Error ( "Usage: perl makefile.pl <ROOTDIR> <makelib.pl> [options ...]",
168
Valid options:
118
            "Valid options:",
169
\t-V                Verbose mode.
119
            "   --help            Display Help",
170
\t-D<debug-level>   Set the debug level.
-
 
171
\t                  except all SCM support files are removed (eg CVS).
120
            "   --interface=name  Set interface directory",
172
\n";
-
 
173
    exit(42);
121
            );
174
}
122
}
175
 
123
 
176
#-------------------------------------------------------------------------------
124
#-------------------------------------------------------------------------------
177
# Function        : SubDir
125
# Function        : SubDir
178
#
126
#
Line 599... Line 547...
599
#.. Generate primary makefile
547
#.. Generate primary makefile
600
#
548
#
601
    $exitVal = Generate( $noplatforms );
549
    $exitVal = Generate( $noplatforms );
602
    if ($::ROOTMAKEFILE == 1) {
550
    if ($::ROOTMAKEFILE == 1) {
603
        print STDERR "WARNING: problem generating Makefile ($exitVal)\n"
551
        print STDERR "WARNING: problem generating Makefile ($exitVal)\n"
604
            unless (($exitVal == $::Generated) || ($exitVal == 0));
552
            if ($exitVal);
605
        return ($exitVal);
553
        return ($exitVal);
606
    }
554
    }
607
 
555
 
608
    Debug( "Platform ExitVal:   $exitVal" );
556
    Debug( "Platform ExitVal:   $exitVal" );
609
    exit( $exitVal );
557
    exit( $exitVal );
Line 640... Line 588...
640
    #
588
    #
641
    $exitVal = GeneratePlatforms()
589
    $exitVal = GeneratePlatforms()
642
        unless ($noplatforms );
590
        unless ($noplatforms );
643
 
591
 
644
    GenerateMakefile( $noplatforms );
592
    GenerateMakefile( $noplatforms );
645
    $exitVal = $::Generated if ( $exitVal == 0);
-
 
646
 
-
 
647
    return $exitVal;
593
    return $exitVal;
648
}
594
}
649
 
595
 
650
 
596
 
651
#
597
#
Line 659... Line 605...
659
{
605
{
660
    my( $exitVal, $exitVal2 ) = 0;
606
    my( $exitVal, $exitVal2 ) = 0;
661
 
607
 
662
    foreach my $platform ( @::PLATFORMS )
608
    foreach my $platform ( @::PLATFORMS )
663
    {
609
    {
-
 
610
        my @CmdLine;
664
        my( $Cmdline ) = "$::GBE_PERL $0 $::ScmRoot " . $::ScmMakelib . "2" . " $platform";
611
        push @CmdLine, $::GBE_PERL, $0, $::ScmRoot;
665
 
-
 
666
        $Cmdline .= " --interface=$::ScmInterface"
612
        push @CmdLine, $::ScmMakelib . "2";
-
 
613
        push @CmdLine, $platform;
667
            if ( $::ScmInterface ne "" );
614
        push @CmdLine, "--interface=$::ScmInterface" if ( $::ScmInterface ne "" );
668
 
615
 
669
        #
616
        #
670
        #   Insert platform local arguments
617
        #   Insert platform local arguments
671
        #
618
        #
672
        if ($::PLATFORMARGS{ $platform })
619
        if ($::PLATFORMARGS{ $platform })
673
        {
620
        {
674
            my( @args ) = split( /$;/, $::PLATFORMARGS{ $platform } );
621
            foreach my $arg (split( /$;/, $::PLATFORMARGS{ $platform } )) {
675
            foreach my $arg (@args) {
-
 
676
                $Cmdline .= " --arg=$arg";
622
                push @CmdLine,"--arg=$arg";
677
            }
623
            }
678
        }
624
        }
679
 
625
 
680
        $Cmdline .= " --expert"
626
        #
681
            if ( $::ScmExpert );
627
        #   Invoke the command
682
 
-
 
683
        $Cmdline .= " --all"
628
        #   Don't use a Shell. Don't need the overhead
684
            if ( $::ScmAll );
629
        #
685
 
-
 
686
        $exitVal2 = System( $Cmdline );
630
        $exitVal2 = System( '--NoShell', @CmdLine );
687
 
-
 
688
        Warning ("Problem generating $platform.mk in $::Cwd ($exitVal2)")
-
 
689
            unless (($exitVal2 == $::Generated) || ($exitVal2 == 0));
-
 
690
 
631
 
-
 
632
        #
-
 
633
        #   Warn on any error
-
 
634
        #   Overall return code will be set if any platform fails
-
 
635
        #
691
        if ($exitVal == 0) {
636
        if ( $exitVal2 )
-
 
637
        {
-
 
638
            Warning ("Problem generating $platform.mk in $::Cwd ($exitVal2)");
692
            $exitVal = $exitVal2;
639
            $exitVal = $exitVal2;
693
        } elsif ($exitVal == $::Generated) {
-
 
694
            $exitVal = $exitVal2
-
 
695
                if ($exitVal2);
-
 
696
        }
640
        }
697
    }
641
    }
698
 
642
 
699
    return $exitVal;
643
    return $exitVal;
700
}
644
}