Subversion Repositories DevTools

Rev

Rev 6177 | 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
6276 dpurdie 172
        $(call show_cmdfile,$(cc_cmdfile))
227 dpurdie 173
endef
174
 
175
ifndef LEAVETMP
176
define cc_post
177
        @$(rm) -f $(cc_cmdfile)
178
endef
179
else
180
define cc_post
181
endef
182
endif
183
 
184
###############################################################################
185
#..     C/C++ dependencies
186
#       depend and depend.err
187
#
188
mri_depend      = -D__STDC__
189
ifdef USE_DEBUGINFO
190
mri_depend       += -DDEBUG
191
else
192
mri_depend       += -DNDEBUG
193
endif
194
ifdef ALVL
195
mri_depend      += -DALVL=$(ALVL)
196
endif
197
ifdef DLVL
198
mri_depend      += -DDLVL=$(DLVL)
199
endif
200
mri_depend      += -D__SOURCE__=$(notdir $<)
201
 
202
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
203
ccdep_init      =
204
ccdep_o_switch  = -f -
205
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
206
ccdep_flags     = -MM -b -p \$$\(OBJDIR\)/ \
207
                  $(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
208
                  -o .$(o) \
209
                  $(patsubst %,%,$(CFLAGS)) \
210
                  $(patsubst %,-D%,$(cc_defines)) \
211
                  $(patsubst %,%,$(mri_depend)) \
212
                  $(patsubst %,-I %,$(INCDIRS)) \
213
                  $(patsubst %,-Y %,$(cc_includes)) \
214
                  $(patsubst %,-Y %,$(mri_includes)) \
215
                  $(patsubst %,-Y %,$(NODEPDIRS))
216
ccdep_pre       =
217
ccdep_post      =
218
 
219
#..     C/C++ Lint definitions
220
#
221
lint_flags	+= \
222
	$(patsubst %,%,$(mri_depend)) \
223
	$(patsubst %,%,$(CLINTFLAGS)) \
224
	$(patsubst %,-D%,$(cc_defines)) \
225
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(INCDIRS))) \
226
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(cc_includes))) \
227
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(mri_includes)))
228
 
229
 
230
lint_libpath	= $(MRI_LIB)
231
 
232
 
233
#..     C++ Compiler definition
234
#
235
cxx             = $(CC_PRE) $(mri_cpp_compiler)
236
cxx_init        =
237
cxx_o_switch    =
238
cxx_object      = -o$@
239
cxx_source      = $<
240
cxx_cmdfile     = $(basename $@).cmd
241
cxx_flags       = -d$(cxx_cmdfile)
242
 
243
define cxx_pre
6177 dpurdie 244
        @$(echo) '[$<] compiling..' ; \
227 dpurdie 245
        $(cmdfile) -ko$(cxx_cmdfile) "\
246
                $(patsubst %,%\\n,$(CFLAGS)) \
247
                $(patsubst %,-D%\\n,$(cc_defines)) \
248
                $(patsubst %,%\\n,$(mri_flags)) \
249
                -J$(subst /,\\\\,$(dir $<))\\n \
250
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(INCDIRS))) \
251
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(cc_includes))) \
252
                $(patsubst %,-J%\\n,$(subst /,\\\\,$(mri_includes))) \
253
                $(subst /,\\\\,$(cxx_object))"
254
endef
255
 
256
ifndef LEAVETMP
257
define cxx_post
258
        @$(rm) -f $(cxx_cmdfile)
259
endef
260
else
261
define cxx_post
262
endef
263
endif
264
 
265
 
266
 
267
 
268
###############################################################################
269
#..     Assembler definition
270
#
271
# Note:  All the options go on the command line at present so this
272
#        passes a minimal set of definitions. (v4.3)
273
#
274
 
275
as              = $(XX_PRE) $(mri_assembler)
276
as_init         =
277
as_i_switch     = -I
278
as_o_switch     = -o$@
279
as_source       = <$<
280
as_cmdfile      =
281
 
6276 dpurdie 282
asm68_flags     = -fP=$(mri_cpu_type)$(mri_coprocessor_type) -frel32 -DCcCpu=$(mri_cpu_code)
227 dpurdie 283
asm68_flags    += $(ASFLAGS)
284
 
285
ifdef as_defines
286
asm68_flags    += $(addprefix -D,$(as_defines))
287
endif
288
 
289
ifdef USE_DEBUGINFO
290
asm68_flags       += -DDEBUG
291
else
292
asm68_flags       += -DNDEBUG
293
endif
294
 
295
as_flags        = $(asm68_flags)
296
ifdef as_includes
297
as_flags       += "-I$(subst $(space),;,$(strip $(as_includes)))"
298
endif
299
 
300
as_flags       += $(patsubst %,-I%,$(INCDIRS))
301
 
302
define as_pre
6177 dpurdie 303
    @$(echo) '[$@] Assembling file..' ; \
235 dpurdie 304
    if [ -n "$(MRI_TMP)" ] ; then\
305
        if [ ! -d $(MRI_TMP) ] ; then mkdir -p $(MRI_TMP) ; fi;\
306
        touch $(MRI_TMP)/xxx;\
307
        cd "$(MRI_TMP)" && rm -f *;\
308
    fi
309
 
227 dpurdie 310
endef
311
define as_post
312
endef
313
 
314
 
315
#..     Archiver
316
#
317
ar              = $(XX_PRE) $(mri_librarian)
318
ar_init         =
319
ar_cmdfile      = $(basename $@).ar
320
ar_logfile      = $(basename $@).ar.log
321
ar_flags        =
322
ar_o_switch     = < $(ar_cmdfile)
323
ar_term         = > $(ar_logfile)
324
 
325
define ar_pre
6177 dpurdie 326
        @$(echo) '[$@] Creating library archive..' ; \
227 dpurdie 327
        $(rm) -f $@ ;\
328
        $(cmdfile) -ko$(ar_cmdfile) \
6276 dpurdie 329
                create $(@D)\\$(@F)\\n\
227 dpurdie 330
                $(patsubst %,addmod %\\n,$(filter %.obj, $^))\
331
                save\\n end\\n
332
endef
333
 
334
ifndef LEAVETMP
335
define ar_post
336
        @$(rm) -f $(ar_logfile) $(ar_cmdfile)
337
endef
338
else
339
define ar_post
340
endef
341
endif
342
 
343
 
344
#..     Archive Merge
345
#
346
armerge              = $(XX_PRE) $(mri_librarian)
347
armerge_init         =
348
armerge_cmdfile      = $(basename $@).armerge
349
armerge_logfile      = $(basename $@).armerge.log
350
armerge_flags        =
351
armerge_o_switch     = < $(armerge_cmdfile) > $(armerge_logfile)
352
 
353
define armerge_pre
6177 dpurdie 354
        @$(echo) '[$@] Creating a Merged library..' ; \
227 dpurdie 355
        $(rm) -f $@ ;\
356
        $(cmdfile) -ko$(armerge_cmdfile) \
357
                create $@\\n\
358
                $(patsubst %,addlib %\\n,$^)\
359
                save\\n end\\n
360
endef
361
 
362
ifndef LEAVETMP
363
define armerge_post
364
        @$(rm) -f $(armerge_logfile) $(armerge_cmdfile)
365
endef
366
else
367
define armerge_post
368
endef
369
endif
370
 
371
 
372
#..     Linker
373
#
374
shld              = $(XX_PRE) $(mri_linker)
375
shld_cmdfile      = $(basename $@).ld
376
shldabs_flags     = -m -c$(shld_cmdfile)
377
shldabs_o_switch  = -o$(basename $@).abs > $(basename $@).map
378
 
379
define shld_pre
6177 dpurdie 380
        @$(echo) '[$@] Linking program ..' ;\
227 dpurdie 381
        export MRI_LIB; \
382
                MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \
383
        $(cmdfile) -ko$(shld_cmdfile) "$($(notdir $(SHBASE))_shld)"
384
endef
385
 
386
ifndef LEAVETMP
387
define shld_post
388
        @$(rm) -f $(shld_cmdfile)
389
endef
390
else
391
define shld_post
392
endef
393
endif
394
 
395
define SHLDABS
396
        $(show_environment)
397
        $(shld_pre)
398
        $(shld) $(shldabs_flags) $(shldabs_o_switch); rv=$$?; [ $$rv = 0 ] || rm -f $@; exit $$rv
399
        $(shld_post)
400
endef
401
 
402
#
403
#   Create Library dependency file
404
#
405
define SHLDDEPEND
406
        $(XX_PRE) export MRI_LIB; \
407
                MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 408
	$(cmdfile) -ko$@ "$($(DPLIST))";
227 dpurdie 409
endef
410
 
411
#
412
#   Use the BRT utility to generate relocation information
413
#   Assumes that the variable BRTROOT has been set to provide the root of all file names
414
#
415
define  BRT
416
    @$(echo) "[$@] Generate Relocation information.."
417
	$(XX_PRE)$(TOOL_BRT) $(OBJDIR)/$(BRTROOT)_0.abs $(OBJDIR)/$(BRTROOT)_o.abs $(OBJDIR)/$(BRTROOT)_rtab_cd.asm $(OBJDIR)/$(BRTROOT)_rtab_d.asm
418
endef
419
 
420
 
421
#
422
#   Use the modcrc utility to convert an .abs files (really s19) into a .thx file
423
#
424
define  MODCRC
425
    @$(echo) "[$@] Add CRC information.."
426
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -t=247
427
endef
428
 
429
#
430
#   Use the modcrc utility to convert an .abs files (really s19) into a .bin file
431
#
432
define  MODCRC_BIN
433
    @$(echo) "[$@] Add CRC information to BIN.."
434
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -o=bin
435
endef
436
 
437
#
438
#   Convert the .rel file into a head.obj file
439
#   This is done as an atomic step
440
#   NOTE: This is a function and not a definition
441
#       Args:   $1 - Rel file
442
#               $2 - head.asm file
443
#               $3 - output objfile
444
#               $4 - saved head.inc file
445
#
446
#   Assumes that include files required by head.asm are in the same
447
#   directory as head.asm.
448
#
449
define AS_HEAD
450
    @$(echo) "[$@] Creating module header.."
451
    $(XX_PRE) $(TOOL_REL) i -d$1 -t$(OBJDIR)
6276 dpurdie 452
	$(XX_PRE) $(as) -fP=$(mri_cpu_type)$(mri_coprocessor_type) -fNOPCR -frel32 -I $(OBJDIR) -I $(dir $2) -o$3 <$2
227 dpurdie 453
    $(XX_PRE) $(rm) -f $4
454
    $(XX_PRE) $(cp) $(OBJDIR)/head.inc $4
455
endef
456
 
457
 
458
#
459
#   Create VisionClick files
460
#   Args:   $1 Path of the source ABS file
461
#           $2 Output visionclick path file
462
#           $3 Vclick drive prefix
463
#   Use convert twice: Sometimes fails if both files generated together
464
#
465
define  VCLICK
261 dpurdie 466
    $(XX_PRE) $(echo) "[$@] Create VISIONCLICK files.." ;\
227 dpurdie 467
    $(TOOL_VPATHS) $1 -o $2 -p $3 ;\
468
    $(est32)/convert -e $(basename $1).abs -c $(basename $1).ab ;\
469
    $(est32)/convert -e $(basename $1).abs -b $(basename $1).bdx
470
endef
471
 
472
#