Subversion Repositories DevTools

Rev

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

###############################################################################
# Copyright (c) ERG Transit Systems. 1996-2006
#
# File:         PLATFORM/SOLARIS.cfg
#
# Contents:     SOLARIS Build support
#
#               This package is used during the processing of the build.pl file
#               Values provided by this package are used to extend the Platform
#               information as platforms are being created. This provides a
#               powerful set of mechanism to extend the entire JATS toolset
#
#
# Version   Who      Date       Description
#           DDP      01-Aug-06  Created
###############################################################################

use strict;
use warnings;

package SOLARIS_Build;
use JatsError;
use Storable qw(dclone);

#
#   Create a hash of GBE_MACHTYPEs for which the SOLARIS platform is available
#   It won't just build on any only machine
#
#   Hash values are an array of:
#           Operating System
#           architecture
#
my %valid_machines = (
    'sparc'             => [ 'SOLARIS8' , 'sparc' ],
    'solaris10_sparc32' => [ 'SOLARIS10', 'sparc' ],
    'solaris10_sparc64' => [ 'SOLARIS10', 'sparc' ],
    'solaris10_x86'     => [ 'SOLARIS10', 'amd' ],
    'solaris10_x64'     => [ 'SOLARIS10', 'amd' ],
);

my %arch_to_name = (
    'sparc' => { '32' => 'sparc32', '64' => 'sparc64' },
    'amd'   => { '32' => 'x86'    , '64' => 'x64' },
);

#-------------------------------------------------------------------------------
# Function        : new_platform
#
# Description     : Called when a new platform is being created
#                   The function can extend the build information
#
#                   The 'SOLARIS' platform will be converted into a 'suitable'
#                   platform for the current machine.
#
#                   There a few legacy issues to contend with.
#
# Inputs          : $pInfo          - Reference to the platform build info hash
#
# Returns         : Nothing yet
#

sub new_platform
{
    my $class = shift;              # Not really a class, but its called like a class
    my $pInfo  = shift;

    #
    #   Ignore this platform if there is no way that it can be built on the
    #   current machine.
    #
    my $entry = $valid_machines{$::GBE_MACHTYPE};
    unless ( $entry )
    {
        Verbose ("SOLARIS will not build on this machine type: $::GBE_MACHTYPE");
        $pInfo->{NOT_AVAILABLE} = 1;
        return;
    }

    #-------------------------------------------------------------------------------
    #
    #   Determine the type of system we are dealing with the GBE_MACHTYPE
    #   is the only real way of doing this
    #
    if ( $::GBE_MACHTYPE eq 'sparc' )
    {

        #
        #   Provide an alais for the name that we would really like to call
        #   this platform.
        #
        $pInfo->{ALIAS} = 'SOLARIS8_SPARC32';

        #
        #   Legacy target. Really solaris8_sparc32, but it has been configured
        #   as SOLARIS. This, unfortunately, must continue.
        #
        $pInfo->{TARGET} = 'SOLARIS';

        #
        #   Specify the hardware family
        #   Will be used to create an ALIAS
        #
        $pInfo->{HARDWARE} = 'SPARC';
        return;
    }

    #
    #   Not building for the legacy :)
    #   Generate a 32-bit and a 64-bit build target
    #

    my $os   = $entry->[0];
    my $arch = $entry->[1];

    SOLARIS_generic(  dclone($pInfo), $os, $arch, '32' );
    SOLARIS_generic(  dclone($pInfo), $os, $arch, '64' );

    #
    #   All done
    #   Mark the original entry as a TEMPLATE so that it won't be added
    #   We have cloned two copies of SOLARIS
    #
    $pInfo->{TEMPLATE} = 1;
}

#-------------------------------------------------------------------------------
# Function        : SOLARIS_generic
#
# Description     : Take a clone of the buildinfo structure and specialise it
#                   for either a 32-bit or a 64-bit build target
#
# Inputs          : $pInfo       - A clone of the buildinfo data
#                   $os         - Current OS
#                   $arch       - Current architecture
#                   $size       - Length required
#
# Returns         : Nothing
#                   The buildinfo MUST be added to the build system
#
sub SOLARIS_generic
{
    my ($pInfo, $os, $arch, $size) = @_;
    Debug("SOLARIS_generic: $os, $arch, $size");

    #
    #   Request that a simple BuildAlias be created for this platform
    #   Use the original name of the TARGET
    #
    $pInfo->{ALIAS} = $pInfo->{TARGET};

    #
    #   Specify the hardware family
    #   Will be used to create an ALIAS
    #
    $pInfo->{HARDWARE} = uc($arch);
    
    #
    #   Alter the 'TARGET' name
    #   This is allowed (expected)
    #
    my $name = $arch_to_name{$arch}{$size};
    Error ("Bad table: %arch_to_name") unless ( $name );
    $pInfo->{TARGET} = uc("${os}_${name}");

    #
    #   Register this 'new' buildinfo entry with the build system
    #
    ::AddBuildPlatformEntry( $pInfo );
}


#-------------------------------------------------------------------------------
# Function        : add_platform
#
# Description     : This function is invoked just before a 'platform' is about
#                   to be added to the build system.
#
#                   This call is allowed to alter or extend the platform build
#                   information.
#
#                   This particular function, in the SOLARIS.CFG file, is called
#                   when the target platform 'SOLARIS'. The SOLARIS target is
#                   a complex as it serves two purposes.
#
#                   1 )SOLARIS is a dynamic platform. It will be chnaged
#                      into a machine specific platform.
#
#                   2) One of the 'dynamic' platforms is itself SOLARIS
#                      This name exists for compatability purposes as it is
#                      really a SOLARIS8_sparc32, but the name and a stack
#                      of kludges must be retained.
#
# Inputs          : $pInfo          - Reference to the platform build info hash
#
# Returns         : Nothing yet
#
sub add_platform
{
    my $class = shift;              # Not really a class, but its called like a class
    my $pInfo  = shift;

    #
    #   Insert data into the class
    #
    #   ALSO_USES
    #   An array of other platforms that may be 'used' by this platform.
    #   The process is not recursive
    #   Similar to the --Uses option in BuildPlatforms()
    #   Will be subject to product expansion.
    #
    #   Intended use: VS2003 can use stuff from WIN32, but only if the
    #                 VS2003 stuff is not available.
#    $pInfo->{ALSO_USES} = [];

    #
    #   EXTRA_USES
    #   An array of other platforms to be 'used' by this platform.
    #   This list is not expanded in a PRODUCT as the USERS list is.
    #
    #   Intended use: Extend the SOLARIS on a sparc platform to allow for bad usage.
    #                 ie: Stuff is in SOLARIS, SOLARIS_sparc and sparc
    #
    $pInfo->{EXTRA_USES} = ['SOLARIS', 'SOLARIS_sparc', 'sparc'];

    #
    #   SCMMACHTYPE
    #   Override for ScmMachType which appears in makefiles as GBE_MACHTYPE
    #   Default value is $ScmPlatform
    #
    #   Intended use: Legacy Support only
    #   Many legacy package.pl files use GBE_MACHTYPE to specify bin and lib
    #   subdirectores.
    #       The legacy SOLARIS on sparc sets this to 'sparc'
    #       For some reason WIN32 sets this to 'win32'
    #
    $pInfo->{SCMMACHTYPE} = 'sparc';

    #
    #   EXT_SHARED
    #   Set to the value of the shared library extension
    #
    #   Intended Use
    #   Used to locate shared libraries in packgages for use in the
    #   generation set_<PLATFORM>.sh/.bat
    #
    #   If not set then the set_.sh files will no be created
    #
    $pInfo->{EXT_SHARED} = '.so';

    #
    #   OS_COMMON
    #   Set the name of a directory to be used to package header files to be
    #   used on targets that share a common OS
    #
    #   Note: Should also be a part of EXTRA_USES
    #
    #   Intended Use
    #   Extend the operation of the PackageHdr directive to allow files
    #   common files to be packaged
    #
    $pInfo->{OS_COMMON} = 'SOLARIS';
}
    
1;