Subversion Repositories DevTools

Rev

Rev 335 | Details | Compare with Previous | 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
6177 dpurdie 150
	@echo '[$<] compiling..'
283 dpurdie 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
6177 dpurdie 172
	@echo '[$<] compiling..'
283 dpurdie 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_flags	=
205
 
206
ifeq ($(SHOWARGS),ALL)
207
ld_flags	+= --show_cmdline
208
endif
209
 
210
ld_flags	+= --device=$(USE_DEVICE) --strict  \
211
		$(patsubst %,%,$(LDFLAGS)) \
212
		$($(notdir $(basename $@))_ld) \
213
                --libpath=$(subst $(space),$(comma),$(KEIL_LIBS) ) \
214
                --diag_suppress L6373 \
215
		--summary_stderr 
216
 
217
 
6177 dpurdie 218
ld_pre   	= @echo '[$@] Linking..';
283 dpurdie 219
ld_post		=
220
 
221
################################################################################
222
#	Library dependency file generation
223
#	Use cmdfile to create a file that will be included in this makefile
224
#	The generated file will contain library path names that can only be
225
#	calculated on the fly
226
#
227
define LDDEPEND
335 dpurdie 228
	$(XX_PRE)$(cmdfile) -wkWeo$(@) "$($(DPLIST))"
283 dpurdie 229
endef
230
 
231
################################################################################
232
#..	Archiver Definitions
233
#
234
#..     Archiver
235
#
236
ar              = $(XX_PRE) $(librarian)
237
ar_init         =
238
ar_cmdfile      = $(basename $@).ar
239
ar_flags        =
240
ar_o_switch     = --via $(ar_cmdfile)
241
 
242
define ar_pre
6177 dpurdie 243
        @$(echo) '[$@] Creating library archive..' ; \
283 dpurdie 244
        $(rm) -f $@ ;\
245
        $(cmdfile) -ko$(ar_cmdfile) \
246
                --create $@\\n\
247
                $(patsubst %,-r %\\n,$(filter %.o, $^))
248
endef
249
 
250
ifndef LEAVETMP
251
define ar_post
252
        @$(rm) -f $(ar_cmdfile)
253
endef
254
else
255
define ar_post
256
endef
257
endif
258
 
259
 
260
################################################################################
261
#..     Archive Merge
262
#	The archive tool can directly merge libaries
263
#
264
armerge              = $(XX_PRE) $(librarian)
265
armerge_init         =
266
armerge_flags        = --create $@ -r $^
267
armerge_o_switch     =
268
 
269
define armerge_pre
6177 dpurdie 270
        @$(echo) '[$@] Creating a Merged library..' ; \
283 dpurdie 271
        $(rm) -f $@
272
endef
273
 
274
armerge_post 	     =
275
 
276
###############################################################################
277
#..     Assembler definition
278
#
279
#
280
as              = $(XX_PRE) $(assembler)
281
as_init         =
282
as_o_switch     = -o $@
283
as_source       = $<
284
 
285
asm_flags	+= --device $(USE_DEVICE)
286
asm_flags	+= --apcs=interwork
287
 
288
ifdef USE_THUMB
289
asm_flags	+= --thumb
290
endif
291
 
292
asm_flags    += $(ASFLAGS)
293
 
294
ifdef as_defines
295
#asm_flags    += $(addprefix -D,$(as_defines))
296
endif
297
 
298
ifdef USE_DEBUGINFO
299
#asm_flags       += -DDEBUG
300
asm_flags       += --debug
301
else
302
#asm_flags       += -DNDEBUG
303
endif
304
 
305
as_flags        = $(asm_flags)
306
ifdef as_includes
307
as_flags       += "-I$(subst $(space),;,$(strip $(as_includes)))"
308
endif
309
 
310
as_flags       += $(patsubst %,-I%,$(INCDIRS))
311
 
312
ifdef USE_LIST
313
as_flags       += --xref --list $(addsuffix .lst, $(basename $(@F)))
314
endif
315
 
316
ifdef USE_WALL
317
as_flags 	+=
318
else
319
ifdef NOWARNLIST
320
as_flags 	+= --diag_suppress $(subst $(comma),\$(comma),$(NOWARNLIST))
321
endif
322
endif
323
 
324
define as_pre
6177 dpurdie 325
    @$(echo) '[$<] Assembling file..'
283 dpurdie 326
endef
327
 
328
define as_post
329
endef
330
 
331
###############################################################################
332
#..     Elf Conversion
333
#
334
#
335
define FROMELF
6177 dpurdie 336
	@echo '[$@] Convert from ELF..';
283 dpurdie 337
	$(XX_PRE)$(fromelf) --bin --output $@ $<
338
endef
339