######################################################################## # Copyright ( C ) 2007 ERG Limited, All rights reserved # # Module name : jats.sh # Module type : Makefile system # Compiler(s) : n/a # Environment(s): jats build system # # Description : Provide access to information from the Makefile.gbe file # # Designed to be called by utilities that process # makefile data. # # Interface : CreateMakeInfo - Create MAkefile.gbe # ReadMakeInfo - Read Makefile.gbe # TestMachType - Validate Machine Type # #......................................................................# require 5.006_001; use strict; use warnings; #=============================================================================== package JatsMakeInfo; use JatsError; use ConfigurationFile; # automatically export what we need into namespace of caller. use Exporter(); our (@ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK, @EXPORT_BASIC); @ISA = qw(Exporter); @EXPORT = qw( TestMachType ReadMakeInfo $ScmBuildMachType $ScmRoot $ScmInterface $ScmBuildFilter ); @EXPORT_OK = qw( CreateMakeInfo TestMachType ); @EXPORT_BASIC = qw( TestMachType ); %EXPORT_TAGS = (create => [@EXPORT_OK], basic => [@EXPORT_BASIC]); #------------------------------------------------------------------------------- # Global variables # #our $GBE_HOSTMACH; # Current machine type our $ScmBuildMachType; # from Makefile.gbe our $ScmRoot; # Built Root our $ScmInterface; # Interface (relative to root) #------------------------------------------------------------------------------- # Function : BEGIN # # Description : Global initialisation # Ensure required environment variables are present # # Inputs : # # Returns : # BEGIN { $::GBE_HOSTMACH = $ENV{ GBE_HOSTMACH }; Error( "Environment Variable 'GBE_HOSTMACH' not defined." ) unless( defined $::GBE_HOSTMACH ); } #------------------------------------------------------------------------------- # Function : CreateMakeInfo # # Description : Create the Makefile.gbe file # This contains sufficient info to locate: # The build root # The interface # Designed to be required directly into a script # # Inputs : EnvVars # # Returns : # sub CreateMakeInfo { # # Validate globals that are used # Error ("JatsMakeInfo - ScmRoot not defined") unless ( $::ScmRoot ); Error ("JatsMakeInfo - ScmInterface not defined") unless ( $::ScmInterface ); Error ("JatsMakeInfo - GBE_HOSTMACH not defined") unless ( $::GBE_HOSTMACH ); # # Create Makefile.gbe in the current directory # my $fh = ConfigurationFile::New( "Makefile.gbe" ); $fh->Header( $::ScmMakelib , 'Make Control Files'); $fh->Write("\$ScmBuildMachType = \"$::GBE_HOSTMACH\";\n") ; $fh->Write("\$ScmRoot = \"$::ScmRoot\";\n") ; $fh->Write("\$ScmInterface = \"$::ScmInterface\";\n") ; $fh->Write("\$ScmBuildFilter = \"$::GBE_BUILDFILTER\";\n") if ($::GBE_BUILDFILTER) ; $fh->Close(); ::ToolsetFile ("Makefile.gbe"); } #------------------------------------------------------------------------------- # Function : ReadMakeInfo # # Description : Reads in Makefile.gbe data in the current directory # This is used to provide basic information including # The path to the build root # The path to the interface directory # # Inputs : # # Returns : Reference to a structure that contains the data # # sub ReadMakeInfo { # # Read in the file # Reads some global variables directly into the global variable space # my $tag_file = "Makefile.gbe"; Error ("Expected config file not found: $tag_file") unless ( -f $tag_file ); require $tag_file; # # Sanity tests # Error ("Bad Makefile.gbe file. Rebuild required") unless ( $ScmBuildMachType ); TestMachType ( $ScmBuildMachType, "Makefile.gbe" ); } #------------------------------------------------------------------------------- # Function : TestMachType # # Description : Validate the current machine type # # Inputs : MachType to test # Source of test # # Returns : May not return # sub TestMachType { my ($MachType, $src) = @_; Error ("Incorrect Machine Type in $src", "The build has been construct for a Machine Type of: $MachType", "Current Machine Type is: $::GBE_HOSTMACH", ) unless ( $MachType eq $::GBE_HOSTMACH ); } #------------------------------------------------------------------------------ 1;