Rev 251 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
# -*- mode: perl -*-## Module name : cygnus_thyron# Module type : Makefile system# Compiler(s) : ANSI C# Environment(s): GNU/MPT## Description:# GNU C/C++ toolset## Version Who Date Description# 1.0 ANT 11/05/04 Created#............................................................................################################################################################ ToolsetInit()# Runtime initialisation###############################################################################ToolsetInit();$GNUVersion = "3.0"; # Compiler versionsub ToolsetInit{#.. Parse arguments#Debug( "gnu_mpt(@args)\n" );foreach $_ ( @args ) {if (/^--Version=(.*)/) { # Compiler version$MriVersion = "$1";} else { # Unknown optionMessage( "gnu_mpt: unknown option $_ -- ignored\n" );}}#.. Standard.rul requirements#$s = 'asm';$o = 'o';$a = 'a';$exe = "";#.. Define environment#Init( "gnu_mpt" );ToolsetDefine( "#################################################" );ToolsetDefine( "# Compiler version" );ToolsetDefine( "#" );ToolsetDefine( "gnu_ver = $GNUVersion" );ToolsetDefine( "" );ToolsetDefine( "#" );ToolsetDefines( "gnu_mpt.def" );ToolsetRules( "gnu_mpt.rul" );ToolsetRules( "standard.rul" );}################################################################################ 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 ) = @_;Debug( "CC: $source -> $obj" );foreach ( @$pArgs ) {Debug( "option: $_" );if ( /--Shared$/ ) { # Building a 'shared' object$cflags = "$cflags \$(SHCFLAGS)";Debug( "CC: as shared object" );} else { # unknown optionMessage( "CC: unknown option $_ -- ignored\n" );}}MakePrint( "\n\t\$(CC)\n" );MakePrint( "\$(OBJDIR)/$i.${o}:\tCFLAGS +=$cflags\n" )if ( $cflags );}################################################################################ 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" );}################################################################################ ToolsetCXX( $source, $obj, \@args )# This subroutine takes the user options and builds the rule(s)# required to compile the source file 'source' to 'obj'################################################################################sub ToolsetCXX{my( $source, $obj, $pArgs ) = @_;my( $cflags ) = "";Debug( "CCX: $source -> $obj" );foreach ( @$pArgs ) {Debug( "option: $_" );if ( /--Shared$/ ) { # Building a 'shared' object$cflags = "$cflags \$(SHCXXFLAGS)";Debug( "CCX: as shared object" );} else {Message( "CCX: unknown option $_ -- ignored\n" );}}MakePrint( "\n\t\$(CXX)\n" );MakePrint( "\$(OBJDIR)/$i.${o}:\tCXXFLAGS +=$cflags\n" )if ( $cflags );}################################################################################ ToolsetCXXDepend( $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 ToolsetCXXDepend{#ToolsetCCDepend() handles both CC and CXX source}################################################################################ ToolsetAS( $source, $obj, \@args )# This subroutine takes the user options and builds the rule(s)# required to compile the source file 'source' to 'obj'################################################################################sub ToolsetAS{my( $source, $obj, $pArgs ) = @_;foreach $_ ( @$pArgs ) {Message( "CC: unknown option $_ -- ignored\n" );}MakePrint( "\n\t\$(AS)\n" );}sub ToolsetASDepend{}################################################################################ ToolsetAR( $name, \@args, \@objs )# This subroutine takes the user options and builds the rules# required to build the library 'name'.## Arguments:# n/a## Output:# [ $(BINDIR)/name$.${a}: .... ]# $(AR)## name_ld += ... Linker command file# :## name_dp += ... Dependency list# :################################################################################sub ToolsetAR{my( $name, $pArgs, $pObjs ) = @_;local( $name_ld );#.. Parse arguments#foreach $_ ( @$pArgs ){Message( "AR: unknown option $_ -- ignored\n" );}#.. Build library rule (just append to standard rule)#MakeEntry( "\$(LIBDIR)/$name\$(SCM_TYPE).${a}:\t","", "\\\n\t\t", ".${o} ", @$pObjs );MakePrint( "\n\t\$(AR)\n\n" );}################################################################################ ToolsetLD( $name, \@args, \@objs, \@libraries )# This subroutine takes the user options and builds the rules# required to link the program 'name'.## Arguments:# n/a## Output:# $(BINDIR)/name${exe}:# $(BINDIR)/name.dep \# $(BINDIR)/name.[abs|bin]## .PHONY: $(BINDIR)/name${exe}:## $(BINDIR)/name.dep: $(SCM_PLATFORM).mk# $(LDDEPEND)## ifeq "$(IFLAG)" "3"# -include "$(BINDIR)/name.dep"# endif## $(BINDIR)/name.[abs|bin]# objs ...# $(LD)## name_ld += ... Linker command file# :## name_dp += ... Dependency list# :################################################################################sub ToolsetLD{my( $name, $pArgs, $pObjs, $pLibs ) = @_;my( $bin );local( $varname );#.. Parse arguments#$bin = 0; # toolset optionsforeach $_ ( @$pArgs ){#.. Target specific#if (/^--Bin/) { # Download image$bin = 1;} elsif (/^--Abs/) { # Powerscope image$bin = 0;#.. Toolset specific#} else {Message( "LD: unknown option $_ -- ignored\n" );}}#.. Command file EOS dependencies##.. Cleanup rules#ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).ld" );ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).dep" );if ($bin) {ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).bin" );ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).s2" );}ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).map" );#.. Linker command file## Now the fun part... piecing together a variable $(name_ld)# which ends up in the command file.#if ($bin){MakePrint( "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).dep " ."\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).prg\n\n" .".PHONY:\t\t\t\$(BINDIR)/${name}\$(GBE_TYPE)${exe}\n\n" );MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).dep:\t\$(SCM_PLATFORM).mk\n"."\t\$(LDDEPEND)\n\n" );MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" ."-include\t\$(BINDIR)/${name}\$(GBE_TYPE).dep\n" ."endif\n\n" );MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).prg:" );foreach $i ( @$pObjs ) {MakePrint( " \\\n\t\t$i.${o}" );}MakePrint( "\n\t\$(LD)" );MakePrint( "\n\t\$(GNUBIN)\\objcopy -O srec \$(basename \$@).bin \$(basename \$@).s2" );MakePrint( "\n\t\$(thyron)\\thyron\\tools\\s2toprog \$(basename \$@).s2 \$@" );}else{MakePrint( "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).dep " ."\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).abs\n\n" .".PHONY:\t\t\t\$(BINDIR)/${name}\$(GBE_TYPE)${exe}\n\n" );MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).dep:\t\$(SCM_PLATFORM).mk\n"."\t\$(LDDEPEND)\n\n" );MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" ."-include\t\$(BINDIR)/${name}\$(GBE_TYPE).dep\n" ."endif\n\n" );MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).abs:" );foreach $i ( @$pObjs ) {MakePrint( " \\\n\t\t$i.${o}" );}MakePrint( "\n\t\$(LD)\n" );}MakePrint( "\n" );#.. Linker command file## Now the fun part... piecing together a variable $(name_ld)# which ends up in the command file.#$varname = "${name}\$(GBE_TYPE)_ld";sub VarCmd { # with line feed ...MakeQuote ("$varname += @_\\n\n");}sub VarCmd2 { # without line feed ...MakeQuote ("$varname += @_\n");}sub VarPrt {MakePrint ("@_\n");}# Section definitions and startup code:## HDI file to generate ABS target for HDI.# OS files to generate S2 target to run under operating system.#..VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );VarCmd( "\$(MPTLIB)/lib/debug/bin/start.o" );VarPrt( "else" );VarCmd( "\$(MPTLIB)/lib/release/bin/start.o" );VarPrt( "endif" );foreach $i ( @$pObjs ) {VarCmd( "\$(strip $i).${o}" );}foreach $i ( @$pLibs ) {VarCmd( "@(vpath,$i.${a},GCC_LIB)" );}VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );VarCmd( "\$(MPTLIB)/lib/debug/bin/appllib.a" );VarCmd( "-L \$(MPTLIB)/lib/debug/bin" );VarCmd( "-L \$(MPTLIB)/stdclib/debug/bin" );VarCmd( "-L \$(MPTLIB)/genlib/com/paycell2/debug/bin" );VarCmd( "-L \$(MPTLIB)/genlib/dat/paycell2/debug/bin" );VarCmd( "-L \$(MPTLIB)/genlib/lwip/paycell2/debug/bin" );VarCmd( "-L \$(MPTLIB)/genlib/pcc/paycell2/debug/bin" );VarCmd( "-L \$(MPTLIB)/genlib/tmr/paycell2/debug/bin" );VarCmd( "-L \$(MPTLIB)/genlib/tsk/paycell2/debug/bin" );VarCmd( "-L \$(MPTLIB)/genlib/xtr/paycell2/debug/bin" );VarPrt( "else" );VarCmd( "\$(MPTLIB)/lib/release/bin/appllib.a" );VarCmd( "-L \$(MPTLIB)/lib/release/bin" );VarCmd( "-L \$(MPTLIB)/stdclib/release/bin" );VarCmd( "-L \$(MPTLIB)/genlib/com/paycell2/release/bin" );VarCmd( "-L \$(MPTLIB)/genlib/dat/paycell2/release/bin" );VarCmd( "-L \$(MPTLIB)/genlib/lwip/paycell2/release/bin" );VarCmd( "-L \$(MPTLIB)/genlib/pcc/paycell2/release/bin" );VarCmd( "-L \$(MPTLIB)/genlib/tmr/paycell2/release/bin" );VarCmd( "-L \$(MPTLIB)/genlib/tsk/paycell2/release/bin" );VarCmd( "-L \$(MPTLIB)/genlib/xtr/paycell2/release/bin" );VarPrt( "endif" );VarCmd( "-Map \$(BINDIR)/${name}\$(GBE_TYPE).map" );if ($bin){VarCmd( "-o \$(BINDIR)/${name}\$(GBE_TYPE).bin" );}else{VarCmd( "-o \$(BINDIR)/${name}\$(GBE_TYPE).abs" );}VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );VarCmd( "-T \$(MPTLIB)/Lib/Debug/Lnk/link.cmd" );VarCmd( "-lgdb" ); # Required for Insight debuggerVarPrt( "else" );VarCmd( "-T \$(MPTLIB)/Lib/Release/Lnk/link.cmd" );VarPrt( "endif" );VarCmd( "-lcom" ); # Thyron LibrariesVarCmd( "-ldat" );VarCmd( "-llwip" );VarCmd( "-lpcc" );VarCmd( "-ltsk" );VarCmd( "-ltmr" );VarCmd( "-lxtr" );VarCmd( "-lc" );VarCmd( "-lm" );VarCmd( "-lgcc" );VarPrt( "" );#.. Dependency link,## Now piece together a variable $(name_dp) which ends up in# the command file building the application dependency list.#$varname = "${name}\$(GBE_TYPE)_dp";foreach $i ( @$pLibs ) {VarCmd("\$(BINDIR)/${name}\$(GBE_TYPE)${exe}: @(vpath,$i.${a},GCC_LIB)" );}if ($bin){PackageProgRemoveFiles($name);PackageProgAddFiles($name, "\$(BINDIR)/${name}\$(GBE_TYPE).prg");}else{PackageProgRemoveFiles($name);PackageProgAddFiles($name, "\$(BINDIR)/${name}\$(GBE_TYPE).abs");}}#.. Successful termination1;