| 5677 |
dpurdie |
1 |
#..
|
|
|
2 |
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
|
|
|
3 |
#
|
|
|
4 |
# Module name : CORTEXM3_IAR.PL
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : ANSI C
|
|
|
7 |
# Environment(s): Atmel AVR
|
|
|
8 |
#
|
|
|
9 |
# Description:
|
|
|
10 |
# This file provides Toolset initialisation and plugin functions
|
|
|
11 |
# to makelib.pl2
|
|
|
12 |
#
|
|
|
13 |
# Contents: IAR rules as used for the CORTEXM3
|
|
|
14 |
# Similar to the AVR_IAR
|
|
|
15 |
#
|
|
|
16 |
#............................................................................#
|
|
|
17 |
|
|
|
18 |
use strict;
|
|
|
19 |
use JatsVersionUtils;
|
|
|
20 |
|
|
|
21 |
our $s;
|
|
|
22 |
our $o;
|
|
|
23 |
our $so;
|
|
|
24 |
our $exe;
|
|
|
25 |
my $ToolSetName = 'cortexm3_iar';
|
|
|
26 |
|
|
|
27 |
##############################################################################
|
|
|
28 |
# ToolsetInit()
|
|
|
29 |
# Runtime initialisation
|
|
|
30 |
#
|
|
|
31 |
##############################################################################
|
|
|
32 |
|
|
|
33 |
ToolsetInit();
|
|
|
34 |
|
|
|
35 |
sub ToolsetInit
|
|
|
36 |
{
|
|
|
37 |
my( @args ) = @::ScmToolsetArgs; # Toolset arguments
|
|
|
38 |
my( $version, $product, @defines, @dirs, @flags, @asflags, @asdefines );
|
|
|
39 |
my $productFound;
|
|
|
40 |
|
|
|
41 |
#.. Parse arguments
|
|
|
42 |
#
|
|
|
43 |
Debug( "$ToolSetName:(@args)\n" );
|
|
|
44 |
|
|
|
45 |
foreach $_ ( @args ) {
|
|
|
46 |
if (/^--Version=(.*)/) { # Compiler version
|
|
|
47 |
$version = "$1";
|
|
|
48 |
} else {
|
|
|
49 |
Message( "$ToolSetName: unknown toolset argument $_ -- ignored\n" );
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
#.. Parse Platform Arguments
|
|
|
54 |
#
|
|
|
55 |
@args = @::ScmPlatformArgs; # Platform arguments
|
|
|
56 |
foreach $_ ( @args ) {
|
|
|
57 |
if (/^--product=(.*)/) { # GBE product
|
|
|
58 |
$product = $1;
|
|
|
59 |
} else {
|
|
|
60 |
Message( "$ToolSetName: unknown platform argument $_ -- ignored\n" );
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
#
|
|
|
65 |
# Definitions common to all products
|
|
|
66 |
# These will be picked up when no platform has been defined
|
|
|
67 |
#
|
|
|
68 |
push @defines, 'JATS_BUILD';
|
| 5680 |
dpurdie |
69 |
push @dirs, '$(COMPILER_HOME_AVR)/inc/c';
|
| 5677 |
dpurdie |
70 |
push @dirs, '$(COMPILER_HOME_AVR)/inc';
|
|
|
71 |
|
|
|
72 |
#
|
|
|
73 |
# Platform specific definitions
|
|
|
74 |
#
|
|
|
75 |
if ( $product eq "MS6001" )
|
|
|
76 |
{
|
|
|
77 |
$productFound = $product;
|
| 5680 |
dpurdie |
78 |
#push @flags , '--eeprom_size=32768';
|
| 5677 |
dpurdie |
79 |
|
|
|
80 |
# Compiler flags and definitions
|
| 5679 |
dpurdie |
81 |
push @defines, '_MS6001';
|
| 5677 |
dpurdie |
82 |
|
|
|
83 |
# Assembler flags and definitions
|
|
|
84 |
push @asdefines, '_MS6001';
|
|
|
85 |
}
|
|
|
86 |
elsif ( $product )
|
|
|
87 |
{
|
|
|
88 |
Message( "$ToolSetName: Unknown product: $product -- ignored\n" );
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
# common flags
|
|
|
92 |
if ( $productFound )
|
|
|
93 |
{
|
|
|
94 |
#
|
|
|
95 |
# Compiler flags and definitions
|
|
|
96 |
#
|
|
|
97 |
Warning("TODO: Compiler Flags");
|
| 5680 |
dpurdie |
98 |
push @flags , '--endian=little';
|
|
|
99 |
push @flags , '--cpu=Cortex-M3';
|
| 5726 |
dpurdie |
100 |
push @flags , '--diag_suppress=Pa050,Pa091';
|
| 5680 |
dpurdie |
101 |
push @flags , '-e';
|
|
|
102 |
push @flags , '--fpu=None';
|
|
|
103 |
push @flags , '-Oh';
|
|
|
104 |
push @flags , '--vla';
|
|
|
105 |
push @flags , '--require_prototypes';
|
| 5726 |
dpurdie |
106 |
#push @flags , '--discard_unused_publics';
|
|
|
107 |
#push @flags , '--mfc';
|
|
|
108 |
push @flags , '--remarks';
|
| 5680 |
dpurdie |
109 |
push @flags , '--dlib_config=DLib_Config_Normal.h';
|
| 5726 |
dpurdie |
110 |
push @flags, '-lC $(OBJDIR)';
|
|
|
111 |
push @flags, '-lA $(OBJDIR)';
|
| 5677 |
dpurdie |
112 |
|
| 5680 |
dpurdie |
113 |
# Defines
|
| 5726 |
dpurdie |
114 |
#push @defines, 'xxxxxx';
|
| 5677 |
dpurdie |
115 |
|
| 5680 |
dpurdie |
116 |
|
| 5677 |
dpurdie |
117 |
#
|
|
|
118 |
# Assembler flags and definitions
|
|
|
119 |
#
|
|
|
120 |
Warning("TODO: Assembler Flags");
|
| 5679 |
dpurdie |
121 |
# push @asflags , '-v6'; # processor configuration
|
|
|
122 |
# push @asflags , '-s+'; # Case-sensitive user symbols
|
|
|
123 |
# push @asflags , '-t8'; # tab spacing...
|
|
|
124 |
# push @asflags , '-u_enhancedCore'; # enable AVR-specific enhanced instructions
|
| 5677 |
dpurdie |
125 |
|
| 5680 |
dpurdie |
126 |
# push @asdefines, '__MEMORY_MODEL__=2';
|
|
|
127 |
# push @asdefines, '__HAS_ELPM__=1 ';
|
|
|
128 |
# push @asdefines, '__HAS_ENHANCED_CORE__=1 ';
|
|
|
129 |
# push @asdefines, 'ASSEMBLER';
|
| 5677 |
dpurdie |
130 |
}
|
|
|
131 |
|
|
|
132 |
#.. Standard.rul requirements
|
|
|
133 |
#
|
|
|
134 |
$s = 's90'; # Assembler source file
|
|
|
135 |
$o = 'r90'; # Object file
|
|
|
136 |
$a = 'r90'; # Library file
|
|
|
137 |
$so = ''; # Shared library
|
| 5726 |
dpurdie |
138 |
$exe = '.srec'; # Linked binary images
|
| 5677 |
dpurdie |
139 |
|
|
|
140 |
AddSourceType( ".$s", '.asm' );
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
#.. Toolset configuration
|
|
|
144 |
#
|
|
|
145 |
$::ScmToolsetVersion = "1.0.0"; # our version
|
|
|
146 |
$::ScmToolsetGenerate = 0; # generate optional
|
|
|
147 |
$::ScmToolsetProgDependancies = 0; # handle Prog dependancies myself
|
|
|
148 |
|
|
|
149 |
#.. Cleanup rules
|
|
|
150 |
#
|
| 5680 |
dpurdie |
151 |
# Files that appear to be created by the compiler
|
| 5677 |
dpurdie |
152 |
#
|
|
|
153 |
Warning("TODO: Generated File List");
|
| 5680 |
dpurdie |
154 |
ToolsetGenerate( '$(OBJDIR)/tmp*' );
|
|
|
155 |
ToolsetGenerate( '$(LIBDIR)/tmp*' );
|
|
|
156 |
ToolsetGenerate( '$(BINDIR)/tmp*' );
|
| 5677 |
dpurdie |
157 |
|
|
|
158 |
#.. Define IAR environment
|
|
|
159 |
#
|
|
|
160 |
#
|
|
|
161 |
# Define initialisation targets
|
|
|
162 |
# These will be used to ensure that correct versions of the toolset are present
|
|
|
163 |
# Retain 'avr_air' so we can reuse the .RUL file
|
|
|
164 |
#
|
|
|
165 |
Init( "cortexm3" );
|
|
|
166 |
|
|
|
167 |
ToolsetDefine ( "#################################################" );
|
|
|
168 |
ToolsetDefine ( "# CORTEX IAR compiler version" );
|
|
|
169 |
ToolsetDefine ( "#" );
|
|
|
170 |
ToolsetDefine ( "avr_iar_ver = $version" );
|
|
|
171 |
ToolsetDefine ( "avr_iar_prod = $product" );
|
|
|
172 |
ToolsetDefine ( "" );
|
|
|
173 |
ToolsetDefine ( "#" );
|
| 5679 |
dpurdie |
174 |
ToolsetDefines( "cortexm3_iar.def" );
|
| 5677 |
dpurdie |
175 |
ToolsetRules ( "avr_iar.rul" );
|
|
|
176 |
ToolsetRules ( "standard.rul" );
|
|
|
177 |
|
|
|
178 |
#
|
|
|
179 |
# Specify compiler parameters
|
|
|
180 |
# Note: AVR_IAR_INCLUDES is ";" seperated as it may contain spaces
|
|
|
181 |
# when expanded ("Program Files")
|
|
|
182 |
#
|
|
|
183 |
|
|
|
184 |
PlatformEntry( "AVR_IAR_DEFINES\t=", "\n", "\\\n\t", "", @defines )
|
|
|
185 |
if ( scalar @defines );
|
|
|
186 |
PlatformEntry( "AVR_IAR_INCLUDES\t=", "\n", "\\\n\t", ";", @dirs )
|
|
|
187 |
if ( scalar @dirs );
|
|
|
188 |
PlatformEntry( "AVR_IAR_FLAGS\t=", "\n", "\\\n\t", "", @flags )
|
|
|
189 |
if ( scalar @flags );
|
|
|
190 |
|
|
|
191 |
PlatformEntry( "AVR_IAR_ASFLAGS\t=", "\n", "\\\n\t", "", @asflags )
|
|
|
192 |
if ( scalar @asflags );
|
|
|
193 |
PlatformEntry( "AVR_IAR_ASDEFINES\t=", "\n", "\\\n\t", "", @asdefines )
|
|
|
194 |
if ( scalar @asdefines );
|
|
|
195 |
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
##############################################################################
|
|
|
200 |
# ToolsetPreprocess()
|
|
|
201 |
# Process collected data before the makefile is generated
|
|
|
202 |
# This, optional, routine is called from within MakefileGenerate()
|
|
|
203 |
# It allows the toolset to massage any of the collected data before
|
|
|
204 |
# the makefile is created
|
|
|
205 |
#
|
|
|
206 |
##############################################################################
|
|
|
207 |
|
|
|
208 |
#sub ToolsetPreprocess
|
|
|
209 |
#{
|
|
|
210 |
#}
|
|
|
211 |
|
|
|
212 |
###############################################################################
|
|
|
213 |
# ToolsetCC( $source, $obj, \@args )
|
|
|
214 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
215 |
# required to compile the source file 'source' to 'obj'
|
|
|
216 |
#
|
|
|
217 |
###############################################################################
|
|
|
218 |
|
|
|
219 |
sub ToolsetCC
|
|
|
220 |
{
|
|
|
221 |
MakePrint( "\n\t\$(CC)\n" );
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
###############################################################################
|
|
|
225 |
# ToolsetCCDepend( $depend, \@sources )
|
|
|
226 |
# This subroutine takes the user options and builds the
|
|
|
227 |
# rule(s) required to build the dependencies for the source
|
|
|
228 |
# files 'sources' to 'depend'.
|
|
|
229 |
#
|
|
|
230 |
###############################################################################
|
|
|
231 |
|
|
|
232 |
sub ToolsetCCDepend
|
|
|
233 |
{
|
|
|
234 |
MakePrint( "\t\$(CCDEPEND)\n" );
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
###############################################################################
|
|
|
239 |
# ToolsetCXX( $source, $obj, \@args )
|
|
|
240 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
241 |
# required to compile the source file 'source' to 'obj'
|
|
|
242 |
#
|
|
|
243 |
###############################################################################
|
|
|
244 |
|
|
|
245 |
sub ToolsetCXX
|
|
|
246 |
{
|
|
|
247 |
MakePrint( "\n\t\$(CXX)\n" );
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
###############################################################################
|
|
|
251 |
# ToolsetCXXDepend( $depend, \@sources )
|
|
|
252 |
# This subroutine takes the user options and builds the
|
|
|
253 |
# rule(s) required to build the dependencies for the source
|
|
|
254 |
# files 'sources' to 'depend'.
|
|
|
255 |
#
|
|
|
256 |
###############################################################################
|
|
|
257 |
|
|
|
258 |
sub ToolsetCXXDepend
|
|
|
259 |
{
|
|
|
260 |
ToolsetCCDepend();
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
###############################################################################
|
|
|
265 |
# ToolsetAS( $source, $obj, \@args )
|
|
|
266 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
267 |
# required to compile the source file 'source' to 'obj'
|
|
|
268 |
#
|
|
|
269 |
###############################################################################
|
|
|
270 |
|
|
|
271 |
sub ToolsetAS
|
|
|
272 |
{
|
|
|
273 |
MakePrint( "\n\t\$(AS)\n" );
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
sub ToolsetASDepend
|
|
|
277 |
{
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
###############################################################################
|
|
|
281 |
# ToolsetAR( $name, \@args, \@objs )
|
|
|
282 |
# This subroutine takes the user options and builds the rules
|
|
|
283 |
# required to build the library 'name'.
|
|
|
284 |
|
|
|
285 |
#
|
|
|
286 |
# Arguments:
|
|
|
287 |
# --xxx No arguments currently defined
|
|
|
288 |
#
|
|
|
289 |
# Output:
|
|
|
290 |
# [ $(BINDIR)/name$.${a}: .... ]
|
|
|
291 |
# $(AR)
|
|
|
292 |
#
|
|
|
293 |
###############################################################################
|
|
|
294 |
|
|
|
295 |
sub ToolsetAR
|
|
|
296 |
{
|
|
|
297 |
my( $name, $pArgs, $pObjs ) = @_;
|
|
|
298 |
|
|
|
299 |
Debug("ToolsetAR");
|
|
|
300 |
|
|
|
301 |
#.. Parse arguments
|
|
|
302 |
#
|
|
|
303 |
foreach $_ ( @$pArgs ) {
|
|
|
304 |
if (/^--/) {
|
|
|
305 |
Message( "AR: unknown option $_ -- ignored\n" );
|
|
|
306 |
}
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
#.. Target
|
|
|
310 |
#
|
|
|
311 |
MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).${a}:\t", "", " \\\n\t\t", ".${o}", @$pObjs );
|
|
|
312 |
|
|
|
313 |
#.. Build library rule (just append to standard rule)
|
|
|
314 |
#
|
|
|
315 |
MakePrint( "\n\t\$(AR)\n\n" );
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
###############################################################################
|
|
|
320 |
# ToolsetARMerge()
|
|
|
321 |
# Generate the recipe to merge libraries.
|
|
|
322 |
# The dependency list is created by the caller.
|
|
|
323 |
#
|
|
|
324 |
###############################################################################
|
|
|
325 |
|
|
|
326 |
sub ToolsetARMerge
|
|
|
327 |
{
|
|
|
328 |
MakePrint( "\n\t\$(ARMERGE)\n\n" );
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
###############################################################################
|
|
|
333 |
# ToolsetLD( $name, \@args, \@objs, \@libraries )
|
|
|
334 |
# This subroutine takes the user options and builds the rules
|
|
|
335 |
# required to link the program 'name'.
|
|
|
336 |
#
|
|
|
337 |
# Arguments:
|
|
|
338 |
# --xxx No Arguments currently specified
|
|
|
339 |
#
|
|
|
340 |
# Linker specific:
|
|
|
341 |
# --LinkScript=filename Specify the name of a linker script file
|
|
|
342 |
# --Loader=filename Specify a loader file to be merged
|
|
|
343 |
# This will be a program
|
|
|
344 |
# --Type=typetext Text to be placed in type field
|
| 5726 |
dpurdie |
345 |
# --Entry=Name Alternate Program Entry Point
|
| 5677 |
dpurdie |
346 |
#
|
|
|
347 |
# Output:
|
|
|
348 |
#
|
|
|
349 |
# name.map - Loadable module
|
| 5726 |
dpurdie |
350 |
# name.out - Output from the linker
|
|
|
351 |
# name.srec - Output from the elftool
|
| 5677 |
dpurdie |
352 |
# name.d90 -
|
| 5726 |
dpurdie |
353 |
# name.sxml - Wrapped srec file
|
| 5677 |
dpurdie |
354 |
#
|
|
|
355 |
###############################################################################
|
|
|
356 |
|
|
|
357 |
sub ToolsetLD
|
|
|
358 |
{
|
|
|
359 |
my( $name, $pArgs, $pObjs, $pLibs ) = @_;
|
|
|
360 |
my( $script );
|
|
|
361 |
my( $loader, $loader_file);
|
|
|
362 |
my $type_text = '';
|
| 5726 |
dpurdie |
363 |
my $entyPoint = '__iar_program_start';
|
| 5677 |
dpurdie |
364 |
|
|
|
365 |
|
|
|
366 |
#.. Parse arguments
|
|
|
367 |
#
|
|
|
368 |
foreach $_ ( @$pArgs )
|
|
|
369 |
{
|
|
|
370 |
#.. Target specific
|
|
|
371 |
#
|
|
|
372 |
|
|
|
373 |
#.. Toolset specific
|
|
|
374 |
#
|
|
|
375 |
if (/^--Script=(.*)/) { # External file
|
|
|
376 |
$script = $1;
|
| 5726 |
dpurdie |
377 |
$script .= ".icf" unless ( $script =~ m~\.icf$~ );
|
| 5677 |
dpurdie |
378 |
|
|
|
379 |
} elsif ( /^--ProgLoader=(.*)/ ) { # Loader/Burner file
|
|
|
380 |
$loader = $1;
|
|
|
381 |
$loader =~ s~$exe$~~;
|
|
|
382 |
|
|
|
383 |
} elsif ( /^--Type=(.*)/ ) { # Type of Payload
|
|
|
384 |
$type_text = $1;
|
|
|
385 |
|
| 5726 |
dpurdie |
386 |
} elsif ( /^--Entry=(.*)/ ) { # Entry Point
|
|
|
387 |
$entyPoint = $1;
|
|
|
388 |
|
| 5677 |
dpurdie |
389 |
} else {
|
|
|
390 |
Message( "Prog: unknown option $_ -- ignored\n" );
|
|
|
391 |
}
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
#
|
|
|
395 |
# Sanity check
|
|
|
396 |
# - Ensure a linker script has been provided
|
|
|
397 |
#
|
|
|
398 |
unless ( $script )
|
|
|
399 |
{
|
| 5726 |
dpurdie |
400 |
$script = "$name.icf";
|
| 5677 |
dpurdie |
401 |
Warning( "Prog: Linker Script file not provided. Using $script" );
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
#
|
|
|
405 |
# Locate the true path of the provided script file
|
|
|
406 |
# If it is a generate file so it will be in the SRCS hash
|
|
|
407 |
# Other wise the use will have to use Src to locate the file
|
|
|
408 |
#
|
|
|
409 |
$script = MakeSrcResolve ( $script );
|
|
|
410 |
|
|
|
411 |
#
|
|
|
412 |
# Locate the loader file, if it has been provided
|
|
|
413 |
# The file must be a program and should be created within this makefile
|
|
|
414 |
#
|
|
|
415 |
if ( $loader )
|
|
|
416 |
{
|
|
|
417 |
if ( $::PROGS->Get( $loader) )
|
|
|
418 |
{
|
|
|
419 |
$loader_file = "\$(BINDIR)/$loader$exe";
|
|
|
420 |
}
|
|
|
421 |
elsif ( $::SRCS{$loader} )
|
|
|
422 |
{
|
|
|
423 |
$loader_file = $::SRCS{$loader};
|
|
|
424 |
}
|
|
|
425 |
else
|
|
|
426 |
{
|
|
|
427 |
Error ("Prog: ProgLoader file not found" );
|
|
|
428 |
}
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
#
|
|
|
432 |
# Extend the list of libraries with compiler specific libraries
|
|
|
433 |
#
|
| 5679 |
dpurdie |
434 |
# push( @$pLibs, "\$(avr_linker_lib)" );
|
|
|
435 |
Warning("TODO: Add toolset library-1");
|
| 5677 |
dpurdie |
436 |
|
|
|
437 |
#
|
|
|
438 |
# Create a ToolsetPrinter
|
|
|
439 |
#
|
|
|
440 |
my ($io) = ToolsetPrinter::New();
|
|
|
441 |
my $dep = $io->SetLdTarget( $name );
|
|
|
442 |
|
|
|
443 |
#
|
|
|
444 |
# Determine the target output name
|
|
|
445 |
#
|
|
|
446 |
my $root = "\$(BINDIR)/$name";
|
|
|
447 |
my $full = $root . $::exe;
|
|
|
448 |
my $map = $root . '.map';
|
| 5726 |
dpurdie |
449 |
my $log = $root . '.log';
|
|
|
450 |
my $out = $root . '.out';
|
|
|
451 |
my $srec = $root . '.srec';
|
| 5677 |
dpurdie |
452 |
|
|
|
453 |
|
|
|
454 |
########################################################################
|
|
|
455 |
#
|
|
|
456 |
# Before this function was called, makelib.pl2 has generated a
|
|
|
457 |
# partial rule consisting of:
|
|
|
458 |
#
|
|
|
459 |
# $(BINDIR)/${name}${exe} :
|
|
|
460 |
# All the specified object files
|
|
|
461 |
#
|
|
|
462 |
# Add the names of all the other files required in the process
|
|
|
463 |
# This will then serve as a target fo all things that need to be
|
|
|
464 |
# created when a "program" is required
|
|
|
465 |
#
|
|
|
466 |
# These are:
|
|
|
467 |
# User linker script file
|
|
|
468 |
# Library dependency file
|
|
|
469 |
#
|
|
|
470 |
$io->Label( "Program", $name ); # label
|
| 5726 |
dpurdie |
471 |
$io->Prt( "$out : \t$dep" ); # Dependencies
|
| 5677 |
dpurdie |
472 |
$io->Prt( "\\\n\t\t$script" );
|
|
|
473 |
$io->Prt( " \\\n\t\t$loader_file" ) if ($loader_file);
|
|
|
474 |
$io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs ); # Object Files
|
|
|
475 |
$io->Prt( "\n\t\$(LD_IAR)\n" );
|
|
|
476 |
|
|
|
477 |
#
|
|
|
478 |
# Insert post processing call if a program loader is needed
|
|
|
479 |
#
|
|
|
480 |
$io->Prt( "\t\$(call LD_IAR_PROCESS, \\" .
|
|
|
481 |
"\n\t\t$full, \\" .
|
|
|
482 |
"\n\t\t$loader_file)\n"
|
|
|
483 |
) if ($loader_file);
|
|
|
484 |
|
|
|
485 |
$io->Newline();
|
|
|
486 |
|
|
|
487 |
#
|
|
|
488 |
# Specify files created by the linker
|
|
|
489 |
# These will be added to the clean list
|
|
|
490 |
#
|
|
|
491 |
ToolsetGenerate( $map );
|
| 5726 |
dpurdie |
492 |
ToolsetGenerate( $log );
|
|
|
493 |
ToolsetGenerate( $out );
|
|
|
494 |
ToolsetGenerate( $srec );
|
| 5677 |
dpurdie |
495 |
ToolsetGenerate( "$full.keep" );
|
|
|
496 |
|
|
|
497 |
#
|
|
|
498 |
# Create a linker command file
|
|
|
499 |
# Piecing together a variable $(name_ld) which ends up in the command file.
|
|
|
500 |
# This bit of magic will be performed by the LD_IAR recipe
|
|
|
501 |
#
|
|
|
502 |
$io->SetTag( "${name}_ld" ); # macro tag
|
|
|
503 |
$io->Label( "Linker commands", $name ); # label
|
|
|
504 |
|
| 5726 |
dpurdie |
505 |
# $io->Cmd("-S" ); # Silent
|
|
|
506 |
$io->Cmd("-o $out" ); # Output file
|
|
|
507 |
$io->Cmd("--map $map" ); # Map file
|
|
|
508 |
# Configue Logging
|
|
|
509 |
$io->Cmd("--log libraries,initialization,modules,redirects,sections,veneers,unused_fragments,call_graph" );
|
|
|
510 |
$io->Cmd("--log_file $log" ); # Log file
|
|
|
511 |
$io->Cmd("--semihosting" );
|
|
|
512 |
$io->Cmd("--entry $entyPoint" );
|
|
|
513 |
$io->Cmd("--inline" );
|
|
|
514 |
$io->Cmd("--vfe" );
|
|
|
515 |
$io->Cmd("--config $script" ); # User script file
|
| 5677 |
dpurdie |
516 |
|
|
|
517 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe ); # Object files
|
|
|
518 |
|
|
|
519 |
#
|
|
|
520 |
# Specify the library files
|
|
|
521 |
#
|
| 5679 |
dpurdie |
522 |
# $io->Cmd( '"-I$(avr_linker_lib_dir)"' ); # Toolset library directory
|
|
|
523 |
Warning("TODO: Add toolset library-2");
|
| 5677 |
dpurdie |
524 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe ); # Specify the libraries too
|
|
|
525 |
$io->Newline();
|
|
|
526 |
|
|
|
527 |
#.. Dependency link,
|
|
|
528 |
# Create a library dependency file
|
|
|
529 |
# Create command file to build applicaton dependency list
|
|
|
530 |
# from the list of dependent libraries
|
|
|
531 |
#
|
|
|
532 |
# Create makefile directives to include the dependency
|
|
|
533 |
# list into the makefile.
|
|
|
534 |
#
|
| 5726 |
dpurdie |
535 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, $out );
|
| 5677 |
dpurdie |
536 |
$io->LDDEPEND();
|
|
|
537 |
|
|
|
538 |
#
|
|
|
539 |
# Add the MAP file to the program package
|
|
|
540 |
#
|
|
|
541 |
PackageProgAddFiles ( $name, $full );
|
|
|
542 |
PackageProgAddFiles ( $name, $map , 'Class=map' );
|
|
|
543 |
|
| 5726 |
dpurdie |
544 |
#
|
|
|
545 |
# Create the .srec file
|
|
|
546 |
#
|
|
|
547 |
$io->Label( "SREC File", $name );
|
|
|
548 |
$io->Prt( "$srec: $out\n");
|
|
|
549 |
$io->Prt( "\t\$(call GENERATE_SREC $out,$srec)\n");
|
|
|
550 |
$io->Newline();
|
| 5677 |
dpurdie |
551 |
|
| 5726 |
dpurdie |
552 |
|
| 5677 |
dpurdie |
553 |
#
|
|
|
554 |
# Create the .sxml file
|
|
|
555 |
#
|
|
|
556 |
my $sxml = "\$(BINDIR)/${name}.sxml";
|
|
|
557 |
my ($major, $minor, $patch, $build, $raw_patch) = SplitVersion($ScmBuildVersionFull);
|
|
|
558 |
|
|
|
559 |
$io->Label( "SXML File", $name );
|
| 5726 |
dpurdie |
560 |
$io->Prt( "$sxml: $srec\n");
|
| 5677 |
dpurdie |
561 |
$io->Prt( "\t\$(call GENERATE_SXML, \\" .
|
|
|
562 |
"\n\t\t\$(BINDIR)/${name}$exe, \\" .
|
| 5679 |
dpurdie |
563 |
"\n\t\t$sxml,$type_text,$major,$minor,$patch,$build,InsideSecure)\n"
|
| 5677 |
dpurdie |
564 |
);
|
|
|
565 |
$io->Newline();
|
|
|
566 |
|
|
|
567 |
#
|
|
|
568 |
# Generated files to be added to the program file list
|
|
|
569 |
#
|
|
|
570 |
ToolsetGenerate( $sxml );
|
|
|
571 |
PackageProgAddFiles( $name, $sxml, 'Class=extras' );
|
|
|
572 |
ProgAddExtra( $name, $sxml );
|
|
|
573 |
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
########################################################################
|
|
|
577 |
#
|
|
|
578 |
# Generate a linker object recipe. This is a helper function used
|
|
|
579 |
# within this toolset.
|
|
|
580 |
#
|
|
|
581 |
# Arguments:
|
|
|
582 |
# $io I/O stream
|
|
|
583 |
#
|
|
|
584 |
# $target Name of the target
|
|
|
585 |
#
|
|
|
586 |
# $obj Library specification
|
|
|
587 |
#
|
|
|
588 |
########################################################################
|
|
|
589 |
|
|
|
590 |
sub ToolsetObjRecipe
|
|
|
591 |
{
|
|
|
592 |
my ($io, $target, $obj) = @_;
|
|
|
593 |
|
|
|
594 |
$io->Cmd("$obj.$::o" );
|
|
|
595 |
}
|
|
|
596 |
|
|
|
597 |
########################################################################
|
|
|
598 |
#
|
|
|
599 |
# Generate a linker/depend library recipe. This is a helper function
|
|
|
600 |
# used within this toolset.
|
|
|
601 |
#
|
|
|
602 |
# Arguments:
|
|
|
603 |
# $io I/O stream
|
|
|
604 |
#
|
|
|
605 |
# $target Name of the target
|
|
|
606 |
#
|
|
|
607 |
# $lib Library specification
|
|
|
608 |
#
|
|
|
609 |
# $dp If building a depend list, the full target name.
|
|
|
610 |
#
|
|
|
611 |
########################################################################
|
|
|
612 |
|
|
|
613 |
sub ToolsetLibRecipe
|
|
|
614 |
{
|
|
|
615 |
my ($io, $target, $lib, $dp) = @_;
|
|
|
616 |
|
|
|
617 |
if ( !defined($dp) ) { # linker
|
| 5726 |
dpurdie |
618 |
$io->Cmd("--search @(vpath2,\"$lib.$::a\",IAR_LIB)" );
|
| 5677 |
dpurdie |
619 |
} else { # depend
|
|
|
620 |
$io->Cmd( "$dp:\t@(vlib2,\"$lib.$::a\",IAR_LIB)" );
|
|
|
621 |
}
|
|
|
622 |
}
|
|
|
623 |
|
|
|
624 |
#.. Successful termination
|
|
|
625 |
1;
|
|
|
626 |
|