| 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
|
| 363 |
dpurdie |
41 |
$ScmBuildFilter
|
| 227 |
dpurdie |
42 |
);
|
|
|
43 |
@EXPORT_OK = qw(
|
|
|
44 |
CreateMakeInfo
|
|
|
45 |
TestMachType
|
|
|
46 |
);
|
|
|
47 |
@EXPORT_BASIC = qw(
|
|
|
48 |
TestMachType
|
|
|
49 |
);
|
|
|
50 |
|
|
|
51 |
%EXPORT_TAGS = (create => [@EXPORT_OK],
|
|
|
52 |
basic => [@EXPORT_BASIC]);
|
|
|
53 |
|
|
|
54 |
#-------------------------------------------------------------------------------
|
|
|
55 |
# Global variables
|
|
|
56 |
#
|
| 273 |
dpurdie |
57 |
#our $GBE_HOSTMACH; # Current machine type
|
| 227 |
dpurdie |
58 |
our $ScmBuildMachType; # from Makefile.gbe
|
|
|
59 |
our $ScmRoot; # Built Root
|
|
|
60 |
our $ScmInterface; # Interface (relative to root)
|
|
|
61 |
|
|
|
62 |
#-------------------------------------------------------------------------------
|
|
|
63 |
# Function : BEGIN
|
|
|
64 |
#
|
|
|
65 |
# Description : Global initialisation
|
|
|
66 |
# Ensure required environment variables are present
|
|
|
67 |
#
|
|
|
68 |
# Inputs :
|
|
|
69 |
#
|
|
|
70 |
# Returns :
|
|
|
71 |
#
|
|
|
72 |
BEGIN
|
|
|
73 |
{
|
| 273 |
dpurdie |
74 |
$::GBE_HOSTMACH = $ENV{ GBE_HOSTMACH };
|
|
|
75 |
Error( "Environment Variable 'GBE_HOSTMACH' not defined." )
|
|
|
76 |
unless( defined $::GBE_HOSTMACH );
|
| 227 |
dpurdie |
77 |
}
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
#-------------------------------------------------------------------------------
|
|
|
81 |
# Function : CreateMakeInfo
|
|
|
82 |
#
|
|
|
83 |
# Description : Create the Makefile.gbe file
|
|
|
84 |
# This contains sufficient info to locate:
|
|
|
85 |
# The build root
|
|
|
86 |
# The interface
|
|
|
87 |
# Designed to be required directly into a script
|
|
|
88 |
#
|
|
|
89 |
# Inputs : EnvVars
|
|
|
90 |
#
|
|
|
91 |
# Returns :
|
|
|
92 |
#
|
|
|
93 |
sub CreateMakeInfo
|
|
|
94 |
{
|
|
|
95 |
#
|
|
|
96 |
# Validate globals that are used
|
|
|
97 |
#
|
|
|
98 |
Error ("JatsMakeInfo - ScmRoot not defined") unless ( $::ScmRoot );
|
|
|
99 |
Error ("JatsMakeInfo - ScmInterface not defined") unless ( $::ScmInterface );
|
| 273 |
dpurdie |
100 |
Error ("JatsMakeInfo - GBE_HOSTMACH not defined") unless ( $::GBE_HOSTMACH );
|
| 227 |
dpurdie |
101 |
|
|
|
102 |
#
|
|
|
103 |
# Create Makefile.gbe in the current directory
|
|
|
104 |
#
|
|
|
105 |
my $fh = ConfigurationFile::New( "Makefile.gbe" );
|
|
|
106 |
$fh->Header( $::ScmMakelib , 'Make Control Files');
|
| 273 |
dpurdie |
107 |
$fh->Write("\$ScmBuildMachType = \"$::GBE_HOSTMACH\";\n") ;
|
| 227 |
dpurdie |
108 |
$fh->Write("\$ScmRoot = \"$::ScmRoot\";\n") ;
|
|
|
109 |
$fh->Write("\$ScmInterface = \"$::ScmInterface\";\n") ;
|
| 363 |
dpurdie |
110 |
$fh->Write("\$ScmBuildFilter = \"$::GBE_BUILDFILTER\";\n") if ($::GBE_BUILDFILTER) ;
|
| 227 |
dpurdie |
111 |
$fh->Close();
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
#-------------------------------------------------------------------------------
|
|
|
116 |
# Function : ReadMakeInfo
|
|
|
117 |
#
|
|
|
118 |
# Description : Reads in Makefile.gbe data in the current directory
|
|
|
119 |
# This is used to provide basic information including
|
|
|
120 |
# The path to the build root
|
|
|
121 |
# The path to the interface directory
|
|
|
122 |
#
|
|
|
123 |
# Inputs :
|
|
|
124 |
#
|
|
|
125 |
# Returns : Reference to a structure that contains the data
|
|
|
126 |
#
|
|
|
127 |
#
|
|
|
128 |
sub ReadMakeInfo
|
|
|
129 |
{
|
|
|
130 |
#
|
|
|
131 |
# Read in the file
|
|
|
132 |
# Reads some global variables directly into the global variable space
|
|
|
133 |
#
|
|
|
134 |
my $tag_file = "Makefile.gbe";
|
|
|
135 |
Error ("Expected config file not found: $tag_file") unless ( -f $tag_file );
|
|
|
136 |
require $tag_file;
|
|
|
137 |
|
|
|
138 |
#
|
|
|
139 |
# Sanity tests
|
|
|
140 |
#
|
|
|
141 |
Error ("Bad Makefile.gbe file. Rebuild required") unless ( $ScmBuildMachType );
|
|
|
142 |
TestMachType ( $ScmBuildMachType, "Makefile.gbe" );
|
|
|
143 |
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
#-------------------------------------------------------------------------------
|
|
|
147 |
# Function : TestMachType
|
|
|
148 |
#
|
|
|
149 |
# Description : Validate the current machine type
|
|
|
150 |
#
|
|
|
151 |
# Inputs : MachType to test
|
|
|
152 |
# Source of test
|
|
|
153 |
#
|
|
|
154 |
# Returns : May not return
|
|
|
155 |
#
|
|
|
156 |
sub TestMachType
|
|
|
157 |
{
|
|
|
158 |
my ($MachType, $src) = @_;
|
|
|
159 |
|
|
|
160 |
Error ("Incorrect Machine Type in $src",
|
|
|
161 |
"The build has been construct for a Machine Type of: $MachType",
|
| 273 |
dpurdie |
162 |
"Current Machine Type is: $::GBE_HOSTMACH",
|
|
|
163 |
) unless ( $MachType eq $::GBE_HOSTMACH );
|
| 227 |
dpurdie |
164 |
}
|
|
|
165 |
|
|
|
166 |
#------------------------------------------------------------------------------
|
|
|
167 |
1;
|