Subversion Repositories DevTools

Rev

Rev 255 | Rev 363 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
########################################################################
2
# Copyright ( C ) 2007 ERG Limited, All rights reserved
3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats build system
8
#
9
# Description   : Provide access to information from the Makefile.gbe file
10
#
11
#                 Designed to be called by utilities that process
12
#                 makefile data.
13
#
14
# Interface     : CreateMakeInfo            - Create MAkefile.gbe
15
#                 ReadMakeInfo              - Read Makefile.gbe
16
#                 TestMachType              - Validate Machine Type
17
#
18
#......................................................................#
19
 
255 dpurdie 20
require 5.006_001;
227 dpurdie 21
use strict;
22
use warnings;
23
 
24
#===============================================================================
25
 
26
 
27
package JatsMakeInfo;
28
 
29
use JatsError;
30
use ConfigurationFile;
31
 
32
# automatically export what we need into namespace of caller.
33
use Exporter();
34
our (@ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK, @EXPORT_BASIC);
35
@ISA         = qw(Exporter);
36
@EXPORT      = qw(  TestMachType
37
                    ReadMakeInfo
38
                    $ScmBuildMachType
39
                    $ScmRoot
40
                    $ScmInterface
41
                );
42
@EXPORT_OK =  qw(
43
                    CreateMakeInfo
44
                    TestMachType
45
                );
46
@EXPORT_BASIC = qw(
47
                    TestMachType
48
                  );
49
 
50
%EXPORT_TAGS = (create => [@EXPORT_OK],
51
                basic  => [@EXPORT_BASIC]);
52
 
53
#-------------------------------------------------------------------------------
54
#   Global variables
55
#
273 dpurdie 56
#our $GBE_HOSTMACH;                          # Current machine type
227 dpurdie 57
our $ScmBuildMachType;                      # from Makefile.gbe
58
our $ScmRoot;                               # Built Root
59
our $ScmInterface;                          # Interface (relative to root)
60
 
61
#-------------------------------------------------------------------------------
62
# Function        : BEGIN
63
#
64
# Description     : Global initialisation
65
#                   Ensure required environment variables are present
66
#
67
# Inputs          : 
68
#
69
# Returns         : 
70
#
71
BEGIN
72
{
273 dpurdie 73
    $::GBE_HOSTMACH = $ENV{ GBE_HOSTMACH };
74
    Error( "Environment Variable 'GBE_HOSTMACH' not defined." )
75
            unless( defined $::GBE_HOSTMACH );
227 dpurdie 76
}
77
 
78
 
79
#-------------------------------------------------------------------------------
80
# Function        : CreateMakeInfo
81
#
82
# Description     : Create the Makefile.gbe file
83
#                   This contains sufficient info to locate:
84
#                       The build root
85
#                       The interface
86
#                   Designed to be required directly into a script
87
#
88
# Inputs          : EnvVars
89
#
90
# Returns         : 
91
#
92
sub CreateMakeInfo
93
{
94
    #
95
    #   Validate globals that are used
96
    #
97
    Error ("JatsMakeInfo - ScmRoot not defined") unless ( $::ScmRoot  );
98
    Error ("JatsMakeInfo - ScmInterface not defined") unless ( $::ScmInterface  );
273 dpurdie 99
    Error ("JatsMakeInfo - GBE_HOSTMACH not defined") unless ( $::GBE_HOSTMACH  );
227 dpurdie 100
 
101
    #
102
    #   Create Makefile.gbe in the current directory
103
    #
104
    my $fh = ConfigurationFile::New( "Makefile.gbe" );
105
    $fh->Header( $::ScmMakelib , 'Make Control Files');
273 dpurdie 106
    $fh->Write("\$ScmBuildMachType = \"$::GBE_HOSTMACH\";\n") ;
227 dpurdie 107
    $fh->Write("\$ScmRoot          = \"$::ScmRoot\";\n") ;
108
    $fh->Write("\$ScmInterface     = \"$::ScmInterface\";\n") ;
109
    $fh->Close();
110
}
111
 
112
 
113
#-------------------------------------------------------------------------------
114
# Function        : ReadMakeInfo
115
#
116
# Description     : Reads in Makefile.gbe data in the current directory
117
#                   This is used to provide basic information including
118
#                   The path to the build root
119
#                   The path to the interface directory
120
#
121
# Inputs          :
122
#
123
# Returns         : Reference to a structure that contains the data
124
#
125
#
126
sub ReadMakeInfo
127
{
128
    #
129
    #   Read in the file
130
    #   Reads some global variables directly into the global variable space
131
    #
132
    my $tag_file = "Makefile.gbe";
133
    Error ("Expected config file not found: $tag_file") unless ( -f $tag_file );
134
    require $tag_file;
135
 
136
    #
137
    #   Sanity tests
138
    #
139
    Error ("Bad Makefile.gbe file. Rebuild required") unless ( $ScmBuildMachType );
140
    TestMachType ( $ScmBuildMachType, "Makefile.gbe" );
141
 
142
}
143
 
144
#-------------------------------------------------------------------------------
145
# Function        : TestMachType
146
#
147
# Description     : Validate the current machine type
148
#
149
# Inputs          : MachType to test
150
#                   Source of test
151
#
152
# Returns         : May not return
153
#
154
sub TestMachType
155
{
156
    my ($MachType, $src) = @_;
157
 
158
    Error ("Incorrect Machine Type in $src",
159
           "The build has been construct for a Machine Type of: $MachType",
273 dpurdie 160
           "Current Machine Type is: $::GBE_HOSTMACH",
161
           ) unless ( $MachType eq $::GBE_HOSTMACH );
227 dpurdie 162
}
163
 
164
#------------------------------------------------------------------------------
165
1;