Subversion Repositories DevTools

Rev

Rev 335 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
283 dpurdie 1
###############################################################################
2
# Module name   : TOOLSET/KeilArmV3
3
# Module type   : Makefile system
4
# Environment(s): KeilArmV3
5
#
6
#
7
###################################################################
8
 
9
###############################################################################
10
#..  Remove "undef" warnings
11
#
12
cc_includes	+=
13
cc_defines	+=
14
cxx_include	+=
15
cxx_defines	+=
16
as_includes	+=
17
as_defines	+=
18
 
19
###############################################################################
20
#..     Parse user options
21
#       Global options already parsed
22
#       These options extend the global options
23
#
24
 
25
ifdef OPTIONS
26
 
27
ifneq "$(findstring wall,$(OPTIONS))" ""	# Enable all warnings
28
USE_WALL	= 1
29
endif
30
 
31
ifneq "$(findstring list,$(OPTIONS))" ""	# Create Listings
32
USE_LIST	= 1
33
endif
34
 
35
endif
36
 
37
###############################################################################
38
#
39
#	Extend LIBDIRS with toolset libraries
40
#	Create a ';' separated list
41
#	Start with a space separated list
42
#		May need to change if KEIL_LIBS is to be installed
43
#		in a path with spaces in it.
44
 
45
LIB         := $(patsubst %,%;,$(LIBDIRS) $(KEIL_LIBS) )
46
export LIB
47
 
48
 
49
###############################################################################
50
#..     C Compiler definition
51
#
52
 
53
cc_filter := $(wildcard $(GBE_ROOT)/warnings.keil)
54
ifdef cc_filter
55
cc_redirect     = 1
56
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.keil
57
endif
58
 
59
 
60
# Standard defines
61
#
62
#..
63
ifdef ALVL
64
arm_defines	+= -DALVL=$(ALVL)
65
endif
66
 
67
ifdef DLVL
68
arm_defines	+= -DDLVL=$(DLVL)
69
endif
70
 
71
arm_defines	+= -D__SOURCE__=\"$(notdir $<)\"
72
 
73
# Standard flags
74
#
75
arm_flags	+= --device=$(USE_DEVICE)
76
arm_flags	+= -c --apcs=interwork
77
 
78
ifdef FORCE_C_COMPILE
79
arm_flags	+= --c90
80
endif
81
 
82
ifdef FORCE_CC_COMPILE
83
arm_flags	+= --cpp
84
endif
85
 
86
ifdef USE_THUMB
87
arm_flags	+= --thumb
88
endif
89
 
90
ifdef USE_OPTIMISE				# default for production
91
ifdef OPT_MODE
92
arm_flags 	+= -O$(OPT_MODE)
93
endif
94
else
95
arm_flags 	+= -O0
96
endif
97
 
98
ifdef USE_DEBUGINFO				# default for debug
99
arm_flags	+= -g
100
arm_defines	+= -DDEBUG
101
else
102
arm_defines	+= -DNDEBUG
103
endif
104
 
105
ifdef USE_STRICT_ANSI				# default NO
106
arm_flags	+= --strict
107
endif
108
 
109
ifdef LEAVETMP					# default NO
110
arm_flags	+=
111
endif
112
 
113
ifdef USE_LIST
114
arm_flags 	+= --list
115
endif
116
 
117
ifdef USE_WALL
118
arm_flags 	+=
119
else
120
ifdef NOWARNLIST
121
arm_flags 	+= --diag_suppress $(subst $(comma),\$(comma),$(NOWARNLIST))
122
endif
123
endif
124
 
125
# Standard includes
126
#
127
#..
128
 
129
arm_includes	+=
130
arm_includes	+= $(KEIL_INCLUDES)         	# From Toolset Defs
131
 
132
###############################################################################
133
#..     C Compiler definition
134
#
135
cc		= $(CC_PRE) $(compiler)
136
cc_init		=
137
cc_o_switch	= -o $@
138
cc_source	= $<
139
cc_flags	= \
140
		$(patsubst %,%,$(CFLAGS)) \
141
		$(patsubst %,%,$(arm_flags)) \
142
		$(patsubst %,%,$(arm_defines)) \
143
		$(patsubst %,-D%,$(cc_defines)) \
144
		$(patsubst %,-I %,$(INCDIRS)) \
145
		$(patsubst %,-I %,$(cc_includes)) \
146
		$(patsubst %,-I %,$(arm_includes))
147
cc_term		=
148
 
149
define cc_pre
150
	@echo [$<] compiling..
151
endef
152
 
153
cc_post =
154
 
155
###############################################################################
156
#..     C++ Compiler definition
157
#
158
cxx		= $(CC_PRE) $(compiler)
159
cxx_init	=
160
cxx_o_switch	= -o $@
161
cxx_source	= $<
162
cxx_flags	= \
163
		$(patsubst %,%,$(CXXFLAGS)) \
164
		$(patsubst %,%,$(arm_flags)) \
165
		$(patsubst %,%,$(arm_defines)) \
166
		$(patsubst %,-d%,$(cxx_defines)) \
167
		$(patsubst %,-I %,$(INCDIRS)) \
168
		$(patsubst %,-I %,$(cxx_includes)) \
169
		$(patsubst %,-I %,$(arm_includes))
170
 
171
define cxx_pre
172
	@echo [$<] compiling..
173
endef
174
 
175
define cxx_post
176
endef
177
 
178
###############################################################################
179
#..     C/C++ dependencies
180
#
181
ccdep		= $(XX_PRE) $(GBE_BIN)/mkdepend
182
ccdep_init	=
183
ccdep_o_switch	= -f -
184
ccdep_flags	= -MM -b -We -p '$$(OBJDIR)/' -o ".$(o)"
185
ccdep_source	= $(filter %.c %.cc %.cpp, $+) > $@ 2> $(OBJDIR)/depend.err
186
 
187
ccdep_flags	+= \
188
		$(patsubst %,%,$(CFLAGS)) \
189
		$(patsubst %,%,$(arm_depend)) \
190
		$(patsubst %,%,$(arm_defines)) \
191
		$(patsubst %,-D%,$(cc_defines)) \
192
		$(patsubst %,-I %,$(INCDIRS)) \
193
		$(patsubst %,-I %,$(cc_includes)) \
194
		$(patsubst %,-Y %,$(arm_includes))
195
ccdep_pre	=
196
ccdep_post	=
197
 
198
###############################################################################
199
#..     Linker definition
200
#
201
ld		= $(CC_PRE) $(linker)
202
ld_init		=
203
ld_o_switch	= -o $@
204
ld_depfile	= $(subst /,\\,$(basename $@).dep)
205
ld_flags	=
206
 
207
ifeq ($(SHOWARGS),ALL)
208
ld_flags	+= --show_cmdline
209
endif
210
 
211
ld_flags	+= --device=$(USE_DEVICE) --strict  \
212
		$(patsubst %,%,$(LDFLAGS)) \
213
		$($(notdir $(basename $@))_ld) \
214
                --libpath=$(subst $(space),$(comma),$(KEIL_LIBS) ) \
215
                --diag_suppress L6373 \
216
		--summary_stderr 
217
 
218
 
219
ld_pre   	= @echo [$@] Linking..;
220
ld_post		=
221
 
222
################################################################################
223
#	Library dependency file generation
224
#	Use cmdfile to create a file that will be included in this makefile
225
#	The generated file will contain library path names that can only be
226
#	calculated on the fly
227
#
228
define LDDEPEND
229
	$(XX_PRE) $(cmdfile) -wkWeo$(ld_depfile) \
230
		"$($(notdir $(basename $@))_dp)";
231
endef
232
 
233
################################################################################
234
#..	Archiver Definitions
235
#
236
#..     Archiver
237
#
238
ar              = $(XX_PRE) $(librarian)
239
ar_init         =
240
ar_cmdfile      = $(basename $@).ar
241
ar_flags        =
242
ar_o_switch     = --via $(ar_cmdfile)
243
 
244
define ar_pre
245
        @$(echo) [\$@] Creating library archive.. ; \
246
        $(rm) -f $@ ;\
247
        $(cmdfile) -ko$(ar_cmdfile) \
248
                --create $@\\n\
249
                $(patsubst %,-r %\\n,$(filter %.o, $^))
250
endef
251
 
252
ifndef LEAVETMP
253
define ar_post
254
        @$(rm) -f $(ar_cmdfile)
255
endef
256
else
257
define ar_post
258
endef
259
endif
260
 
261
 
262
################################################################################
263
#..     Archive Merge
264
#	The archive tool can directly merge libaries
265
#
266
armerge              = $(XX_PRE) $(librarian)
267
armerge_init         =
268
armerge_flags        = --create $@ -r $^
269
armerge_o_switch     =
270
 
271
define armerge_pre
272
        @$(echo) [\$@] Creating a Merged library.. ; \
273
        $(rm) -f $@
274
endef
275
 
276
armerge_post 	     =
277
 
278
###############################################################################
279
#..     Assembler definition
280
#
281
#
282
as              = $(XX_PRE) $(assembler)
283
as_init         =
284
as_o_switch     = -o $@
285
as_source       = $<
286
 
287
asm_flags	+= --device $(USE_DEVICE)
288
asm_flags	+= --apcs=interwork
289
 
290
ifdef USE_THUMB
291
asm_flags	+= --thumb
292
endif
293
 
294
asm_flags    += $(ASFLAGS)
295
 
296
ifdef as_defines
297
#asm_flags    += $(addprefix -D,$(as_defines))
298
endif
299
 
300
ifdef USE_DEBUGINFO
301
#asm_flags       += -DDEBUG
302
asm_flags       += --debug
303
else
304
#asm_flags       += -DNDEBUG
305
endif
306
 
307
as_flags        = $(asm_flags)
308
ifdef as_includes
309
as_flags       += "-I$(subst $(space),;,$(strip $(as_includes)))"
310
endif
311
 
312
as_flags       += $(patsubst %,-I%,$(INCDIRS))
313
 
314
ifdef USE_LIST
315
as_flags       += --xref --list $(addsuffix .lst, $(basename $(@F)))
316
endif
317
 
318
ifdef USE_WALL
319
as_flags 	+=
320
else
321
ifdef NOWARNLIST
322
as_flags 	+= --diag_suppress $(subst $(comma),\$(comma),$(NOWARNLIST))
323
endif
324
endif
325
 
326
define as_pre
327
    @$(echo) [$<] Assembling file..
328
endef
329
 
330
define as_post
331
endef
332
 
333
###############################################################################
334
#..     Elf Conversion
335
#
336
#
337
define FROMELF
338
	@echo [$@] Convert from ELF..;
339
	$(XX_PRE)$(fromelf) --bin --output $@ $<
340
endef
341