Subversion Repositories DevTools

Rev

Rev 5709 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: mak; -*-
2
###############################################################################
6177 dpurdie 3
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
227 dpurdie 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.
237 dpurdie 48
#   -Og     - Enables global-flow optimizations. (-nOg is default)
227 dpurdie 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
 
95
ifdef USE_32BIT_RELATIVE
96
mri_flags       += -Ml
97
endif
98
 
99
ifdef LEAVETMP
100
mri_flags       += -H -Fsm
101
endif
102
 
237 dpurdie 103
mri_compiler_strict_ansi    ?= -A -nx
104
mri_compiler_no_strict_ansi ?= -A -x
105
 
227 dpurdie 106
ifdef USE_STRICT_ANSI
237 dpurdie 107
mri_flags       += $(mri_compiler_strict_ansi)
227 dpurdie 108
else
237 dpurdie 109
mri_flags       += $(mri_compiler_no_strict_ansi)
227 dpurdie 110
endif
111
 
237 dpurdie 112
mri_compiler_opt    ?= -Ol -OR -Or -Os -Oe -nOb
113
mri_compiler_no_opt ?= -nOl -nOR -nOg
114
 
241 dpurdie 115
mri_compiler_no_gopt ?= -nOg
116
mri_compiler_gopt    ?= -Og
237 dpurdie 117
 
227 dpurdie 118
ifdef USE_OPTIMISE
119
ifdef NO_OPT_GLOBAL
237 dpurdie 120
mri_flags       += $(mri_compiler_no_gopt)
227 dpurdie 121
else
237 dpurdie 122
mri_flags       += $(mri_compiler_gopt)
227 dpurdie 123
endif
124
mri_flags       += $(mri_compiler_opt)
125
else
237 dpurdie 126
mri_flags       += $(mri_compiler_no_opt)
227 dpurdie 127
endif
128
 
237 dpurdie 129
mri_compiler_flags_debug    ?= -g -DDEBUG -Kf
130
mri_compiler_flags_no_debug ?= -DNDEBUG -U_DEBUG -UDEBUG    # Compiler bug. _DEBUG is defined by default
131
 
227 dpurdie 132
ifdef USE_DEBUGINFO
237 dpurdie 133
mri_flags       += $(mri_compiler_flags_debug)
227 dpurdie 134
else
237 dpurdie 135
mri_flags       += $(mri_compiler_flags_no_debug)
227 dpurdie 136
endif
137
 
138
ifdef ALVL
139
mri_flags       += -DALVL=$(ALVL)
140
endif
141
 
142
ifdef DLVL
143
mri_flags       += -DDLVL=$(DLVL)
144
endif
145
mri_flags       += -D__SOURCE__=$(notdir $<)
146
 
147
#
148
#   Before executing the compiler we must
149
#   1) Create a command file to contain all the command line arguments
150
#   2) Work around a bug in the MicroTex 68K compiler
151
#      The bug is that the compiler uses temp files, but it does not
152
#      ensure that the files are empty before it uses them.
153
#      The work around is to generate the temp files in a known directory
154
#      and to delete all temp files before we compile.
155
#
156
define cc_pre
6177 dpurdie 157
        @$(echo) '[$<] compiling..' ; \
227 dpurdie 158
        $(cmdfile) -ko$(cc_cmdfile) "\
159
                $(patsubst %,%\\n,$(CFLAGS)) \
160
                $(patsubst %,-D%\\n,$(cc_defines)) \
161
                $(patsubst %,%\\n,$(mri_flags)) \
162
                -J$(subst /,\\\\,$(dir $<))\\n \
163
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(INCDIRS))) \
164
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(cc_includes))) \
165
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(mri_includes))) \
166
                $(subst /,\\\\,$(cc_object))";\
167
                if [ -n "$(MRI_TMP)" ] ; then\
168
                    if [ ! -d $(MRI_TMP) ] ; then mkdir -p $(MRI_TMP) ; fi;\
169
                    touch $(MRI_TMP)/xxx;\
170
                    cd "$(MRI_TMP)" && rm -f *;\
171
                fi
172
endef
173
 
174
ifndef LEAVETMP
175
define cc_post
176
        @$(rm) -f $(cc_cmdfile)
177
endef
178
else
179
define cc_post
180
endef
181
endif
182
 
183
###############################################################################
184
#..     C/C++ dependencies
185
#       depend and depend.err
186
#
187
mri_depend      = -D__STDC__
188
ifdef USE_DEBUGINFO
189
mri_depend       += -DDEBUG
190
else
191
mri_depend       += -DNDEBUG
192
endif
193
ifdef ALVL
194
mri_depend      += -DALVL=$(ALVL)
195
endif
196
ifdef DLVL
197
mri_depend      += -DDLVL=$(DLVL)
198
endif
199
mri_depend      += -D__SOURCE__=$(notdir $<)
200
 
201
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
202
ccdep_init      =
203
ccdep_o_switch  = -f -
204
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
205
ccdep_flags     = -MM -b -p \$$\(OBJDIR\)/ \
206
                  $(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
207
                  -o .$(o) \
208
                  $(patsubst %,%,$(CFLAGS)) \
209
                  $(patsubst %,-D%,$(cc_defines)) \
210
                  $(patsubst %,%,$(mri_depend)) \
211
                  $(patsubst %,-I %,$(INCDIRS)) \
212
                  $(patsubst %,-Y %,$(cc_includes)) \
213
                  $(patsubst %,-Y %,$(mri_includes)) \
214
                  $(patsubst %,-Y %,$(NODEPDIRS))
215
ccdep_pre       =
216
ccdep_post      =
217
 
218
#..     C/C++ Lint definitions
219
#
220
lint_flags	+= \
221
	$(patsubst %,%,$(mri_depend)) \
222
	$(patsubst %,%,$(CLINTFLAGS)) \
223
	$(patsubst %,-D%,$(cc_defines)) \
224
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(INCDIRS))) \
225
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(cc_includes))) \
226
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(mri_includes)))
227
 
228
 
229
lint_libpath	= $(MRI_LIB)
230
 
231
 
232
#..     C++ Compiler definition
233
#
234
cxx             = $(CC_PRE) $(mri_cpp_compiler)
235
cxx_init        =
236
cxx_o_switch    =
237
cxx_object      = -o$@
238
cxx_source      = $<
239
cxx_cmdfile     = $(basename $@).cmd
240
cxx_flags       = -d$(cxx_cmdfile)
241
 
242
define cxx_pre
6177 dpurdie 243
        @$(echo) '[$<] compiling..' ; \
227 dpurdie 244
        $(cmdfile) -ko$(cxx_cmdfile) "\
245
                $(patsubst %,%\\n,$(CFLAGS)) \
246
                $(patsubst %,-D%\\n,$(cc_defines)) \
247
                $(patsubst %,%\\n,$(mri_flags)) \
248
                -J$(subst /,\\\\,$(dir $<))\\n \
249
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(INCDIRS))) \
250
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(cc_includes))) \
251
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(mri_includes))) \
252
                $(subst /,\\\\,$(cxx_object))"
253
endef
254
 
255
ifndef LEAVETMP
256
define cxx_post
257
        @$(rm) -f $(cxx_cmdfile)
258
endef
259
else
260
define cxx_post
261
endef
262
endif
263
 
264
 
265
 
266
 
267
###############################################################################
268
#..     Assembler definition
269
#
270
# Note:  All the options go on the command line at present so this
271
#        passes a minimal set of definitions. (v4.3)
272
#
273
 
274
as              = $(XX_PRE) $(mri_assembler)
275
as_init         =
276
as_i_switch     = -I
277
as_o_switch     = -o$@
278
as_source       = <$<
279
as_cmdfile      =
280
 
281
asm68_flags     = -fP=$(mri_cpu_type) -frel32 -DCcCpu=$(mri_cpu_code) -fd
282
asm68_flags    += $(ASFLAGS)
283
 
284
ifdef as_defines
285
asm68_flags    += $(addprefix -D,$(as_defines))
286
endif
287
 
288
ifdef USE_DEBUGINFO
289
asm68_flags       += -DDEBUG
290
else
291
asm68_flags       += -DNDEBUG
292
endif
293
 
294
as_flags        = $(asm68_flags)
295
ifdef as_includes
296
as_flags       += "-I$(subst $(space),;,$(strip $(as_includes)))"
297
endif
298
 
299
as_flags       += $(patsubst %,-I%,$(INCDIRS))
300
 
301
define as_pre
6177 dpurdie 302
    @$(echo) '[$@] Assembling file..' ; \
235 dpurdie 303
    if [ -n "$(MRI_TMP)" ] ; then\
304
        if [ ! -d $(MRI_TMP) ] ; then mkdir -p $(MRI_TMP) ; fi;\
305
        touch $(MRI_TMP)/xxx;\
306
        cd "$(MRI_TMP)" && rm -f *;\
307
    fi
308
 
227 dpurdie 309
endef
310
define as_post
311
endef
312
 
313
 
314
#..     Archiver
315
#
316
ar              = $(XX_PRE) $(mri_librarian)
317
ar_init         =
318
ar_cmdfile      = $(basename $@).ar
319
ar_logfile      = $(basename $@).ar.log
320
ar_flags        =
321
ar_o_switch     = < $(ar_cmdfile)
322
ar_term         = > $(ar_logfile)
323
 
324
define ar_pre
6177 dpurdie 325
        @$(echo) '[$@] Creating library archive..' ; \
227 dpurdie 326
        $(rm) -f $@ ;\
327
        $(cmdfile) -ko$(ar_cmdfile) \
328
                create $@\\n\
329
                $(patsubst %,addmod %\\n,$(filter %.obj, $^))\
330
                save\\n end\\n
331
endef
332
 
333
ifndef LEAVETMP
334
define ar_post
335
        @$(rm) -f $(ar_logfile) $(ar_cmdfile)
336
endef
337
else
338
define ar_post
339
endef
340
endif
341
 
342
 
343
#..     Archive Merge
344
#
345
armerge              = $(XX_PRE) $(mri_librarian)
346
armerge_init         =
347
armerge_cmdfile      = $(basename $@).armerge
348
armerge_logfile      = $(basename $@).armerge.log
349
armerge_flags        =
350
armerge_o_switch     = < $(armerge_cmdfile) > $(armerge_logfile)
351
 
352
define armerge_pre
6177 dpurdie 353
        @$(echo) '[$@] Creating a Merged library..' ; \
227 dpurdie 354
        $(rm) -f $@ ;\
355
        $(cmdfile) -ko$(armerge_cmdfile) \
356
                create $@\\n\
357
                $(patsubst %,addlib %\\n,$^)\
358
                save\\n end\\n
359
endef
360
 
361
ifndef LEAVETMP
362
define armerge_post
363
        @$(rm) -f $(armerge_logfile) $(armerge_cmdfile)
364
endef
365
else
366
define armerge_post
367
endef
368
endif
369
 
370
 
371
#..     Linker
372
#
373
shld              = $(XX_PRE) $(mri_linker)
374
shld_cmdfile      = $(basename $@).ld
375
shldabs_flags     = -m -c$(shld_cmdfile)
376
shldabs_o_switch  = -o$(basename $@).abs > $(basename $@).map
377
 
378
define shld_pre
6177 dpurdie 379
        @$(echo) '[$@] Linking program ..' ;\
227 dpurdie 380
        export MRI_LIB; \
381
                MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \
382
        $(cmdfile) -ko$(shld_cmdfile) "$($(notdir $(SHBASE))_shld)"
383
endef
384
 
385
ifndef LEAVETMP
386
define shld_post
387
        @$(rm) -f $(shld_cmdfile)
388
endef
389
else
390
define shld_post
391
endef
392
endif
393
 
394
define SHLDABS
395
        $(show_environment)
396
        $(shld_pre)
397
        $(shld) $(shldabs_flags) $(shldabs_o_switch); rv=$$?; [ $$rv = 0 ] || rm -f $@; exit $$rv
398
        $(shld_post)
399
endef
400
 
401
#
402
#   Create Library dependency file
403
#
404
define SHLDDEPEND
405
        $(XX_PRE) export MRI_LIB; \
406
                MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 407
	$(cmdfile) -ko$@ "$($(DPLIST))";
227 dpurdie 408
endef
409
 
410
#
411
#   Use the BRT utility to generate relocation information
412
#   Assumes that the variable BRTROOT has been set to provide the root of all file names
413
#
414
define  BRT
415
    @$(echo) "[$@] Generate Relocation information.."
416
	$(XX_PRE)$(TOOL_BRT) $(OBJDIR)/$(BRTROOT)_0.abs $(OBJDIR)/$(BRTROOT)_o.abs $(OBJDIR)/$(BRTROOT)_rtab_cd.asm $(OBJDIR)/$(BRTROOT)_rtab_d.asm
417
endef
418
 
419
 
420
#
421
#   Use the modcrc utility to convert an .abs files (really s19) into a .thx file
422
#
423
define  MODCRC
424
    @$(echo) "[$@] Add CRC information.."
425
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -t=247
426
endef
427
 
428
#
429
#   Use the modcrc utility to convert an .abs files (really s19) into a .bin file
430
#
431
define  MODCRC_BIN
432
    @$(echo) "[$@] Add CRC information to BIN.."
433
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -o=bin
434
endef
435
 
436
#
437
#   Convert the .rel file into a head.obj file
438
#   This is done as an atomic step
439
#   NOTE: This is a function and not a definition
440
#       Args:   $1 - Rel file
441
#               $2 - head.asm file
442
#               $3 - output objfile
443
#               $4 - saved head.inc file
444
#
445
#   Assumes that include files required by head.asm are in the same
446
#   directory as head.asm.
447
#
448
define AS_HEAD
449
    @$(echo) "[$@] Creating module header.."
450
    $(XX_PRE) $(TOOL_REL) i -d$1 -t$(OBJDIR)
451
	$(XX_PRE) $(as) -fP=$(mri_cpu_type) -fd -fNOPCR -frel32 -I $(OBJDIR) -I $(dir $2) -o$3 <$2
452
    $(XX_PRE) $(rm) -f $4
453
    $(XX_PRE) $(cp) $(OBJDIR)/head.inc $4
454
endef
455
 
456
 
457
#
458
#   Create VisionClick files
459
#   Args:   $1 Path of the source ABS file
460
#           $2 Output visionclick path file
461
#           $3 Vclick drive prefix
462
#   Use convert twice: Sometimes fails if both files generated together
463
#
464
define  VCLICK
261 dpurdie 465
    $(XX_PRE) $(echo) "[$@] Create VISIONCLICK files.." ;\
227 dpurdie 466
    $(TOOL_VPATHS) $1 -o $2 -p $3 ;\
467
    $(est32)/convert -e $(basename $1).abs -c $(basename $1).ab ;\
468
    $(est32)/convert -e $(basename $1).abs -b $(basename $1).bdx
469
endef
470
 
471
#