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: mak; -*-
2
###############################################################################
3
# Copyright (c) 1996-2003 ERG Transit Systems.
4
#
5
# File:         TOOLSET/mos_mri.rul[e]
6
# Contents:     MRI 68k/CF rules as used for the MOS
7
#               Make definitions for the Microtec tools.
8
#
9
# Description:
10
#       MRI 68k/CF toolset for MOS
11
#       This file provides Toolset rules for the target makefiles
12
#       The file is dropped into the target makefile
13
#
14
# Revision History:
15
#       12-Feb-04   DDP     Started Work
16
###############################################################################
17
 
18
###############################################################################
19
#..     Remove "undef" warnings
20
#
21
cc_includes	+=
22
cc_defines	+=
23
as_includes	+=
24
as_defines	+=
25
cxx_includes	+=
26
cxx_defines	+=
27
 
28
###############################################################################
29
#..     Parse user options
30
#       Global options already parsed
31
#       These options extend the global options
32
#
33
ifdef OPTIONS
34
endif
35
 
36
###############################################################################
37
#..     C Compiler definition
38
#
39
#
40
#   Compiler flags
41
#   -A,     - Sets ANSI-compliant mode. -nA disables all ANSI features. This
42
#             is not the same as strict ansi, so don't use it.
43
#   -c      - Produces an object file but not an executable file.
44
#   -Feo    - Writes diagnostic messages to standard output.
45
#   -Fsm    - Includes high-level source code as comments in the assembly output file.
46
#   -g      - Generates debugging information.
47
#   -H      - Saves assembly file.
48
#   -Og     - Enables global-flow optimizations.
49
#   -Ol     - Enables local optimizations.
50
#   -OR     - Allocates heavily used variables to registers.
51
#   -Ob     - Performs optimizations that assume that global memory objects are not changed through aliases.
52
#             Do not use. More troible than its worth.
53
#   -Oe     - Generates only one exit (return) from a function.
54
#   -Or     - Enables instruction scheduling optimization.
55
#   -Os     - Optimizes in favor of code size rather than execution time.
56
#   -v      - Detects and issues warnings for features in the source files that can cause problems.
57
#   -x      - Enables Microtec Compiler extensions to C and C++. (default)
58
#   -Kf     - Generate stack frame for all functions.
59
#
60
#
61
#   The following options are specified within $(mri_compiler_flags) and are considered global
62
#   -pxxxx  - Produces code for a specified processor.
63
#   -mac    - Take advantage of the ColdFire MAC unit.
64
#   -mdiv   - Take advantage of the ColdFire DIV unit.
65
#   -Gf     - Generates fully qualified path names for input files.
66
#   -KhA5   - Reserves one or more registers.
67
#   -Ku     - Treats plain char variables as unsigned.
68
#   -Mcp    - Use PC-relative addressing for all code references.
69
#   -Md5    - Use register-relative addressing for all static data references.
70
#   -Ml     - Use 32-bit displacements for register An-relative or PC-relative addressing.
71
#   -nQ     - The -nQ option does not suppress any messages.
72
#   -nze    - Disable C++ exception handling.
73
#   -Wa,-fNOPCR     - Passes options to the assembler.
74
#   -Xp     - Allocates space for global variables that have not been explicitly initialized.
75
#   -zc     - Allows // comments in C code.
76
#
77
cc              = $(CC_PRE) $(mri_compiler)
78
cc_init         =
79
cc_o_switch     =
80
cc_object       = -o$@
81
cc_source       = $<
82
cc_cmdfile      = $(basename $@).cmd
83
cc_flags        = -d$(cc_cmdfile)
84
cc_defines      = $(mri_compiler_define) $(MRI_DEFINES)
85
 
86
cc_filter := $(wildcard $(GBE_ROOT)/warnings.mri)
87
ifdef cc_filter
88
cc_redirect     = 1
89
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.mri
90
endif
91
 
92
mri_includes    += $(MRI_INC)
93
mri_flags       += -c $(mri_compiler_flags)
94
mri_flags       += -v -Feo
95
 
96
ifdef USE_32BIT_RELATIVE
97
mri_flags       += -Ml
98
endif
99
 
100
ifdef LEAVETMP
101
mri_flags       += -H -Fsm
102
endif
103
 
104
ifdef USE_STRICT_ANSI
105
mri_flags       += -A -nx
106
else
107
mri_flags       += -A -x
108
endif
109
 
110
mri_compiler_opt ?= -Ol -OR -Or -Os -Oe -nOb
111
ifdef USE_OPTIMISE
112
ifdef NO_OPT_GLOBAL
113
mri_flags       += -nOg
114
else
115
mri_flags       += -Og
116
endif
117
mri_flags       += $(mri_compiler_opt)
118
else
119
mri_flags       += -nOl -nOR -nOg
120
endif
121
 
122
ifdef USE_DEBUGINFO
123
mri_flags       += -g -DDEBUG -Kf
124
else
125
mri_flags       += -DNDEBUG -U_DEBUG -UDEBUG    # Compiler bug. _DEBUG is defined by default
126
endif
127
 
128
ifdef ALVL
129
mri_flags       += -DALVL=$(ALVL)
130
endif
131
 
132
ifdef DLVL
133
mri_flags       += -DDLVL=$(DLVL)
134
endif
135
mri_flags       += -D__SOURCE__=$(notdir $<)
136
 
137
#
138
#   Before executing the compiler we must
139
#   1) Create a command file to contain all the command line arguments
140
#   2) Work around a bug in the MicroTex 68K compiler
141
#      The bug is that the compiler uses temp files, but it does not
142
#      ensure that the files are empty before it uses them.
143
#      The work around is to generate the temp files in a known directory
144
#      and to delete all temp files before we compile.
145
#
146
define cc_pre
147
        @$(echo) [$<] compiling.. ; \
148
        $(cmdfile) -ko$(cc_cmdfile) "\
149
                $(patsubst %,%\\n,$(CFLAGS)) \
150
                $(patsubst %,-D%\\n,$(cc_defines)) \
151
                $(patsubst %,%\\n,$(mri_flags)) \
152
                -J$(subst /,\\\\,$(dir $<))\\n \
153
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(INCDIRS))) \
154
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(cc_includes))) \
155
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(mri_includes))) \
156
                $(subst /,\\\\,$(cc_object))";\
157
                if [ -n "$(MRI_TMP)" ] ; then\
158
                    if [ ! -d $(MRI_TMP) ] ; then mkdir -p $(MRI_TMP) ; fi;\
159
                    touch $(MRI_TMP)/xxx;\
160
                    cd "$(MRI_TMP)" && rm -f *;\
161
                fi
162
endef
163
 
164
ifndef LEAVETMP
165
define cc_post
166
        @$(rm) -f $(cc_cmdfile)
167
endef
168
else
169
define cc_post
170
endef
171
endif
172
 
173
###############################################################################
174
#..     C/C++ dependencies
175
#       depend and depend.err
176
#
177
mri_depend      = -D__STDC__
178
ifdef USE_DEBUGINFO
179
mri_depend       += -DDEBUG
180
else
181
mri_depend       += -DNDEBUG
182
endif
183
ifdef ALVL
184
mri_depend      += -DALVL=$(ALVL)
185
endif
186
ifdef DLVL
187
mri_depend      += -DDLVL=$(DLVL)
188
endif
189
mri_depend      += -D__SOURCE__=$(notdir $<)
190
 
191
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
192
ccdep_init      =
193
ccdep_o_switch  = -f -
194
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
195
ccdep_flags     = -MM -b -p \$$\(OBJDIR\)/ \
196
                  $(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
197
                  -o .$(o) \
198
                  $(patsubst %,%,$(CFLAGS)) \
199
                  $(patsubst %,-D%,$(cc_defines)) \
200
                  $(patsubst %,%,$(mri_depend)) \
201
                  $(patsubst %,-I %,$(INCDIRS)) \
202
                  $(patsubst %,-Y %,$(cc_includes)) \
203
                  $(patsubst %,-Y %,$(mri_includes)) \
204
                  $(patsubst %,-Y %,$(NODEPDIRS))
205
ccdep_pre       =
206
ccdep_post      =
207
 
208
#..     C/C++ Lint definitions
209
#
210
lint_flags	+= \
211
	$(patsubst %,%,$(mri_depend)) \
212
	$(patsubst %,%,$(CLINTFLAGS)) \
213
	$(patsubst %,-D%,$(cc_defines)) \
214
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(INCDIRS))) \
215
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(cc_includes))) \
216
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(mri_includes)))
217
 
218
 
219
lint_libpath	= $(MRI_LIB)
220
 
221
 
222
#..     C++ Compiler definition
223
#
224
cxx             = $(CC_PRE) $(mri_cpp_compiler)
225
cxx_init        =
226
cxx_o_switch    =
227
cxx_object      = -o$@
228
cxx_source      = $<
229
cxx_cmdfile     = $(basename $@).cmd
230
cxx_flags       = -d$(cxx_cmdfile)
231
 
232
define cxx_pre
233
        @$(echo) [\$<] compiling.. ; \
234
        $(cmdfile) -ko$(cxx_cmdfile) "\
235
                $(patsubst %,%\\n,$(CFLAGS)) \
236
                $(patsubst %,-D%\\n,$(cc_defines)) \
237
                $(patsubst %,%\\n,$(mri_flags)) \
238
                -J$(subst /,\\\\,$(dir $<))\\n \
239
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(INCDIRS))) \
240
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(cc_includes))) \
241
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(mri_includes))) \
242
                $(subst /,\\\\,$(cxx_object))"
243
endef
244
 
245
ifndef LEAVETMP
246
define cxx_post
247
        @$(rm) -f $(cxx_cmdfile)
248
endef
249
else
250
define cxx_post
251
endef
252
endif
253
 
254
 
255
 
256
 
257
###############################################################################
258
#..     Assembler definition
259
#
260
# Note:  All the options go on the command line at present so this
261
#        passes a minimal set of definitions. (v4.3)
262
#
263
 
264
as              = $(XX_PRE) $(mri_assembler)
265
as_init         =
266
as_i_switch     = -I
267
as_o_switch     = -o$@
268
as_source       = <$<
269
as_cmdfile      =
270
 
271
asm68_flags     = -fP=$(mri_cpu_type) -frel32 -DCcCpu=$(mri_cpu_code) -fd
272
asm68_flags    += $(ASFLAGS)
273
 
274
ifdef as_defines
275
asm68_flags    += $(addprefix -D,$(as_defines))
276
endif
277
 
278
ifdef USE_DEBUGINFO
279
asm68_flags       += -DDEBUG
280
else
281
asm68_flags       += -DNDEBUG
282
endif
283
 
284
as_flags        = $(asm68_flags)
285
ifdef as_includes
286
as_flags       += "-I$(subst $(space),;,$(strip $(as_includes)))"
287
endif
288
 
289
as_flags       += $(patsubst %,-I%,$(INCDIRS))
290
 
291
define as_pre
235 dpurdie 292
    @$(echo) [$@] Assembling file ; \
293
    if [ -n "$(MRI_TMP)" ] ; then\
294
        if [ ! -d $(MRI_TMP) ] ; then mkdir -p $(MRI_TMP) ; fi;\
295
        touch $(MRI_TMP)/xxx;\
296
        cd "$(MRI_TMP)" && rm -f *;\
297
    fi
298
 
227 dpurdie 299
endef
300
define as_post
301
endef
302
 
303
 
304
#..     Archiver
305
#
306
ar              = $(XX_PRE) $(mri_librarian)
307
ar_init         =
308
ar_cmdfile      = $(basename $@).ar
309
ar_logfile      = $(basename $@).ar.log
310
ar_flags        =
311
ar_o_switch     = < $(ar_cmdfile)
312
ar_term         = > $(ar_logfile)
313
 
314
define ar_pre
315
        @$(echo) [\$@] Creating library archive.. ; \
316
        $(rm) -f $@ ;\
317
        $(cmdfile) -ko$(ar_cmdfile) \
318
                create $@\\n\
319
                $(patsubst %,addmod %\\n,$(filter %.obj, $^))\
320
                save\\n end\\n
321
endef
322
 
323
ifndef LEAVETMP
324
define ar_post
325
        @$(rm) -f $(ar_logfile) $(ar_cmdfile)
326
endef
327
else
328
define ar_post
329
endef
330
endif
331
 
332
 
333
#..     Archive Merge
334
#
335
armerge              = $(XX_PRE) $(mri_librarian)
336
armerge_init         =
337
armerge_cmdfile      = $(basename $@).armerge
338
armerge_logfile      = $(basename $@).armerge.log
339
armerge_flags        =
340
armerge_o_switch     = < $(armerge_cmdfile) > $(armerge_logfile)
341
 
342
define armerge_pre
343
        @$(echo) [\$@] Creating a Merged library.. ; \
344
        $(rm) -f $@ ;\
345
        $(cmdfile) -ko$(armerge_cmdfile) \
346
                create $@\\n\
347
                $(patsubst %,addlib %\\n,$^)\
348
                save\\n end\\n
349
endef
350
 
351
ifndef LEAVETMP
352
define armerge_post
353
        @$(rm) -f $(armerge_logfile) $(armerge_cmdfile)
354
endef
355
else
356
define armerge_post
357
endef
358
endif
359
 
360
 
361
#..     Linker
362
#
363
shld              = $(XX_PRE) $(mri_linker)
364
shld_cmdfile      = $(basename $@).ld
365
shld_depfile	  = $(subst /,\\,$(basename $@).dep)
366
shldabs_flags     = -m -c$(shld_cmdfile)
367
shldabs_o_switch  = -o$(basename $@).abs > $(basename $@).map
368
 
369
define shld_pre
370
        @$(echo) [$@] Linking program .. ;\
371
        export MRI_LIB; \
372
                MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \
373
        $(cmdfile) -ko$(shld_cmdfile) "$($(notdir $(SHBASE))_shld)"
374
endef
375
 
376
ifndef LEAVETMP
377
define shld_post
378
        @$(rm) -f $(shld_cmdfile)
379
endef
380
else
381
define shld_post
382
endef
383
endif
384
 
385
define SHLDABS
386
        $(show_environment)
387
        $(shld_pre)
388
        $(shld) $(shldabs_flags) $(shldabs_o_switch); rv=$$?; [ $$rv = 0 ] || rm -f $@; exit $$rv
389
        $(shld_post)
390
endef
391
 
392
#
393
#   Create Library dependency file
394
#
395
define SHLDDEPEND
396
        $(XX_PRE) export MRI_LIB; \
397
                MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \
398
	$(cmdfile) -ko$(shld_depfile) "$($(notdir $(SHBASE))_shdp)";
399
endef
400
 
401
#
402
#   Use the BRT utility to generate relocation information
403
#   Assumes that the variable BRTROOT has been set to provide the root of all file names
404
#
405
define  BRT
406
    @$(echo) "[$@] Generate Relocation information.."
407
	$(XX_PRE)$(TOOL_BRT) $(OBJDIR)/$(BRTROOT)_0.abs $(OBJDIR)/$(BRTROOT)_o.abs $(OBJDIR)/$(BRTROOT)_rtab_cd.asm $(OBJDIR)/$(BRTROOT)_rtab_d.asm
408
endef
409
 
410
 
411
#
412
#   Use the modcrc utility to convert an .abs files (really s19) into a .thx file
413
#
414
define  MODCRC
415
    @$(echo) "[$@] Add CRC information.."
416
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -t=247
417
endef
418
 
419
#
420
#   Use the modcrc utility to convert an .abs files (really s19) into a .bin file
421
#
422
define  MODCRC_BIN
423
    @$(echo) "[$@] Add CRC information to BIN.."
424
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -o=bin
425
endef
426
 
427
#
428
#   Convert the .rel file into a head.obj file
429
#   This is done as an atomic step
430
#   NOTE: This is a function and not a definition
431
#       Args:   $1 - Rel file
432
#               $2 - head.asm file
433
#               $3 - output objfile
434
#               $4 - saved head.inc file
435
#
436
#   Assumes that include files required by head.asm are in the same
437
#   directory as head.asm.
438
#
439
define AS_HEAD
440
    @$(echo) "[$@] Creating module header.."
441
    $(XX_PRE) $(TOOL_REL) i -d$1 -t$(OBJDIR)
442
	$(XX_PRE) $(as) -fP=$(mri_cpu_type) -fd -fNOPCR -frel32 -I $(OBJDIR) -I $(dir $2) -o$3 <$2
443
    $(XX_PRE) $(rm) -f $4
444
    $(XX_PRE) $(cp) $(OBJDIR)/head.inc $4
445
endef
446
 
447
 
448
#
449
#   Create VisionClick files
450
#   Args:   $1 Path of the source ABS file
451
#           $2 Output visionclick path file
452
#           $3 Vclick drive prefix
453
#   Use convert twice: Sometimes fails if both files generated together
454
#
455
define  VCLICK
456
    $(XX_PRE) $(echo) "[$@]Create VISIONCLICK files.." ;\
457
    $(TOOL_VPATHS) $1 -o $2 -p $3 ;\
458
    $(est32)/convert -e $(basename $1).abs -c $(basename $1).ab ;\
459
    $(est32)/convert -e $(basename $1).abs -b $(basename $1).bdx
460
endef
461
 
462
#