Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
2
# Copyright (c) 1996-2005 ERG Transit Systems.
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
 
110
cc_pre = @$(echo) [$<] compiling..
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
 
172
as_pre          = @$(echo) [$@] Assembling file ...
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
185
        @$(echo) [\$@] Creating library archive.. ; \
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
216
        $(echo) [$@] Linking program .. ;\
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
224
        @$(rm) -f $(ld_cmdfile)
225
endef
226
else
227
define ld_post
228
endef
229
endif
230
 
231
#..     Create Library dependency file
232
#
233
define LDDEPEND
234
        $(XX_PRE) export M16C_LIB; \
235
                M16C_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 236
	$(cmdfile) -ko$(@) "$($(DPLIST))";
227 dpurdie 237
endef
238
 
239
 
240
#
241
#   Use the LMC utility to convert an .X30 file into a .mot file
242
#       $1      - Name of target .bin file
243
#
244
define  LMC
245
    @$(echo) "[$@] Convert to binary.."
246
    $(XX_PRE)$(LinkerLMC) -. $<
247
    $(XX_PRE)$(TOOL_APPCRC) $(basename $@).mot
248
    $(XX_PRE)$(cp) $(basename $@).bin $(basename $@).raw
249
    $(XX_PRE)$(cp) $(basename $@).bin $1
250
endef
251
 
252
#
253
#   Use the LMC_MOT utility to convert an .X30 file into a .mot file
254
#       $1      - Name of target .mot file
255
#
256
define  LMC_MOT
257
    @$(echo) "[$@] Convert to MOT.."
258
    $(XX_PRE)$(LinkerLMC) -. $<
259
    $(XX_PRE)$(cp) $(basename $<).mot $1
260
endef
261
 
262
 
263
#
264
#   Use the modcrc utility to convert an .raw file into a .thx file
265
#   $1 is the name 'rel' file
266
#
267
define  MODCRC
268
    @$(echo) "[$@] Add CRC information.."
269
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -i=raw -o=thx -f=$1
270
    $(XX_PRE)( $(rm) -f dummy.thx; $(cp) -f $(basename $@).thx dummy.thx; $(chmod) -f +w dummy.thx )
271
    $(XX_PRE)$(TOOL_MODCRC) -m=dummy -i=thx -o=bin
272
    $(XX_PRE)$(mv) dummy.bin $(basename $@).mod
273
    $(XX_PRE)$(rm) -f dummy.thx
274
endef
275
 
276
 
277
#
278
#   Convert a THX file to an R30 object file
279
#   This is done by
280
#       .thx    -> modcrc      ->   .bin
281
#       .bin    -> fontcrc     ->   .c
282
#       .c      -> compiler    ->   .r30
283
#
284
#       $1  - source filename
285
#       $2  - target file ( without extension )
286
#
287
#   Note: Silly modcrc requires that its input file is writable
288
#         Must transfer it to another directory
289
#
290
define  THX2R30
291
    @$(echo) "[$@] Convert THX to object.."
292
    $(XX_PRE)( $(rm) -f $2.thx; $(cp) -f $1 $2.thx; $(chmod) -f +w $2.thx )
293
    $(XX_PRE)$(TOOL_MODCRC) -m=$2 -i=thx -o=bin > $2.nul || rm -f $2.null
294
    $(XX_PRE)$(TOOL_FONTCONV) $2.bin
295
    $(CC)
296
endef
297
 
298
#
299
#   Convert a BIN file into a PAYLOAD file
300
#
301
#   $1      - Version string
302
define MCRPLD
303
    @$(echo) "[$@] Convert BIN to Payload.."
304
    $(XX_PRE)$(GBE_PERL) $(TOOL_MCRPLD) -v $1 -i $< -o $@
305
endef
306
 
307
#