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