Subversion Repositories DevTools

Rev

Rev 279 | Go to most recent revision | Details | 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
 
67
ifdef LEAVETMP
68
cc_opts       += -g
69
endif
70
 
71
ifdef USE_STRICT_ANSI
72
cc_opts       +=
73
else
74
cc_opts       +=
75
endif
76
 
77
 
78
ifdef USE_OPTIMISE
79
cc_opts       += -OS
80
else
81
cc_opts       +=
82
endif
83
 
84
ifdef USE_DEBUGINFO
85
cc_opts       += -g -DDEBUG
86
else
87
cc_opts       += -DNDEBUG -UDEBUG
88
endif
89
 
90
ifeq "$(DEBUG)" "1"
91
cc_opts       += -DKD30=1
92
else
93
cc_opts       += -DKD30=0
94
endif
95
 
96
ifdef ALVL
97
cc_opts       += -DALVL=$(ALVL)
98
endif
99
 
100
ifdef DLVL
101
cc_opts       += -DDLVL=$(DLVL)
102
endif
103
 
104
cc_opts       += -D__SOURCE__=$(notdir $<)
105
 
106
cc_includes = $(patsubst %,-I%,$(INCDIRS))
107
 
108
 
109
cc_pre = @$(echo) [$<] compiling..
110
cc_post =
111
 
112
 
113
###############################################################################
114
#..     C/C++ dependencies
115
#       depend and depend.err
116
#
117
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
118
ccdep_init      =
119
ccdep_o_switch  = -f -
120
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err
121
ccdep_flags     = -MM -b -p \$$\(OBJDIR\)/ \
122
                  $(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
123
                  -o .$(o) \
124
                  $(patsubst %,%,$(CFLAGS)) \
125
                  $(patsubst %,-D%,$(cc_defines)) \
126
                  $(patsubst %,-I %,$(INCDIRS)) \
127
                  $(patsubst %,-Y %,$(subst \,/,$(INC30))) \
128
                  $(patsubst %,-Y %,$(NODEPDIRS))
129
ccdep_pre       =
130
ccdep_post      =
131
 
132
 
133
###############################################################################
134
#..     Assembler definition
135
#
136
#   Note: The assembler command line is limited in length and the command
137
#         does not accept a command file
138
#
139
#         Do not include INCDIRS as this will blow the command line length
140
#         The assumption is that assember use is trivial and does not
141
#         need include paths
142
#
143
 
144
as              = $(XX_PRE) $(Assembler)
145
as_init         =
146
as_o_switch     = -O$(subst /,\\,$(@D))
147
as_source       = $(subst /,\\,$<)
148
 
149
as_flags       = -M -. -L
150
as_flags      += $(ASFLAGS)
151
 
152
ifeq "$(DEBUG)" "1"
153
as_flags       += -DKD30=1
154
else
155
as_flags       += -DKD30=0
156
endif
157
 
158
#as_flags       += $(patsubst %,-I%,$(INCDIRS))
159
 
160
as_pre          = @$(echo) [$@] Assembling file ...
161
as_post         =
162
 
163
 
164
#..     Archiver
165
#
166
ar              = $(XX_PRE) $(m16c_librarian)
167
ar_init         =
168
ar_cmdfile      = $(basename $@).ar
169
ar_flags        =
170
ar_o_switch     = @$(ar_cmdfile)
171
 
172
define ar_pre
173
        @$(echo) [\$@] Creating library archive.. ; \
174
        $(rm) -f $@ ;\
175
        $(cmdfile) -ko$(ar_cmdfile) \
176
                -. -C $@\\n\
177
                $(subst /,\\\\,$(patsubst %,%\\n,$(filter %.R30, $^)))\
178
                \\n
179
endef
180
 
181
ifndef LEAVETMP
182
define ar_post
183
        @$(rm) -f $(ar_cmdfile)
184
endef
185
else
186
define ar_post
187
endef
188
endif
189
 
190
 
191
#..     Archive Merge
192
#       Not currently supported
193
#       No reason for this - just no need yet
194
 
195
 
196
#..     Linker
197
#
198
ld              = $(XX_PRE) $(Linker)
199
ld_cmdfile      = $(basename $@).ld
200
ld_depfile	  = $(subst /,\\,$(basename $@).dep)
201
ld_flags        = @$(ld_cmdfile)
202
ld_o_switch     =
203
 
204
define ld_pre
205
        $(echo) [$@] Linking program .. ;\
206
        export M16C_LIB; \
207
                M16C_LIB="$(subst /,\\,$(subst $(space),;,$(LIBDIRS)))"; \
208
        $(cmdfile) -ko$(ld_cmdfile) "$($(notdir $(SHBASE))_ld)"
209
endef
210
 
211
ifndef LEAVETMP
212
define ld_post
213
        @$(rm) -f $(ld_cmdfile)
214
endef
215
else
216
define ld_post
217
endef
218
endif
219
 
220
#..     Create Library dependency file
221
#
222
define LDDEPEND
223
        $(XX_PRE) export M16C_LIB; \
224
                M16C_LIB="$(subst $(space),;,$(LIBDIRS))"; \
225
	$(cmdfile) -ko$(ld_depfile) "$($(notdir $(basename $@))_dp)";
226
endef
227
 
228
 
229
#
230
#   Use the LMC utility to convert an .X30 file into a .mot file
231
#       $1      - Name of target .bin file
232
#
233
define  LMC
234
    @$(echo) "[$@] Convert to binary.."
235
    $(XX_PRE)$(LinkerLMC) -. $<
236
    $(XX_PRE)$(TOOL_APPCRC) $(basename $@).mot
237
    $(XX_PRE)$(cp) $(basename $@).bin $(basename $@).raw
238
    $(XX_PRE)$(cp) $(basename $@).bin $1
239
endef
240
 
241
#
242
#   Use the LMC_MOT utility to convert an .X30 file into a .mot file
243
#       $1      - Name of target .mot file
244
#
245
define  LMC_MOT
246
    @$(echo) "[$@] Convert to MOT.."
247
    $(XX_PRE)$(LinkerLMC) -. $<
248
    $(XX_PRE)$(cp) $(basename $<).mot $1
249
endef
250
 
251
 
252
#
253
#   Use the modcrc utility to convert an .raw file into a .thx file
254
#   $1 is the name 'rel' file
255
#
256
define  MODCRC
257
    @$(echo) "[$@] Add CRC information.."
258
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -i=raw -o=thx -f=$1
259
    $(XX_PRE)( $(rm) -f dummy.thx; $(cp) -f $(basename $@).thx dummy.thx; $(chmod) -f +w dummy.thx )
260
    $(XX_PRE)$(TOOL_MODCRC) -m=dummy -i=thx -o=bin
261
    $(XX_PRE)$(mv) dummy.bin $(basename $@).mod
262
    $(XX_PRE)$(rm) -f dummy.thx
263
endef
264
 
265
 
266
#
267
#   Convert a THX file to an R30 object file
268
#   This is done by
269
#       .thx    -> modcrc      ->   .bin
270
#       .bin    -> fontcrc     ->   .c
271
#       .c      -> compiler    ->   .r30
272
#
273
#       $1  - source filename
274
#       $2  - target file ( without extension )
275
#
276
#   Note: Silly modcrc requires that its input file is writable
277
#         Must transfer it to another directory
278
#
279
define  THX2R30
280
    @$(echo) "[$@] Convert THX to object.."
281
    $(XX_PRE)( $(rm) -f $2.thx; $(cp) -f $1 $2.thx; $(chmod) -f +w $2.thx )
282
    $(XX_PRE)$(TOOL_MODCRC) -m=$2 -i=thx -o=bin > $2.nul || rm -f $2.null
283
    $(XX_PRE)$(TOOL_FONTCONV) $2.bin
284
    $(CC)
285
endef
286
 
287
#
288
#   Convert a BIN file into a PAYLOAD file
289
#
290
#   $1      - Version string
291
define MCRPLD
292
    @$(echo) "[$@] Convert BIN to Payload.."
293
    $(XX_PRE)$(GBE_PERL) $(TOOL_MCRPLD) -v $1 -i $< -o $@
294
endef
295
 
296
#