Subversion Repositories DevTools

Rev

Rev 261 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: perl -*- 
2
#
3
# Module name   : cygnus_thyron
4
# Module type   : Makefile system
5
# Compiler(s)   : ANSI C
6
# Environment(s): GNU/MPT
7
#
8
# Description:
9
#   GNU C/C++ toolset
10
#
11
# Version   Who      Date        Description
12
# 1.0       ANT      11/05/04    Created
13
#............................................................................#
14
 
15
##############################################################################
16
#   ToolsetInit()
17
#       Runtime initialisation
18
#
19
##############################################################################
20
 
21
ToolsetInit();
22
 
23
$GNUVersion                 = "3.0";            # Compiler version
24
 
25
sub ToolsetInit
26
{
27
#.. Parse arguments
28
#
29
    Debug( "gnu_mpt(@args)\n" );
30
 
31
    foreach $_ ( @args ) {
32
        if (/^--Version=(.*)/) {                # Compiler version
33
            $MriVersion = "$1";
34
 
35
        } else {                                # Unknown option
36
            Message( "gnu_mpt: unknown option $_ -- ignored\n" );
37
        }
38
    }
39
 
40
#.. Standard.rul requirements
41
#
261 dpurdie 42
    $s = 'asm';
43
    $o = 'o';
44
    $a = 'a';
227 dpurdie 45
    $exe = "";
46
 
47
#.. Define environment
48
#
49
    Init( "gnu_mpt" );
50
 
51
    ToolsetDefine( "#################################################" );
52
    ToolsetDefine( "# Compiler version" );
53
    ToolsetDefine( "#" );
54
    ToolsetDefine( "gnu_ver      = $GNUVersion" );
55
    ToolsetDefine( "" );
56
    ToolsetDefine( "#" );
57
 
58
    ToolsetDefines( "gnu_mpt.def" );
59
    ToolsetRules( "gnu_mpt.rul" );
60
    ToolsetRules( "standard.rul" );
61
}
62
 
63
 
64
###############################################################################
65
#   ToolsetCC( $source, $obj, \@args )
66
#       This subroutine takes the user options and builds the rule(s)
67
#       required to compile the source file 'source' to 'obj'
68
#
69
###############################################################################
70
 
71
sub ToolsetCC
72
{
73
    my( $source, $obj, $pArgs ) = @_;
74
 
75
    Debug( "CC:  $source -> $obj" );
76
    foreach ( @$pArgs ) {
77
        Debug( "option:    $_" );
78
        if ( /--Shared$/ ) {                    # Building a 'shared' object
79
            $cflags = "$cflags \$(SHCFLAGS)";
80
            Debug( "CC:    as shared object" );
81
        } else {                                # unknown option
82
            Message( "CC: unknown option $_ -- ignored\n" );
83
        }
84
    }
85
 
86
    MakePrint( "\n\t\$(CC)\n" );
87
    MakePrint( "\$(OBJDIR)/$i.${o}:\tCFLAGS +=$cflags\n" )
88
        if ( $cflags );
89
}
90
 
91
###############################################################################
92
#   ToolsetCCDepend( $depend, \@sources )
93
#       This subroutine takes the user options and builds the
94
#       rule(s) required to build the dependencies for the source
95
#       files 'sources' to 'depend'.
96
#
97
###############################################################################
98
 
99
sub ToolsetCCDepend
100
{
101
    MakePrint( "\t\$(CCDEPEND)\n" );
102
}
103
 
104
 
105
###############################################################################
106
#   ToolsetCXX( $source, $obj, \@args )
107
#       This subroutine takes the user options and builds the rule(s)
108
#       required to compile the source file 'source' to 'obj'
109
#
110
###############################################################################
111
 
112
sub ToolsetCXX
113
{
114
    my( $source, $obj, $pArgs ) = @_;
115
    my( $cflags ) = "";
116
 
117
    Debug( "CCX: $source -> $obj" );
118
    foreach ( @$pArgs ) {
119
        Debug( "option:    $_" );
120
        if ( /--Shared$/ ) {                    # Building a 'shared' object
121
            $cflags = "$cflags \$(SHCXXFLAGS)";
122
            Debug( "CCX:    as shared object" );
123
        } else {
124
            Message( "CCX: unknown option $_ -- ignored\n" );
125
        }
126
    }
127
 
128
    MakePrint( "\n\t\$(CXX)\n" );
129
    MakePrint( "\$(OBJDIR)/$i.${o}:\tCXXFLAGS +=$cflags\n" )
130
        if ( $cflags );
131
}
132
 
133
 
134
###############################################################################
135
#   ToolsetCXXDepend( $depend, \@sources )
136
#       This subroutine takes the user options and builds the
137
#       rule(s) required to build the dependencies for the source
138
#       files 'sources' to 'depend'.
139
#
140
###############################################################################
141
 
142
sub ToolsetCXXDepend
143
{
287 dpurdie 144
    ToolsetCCDepend();
227 dpurdie 145
}
146
 
147
 
148
###############################################################################
149
#   ToolsetAS( $source, $obj, \@args )
150
#       This subroutine takes the user options and builds the rule(s)
151
#       required to compile the source file 'source' to 'obj'
152
#
153
###############################################################################
154
 
155
sub ToolsetAS
156
{
157
    my( $source, $obj, $pArgs ) = @_;
158
 
159
    foreach $_ ( @$pArgs ) {
160
        Message( "CC: unknown option $_ -- ignored\n" );
161
    }
162
 
163
    MakePrint( "\n\t\$(AS)\n" );
164
}
165
 
166
sub ToolsetASDepend
167
{
168
}
169
 
170
 
171
###############################################################################
172
#   ToolsetAR( $name, \@args, \@objs )
173
#       This subroutine takes the user options and builds the rules
174
#       required to build the library 'name'.
175
#
176
#   Arguments:
177
#       n/a
178
#
179
#   Output:
180
#       [ $(BINDIR)/name$.${a}:   .... ]
181
#           $(AR)
182
#
183
#       name_ld += ...  Linker command file
184
#           :
185
#
186
#       name_dp += ...  Dependency list
187
#           :
188
#
189
###############################################################################
190
 
191
sub ToolsetAR
192
{
193
    my( $name, $pArgs, $pObjs ) = @_;
194
 
195
    local( $name_ld );
196
 
197
#.. Parse arguments
198
#
199
    foreach $_ ( @$pArgs ) 
200
    {
201
        Message( "AR: unknown option $_ -- ignored\n" );
202
    }
203
 
204
#.. Build library rule (just append to standard rule)
205
#
206
    MakeEntry( "\$(LIBDIR)/$name\$(SCM_TYPE).${a}:\t",
207
                  "", "\\\n\t\t", ".${o} ", @$pObjs );
208
 
209
    MakePrint( "\n\t\$(AR)\n\n" );
210
}
211
 
212
 
213
###############################################################################
214
#   ToolsetLD( $name, \@args, \@objs, \@libraries )
215
#       This subroutine takes the user options and builds the rules
216
#       required to link the program 'name'.
217
#
218
#   Arguments:
219
#        n/a
220
#
221
#   Output:
222
#     $(BINDIR)/name${exe}:
223
#                   $(BINDIR)/name.dep \
224
#                   $(BINDIR)/name.[abs|bin]
225
#
226
#       .PHONY:                 $(BINDIR)/name${exe}:
227
#
228
#       $(BINDIR)/name.dep:     $(SCM_PLATFORM).mk
229
#               $(LDDEPEND)
230
#
261 dpurdie 231
#       ifeq "$(IFLAG)" "3"
227 dpurdie 232
#       -include    "$(BINDIR)/name.dep"
233
#       endif
234
#
235
#     $(BINDIR)/name.[abs|bin]
236
#                       objs ...
237
#               $(LD)
238
#
239
#       name_ld += ...  Linker command file
240
#           :
241
#
242
#       name_dp += ...  Dependency list
243
#           :
244
#
245
###############################################################################
246
 
247
sub ToolsetLD
248
{
249
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
250
    my( $bin );
251
    local( $varname );
252
 
253
#.. Parse arguments
254
#
255
    $bin = 0;                                   # toolset options
256
 
257
    foreach $_ ( @$pArgs )
258
    {
259
    #.. Target specific
260
    #
261
        if (/^--Bin/) {                         # Download image
262
            $bin = 1;
263
        } elsif (/^--Abs/) {                    # Powerscope image
264
            $bin = 0;
265
 
266
    #.. Toolset specific
267
    #
268
        } else {
269
            Message( "LD: unknown option $_ -- ignored\n" );
270
        }
271
    }
272
 
273
#.. Command file EOS dependencies
274
#
275
 
276
#.. Cleanup rules
277
#
251 dpurdie 278
    ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).ld" );
279
    ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).dep" );
227 dpurdie 280
if ($bin) {
251 dpurdie 281
    ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).bin" );
282
    ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).s2" );
227 dpurdie 283
}
251 dpurdie 284
    ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).map" );
227 dpurdie 285
 
286
#.. Linker command file
287
#
288
#       Now the fun part... piecing together a variable $(name_ld)
289
#       which ends up in the command file.
290
#
291
if ($bin)
292
{
251 dpurdie 293
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).dep " .
294
               "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).prg\n\n" .
295
               ".PHONY:\t\t\t\$(BINDIR)/${name}\$(GBE_TYPE)${exe}\n\n" );
227 dpurdie 296
 
251 dpurdie 297
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).dep:\t\$(SCM_PLATFORM).mk\n".
227 dpurdie 298
                 "\t\$(LDDEPEND)\n\n" );
299
 
261 dpurdie 300
    MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
251 dpurdie 301
               "-include\t\$(BINDIR)/${name}\$(GBE_TYPE).dep\n" .
227 dpurdie 302
               "endif\n\n" );
303
 
251 dpurdie 304
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).prg:" );
227 dpurdie 305
    foreach $i ( @$pObjs ) {
306
        MakePrint( " \\\n\t\t$i.${o}" );
307
    }
308
    MakePrint( "\n\t\$(LD)" );
309
    MakePrint( "\n\t\$(GNUBIN)\\objcopy -O srec \$(basename \$@).bin \$(basename \$@).s2" );
310
    MakePrint( "\n\t\$(thyron)\\thyron\\tools\\s2toprog \$(basename \$@).s2 \$@" );
311
}
312
else
313
{
251 dpurdie 314
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).dep " .
315
               "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).abs\n\n" .
316
               ".PHONY:\t\t\t\$(BINDIR)/${name}\$(GBE_TYPE)${exe}\n\n" );
227 dpurdie 317
 
251 dpurdie 318
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).dep:\t\$(SCM_PLATFORM).mk\n".
227 dpurdie 319
                 "\t\$(LDDEPEND)\n\n" );
320
 
261 dpurdie 321
    MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
251 dpurdie 322
               "-include\t\$(BINDIR)/${name}\$(GBE_TYPE).dep\n" .
227 dpurdie 323
               "endif\n\n" );
324
 
251 dpurdie 325
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).abs:" );
227 dpurdie 326
    foreach $i ( @$pObjs ) {
327
        MakePrint( " \\\n\t\t$i.${o}" );
328
    }
329
    MakePrint( "\n\t\$(LD)\n" );
330
}
331
    MakePrint( "\n" );
332
 
333
#.. Linker command file
334
#
335
#       Now the fun part... piecing together a variable $(name_ld)
336
#       which ends up in the command file.
337
#
251 dpurdie 338
    $varname = "${name}\$(GBE_TYPE)_ld";
227 dpurdie 339
    sub VarCmd {                                # with line feed ...
261 dpurdie 340
        MakeQuote ("$varname += @_\\n\n");
227 dpurdie 341
    }
342
    sub VarCmd2 {                               # without line feed ...
261 dpurdie 343
        MakeQuote ("$varname += @_\n");
227 dpurdie 344
    }
345
    sub VarPrt {
261 dpurdie 346
        MakePrint ("@_\n");
227 dpurdie 347
    }
348
 
349
 
350
    # Section definitions and startup code:
351
    #
352
    #   HDI  file to generate ABS target for HDI.
353
    #   OS   files to generate S2 target to run under operating system.
354
    #..
355
 
356
    VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
357
        VarCmd( "\$(MPTLIB)/lib/debug/bin/start.o" );
358
    VarPrt( "else" );
359
        VarCmd( "\$(MPTLIB)/lib/release/bin/start.o" );
360
    VarPrt( "endif" );
361
 
362
    foreach $i ( @$pObjs ) {
363
        VarCmd( "\$(strip $i).${o}" );
364
    }
365
    foreach $i ( @$pLibs ) {
366
        VarCmd( "@(vpath,$i.${a},GCC_LIB)" );
367
    }
368
 
369
    VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
370
        VarCmd( "\$(MPTLIB)/lib/debug/bin/appllib.a" );
371
        VarCmd( "-L \$(MPTLIB)/lib/debug/bin" );
372
        VarCmd( "-L \$(MPTLIB)/stdclib/debug/bin" );
373
        VarCmd( "-L \$(MPTLIB)/genlib/com/paycell2/debug/bin" );
374
        VarCmd( "-L \$(MPTLIB)/genlib/dat/paycell2/debug/bin" );
375
        VarCmd( "-L \$(MPTLIB)/genlib/lwip/paycell2/debug/bin" );
376
        VarCmd( "-L \$(MPTLIB)/genlib/pcc/paycell2/debug/bin" );
377
        VarCmd( "-L \$(MPTLIB)/genlib/tmr/paycell2/debug/bin" );
378
        VarCmd( "-L \$(MPTLIB)/genlib/tsk/paycell2/debug/bin" );
379
        VarCmd( "-L \$(MPTLIB)/genlib/xtr/paycell2/debug/bin" );
380
    VarPrt( "else" );
381
        VarCmd( "\$(MPTLIB)/lib/release/bin/appllib.a" );
382
        VarCmd( "-L \$(MPTLIB)/lib/release/bin" );
383
        VarCmd( "-L \$(MPTLIB)/stdclib/release/bin" );
384
        VarCmd( "-L \$(MPTLIB)/genlib/com/paycell2/release/bin" );
385
        VarCmd( "-L \$(MPTLIB)/genlib/dat/paycell2/release/bin" );
386
        VarCmd( "-L \$(MPTLIB)/genlib/lwip/paycell2/release/bin" );
387
        VarCmd( "-L \$(MPTLIB)/genlib/pcc/paycell2/release/bin" );
388
        VarCmd( "-L \$(MPTLIB)/genlib/tmr/paycell2/release/bin" );
389
        VarCmd( "-L \$(MPTLIB)/genlib/tsk/paycell2/release/bin" );
390
        VarCmd( "-L \$(MPTLIB)/genlib/xtr/paycell2/release/bin" );
391
    VarPrt( "endif" );
392
 
251 dpurdie 393
    VarCmd( "-Map \$(BINDIR)/${name}\$(GBE_TYPE).map" );
227 dpurdie 394
 
395
    if ($bin)
396
    {
251 dpurdie 397
        VarCmd( "-o \$(BINDIR)/${name}\$(GBE_TYPE).bin" );
227 dpurdie 398
    }
399
    else
400
    {
251 dpurdie 401
        VarCmd( "-o \$(BINDIR)/${name}\$(GBE_TYPE).abs" );
227 dpurdie 402
    }
403
 
404
    VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
405
        VarCmd( "-T \$(MPTLIB)/Lib/Debug/Lnk/link.cmd" );
406
        VarCmd( "-lgdb" );                        # Required for Insight debugger
407
    VarPrt( "else" );
408
        VarCmd( "-T \$(MPTLIB)/Lib/Release/Lnk/link.cmd" );
409
    VarPrt( "endif" );
410
 
411
    VarCmd( "-lcom" );                            # Thyron Libraries
412
    VarCmd( "-ldat" );
413
    VarCmd( "-llwip" );
414
    VarCmd( "-lpcc" );
415
    VarCmd( "-ltsk" );
416
    VarCmd( "-ltmr" );
417
    VarCmd( "-lxtr" );
418
 
419
    VarCmd( "-lc" );
420
    VarCmd( "-lm" );
421
    VarCmd( "-lgcc" );
422
 
423
    VarPrt( "" );
424
 
425
#.. Dependency link,
426
#
427
#       Now piece together a variable $(name_dp) which ends up in
428
#       the command file building the application dependency list.
429
#
251 dpurdie 430
    $varname = "${name}\$(GBE_TYPE)_dp";
227 dpurdie 431
 
432
    foreach $i ( @$pLibs ) {
251 dpurdie 433
         VarCmd("\$(BINDIR)/${name}\$(GBE_TYPE)${exe}: @(vpath,$i.${a},GCC_LIB)" );
227 dpurdie 434
    }
251 dpurdie 435
 
436
    if ($bin)
437
    {
438
        PackageProgRemoveFiles($name);
439
        PackageProgAddFiles($name, "\$(BINDIR)/${name}\$(GBE_TYPE).prg");
440
    }
441
    else
442
    {
443
        PackageProgRemoveFiles($name);
444
        PackageProgAddFiles($name, "\$(BINDIR)/${name}\$(GBE_TYPE).abs");
445
    }
227 dpurdie 446
}
447
 
448
#.. Successful termination
449
1;
450