Subversion Repositories DevTools

Rev

Rev 5709 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
227 dpurdie 3
#
4
# File:         TOOLSET/m16c.rul[e]
5
# Contents:     m16c rules
6
#               Make definitions for the m16c tools.
7
#
8
# Description:
9
#       This file provides Toolset rules for the target makefiles
10
#       The file is dropped into the target makefile
11
#
12
# Revision History:
13
#       26-Oct-05   DDP     Started Work
14
###############################################################################
15
 
16
###############################################################################
17
#..     Remove "undef" warnings
18
#
19
cc_includes     +=
20
cc_defines      +=
21
cc_opts         +=
22
cxx_includes    +=
23
cxx_defines     +=
24
 
25
###############################################################################
26
#..     Parse user options
27
#       Global options already parsed
28
#       These options extend the global options
29
#
30
ifdef OPTIONS
31
endif
32
 
33
###############################################################################
34
#..     C Compiler definition
35
#
36
#
37
#   Compiler flags
38
#
39
#
40
#   -c              - Compile only
41
#   -Dxxx           - Preprocessor define
42
#   -Uxxx           - Preprocessor undefine
43
#   -Ixxx           - Extends include file path ( limit to 8 )
44
#   -g              - Outputs debug info to an assembler source file (extension .a30).
45
#   -silent         - Suppresses the copyright message display at startup.
46
#   -fETI           - Extends char-type or signed char-type data to int-type
47
#                     data to perform operation (extension as per ANSI rules)
48
#   -OS             - Optimise for Speed
49
#   -OR             - Optimise for Rom size
50
#   -dir xxx        - Output directory name
51
 
52
#
53
cc              = $(CC_PRE) $(Compiler)
54
cc_init         =
55
cc_o_switch     = -dir $(@D)
56
cc_source_file  = $<
57
cc_source       =  $(subst /,\\,$(cc_source_file))
58
cc_flags        = -silent -c -fETI $(CFLAGS)
59
cc_flags       += $(cc_opts) $(cc_defines) $(cc_includes)
60
 
61
cc_filter := $(wildcard $(GBE_ROOT)/warnings.m16c)
62
ifdef cc_filter
63
cc_redirect_stderr     = 1
64
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.m16c
65
endif
66
 
279 dpurdie 67
ifneq ($(SHOWARGS),NONE)
68
cc_opts       += -v
69
endif
70
 
227 dpurdie 71
ifdef LEAVETMP
72
cc_opts       += -g
73
endif
74
 
279 dpurdie 75
#ifdef USE_STRICT_ANSI
76
#cc_opts       +=
77
#else
78
#cc_opts       +=
79
#endif
227 dpurdie 80
 
81
ifdef USE_OPTIMISE
82
cc_opts       += -OS
83
else
84
endif
85
 
86
ifdef USE_DEBUGINFO
87
cc_opts       += -g -DDEBUG
88
else
89
cc_opts       += -DNDEBUG -UDEBUG
90
endif
91
 
92
ifeq "$(DEBUG)" "1"
93
cc_opts       += -DKD30=1
94
else
95
cc_opts       += -DKD30=0
96
endif
97
 
98
ifdef ALVL
99
cc_opts       += -DALVL=$(ALVL)
100
endif
101
 
102
ifdef DLVL
103
cc_opts       += -DDLVL=$(DLVL)
104
endif
105
 
106
cc_opts       += -D__SOURCE__=$(notdir $<)
107
 
279 dpurdie 108
cc_includes    = $(patsubst %,-I%,$(INCDIRS))
227 dpurdie 109
 
6177 dpurdie 110
cc_pre = @$(echo) '[$<] compiling..'
227 dpurdie 111
cc_post =
112
 
279 dpurdie 113
###############################################################################
114
#	Compiler sanity test
115
#	It can only handle 16 include paths
116
#	Create an error if there are too many
117
#
118
ifneq ($(word 17, $(INCDIRS)),)
119
$(info ERROR. Too many included directories for the MCR compiler)
120
$(info $(space)      The limit is 16. Complete list is:)
121
$(foreach aa,$(INCDIRS), $(info $(space)       $(aa)))
122
$(error Too many included directories for the MCR compiler)
123
endif
227 dpurdie 124
 
125
###############################################################################
126
#..     C/C++ dependencies
127
#       depend and depend.err
128
#
129
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
130
ccdep_init      =
131
ccdep_o_switch  = -f -
132
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err
133
ccdep_flags     = -MM -b -p \$$\(OBJDIR\)/ \
134
                  $(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
135
                  -o .$(o) \
136
                  $(patsubst %,%,$(CFLAGS)) \
137
                  $(patsubst %,-D%,$(cc_defines)) \
138
                  $(patsubst %,-I %,$(INCDIRS)) \
139
                  $(patsubst %,-Y %,$(subst \,/,$(INC30))) \
140
                  $(patsubst %,-Y %,$(NODEPDIRS))
141
ccdep_pre       =
142
ccdep_post      =
143
 
144
 
145
###############################################################################
146
#..     Assembler definition
147
#
148
#   Note: The assembler command line is limited in length and the command
149
#         does not accept a command file
150
#
151
#         Do not include INCDIRS as this will blow the command line length
152
#         The assumption is that assember use is trivial and does not
153
#         need include paths
154
#
155
 
156
as              = $(XX_PRE) $(Assembler)
157
as_init         =
158
as_o_switch     = -O$(subst /,\\,$(@D))
159
as_source       = $(subst /,\\,$<)
160
 
161
as_flags       = -M -. -L
162
as_flags      += $(ASFLAGS)
163
 
164
ifeq "$(DEBUG)" "1"
165
as_flags       += -DKD30=1
166
else
167
as_flags       += -DKD30=0
168
endif
169
 
170
#as_flags       += $(patsubst %,-I%,$(INCDIRS))
171
 
6177 dpurdie 172
as_pre          = @$(echo) '[$@] Assembling file ...'
227 dpurdie 173
as_post         =
174
 
175
 
176
#..     Archiver
177
#
178
ar              = $(XX_PRE) $(m16c_librarian)
179
ar_init         =
180
ar_cmdfile      = $(basename $@).ar
181
ar_flags        =
182
ar_o_switch     = @$(ar_cmdfile)
183
 
184
define ar_pre
6177 dpurdie 185
        @$(echo) '[$@] Creating library archive..' ; \
227 dpurdie 186
        $(rm) -f $@ ;\
187
        $(cmdfile) -ko$(ar_cmdfile) \
188
                -. -C $@\\n\
189
                $(subst /,\\\\,$(patsubst %,%\\n,$(filter %.R30, $^)))\
190
                \\n
191
endef
192
 
193
ifndef LEAVETMP
194
define ar_post
195
        @$(rm) -f $(ar_cmdfile)
196
endef
197
else
198
define ar_post
199
endef
200
endif
201
 
202
 
203
#..     Archive Merge
204
#       Not currently supported
205
#       No reason for this - just no need yet
206
 
207
 
208
#..     Linker
209
#
210
ld              = $(XX_PRE) $(Linker)
211
ld_cmdfile      = $(basename $@).ld
212
ld_flags        = @$(ld_cmdfile)
213
ld_o_switch     =
214
 
215
define ld_pre
6177 dpurdie 216
        $(echo) '[$@] Linking program ..' ;\
227 dpurdie 217
        export M16C_LIB; \
218
                M16C_LIB="$(subst /,\\,$(subst $(space),;,$(LIBDIRS)))"; \
219
        $(cmdfile) -ko$(ld_cmdfile) "$($(notdir $(SHBASE))_ld)"
220
endef
221
 
222
ifndef LEAVETMP
223
define ld_post
4488 dpurdie 224
        $(call MCRFLASHEND,$@,$(BINDIR)/${SHBASE}.map,$($(notdir $(SHBASE))_FlashEnd))
227 dpurdie 225
        @$(rm) -f $(ld_cmdfile)
226
endef
227
else
228
define ld_post
4488 dpurdie 229
        $(call MCRFLASHEND,$@,$(BINDIR)/${SHBASE}.map,$($(notdir $(SHBASE))_FlashEnd))
227 dpurdie 230
endef
231
endif
232
 
233
#..     Create Library dependency file
234
#
235
define LDDEPEND
236
        $(XX_PRE) export M16C_LIB; \
237
                M16C_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 238
	$(cmdfile) -ko$(@) "$($(DPLIST))";
227 dpurdie 239
endef
240
 
4488 dpurdie 241
#
242
#   Use the mcrflashend.pl tool to verify that the flash memory has not overflowed
243
#       $1      - Name of the build target
244
#       $2      - Map file
245
#       $3      - The first invalid flash address in hex
246
#
247
ifdef TOOL_MCRFLASHEND
248
define MCRFLASHEND
249
        $(XX_PRE)$(GBE_PERL) $(TOOL_MCRFLASHEND) -n "$1" -m "$2" -e "$3" 
250
endef
251
else
252
define MCRFLASHEND
253
endef
254
endif
227 dpurdie 255
 
256
#
257
#   Use the LMC utility to convert an .X30 file into a .mot file
258
#       $1      - Name of target .bin file
259
#
260
define  LMC
261
    @$(echo) "[$@] Convert to binary.."
262
    $(XX_PRE)$(LinkerLMC) -. $<
263
    $(XX_PRE)$(TOOL_APPCRC) $(basename $@).mot
264
    $(XX_PRE)$(cp) $(basename $@).bin $(basename $@).raw
265
    $(XX_PRE)$(cp) $(basename $@).bin $1
266
endef
267
 
268
#
269
#   Use the LMC_MOT utility to convert an .X30 file into a .mot file
270
#       $1      - Name of target .mot file
271
#
272
define  LMC_MOT
273
    @$(echo) "[$@] Convert to MOT.."
274
    $(XX_PRE)$(LinkerLMC) -. $<
275
    $(XX_PRE)$(cp) $(basename $<).mot $1
276
endef
277
 
278
 
279
#
280
#   Use the modcrc utility to convert an .raw file into a .thx file
281
#   $1 is the name 'rel' file
282
#
283
define  MODCRC
284
    @$(echo) "[$@] Add CRC information.."
285
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -i=raw -o=thx -f=$1
286
    $(XX_PRE)( $(rm) -f dummy.thx; $(cp) -f $(basename $@).thx dummy.thx; $(chmod) -f +w dummy.thx )
287
    $(XX_PRE)$(TOOL_MODCRC) -m=dummy -i=thx -o=bin
288
    $(XX_PRE)$(mv) dummy.bin $(basename $@).mod
289
    $(XX_PRE)$(rm) -f dummy.thx
290
endef
291
 
292
 
293
#
294
#   Convert a THX file to an R30 object file
295
#   This is done by
296
#       .thx    -> modcrc      ->   .bin
297
#       .bin    -> fontcrc     ->   .c
298
#       .c      -> compiler    ->   .r30
299
#
300
#       $1  - source filename
301
#       $2  - target file ( without extension )
302
#
303
#   Note: Silly modcrc requires that its input file is writable
304
#         Must transfer it to another directory
305
#
306
define  THX2R30
307
    @$(echo) "[$@] Convert THX to object.."
308
    $(XX_PRE)( $(rm) -f $2.thx; $(cp) -f $1 $2.thx; $(chmod) -f +w $2.thx )
309
    $(XX_PRE)$(TOOL_MODCRC) -m=$2 -i=thx -o=bin > $2.nul || rm -f $2.null
310
    $(XX_PRE)$(TOOL_FONTCONV) $2.bin
311
    $(CC)
312
endef
313
 
314
#
315
#   Convert a BIN file into a PAYLOAD file
316
#
317
#   $1      - Version string
318
define MCRPLD
319
    @$(echo) "[$@] Convert BIN to Payload.."
320
    $(XX_PRE)$(GBE_PERL) $(TOOL_MCRPLD) -v $1 -i $< -o $@
321
endef
322
 
323
#