Subversion Repositories DevTools

Rev

Go to most recent revision | Details | 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
#
42
    $s = asm;
43
    $o = o;
44
    $a = a;
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
{
144
    #ToolsetCCDepend() handles both CC and CXX source
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
#
231
#       ifeq "$(IFLAG)" "2"
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
#
278
    ToolsetGenerate( "\$(BINDIR)/${name}.ld" );
279
    ToolsetGenerate( "\$(BINDIR)/${name}.dep" );
280
if ($bin) {
281
    ToolsetGenerate( "\$(BINDIR)/${name}.bin" );
282
    ToolsetGenerate( "\$(BINDIR)/${name}.s2" );
283
}
284
    ToolsetGenerate( "\$(BINDIR)/${name}.map" );
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
{
293
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}.dep " .
294
               "\\\n\t\t\$(BINDIR)/${name}.prg\n\n" .
295
               ".PHONY:\t\t\t\$(BINDIR)/${name}${exe}\n\n" );
296
 
297
    MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n".
298
 	            "\t\$(LDDEPEND)\n\n" );
299
 
300
    MakePrint( "ifeq \"\$(IFLAG)\" \"2\"\n" .
301
               "-include\t\$(BINDIR)/${name}.dep\n" .
302
               "endif\n\n" );
303
 
304
    MakePrint( "\$(BINDIR)/${name}.prg:" );
305
    foreach $i ( @$pObjs ) {
306
        MakePrint( " \\\n\t\t$i.${o}" );
307
    }
308
    MakePrint( "\n\t\$(LD)" );
309
    MakePrint( "\n\t\$(cygnus)\\objcopy -O srec \$(basename \$@).bin \$(basename \$@).s2" );
241 dpurdie 310
    MakePrint( "\n\t\$(thyron)\\thyron\\tools\\s2toprog \$(basename \$@).s2 \$@" );
227 dpurdie 311
}
312
else
313
{
314
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}.dep " .
315
               "\\\n\t\t\$(BINDIR)/${name}.abs\n\n" .
316
               ".PHONY:\t\t\t\$(BINDIR)/${name}${exe}\n\n" );
317
 
318
    MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n".
319
 	            "\t\$(LDDEPEND)\n\n" );
320
 
321
    MakePrint( "ifeq \"\$(IFLAG)\" \"2\"\n" .
322
               "-include\t\$(BINDIR)/${name}.dep\n" .
323
               "endif\n\n" );
324
 
325
    MakePrint( "\$(BINDIR)/${name}.abs:" );
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
#
338
    $varname = "${name}_ld";
339
    sub VarCmd {                                # with line feed ...
340
        MakeQuote "$varname += @_\\n\n";
341
    }
342
    sub VarCmd2 {                               # without line feed ...
343
        MakeQuote "$varname += @_\n";
344
    }
345
    sub VarPrt {
346
        MakePrint "@_\n";
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( "\$(MPTLIB)/Lib/Debug/Bin/payclibh.a" );
372
        VarCmd( "-L \$(MPTLIB)/Lib/Debug/Bin" );
373
        VarCmd( "-L \$(MPTLIB)/StdCLib/Debug/Bin" );
374
    VarPrt( "else" );
375
    	VarCmd( "\$(MPTLIB)/Lib/Release/Bin/appllib.a" );
376
	    VarCmd( "-L \$(MPTLIB)/Lib/Release/Bin" );
377
    	VarCmd( "-L \$(MPTLIB)/StdCLib/Release/Bin" );
378
    VarPrt( "endif" );
379
 
380
    VarCmd( "-Map \$(BINDIR)/${name}.map" );
381
 
382
	if ($bin)
383
	{
384
        VarCmd( "-o \$(BINDIR)/${name}.bin" );
385
	}
386
	else
387
	{
388
        VarCmd( "-o \$(BINDIR)/${name}.abs" );
389
	}
390
 
391
	VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
392
        VarCmd( "-T \$(MPTLIB)/Lib/Debug/Lnk/link.cmd" );
393
#		VarCmd( "-lg" );						# Required for HDI debugger
394
 		VarCmd( "-lgdb" );						# Required for Insight debugger
395
    VarPrt( "else" );
396
        VarCmd( "-T \$(MPTLIB)/Lib/Release/Lnk/link.cmd" );
397
    VarPrt( "endif" );
398
 
399
    VarCmd( "-lc" );
400
	VarCmd( "-lm" );
401
	VarCmd( "-lgcc" );
402
 
403
    VarPrt( "" );
404
 
405
#.. Dependency link,
406
#
407
#       Now piece together a variable $(name_dp) which ends up in
408
#       the command file building the application dependency list.
409
#
410
    $varname = "${name}_dp";
411
 
412
    foreach $i ( @$pLibs ) {
413
         VarCmd("\$(BINDIR)/${name}${exe}: @(vpath,$i.${a},GCC_LIB)" );
414
    }
415
}
416
 
417
#.. Successful termination
418
1;
419