#.. # COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED. # # Module name : DAFBR # Module type : Makefile system # Compiler(s) : None # Environment(s): All # # Description: # This file provides Toolset initialisation and plugin functions # to makelib.pl2 # # Contents: # # Revision History: # 15-Dec-04 DDP Created #............................................................................# ############################################################################## # ToolsetInit() # Runtime initialisation # ############################################################################## my $v2_compiler = ''; ToolsetInit(); sub ToolsetInit { my( @args ) = @ScmToolsetArgs; # Toolset arguments my( $version, $product, $endian ); $endian = "little"; #.. Parse arguments # Debug( "DAFBR(@args)\n" ); foreach $_ ( @args ) { if ( m/Endian=Big/ ) { $endian = "big"; } elsif ( m/Endian=Little/ ) { $endian = "little"; } else { Message( "DAFBR: unknown toolset argument $_ -- ignored\n" ); } } #.. Parse Platform Arguments # @args = @ScmPlatformArgs; # Platform arguments foreach $_ ( @args ) { if (/^--product=(.*)/) { # GBE product $product = $1; } else { Message( "DAFBR: unknown platform argument $_ -- ignored\n" ); } } #.. Standard.rul requirements # $s = undef; # Assembler source file - not supported $o = 'rul'; # Object files $a = undef; # Library file - not supported $so = undef; # Shared library - not supported $exe = '.bin'; # Linked binary images #.. Toolset configuration # $ScmToolsetVersion = "1.0.0"; # our version $ScmToolsetGenerate = 0; # generate optional $::ScmToolsetProgDependancies = 0; # handle Prog dependancies myself #.. Define the environment # # # Define initialisation targets # These will be used to ensure that correct versions of the toolset are present # Init( "dafbr" ); ToolsetDefine ( "#################################################" ); ToolsetDefine ( "# DAF BR compiler" ); ToolsetDefine ( "#" ); ToolsetDefine ( "ENDIAN := $endian" ); ToolsetDefines( "dafbr.def" ); ToolsetRules ( "dafbr.rul" ); ToolsetRules ( "standard.rul" ); #.. Locate the compiler # The compiler is contained within a package. # This will contol the package version # # Ensure that the pakage has been attached to the build # Ensure that we can find a suitable binary # my $compiler = ToolExtensionProgram( "compile.exe" ); my $compiler_path = StripFileExt( $compiler ); Error ("Cannot locate the BR Compiler", "Check that the daf_br_compiler package is being used" ) unless ( $compiler_path ); ToolsetDefine ( "DAFBRCOMPILER := $compiler" ); ToolsetDefine ( "DAFBRCOMPILER_PATH := $compiler_path" ); #.. Locate the compiler opcode table # This SHOULD be in a different package, but a local version is allowed # to simplify testing of the compiler. # my $opcode = MakeSrcResolveExtended ( 1, "opcodes.tbl" ); if ( $opcode eq "opcodes.tbl") { $opcode = "$::Cwd/opcodes.tbl"; if ( -f $opcode ) { # # Local opcode table is only supported to simplify testing # of the compiler suite. Users should not be encouraged # to provide a local table; # Warning("*** Local opcode table found. ***", "*** Usage not recommended ***"); } else { Error ("Cannot locate the BR Compiler opcodes", "Check that a daf_br_compiler_opcodes package is used" ); } } ToolsetDefine ( "DAFBROPCODE := $opcode" ); my $opcode_path = StripFileExt ( $opcode ); ToolsetDefine ( "DAFBROPCODE_PATH := $opcode_path" ); #.. Determine the version of the compiler # Locate a package with the compiler. Sort of works against the use of # ToolExtensionProgram() above. Perhaps we need a call to determine both. # version_scan: for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} }) { for my $td ( @{$entry->{'TOOLDIRS'}} ) { if ( -f "$td/compile.exe" ) { my ($maj,$min,$patch) = split( '\.', $entry->{'DVERSION'} ); $v2_compiler = 1 if ( $maj > 1 ); Message( "DAFBR: Compiler version: $maj.$min.$patch\n" ); last version_scan; } } } Message( "DAFBR: Using pre-version-2 compiler\n" ) unless $v2_compiler; #.. Extend the CompilerOption directive # Create a standard data structure # This is a hash of hashes # The first hash is keyed by CompileOption keyword # The second hash contains pairs of values to set or remove # %::ScmToolsetCompilerOptions = ( 'usedef=' => { 'BRLD_DEF' , \&locate_PLDEF }, 'addcdheader' => { 'BRLD_FLAGS' , "" }, 'nocdheader' => { 'BRLD_FLAGS' , "noheader" }, ); # # Install defaults # $ScmCompilerOpts{'BRLD_FLAGS'} = "noheader"; $ScmCompilerOpts{'DAFBR_V2'} = 1 if $v2_compiler; } #------------------------------------------------------------------------------- # Function : locate_PLDEF # # Description : Called to validate the "UseDef" option # This function will # 1) verify that user has passed in a name # 2) Save the name of the file for later use # We cannot source the file at this point # # Inputs : $0 - Key ( With a "=" appended ) # $1 - Value # # Returns : undef : Error detected # Name of the file # sub locate_PLDEF { my ($key, $file) = @_; return undef unless $file; return $file; } ############################################################################### # ToolsetCC( $source, $obj, \@args ) # This subroutine takes the user options and builds the rule(s) # required to compile the source file 'source' to 'obj' # ############################################################################### sub ToolsetCC { my( $source, $obj, $pArgs ) = @_; foreach $_ ( @$pArgs ) { Message( "DAFBR: unknown compiler option $_ -- ignored\n" ); } MakePrint( "\n\t\$(CC)\n" ); # # Add in the global DEF file if present # This can only be used by Version-2+ of the compiler. Earlier versions # MUST not use it as they will generate a payload in the first phase. # if ($v2_compiler) { my $def; my $def_name = $ScmCompilerOpts{'BRLD_DEF'}; # Start with global value if ( $def_name ) { # # Locate the true path of the provided REL file # If it is a generate file so it will be in the SRCS hash # Other wise the use will have to use Src to locate the file # $def = MakeSrcResolve ( $def_name ); MakePadded( 4, "\$(OBJDIR)/$obj.$::o:", "\tBRCC_DEF = $def\n" ); } else { Error("dafbr: Must have a global .def file, with the V2 compiler"); } } # # Cleanup files that may be generated # ToolsetGenerate( "\$(OBJDIR)/$obj.rul" ); ToolsetGenerate( "\$(OBJDIR)/$obj.sym" ); ToolsetGenerate( "\$(OBJDIR)/$obj.asm" ); ToolsetGenerate( "\$(OBJDIR)/$obj.pre" ); ToolsetGenerate( "\$(OBJDIR)/$obj.lnk" ); } ############################################################################### # ToolsetCCDepend( $depend, \@sources ) # This subroutine takes the user options and builds the # rule(s) required to build the dependencies for the source # files 'sources' to 'depend'. # ############################################################################### sub ToolsetCCDepend { MakePrint( "\t\$(CCDEPEND)\n" ); } ############################################################################### # ToolsetLD( $name, \@args, \@objs, \@libraries ) # This subroutine takes the user options and builds the rules # required to link the program 'name'. # # Implementation Notes: # # The DAF BR Compiler does not support libraries # It can "link" .rul files into a .bin file with the help of a .def file # # Within this paradigm the objects are .RUL files and the .DEF file is passed # in directly or it may be globally specified # # The compiler cannot take the names of the .RUL files # It can search for them in a specified directory and since they have # been created in the OBJDIR directory this directory is used. # # Supported options # --Def=name - Name of the .DEF file # The global value will be used if none specified # --Header - Add a 32 byte CD file header # --NoHeader - Don't add a CD file header # Default is to take global value # # Arguments: # (none) # ############################################################################### sub ToolsetLD { my ( $name, $pArgs, $pObjs, $pLibs ) = @_; my ( $full ) = '$(BINDIR)/' . $name . $::exe; my ( @slist ); my $def_name = $ScmCompilerOpts{'BRLD_DEF'}; # Start with global value my $opt_header; #.. Parse arguments # foreach $_ ( @$pArgs ) { if (/--Def=(.*)$/) { # Definition file $def_name = $1; } elsif (/--NoHeader/ ) { # No CD header $opt_header = "noheader"; } elsif (/--Header/ ) { $opt_header = ""; # Add CD Header } else { Message( "DAFBR LD: unknown option $_ -- ignored\n" ); } } if ( $def_name ) { # # Locate the true path of the provided REL file # If it is a generate file so it will be in the SRCS hash # Other wise the use will have to use Src to locate the file # $def = MakeSrcResolve ( $def_name ); } #.. Sanity Check # Need a .def file # Need at least one object file # No libraries allowed # Error ("dafbr LD: No .def file specified") unless ( $def ); Error ("dafbr LD: No .rul files specified") unless ( scalar @$pObjs > 0 ); Error ("dafbr LD: Libraries not supported") if ( scalar @$pLibs > 0 ); # # Rules and Recipes to create the Program # my $me = MakeEntry::New (*MAKEFILE, $full ); $me->AddComment ("Build Program: $name" ); $me->AddDependancy ( map ( "$_.$::o", @$pObjs) ); $me->AddRecipe ( '$(LD)' ); $me->AddDefn ( 'BRLD_DEF' => $def ); $me->AddDefn ( 'BRLD_FLAGS' => $opt_header ) if defined($opt_header); $me->Print(); # # Package the file # PackageProgAddFiles ( $name, $full ); } 1;