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): Cygnus/Thyron
7
#
8
# Description:
9
#   Cygnus C/C++ toolset 
10
#
11
# Version   Who      Date        Description
12
# 1.0       APY      17/10/02    Created
13
#............................................................................#
14
 
15
##############################################################################
16
#   ToolsetInit()
17
#       Runtime initialisation
18
#
19
##############################################################################
20
 
21
ToolsetInit();
22
 
23
$CygnusVersion              = "2.0";            # Compiler version
24
 
25
sub ToolsetInit
26
{
27
#.. Parse arguments
28
#
29
    Debug( "cygnus_thyron(@args)\n" );
30
 
31
    foreach $_ ( @args ) {
32
        if (/^--Version=(.*)/) {                # Compiler version
33
            $MriVersion = "$1";
34
 
35
        } else {                                # Unknown option
36
            Message( "cygnus_thyron: 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( "cygnus_thyron" );
50
 
51
    ToolsetDefine( "#################################################" );
52
    ToolsetDefine( "# Compiler version" );
53
    ToolsetDefine( "#" );
54
    ToolsetDefine( "cygnus_ver      = $CygnusVersion" );
55
    ToolsetDefine( "" );
56
    ToolsetDefine( "#" );
57
 
58
    ToolsetDefines( "cygnus_thyron.def" );
59
    ToolsetRules( "cygnus_thyron.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" );
280
    if ($bin) {
281
        ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).bin" );
282
        ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).s2" );
283
        ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).prg" );
284
    }
285
    else {
286
        ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).abs" );
287
    }
288
    ToolsetGenerate( "\$(BINDIR)/${name}\$(GBE_TYPE).map" );
227 dpurdie 289
 
290
#.. Linker command file
291
#
292
#       Now the fun part... piecing together a variable $(name_ld)
293
#       which ends up in the command file.
294
#
295
if ($bin)
296
{
251 dpurdie 297
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).dep " .
298
               "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).prg\n\n" .
299
               ".PHONY:\t\t\t\$(BINDIR)/${name}\$(GBE_TYPE)${exe}\n\n" );
227 dpurdie 300
 
251 dpurdie 301
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).dep:\t\$(SCM_PLATFORM).mk\n".
227 dpurdie 302
 	            "\t\$(LDDEPEND)\n\n" );
303
 
261 dpurdie 304
    MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
251 dpurdie 305
               "-include\t\$(BINDIR)/${name}\$(GBE_TYPE).dep\n" .
227 dpurdie 306
               "endif\n\n" );
307
 
251 dpurdie 308
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).prg:" );
227 dpurdie 309
    foreach $i ( @$pObjs ) {
310
        MakePrint( " \\\n\t\t$i.${o}" );
311
    }
312
    MakePrint( "\n\t\$(LD)" );
313
    MakePrint( "\n\t\$(cygnus)\\objcopy -O srec \$(basename \$@).bin \$(basename \$@).s2" );
241 dpurdie 314
    MakePrint( "\n\t\$(thyron)\\thyron\\tools\\s2toprog \$(basename \$@).s2 \$@" );
227 dpurdie 315
}
316
else
317
{
251 dpurdie 318
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).dep " .
319
               "\\\n\t\t\$(BINDIR)/${name}\$(GBE_TYPE).abs\n\n" .
320
               ".PHONY:\t\t\t\$(BINDIR)/${name}\$(GBE_TYPE)${exe}\n\n" );
227 dpurdie 321
 
251 dpurdie 322
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).dep:\t\$(SCM_PLATFORM).mk\n".
227 dpurdie 323
 	            "\t\$(LDDEPEND)\n\n" );
324
 
261 dpurdie 325
    MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
251 dpurdie 326
               "-include\t\$(BINDIR)/${name}\$(GBE_TYPE).dep\n" .
227 dpurdie 327
               "endif\n\n" );
328
 
251 dpurdie 329
    MakePrint( "\$(BINDIR)/${name}\$(GBE_TYPE).abs:" );
227 dpurdie 330
    foreach $i ( @$pObjs ) {
331
        MakePrint( " \\\n\t\t$i.${o}" );
332
    }
333
    MakePrint( "\n\t\$(LD)\n" );
334
}
335
    MakePrint( "\n" );
336
 
337
#.. Linker command file
338
#
339
#       Now the fun part... piecing together a variable $(name_ld)
340
#       which ends up in the command file.
341
#
251 dpurdie 342
    $varname = "${name}\$(GBE_TYPE)_ld";
227 dpurdie 343
    sub VarCmd {                                # with line feed ...
261 dpurdie 344
        MakeQuote ("$varname += @_\\n\n");
227 dpurdie 345
    }
346
    sub VarCmd2 {                               # without line feed ...
261 dpurdie 347
        MakeQuote ("$varname += @_\n");
227 dpurdie 348
    }
349
    sub VarPrt {
261 dpurdie 350
        MakePrint ("@_\n");
227 dpurdie 351
    }
352
 
353
 
354
	# Section definitions and startup code:
355
	#
356
	#   HDI  file to generate ABS target for HDI.
357
	#   OS   files to generate S2 target to run under operating system.
358
	#..
359
 
360
	VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
361
	    VarCmd( "\$(MPTLIB)/Lib/Debug/Bin/start.o" );
362
    VarPrt( "else" );
363
    	VarCmd( "\$(MPTLIB)/Lib/Release/Bin/start.o" );
364
    VarPrt( "endif" );
365
 
366
    foreach $i ( @$pObjs ) {
367
        VarCmd( "\$(strip $i).${o}" );
368
    }
369
    foreach $i ( @$pLibs ) {
370
        VarCmd( "@(vpath,$i.${a},GCC_LIB)" );
371
    }
372
 
373
	VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
374
        VarCmd( "\$(MPTLIB)/Lib/Debug/Bin/appllib.a" );
375
		VarCmd( "\$(MPTLIB)/Lib/Debug/Bin/payclibh.a" );
376
        VarCmd( "-L \$(MPTLIB)/Lib/Debug/Bin" );
377
        VarCmd( "-L \$(MPTLIB)/StdCLib/Debug/Bin" );
378
    VarPrt( "else" );
379
    	VarCmd( "\$(MPTLIB)/Lib/Release/Bin/appllib.a" );
380
	    VarCmd( "-L \$(MPTLIB)/Lib/Release/Bin" );
381
    	VarCmd( "-L \$(MPTLIB)/StdCLib/Release/Bin" );
382
    VarPrt( "endif" );
383
 
251 dpurdie 384
    VarCmd( "-Map \$(BINDIR)/${name}\$(GBE_TYPE).map" );
227 dpurdie 385
 
386
	if ($bin)
387
	{
251 dpurdie 388
        VarCmd( "-o \$(BINDIR)/${name}\$(GBE_TYPE).bin" );
227 dpurdie 389
	}
390
	else
391
	{
251 dpurdie 392
        VarCmd( "-o \$(BINDIR)/${name}\$(GBE_TYPE).abs" );
227 dpurdie 393
	}
394
 
395
	VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
396
        VarCmd( "-T \$(MPTLIB)/Lib/Debug/Lnk/link.cmd" );
397
#		VarCmd( "-lg" );						# Required for HDI debugger
398
 		VarCmd( "-lgdb" );						# Required for Insight debugger
399
    VarPrt( "else" );
400
        VarCmd( "-T \$(MPTLIB)/Lib/Release/Lnk/link.cmd" );
401
    VarPrt( "endif" );
402
 
403
    VarCmd( "-lc" );
404
	VarCmd( "-lm" );
405
	VarCmd( "-lgcc" );
406
 
407
    VarPrt( "" );
408
 
409
#.. Dependency link,
410
#
411
#       Now piece together a variable $(name_dp) which ends up in
412
#       the command file building the application dependency list.
413
#
251 dpurdie 414
    $varname = "${name}\$(GBE_TYPE)_dp";
227 dpurdie 415
 
416
    foreach $i ( @$pLibs ) {
251 dpurdie 417
         VarCmd("\$(BINDIR)/${name}\$(GBE_TYPE)${exe}: @(vpath,$i.${a},GCC_LIB)" );
227 dpurdie 418
    }
251 dpurdie 419
 
420
    if ($bin)
421
    {
422
        PackageProgRemoveFiles($name);
423
        PackageProgAddFiles($name, "\$(BINDIR)/${name}\$(GBE_TYPE).prg");
424
    }
425
    else
426
    {
427
        PackageProgRemoveFiles($name);
428
        PackageProgAddFiles($name, "\$(BINDIR)/${name}\$(GBE_TYPE).abs");
429
    }
227 dpurdie 430
}
431
 
432
#.. Successful termination
433
1;
434