Rev 227 | 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): Cygnus/Thyron## Description:# Cygnus C/C++ toolset## Version Who Date Description# 1.0 APY 17/10/02 Created#............................................................................################################################################################ ToolsetInit()# Runtime initialisation###############################################################################ToolsetInit();$CygnusVersion = "2.0"; # Compiler versionsub ToolsetInit{#.. Parse arguments#Debug( "cygnus_thyron(@args)\n" );foreach $_ ( @args ) {if (/^--Version=(.*)/) { # Compiler version$MriVersion = "$1";} else { # Unknown optionMessage( "cygnus_thyron: unknown option $_ -- ignored\n" );}}#.. Standard.rul requirements#$s = asm;$o = o;$a = a;$exe = "";#.. Define environment#Init( "cygnus_thyron" );ToolsetDefine( "#################################################" );ToolsetDefine( "# Compiler version" );ToolsetDefine( "#" );ToolsetDefine( "cygnus_ver = $CygnusVersion" );ToolsetDefine( "" );ToolsetDefine( "#" );ToolsetDefines( "cygnus_thyron.def" );ToolsetRules( "cygnus_thyron.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)" "2"# -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}.ld" );ToolsetGenerate( "\$(BINDIR)/${name}.dep" );if ($bin) {ToolsetGenerate( "\$(BINDIR)/${name}.bin" );ToolsetGenerate( "\$(BINDIR)/${name}.s2" );}ToolsetGenerate( "\$(BINDIR)/${name}.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}.dep " ."\\\n\t\t\$(BINDIR)/${name}.prg\n\n" .".PHONY:\t\t\t\$(BINDIR)/${name}${exe}\n\n" );MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n"."\t\$(LDDEPEND)\n\n" );MakePrint( "ifeq \"\$(IFLAG)\" \"2\"\n" ."-include\t\$(BINDIR)/${name}.dep\n" ."endif\n\n" );MakePrint( "\$(BINDIR)/${name}.prg:" );foreach $i ( @$pObjs ) {MakePrint( " \\\n\t\t$i.${o}" );}MakePrint( "\n\t\$(LD)" );MakePrint( "\n\t\$(cygnus)\\objcopy -O srec \$(basename \$@).bin \$(basename \$@).s2" );MakePrint( "\n\t\$(thyron)\\thyron\\tools\\s2toprog \$(basename \$@).s2 \$@" );}else{MakePrint( "\\\n\t\t\$(BINDIR)/${name}.dep " ."\\\n\t\t\$(BINDIR)/${name}.abs\n\n" .".PHONY:\t\t\t\$(BINDIR)/${name}${exe}\n\n" );MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n"."\t\$(LDDEPEND)\n\n" );MakePrint( "ifeq \"\$(IFLAG)\" \"2\"\n" ."-include\t\$(BINDIR)/${name}.dep\n" ."endif\n\n" );MakePrint( "\$(BINDIR)/${name}.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}_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( "\$(MPTLIB)/Lib/Debug/Bin/payclibh.a" );VarCmd( "-L \$(MPTLIB)/Lib/Debug/Bin" );VarCmd( "-L \$(MPTLIB)/StdCLib/Debug/Bin" );VarPrt( "else" );VarCmd( "\$(MPTLIB)/Lib/Release/Bin/appllib.a" );VarCmd( "-L \$(MPTLIB)/Lib/Release/Bin" );VarCmd( "-L \$(MPTLIB)/StdCLib/Release/Bin" );VarPrt( "endif" );VarCmd( "-Map \$(BINDIR)/${name}.map" );if ($bin){VarCmd( "-o \$(BINDIR)/${name}.bin" );}else{VarCmd( "-o \$(BINDIR)/${name}.abs" );}VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );VarCmd( "-T \$(MPTLIB)/Lib/Debug/Lnk/link.cmd" );# VarCmd( "-lg" ); # Required for HDI debuggerVarCmd( "-lgdb" ); # Required for Insight debuggerVarPrt( "else" );VarCmd( "-T \$(MPTLIB)/Lib/Release/Lnk/link.cmd" );VarPrt( "endif" );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}_dp";foreach $i ( @$pLibs ) {VarCmd("\$(BINDIR)/${name}${exe}: @(vpath,$i.${a},GCC_LIB)" );}}#.. Successful termination1;