| 227 |
dpurdie |
1 |
# -*- mode: perl; tabs: 8; indent-width: 4; show-tabs: yes; -*-
|
|
|
2 |
#
|
|
|
3 |
# Module name : mri68k
|
|
|
4 |
# Module type : Makefile system
|
|
|
5 |
# Compiler(s) : ANSI C
|
|
|
6 |
# Environment(s): AMX/EOS
|
|
|
7 |
#
|
|
|
8 |
# ! WARNING - do not detab !
|
|
|
9 |
#
|
|
|
10 |
# Description:
|
|
|
11 |
# MRI 68k toolset
|
|
|
12 |
#
|
|
|
13 |
# Version Who Date Description
|
|
|
14 |
# 1.0 APY 07/05/99 Created
|
|
|
15 |
# 1.3 APY 06/12/99 NetTcp/NetUdp linker options
|
|
|
16 |
# 09/12/99 ToolsetProg()
|
|
|
17 |
# 1.5 06/01/00 Linker --Kdb support
|
| 261 |
dpurdie |
18 |
# 07/01/00 ifeq "$(IFLAG)" "3"
|
| 227 |
dpurdie |
19 |
# around -include directives
|
|
|
20 |
# 14/03/99 vpath2() for remove abs depend issues
|
|
|
21 |
# 15/03/00 Wasn't build dependency list for binaries.
|
|
|
22 |
# 1.9 APY 16/03/00 --Section switch
|
|
|
23 |
# 1.10 APY 06/04/00 MRI version (4.4) support
|
|
|
24 |
# 26/04/00 --NetTcpx
|
|
|
25 |
# APY 13/11/00 ${exe} now embeddes '.' if required.
|
|
|
26 |
# 2.0 APY 26/02/02 Build system +v2 support.
|
|
|
27 |
# - reconstructed isp creation
|
|
|
28 |
# - replaced ToolsetProg() with ToolsetGenerate().
|
|
|
29 |
# - ToolsetCC and ToolsetCXX switch processing
|
|
|
30 |
# 30/04/02 --Isp must allow multiple specifications.
|
|
|
31 |
# 07/05/02 --Section
|
|
|
32 |
#
|
|
|
33 |
# $Name: $
|
|
|
34 |
# $Source: /cvsroot/etm/devl/CFG/TOOLSET/MRI68K,v $
|
|
|
35 |
# $Revision: 1.3 $ $Date: 2004/09/03 10:25:23 $ $State: Exp $
|
|
|
36 |
# $Author: ayoung $ $Locker: $
|
|
|
37 |
#............................................................................#
|
|
|
38 |
|
|
|
39 |
##############################################################################
|
|
|
40 |
# ToolsetInit()
|
|
|
41 |
# Runtime initialisation
|
|
|
42 |
#
|
|
|
43 |
##############################################################################
|
|
|
44 |
|
|
|
45 |
ToolsetInit();
|
|
|
46 |
|
|
|
47 |
$MriVersion = "4.3"; # Compiler version
|
|
|
48 |
|
|
|
49 |
sub ToolsetInit
|
|
|
50 |
{
|
|
|
51 |
my( @args ) = @ScmToolsetArgs; # Toolset arguments
|
|
|
52 |
|
|
|
53 |
#.. Parse arguments
|
|
|
54 |
#
|
|
|
55 |
Debug( "mri68k(@args)" );
|
|
|
56 |
|
|
|
57 |
foreach $_ ( @args ) {
|
|
|
58 |
if (/^--Version=(.*)/) { # Compiler version
|
|
|
59 |
$MriVersion = "$1";
|
|
|
60 |
|
|
|
61 |
} else { # Unknown option
|
|
|
62 |
Message( "mri68k: unknown option $_ -- ignored\n" );
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
#.. Standard.rul requirements
|
|
|
67 |
#
|
| 261 |
dpurdie |
68 |
$s = 'asm'; # Assembler source file
|
|
|
69 |
$o = 'obj'; # Object file
|
|
|
70 |
$a = 'lib'; # Library file
|
| 227 |
dpurdie |
71 |
$exe = ""; # Dummy, real image is either 'abs' or 'bin'
|
|
|
72 |
|
|
|
73 |
#.. Define MRI environment
|
|
|
74 |
#
|
|
|
75 |
Init( "mri", "mri2" );
|
|
|
76 |
ToolsetDefine( "#################################################" );
|
|
|
77 |
ToolsetDefine( "# MRI compiler version" );
|
|
|
78 |
ToolsetDefine( "#" );
|
|
|
79 |
ToolsetDefine( "mri_ver = $MriVersion" );
|
|
|
80 |
ToolsetDefine( "" );
|
|
|
81 |
ToolsetDefine( "#" );
|
|
|
82 |
ToolsetDefines( "mri68k.def" );
|
|
|
83 |
ToolsetRules( "mri68k.rul" );
|
|
|
84 |
ToolsetRules( "standard.rul" );
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
###############################################################################
|
|
|
88 |
# ToolsetCC( $source, $obj, \@args )
|
|
|
89 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
90 |
# required to compile the source file 'source' to 'obj'
|
|
|
91 |
#
|
|
|
92 |
###############################################################################
|
|
|
93 |
|
|
|
94 |
sub ToolsetCC
|
|
|
95 |
{
|
|
|
96 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
97 |
|
|
|
98 |
Debug( "CC: $source -> $obj" );
|
|
|
99 |
foreach ( @$pArgs ) {
|
|
|
100 |
Debug( "option: $_" );
|
|
|
101 |
if ( /--Shared$/ ) { # Building a 'shared' object
|
|
|
102 |
$cflags = "$cflags \$(SHCFLAGS)";
|
|
|
103 |
Debug( "CC: as shared object" );
|
|
|
104 |
|
|
|
105 |
} else { # unknown option
|
|
|
106 |
Message( "CC: unknown option $_ -- ignored\n" );
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
MakePrint( "\n\t\$(CC)\n" );
|
|
|
111 |
MakePrint( "\$(OBJDIR)/$i.${o}:\tCFLAGS +=$cflags\n" )
|
|
|
112 |
if ( $cflags );
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
###############################################################################
|
|
|
116 |
# ToolsetCCDepend( $depend, \@sources )
|
|
|
117 |
# This subroutine takes the user options and builds the
|
|
|
118 |
# rule(s) required to build the dependencies for the source
|
|
|
119 |
# files 'sources' to 'depend'.
|
|
|
120 |
#
|
|
|
121 |
###############################################################################
|
|
|
122 |
|
|
|
123 |
sub ToolsetCCDepend
|
|
|
124 |
{
|
|
|
125 |
MakePrint( "\t\$(CCDEPEND)\n" );
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
###############################################################################
|
|
|
130 |
# ToolsetCXX( $source, $obj, \@args )
|
|
|
131 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
132 |
# required to compile the source file 'source' to 'obj'
|
|
|
133 |
#
|
|
|
134 |
###############################################################################
|
|
|
135 |
|
|
|
136 |
sub ToolsetCXX
|
|
|
137 |
{
|
|
|
138 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
139 |
my( $cflags ) = "";
|
|
|
140 |
|
|
|
141 |
Debug( "CCX: $source -> $obj" );
|
|
|
142 |
foreach ( @$pArgs ) {
|
|
|
143 |
Debug( "option: $_" );
|
|
|
144 |
if ( /--Shared$/ ) { # Building a 'shared' object
|
|
|
145 |
$cflags = "$cflags \$(SHCXXFLAGS)";
|
|
|
146 |
Debug( "CCX: as shared object" );
|
|
|
147 |
|
|
|
148 |
} else {
|
|
|
149 |
Message( "CCX: unknown option $_ -- ignored\n" );
|
|
|
150 |
}
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
MakePrint( "\n\t\$(CXX)\n" );
|
|
|
154 |
MakePrint( "\$(OBJDIR)/$i.${o}:\tCXXFLAGS +=$cflags\n" )
|
|
|
155 |
if ( $cflags );
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
###############################################################################
|
| 261 |
dpurdie |
160 |
# ToolsetCXXDepend( $depend, \@sources )
|
|
|
161 |
# This subroutine takes the user options and builds the
|
|
|
162 |
# rule(s) required to build the dependencies for the source
|
|
|
163 |
# files 'sources' to 'depend'.
|
|
|
164 |
#
|
|
|
165 |
###############################################################################
|
|
|
166 |
|
|
|
167 |
sub ToolsetCXXDepend
|
|
|
168 |
{
|
| 287 |
dpurdie |
169 |
ToolsetCCDepend();
|
| 261 |
dpurdie |
170 |
}
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
###############################################################################
|
| 227 |
dpurdie |
174 |
# ToolsetAS( $source, $obj, \@args )
|
|
|
175 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
176 |
# required to compile the source file 'source' to 'obj'
|
|
|
177 |
#
|
|
|
178 |
###############################################################################
|
|
|
179 |
|
|
|
180 |
sub ToolsetAS
|
|
|
181 |
{
|
|
|
182 |
my( $source, $obj, $pArgs ) = @_;
|
|
|
183 |
|
|
|
184 |
foreach $_ ( @$pArgs ) {
|
|
|
185 |
Message( "CC: unknown option $_ -- ignored\n" );
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
MakePrint( "\n\t\$(AS)\n" );
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
sub ToolsetASDepend
|
|
|
192 |
{
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
###############################################################################
|
|
|
197 |
# ToolsetAR( $name, \@args, \@objs )
|
|
|
198 |
# This subroutine takes the user options and builds the rules
|
|
|
199 |
# required to build the library 'name'.
|
|
|
200 |
#
|
|
|
201 |
# Arguments:
|
|
|
202 |
# --Amx[=prefix] local AMX configuration (defaults to platform)
|
|
|
203 |
# --Isp=name ISP module
|
|
|
204 |
# --[wlib|386lib] Librarian (todo)
|
|
|
205 |
#
|
|
|
206 |
# Output:
|
|
|
207 |
# [ $(LIBDIR)/name$.${a}: .... ]
|
|
|
208 |
# $(AR)
|
|
|
209 |
#
|
|
|
210 |
###############################################################################
|
|
|
211 |
|
|
|
212 |
sub ToolsetAR
|
|
|
213 |
{
|
|
|
214 |
my( $name, $pArgs, $pObjs ) = @_;
|
|
|
215 |
my( $amx, @isp, $insight );
|
|
|
216 |
|
|
|
217 |
local( $name_ld );
|
|
|
218 |
|
|
|
219 |
#.. Parse arguments
|
|
|
220 |
#
|
|
|
221 |
$amx = $insight = 0; # options
|
|
|
222 |
foreach $_ ( @$pArgs ) {
|
|
|
223 |
if (/^--Amx$/) { # Local AMX config
|
|
|
224 |
$amx = "\$(SCM_PLATFORM)";
|
|
|
225 |
} elsif (/^--Amx=(.*)/) { # Specific AMX config
|
|
|
226 |
$amx = "$1";
|
|
|
227 |
} elsif (/^--Isp=(.*)/) { # ISP module
|
|
|
228 |
push( @isp, "$1" );
|
|
|
229 |
|
|
|
230 |
} elsif (/^--Insight$/) { # Enable insight
|
|
|
231 |
$insight = 1;
|
|
|
232 |
} elsif (/^--Insight=(.*)/) { # Specific insight
|
|
|
233 |
$insight = "$1";
|
|
|
234 |
|
|
|
235 |
} else {
|
|
|
236 |
Message( "AR: unknown option $_ -- ignored\n" );
|
|
|
237 |
}
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
#.. Standard library builds, plus AMX configuration
|
|
|
241 |
#
|
|
|
242 |
MakeEntry( "\$(LIBDIR)/$name\$(SCM_TYPE).${a}:\t",
|
|
|
243 |
"", "\\\n\t\t", ".${o} ", @$pObjs );
|
|
|
244 |
|
|
|
245 |
#.. Build library with AMX configuration
|
|
|
246 |
#
|
|
|
247 |
foreach (@isp) {
|
|
|
248 |
AmxLibISP( $name, $_ );
|
|
|
249 |
}
|
|
|
250 |
AmxLib( $name, $amx, $insight )
|
|
|
251 |
if ( $amx );
|
|
|
252 |
|
|
|
253 |
#.. Build library rule (just append to standard rule)
|
|
|
254 |
#
|
|
|
255 |
MakePrint( "\n\t\$(AR)\n\n" );
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
###############################################################################
|
|
|
260 |
# ToolsetLD( $name, \@args, \@objs, \@libraries )
|
|
|
261 |
# This subroutine takes the user options and builds the rules
|
|
|
262 |
# required to link the program 'name'.
|
|
|
263 |
#
|
|
|
264 |
# Arguments:
|
|
|
265 |
# EOS specific:
|
|
|
266 |
# --Eos EOS application
|
|
|
267 |
# --Eosx Extended EOS application
|
|
|
268 |
# --EosRom EOS BOOTROM application
|
|
|
269 |
# --EosRomx Extended EOS BOOTROM application
|
|
|
270 |
# --NetUdp[P] Networking with UDP support
|
|
|
271 |
# --NetTcp[P] Networking with TCP support (static routing)
|
|
|
272 |
# --NetTcpx[P] Networking with TCP support (router)
|
|
|
273 |
# --Kdb Kernel debugger
|
|
|
274 |
#
|
|
|
275 |
# AMX specific:
|
|
|
276 |
# --Amx[=prefix] Local AMX configuration (defaults to platform)
|
|
|
277 |
# --Isp=name ISP module
|
|
|
278 |
# --Insight[=prefix] Enable insight (default to platform.icf)
|
|
|
279 |
# (incomplete)
|
|
|
280 |
#
|
|
|
281 |
# Linker specific:
|
|
|
282 |
# --Bin=LoadAddr Download image
|
|
|
283 |
# --Abs Absoluate image (Powerscope/VisionClick)
|
|
|
284 |
# --Section=... Linker sector order directives
|
|
|
285 |
#
|
|
|
286 |
# Output: (also mri68k.rul)
|
|
|
287 |
#
|
|
|
288 |
# $(BINDIR)/name${exe}:
|
|
|
289 |
# $(BINDIR)/name.dep \
|
|
|
290 |
# $(BINDIR)/name.[abs|bin]
|
|
|
291 |
#
|
|
|
292 |
# .PHONY: $(BINDIR)/name${exe}:
|
|
|
293 |
#
|
|
|
294 |
# $(BINDIR)/name.dep: $(SCM_PLATFORM).mk
|
|
|
295 |
# $(LDDEPEND)
|
|
|
296 |
#
|
| 261 |
dpurdie |
297 |
# ifeq "$(IFLAG)" "3"
|
| 227 |
dpurdie |
298 |
# -include "$(BINDIR)/name.dep"
|
|
|
299 |
# endif
|
|
|
300 |
#
|
|
|
301 |
# $(BINDIR)/name.[abs|bin]
|
|
|
302 |
# objs ...
|
|
|
303 |
# {$(LDABS)|$(LDBIN)}
|
|
|
304 |
#
|
|
|
305 |
# name_ld += ... Linker command file
|
|
|
306 |
# :
|
|
|
307 |
#
|
|
|
308 |
# name_dp += ... Dependency list
|
|
|
309 |
# :
|
|
|
310 |
#
|
|
|
311 |
###############################################################################
|
|
|
312 |
|
|
|
313 |
sub ToolsetLD
|
|
|
314 |
{
|
|
|
315 |
my( $name, $pArgs, $pObjs, $pLibs ) = @_;
|
|
|
316 |
my( $linker, $flags, $amx, $insight );
|
|
|
317 |
my( $laddr, $lsize, $section );
|
|
|
318 |
my( $cond );
|
|
|
319 |
local( $varname );
|
|
|
320 |
|
|
|
321 |
#.. Parse arguments
|
|
|
322 |
#
|
|
|
323 |
$amx = $flags = $insight = 0; # generic options
|
|
|
324 |
$section = ""; $laddr = 0; # toolset options
|
|
|
325 |
|
|
|
326 |
foreach $_ ( @$pArgs )
|
|
|
327 |
{
|
|
|
328 |
#.. EOS
|
|
|
329 |
#
|
|
|
330 |
if (/--Eos$/) { # EOS standard
|
|
|
331 |
$flags = $flags | $EOS_LNK;
|
|
|
332 |
} elsif (/^--Eosx$/) { # EOS extended
|
|
|
333 |
$flags = $flags | $EOS_LNK | $EOS_EXT;
|
|
|
334 |
} elsif (/^--EosRom$/) { # ROM image
|
|
|
335 |
$flags = $flags | $EOS_LNK | $EOS_ROM;
|
|
|
336 |
} elsif (/^--EosRomx$/) { # ROM image extended
|
|
|
337 |
$flags = $flags | $EOS_LNK | $EOS_ROM | $EOS_EXT;
|
|
|
338 |
|
|
|
339 |
} elsif (/^--NetUdp$/) {
|
|
|
340 |
$flags = $flags | $NET_UDP;
|
|
|
341 |
} elsif (/^--NetTcp$/) { # TCP with static router
|
|
|
342 |
$flags = $flags | $NET_TCP;
|
|
|
343 |
} elsif (/^--NetTcpx$/) { # TCP with router
|
|
|
344 |
$flags = $flags | $NET_TCP | $NET_ROUTER;
|
|
|
345 |
|
|
|
346 |
} elsif (/^--NetUdpP$/) {
|
|
|
347 |
$flags = $flags | $NET_UDP | $NET_PROD;
|
|
|
348 |
} elsif (/^--NetTcpP$/) { # TCP with static router
|
|
|
349 |
$flags = $flags | $NET_TCP | $NET_PROD;
|
|
|
350 |
} elsif (/^--NetTcpxP$/) { # TCP with router
|
|
|
351 |
$flags = $flags | $NET_TCP | $NET_ROUTER | $NET_PROD;
|
|
|
352 |
|
|
|
353 |
} elsif (/^--Kdb/) { # Kernel debugger
|
|
|
354 |
$flags = $flags | $EOS_KDB;
|
|
|
355 |
|
|
|
356 |
#.. AMX
|
|
|
357 |
#
|
|
|
358 |
} elsif (/^--Amx$/) { # Local AMX config
|
|
|
359 |
$amx = "\$(SCM_PLATFORM)";
|
|
|
360 |
} elsif (/^--Amx=(.*)/) { # Specific AMX config
|
|
|
361 |
$amx = "$1";
|
|
|
362 |
|
|
|
363 |
} elsif (/^--Isp=(.*)/) { # ISP module
|
|
|
364 |
if ( ! $flags && ! $amx ) {
|
|
|
365 |
Message( "LD: --Isp requires either a EOS or AMX application");
|
|
|
366 |
} else {
|
|
|
367 |
AmxLinkISP( $name, "$1", $pObjs, $pLibs );
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
} elsif (/^--Insight$/) { # Enable insight
|
|
|
371 |
$insight = "\$(SCM_PLATFORM)";
|
|
|
372 |
} elsif (/^--Insight=(.*)/) { # Specific insight
|
|
|
373 |
$insight = "$1";
|
|
|
374 |
|
|
|
375 |
#.. Target specific
|
|
|
376 |
#
|
|
|
377 |
} elsif (/^--Abs/) { # Absolute image
|
|
|
378 |
$lsize = $lsize = "";
|
|
|
379 |
|
|
|
380 |
} elsif (/^--Bin$/) { # Binary 'S-Record' image
|
|
|
381 |
$flags = $flags | $EOS_BIN;
|
|
|
382 |
$laddr = "0"; # Load address
|
|
|
383 |
|
|
|
384 |
} elsif (/^--Bin=(.*)/) { # Download image
|
|
|
385 |
$flags = $flags | $EOS_BIN;
|
|
|
386 |
$laddr = "$1"; # Load address
|
|
|
387 |
|
|
|
388 |
} elsif (/^--Bin=(.*),(.*)/) { # Download image
|
|
|
389 |
$flags = $flags | $EOS_BIN;
|
|
|
390 |
$laddr = "$1"; # Load address
|
|
|
391 |
$lsize = "$2"; # Image size
|
|
|
392 |
|
|
|
393 |
} elsif (/^--Section=(.*)/) { # Section directives
|
|
|
394 |
$section = "$1";
|
|
|
395 |
|
|
|
396 |
#.. Toolset specific
|
|
|
397 |
#
|
|
|
398 |
} else {
|
|
|
399 |
Message( "LD: unknown option $_ -- ignored\n" );
|
|
|
400 |
}
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
#.. Command file, EOS and/or AMX dependencies
|
|
|
404 |
#
|
|
|
405 |
# Library search order,
|
|
|
406 |
# Application
|
|
|
407 |
# EOS
|
|
|
408 |
# AMX
|
|
|
409 |
# Toolset
|
|
|
410 |
#
|
|
|
411 |
if ( $flags & $EOS_LNK ) {
|
|
|
412 |
EosLink( $name, $flags, $pObjs, $pLibs );
|
|
|
413 |
if ( $amx ) {
|
|
|
414 |
AmxLinkCfg( $name, $amx, $insight, $pObjs, $pLibs );
|
|
|
415 |
} else {
|
|
|
416 |
AmxLinkStd( $name, $pObjs, $pLibs );
|
|
|
417 |
}
|
|
|
418 |
} elsif ( $amx ) {
|
|
|
419 |
AmxLinkCfg( $name, $amx, $insight, $pObjs, $pLibs );
|
|
|
420 |
}
|
|
|
421 |
push( @$pLibs, "\$(mri)/68020/mcc68kab" );
|
|
|
422 |
|
|
|
423 |
#.. Link rules
|
|
|
424 |
#
|
|
|
425 |
if ($flags & $EOS_BIN)
|
|
|
426 |
{
|
|
|
427 |
MakePrint( "\\\n\t\t\$(BINDIR)/${name}.dep " .
|
|
|
428 |
"\\\n\t\t\$(BINDIR)/${name}.bin\n\n" .
|
|
|
429 |
".PHONY:\t\t\t\$(BINDIR)/${name}${exe}\n\n" );
|
|
|
430 |
|
|
|
431 |
MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n".
|
|
|
432 |
"\t\$(LDDEPEND)\n\n" );
|
|
|
433 |
|
| 261 |
dpurdie |
434 |
MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
|
| 227 |
dpurdie |
435 |
"-include\t\$(BINDIR)/${name}.dep\n" .
|
|
|
436 |
"endif\n\n" );
|
|
|
437 |
|
|
|
438 |
MakePrint( "\$(BINDIR)/${name}.bin:\tLADDR=$laddr\n" )
|
|
|
439 |
if ( $laddr );
|
|
|
440 |
MakePrint( "\$(BINDIR)/${name}.bin:\tLSIZE=$lsize\n" )
|
|
|
441 |
if ( $lsize );
|
|
|
442 |
|
|
|
443 |
MakePrint( "\$(BINDIR)/${name}.bin:" );
|
|
|
444 |
foreach $i ( @$pObjs ) {
|
|
|
445 |
MakePrint( " \\\n\t\t$i.${o}" );
|
|
|
446 |
}
|
|
|
447 |
MakePrint( "\n\t\$(LDBIN)\n" );
|
|
|
448 |
}
|
|
|
449 |
else
|
|
|
450 |
{
|
|
|
451 |
MakePrint( "\\\n\t\t\$(BINDIR)/${name}.dep " .
|
|
|
452 |
"\\\n\t\t\$(BINDIR)/${name}.abs\n\n" .
|
|
|
453 |
".PHONY:\t\t\t\$(BINDIR)/${name}${exe}\n\n" );
|
|
|
454 |
|
|
|
455 |
MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n".
|
|
|
456 |
"\t\$(LDDEPEND)\n\n" );
|
|
|
457 |
|
| 261 |
dpurdie |
458 |
MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
|
| 227 |
dpurdie |
459 |
"-include\t\$(BINDIR)/${name}.dep\n" .
|
|
|
460 |
"endif\n\n" );
|
|
|
461 |
|
|
|
462 |
MakePrint( "\$(BINDIR)/${name}.abs:" );
|
|
|
463 |
foreach $i ( @$pObjs ) {
|
|
|
464 |
MakePrint( " \\\n\t\t$i.${o}" );
|
|
|
465 |
}
|
|
|
466 |
MakePrint( "\n\t\$(LDABS)\n" );
|
|
|
467 |
}
|
|
|
468 |
MakePrint( "\n" );
|
|
|
469 |
|
|
|
470 |
#.. Cleanup rules
|
|
|
471 |
#
|
|
|
472 |
ToolsetGenerate( "\$(BINDIR)/${name}.ld" );
|
|
|
473 |
ToolsetGenerate( "\$(BINDIR)/${name}.dep" );
|
|
|
474 |
if ($laddr) {
|
|
|
475 |
ToolsetGenerate( "\$(BINDIR)/${name}.bin" );
|
|
|
476 |
} else {
|
|
|
477 |
ToolsetGenerate( "\$(BINDIR)/${name}.abs" );
|
|
|
478 |
}
|
|
|
479 |
ToolsetGenerate( "\$(BINDIR)/${name}.map" );
|
|
|
480 |
|
|
|
481 |
#.. Linker command file
|
|
|
482 |
#
|
|
|
483 |
# Now the fun part... piecing together a variable $(name_ld)
|
|
|
484 |
# which ends up in the command file.
|
|
|
485 |
#
|
|
|
486 |
$varname = "${name}_ld";
|
|
|
487 |
sub VarCmd {
|
| 261 |
dpurdie |
488 |
MakeQuote ("$varname += @_\\n\n");
|
| 227 |
dpurdie |
489 |
}
|
|
|
490 |
sub VarPrt {
|
| 261 |
dpurdie |
491 |
MakePrint ("@_\n");
|
| 227 |
dpurdie |
492 |
}
|
|
|
493 |
|
|
|
494 |
VarCmd("CASE"); #preserve symbols case
|
|
|
495 |
VarCmd("WARN 356"); #warning for undef sections
|
|
|
496 |
VarCmd("CHIP CPU32"); #68xxx (68332/68340/68341)
|
|
|
497 |
VarCmd("INITDATA vars"); #initialise 'vars' section
|
|
|
498 |
|
|
|
499 |
if ($section) {
|
|
|
500 |
VarPrt("#.. User specified section directives");
|
|
|
501 |
VarCmd("$section");
|
|
|
502 |
|
|
|
503 |
} else {
|
|
|
504 |
if (($flags & $EOS_LNK) || $amx) {
|
|
|
505 |
|
|
|
506 |
if ($flags & $EOS_ROM) { #BOOTROM
|
|
|
507 |
if ($flags & $EOS_BIN) {
|
|
|
508 |
VarPrt("#.. Linking an EOS-AMX/ROM image (Binary image)");
|
|
|
509 |
} else {
|
|
|
510 |
VarPrt("#.. Linking an EOS-AMX/ROM image (Powerscope image)");
|
|
|
511 |
}
|
|
|
512 |
|
|
|
513 |
VarCmd("extern _BootVectors"); #create an external reference
|
|
|
514 |
VarCmd("alias code CODE"); #CODE alias
|
|
|
515 |
VarCmd("align vectors 4"); #align on quad boundaries
|
|
|
516 |
VarCmd("align ramVectors 4"); #..
|
|
|
517 |
VarCmd("align header 4"); #..
|
|
|
518 |
VarCmd("align (CODE)=4"); #..
|
|
|
519 |
VarCmd("align (DATA)=4"); #..
|
|
|
520 |
VarCmd("align (ROMDATA)=4"); #..
|
|
|
521 |
|
|
|
522 |
if ($flags & $EOS_ROM) {
|
|
|
523 |
VarCmd("order SysRom"); #boot ROM/flash
|
|
|
524 |
} else {
|
|
|
525 |
VarCmd("order SysRam");
|
|
|
526 |
}
|
|
|
527 |
VarCmd("order vectors,header,startup,code");
|
|
|
528 |
VarCmd("order const,literals,strings,??INITDATA");
|
|
|
529 |
|
|
|
530 |
if ($flags & $EOS_ROM) {
|
|
|
531 |
# Note: Shall generate a order warning if the ROM load address
|
|
|
532 |
# is NOT positioned at $0.
|
|
|
533 |
#
|
|
|
534 |
# eg. "(374) ORDER command could not be obeyed for section SysRam."
|
|
|
535 |
#..
|
|
|
536 |
VarCmd("order SysRam,PLoadEnv"); #program loader RAM
|
|
|
537 |
}
|
|
|
538 |
|
|
|
539 |
VarCmd("order preserve,protected,ramVectors");
|
|
|
540 |
VarCmd("order vars,zerovars"); #MRI specific
|
|
|
541 |
VarCmd("order ioports,tags"); #..
|
|
|
542 |
VarCmd("order 0") #..
|
|
|
543 |
if ($MriVersion ne "4.4");
|
|
|
544 |
|
|
|
545 |
VarCmd("order BootStack,BootData");
|
|
|
546 |
|
|
|
547 |
} else { #application
|
|
|
548 |
if ($flags & $EOS_BIN) {
|
|
|
549 |
VarPrt("#.. Linking an EOS-AMX/Application image (Binary image)");
|
|
|
550 |
} else {
|
|
|
551 |
VarPrt("#.. Linking an EOS-AMX/Application image (Powerscope image)");
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
VarCmd("extern _AsReset"); #create an external reference
|
|
|
555 |
VarCmd("alias code CODE"); #CODE alias
|
|
|
556 |
VarCmd("align vectors 4"); #align on quad boundaries
|
|
|
557 |
VarCmd("align ramVectors 4"); #..
|
|
|
558 |
VarCmd("align header 4"); #..
|
|
|
559 |
VarCmd("align (CODE)=4"); #..
|
|
|
560 |
VarCmd("align (DATA)=4"); #..
|
|
|
561 |
VarCmd("align (ROMDATA)=4"); #..
|
|
|
562 |
VarCmd("order SysRam"); #define sections to go into RAM
|
|
|
563 |
#EOS/AS (start of RAM)
|
|
|
564 |
VarCmd("order preserve,protected,ramVectors");
|
|
|
565 |
VarCmd("order vars,zerovars"); #MRI specific
|
|
|
566 |
VarCmd("order ioports,tags"); #..
|
|
|
567 |
VarCmd("order 0") #..
|
|
|
568 |
if ($MriVersion ne "4.4");
|
|
|
569 |
VarCmd("order stack"); #application stack
|
|
|
570 |
|
|
|
571 |
if ($flags & $EOS_BIN) {
|
|
|
572 |
VarCmd("order SysFlash"); #code image into FLASH
|
|
|
573 |
}
|
|
|
574 |
|
|
|
575 |
VarCmd("order header,vectors"); #EOS/AS (start of FLASH)
|
|
|
576 |
VarCmd("order startup,code"); #..
|
|
|
577 |
VarCmd("order const"); #constant data sections
|
|
|
578 |
VarCmd("order literals");
|
|
|
579 |
VarCmd("order strings");
|
|
|
580 |
VarCmd("order ??INITDATA"); #data to copy into RAM
|
|
|
581 |
}
|
|
|
582 |
} else {
|
|
|
583 |
VarPrt("#.. Link a generic 68k image");
|
|
|
584 |
VarCmd("sect vectors 0000");
|
|
|
585 |
VarCmd("sectsize vectors= 1024");
|
|
|
586 |
VarCmd("common stack= 1024");
|
|
|
587 |
VarCmd("sectsize stack= 4096");
|
|
|
588 |
VarCmd("order vectors,stack,code");
|
|
|
589 |
VarCmd("order literals,strings,const");
|
|
|
590 |
VarCmd("order ??INITDATA,vars,zerovars");
|
|
|
591 |
}
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
VarPrt("#.. The following are cmdfile macros, with libraries");
|
|
|
595 |
VarPrt("# repeated due to single pass linker wierdness");
|
|
|
596 |
foreach $i ( @$pObjs ) {
|
|
|
597 |
VarCmd("LOAD @(dosify,$i.${o})" );
|
|
|
598 |
}
|
|
|
599 |
|
|
|
600 |
# Libraries
|
|
|
601 |
$cond = "";
|
|
|
602 |
foreach $_ ( @$pLibs ) {
|
|
|
603 |
if (/^--ifdef=(.*)/) { # .. conditionals
|
|
|
604 |
$cond = "$1";
|
|
|
605 |
VarPrt( "ifdef $cond" );
|
|
|
606 |
next;
|
|
|
607 |
} elsif (/^--ifndef=(.*)/) {
|
|
|
608 |
$cond = "$1";
|
|
|
609 |
VarPrt( "ifndef $cond" );
|
|
|
610 |
next;
|
|
|
611 |
} elsif (/^--*/) { # .. unknown
|
|
|
612 |
Message( "LD: unknown lib option $_ -- ignored\n" );
|
|
|
613 |
next;
|
|
|
614 |
}
|
|
|
615 |
# .. entry
|
|
|
616 |
VarCmd("LOAD @(dosify,@(vpath2,$_.${a},MRI_LIB))" );
|
|
|
617 |
|
|
|
618 |
if ($cond) { # .. end condition
|
|
|
619 |
VarPrt("endif\t# $cond");
|
|
|
620 |
$cond = "";
|
|
|
621 |
}
|
|
|
622 |
}
|
|
|
623 |
|
|
|
624 |
# single pass linker wierdness
|
|
|
625 |
foreach $_ ( @$pLibs ) {
|
|
|
626 |
if (/^--ifdef=(.*)/) { # .. conditionals
|
|
|
627 |
$cond = "$1";
|
|
|
628 |
VarPrt( "ifdef $cond" );
|
|
|
629 |
next;
|
|
|
630 |
} elsif (/^--ifndef=(.*)/) {
|
|
|
631 |
$cond = "$1";
|
|
|
632 |
VarPrt( "ifndef $cond" );
|
|
|
633 |
next;
|
|
|
634 |
} elsif (/^--*/) { # .. unknown (warning only once)
|
|
|
635 |
next;
|
|
|
636 |
}
|
|
|
637 |
# .. entry
|
|
|
638 |
VarCmd("LOAD @(dosify,@(vpath2,$_.${a},MRI_LIB))" );
|
|
|
639 |
|
|
|
640 |
if ($cond) { # .. end condition
|
|
|
641 |
VarPrt("endif\t# $cond");
|
|
|
642 |
$cond = "";
|
|
|
643 |
}
|
|
|
644 |
}
|
|
|
645 |
|
|
|
646 |
|
|
|
647 |
VarPrt("#.. Map file options");
|
|
|
648 |
VarCmd("LISTABS INTERNALS, PUBLICS");
|
|
|
649 |
VarCmd("LISTMAP LENGTH 64"); # map file page length");
|
|
|
650 |
VarCmd("LISTMAP CROSSREF,INTERNALS,PUBLICS/by_addr");
|
|
|
651 |
VarCmd("DEBUG_SYMBOLS");
|
|
|
652 |
VarCmd("END");
|
|
|
653 |
VarPrt( "" );
|
|
|
654 |
|
|
|
655 |
#.. Dependency link,
|
|
|
656 |
#
|
|
|
657 |
# Now piece together a variable $(name_dp) which ends up in
|
|
|
658 |
# the command file building the application dependency list.
|
|
|
659 |
#
|
|
|
660 |
$varname = "${name}_dp";
|
|
|
661 |
|
|
|
662 |
$cond = "";
|
|
|
663 |
foreach $_ ( @$pLibs ) {
|
|
|
664 |
if (/^--ifdef=(.*)/) { # .. conditionals
|
|
|
665 |
$cond = "$1";
|
|
|
666 |
VarPrt( "ifdef $cond\n" );
|
|
|
667 |
next;
|
|
|
668 |
} elsif (/^--ifndef=(.*)/) {
|
|
|
669 |
$cond = "$1";
|
|
|
670 |
VarPrt( "ifndef $cond\n" );
|
|
|
671 |
next;
|
|
|
672 |
} elsif (/^--*/) { # .. unknown (warning only once)
|
|
|
673 |
next;
|
|
|
674 |
}
|
|
|
675 |
# .. entry
|
|
|
676 |
if ($laddr) {
|
|
|
677 |
VarCmd("\$(BINDIR)/${name}.bin: @(vpath2,$_.${a},MRI_LIB)" );
|
|
|
678 |
} else {
|
|
|
679 |
VarCmd("\$(BINDIR)/${name}.abs: @(vpath2,$_.${a},MRI_LIB)" );
|
|
|
680 |
}
|
|
|
681 |
|
|
|
682 |
if ($cond) { # .. end condition
|
|
|
683 |
VarPrt("endif\t# $cond\n");
|
|
|
684 |
$cond = "";
|
|
|
685 |
}
|
|
|
686 |
}
|
|
|
687 |
|
|
|
688 |
#end ...
|
|
|
689 |
}
|
|
|
690 |
|
|
|
691 |
#.. Successful termination
|
|
|
692 |
1;
|
|
|
693 |
|