Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
369 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2011 Vix Technology, All rights reserved
3
#
4
# Module name   : MSP430.RUL
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Toolset Rules for the Texas Instruments CC Studio
10
#
11
#......................................................................#
12
 
13
###############################################################################
14
#..     Remove "undef" warnings
15
#
16
cc_defines      +=
17
as_defines      +=
18
cxx_includes    +=
19
cxx_defines     +=
20
 
21
###############################################################################
22
#..     Parse user options
23
#       Global options already parsed
24
#       These options extend the global options
25
#
26
ifdef OPTIONS
27
endif
28
 
29
###############################################################################
30
#
31
#	Extend LIBDIRS with toolset libraries
32
#	Create a ';' separated list
33
#	Start with a space separated list
34
#		May need to change if ARMLIB is to be installed
35
#		in a path with spaces in it.
36
 
37
LIB         := $(patsubst %,%;,$(LIBDIRS));$(MSP430_LIBS)
38
export LIB
39
 
40
###############################################################################
41
#..     C++ Compiler definition
42
#..     C   Compiler definition
43
#
44
#
45
#   Compiler flags
46
#
47
#
48
cc              = $(CC_PRE) $(msp430_compiler)
49
cc_init         =
50
cc_o_switch     =
51
cc_object       = --obj_directory=$(@D)
52
cc_source       = $<
53
cc_cmdfile      = $(basename $@).cmd
54
cc_flags        = --compile_only --cmd_file=$(cc_cmdfile)
55
cc_defines      = $(MSP430_DEFINES)
56
msp430_includes    = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(MSP430_INCLUDES)))))
57
msp430_flags       = $(MSP430_FLAGS)
58
 
59
cc_filter      := "$(notdir $(wildcard $(GBE_ROOT)/warnings.msp430*))"
60
ifeq ($(strip $(cc_filter)), "warnings.msp430")
61
cc_redirect     = 1
62
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.msp430
63
endif
64
 
383 dpurdie 65
ifdef ITP_MODE
66
msp430_flags       += --silicon_version=msp
67
else
369 dpurdie 68
msp430_flags       += --silicon_version=mspx
383 dpurdie 69
endif
70
 
369 dpurdie 71
#msp430_flags       += --make_global
72
msp430_flags       += --gcc
73
msp430_flags       += --define=__MSP430F5438A__
74
msp430_flags       += --diag_warning=225
75
msp430_flags       += --silicon_errata=CPU21
76
msp430_flags       += --silicon_errata=CPU22
77
msp430_flags       += --silicon_errata=CPU23
78
msp430_flags       += --printf_support=minimal
79
 
80
ifdef LEAVETMP
81
msp430_flags       += --keep_asm --asm_directory=$(@D)
82
endif
83
 
84
ifdef USE_STRICT_ANSI
85
msp430_flags       += --strict_ansi
86
endif
87
 
88
 
89
ifdef USE_OPTIMISE
90
msp430_flags       += -O2
91
else
92
msp430_flags       +=
93
endif
94
 
95
ifdef USE_DEBUGINFO
96
cc_defines       += DEBUG
97
else
98
cc_defines       += NDEBUG
99
endif
100
 
101
ifeq "$(DEBUG)" "1"
102
msp430_flags       +=
103
else
104
msp430_flags       +=
105
endif
106
 
107
cc_defines      += __SOURCE__=$(notdir $<)
108
 
109
define cc_pre
110
        @$(echo) "[$<] compiling.."; \
111
        $(cmdfile) -ko$(cc_cmdfile) "\
112
                $(patsubst %,%\\n,$(CFLAGS)) \
113
                $(patsubst %,--define=%\\n,$(cc_defines)) \
114
                $(subst =,$(space),$(patsubst %,%\\n,$(msp430_flags))) \
115
                --include_path=$(dir $<)\\n \
116
                $(patsubst %,--include_path=%\\n,$(INCDIRS)) \
117
                $(subst $(spacealt),$(space),$(patsubst %,--include_path=\"%\"\\n,$(msp430_includes))) \
118
                $(cc_object)"
119
        $(call show_cmdfile,$(cc_cmdfile))
120
 
121
endef
122
 
123
ifndef LEAVETMP
124
define cc_post
125
        @$(rm) -f $(cc_cmdfile)
126
endef
127
else
128
define cc_post
129
endef
130
endif
131
 
132
###############################################################################
133
#..     C/C++ dependencies
134
#       depend and depend.err
135
#
136
msp430_depend      = -D__STDC__
137
ifeq "$(DEBUG)" "1"
138
msp430_depend      += -DDEBUG
139
endif
140
msp430_depend      += -D__SOURCE__=$(notdir $<)
141
 
142
ccdep           = $(XX_PRE)$(GBE_BIN)/mkdepend
143
ccdep_init      =
144
ccdep_o_switch  = -f -
145
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
146
ccdep_flags     = -MM -b -We -p \$$\(OBJDIR\)/ -o .$(o) \
147
                  $(filter -D%, $(CFLAGS)) \
148
                  $(filter -U%, $(CFLAGS)) \
149
                  $(patsubst %,-D%,$(cc_defines)) \
150
                  $(patsubst %,%,$(msp430_depend)) \
151
                  $(patsubst %,-I %,$(INCDIRS)) \
152
                  $(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(msp430_includes))) \
153
                  $(patsubst %,-Y %,$(NODEPDIRS))
154
 
155
ccdep_pre       =
156
ccdep_post      =
157
 
158
 
159
###############################################################################
160
#..     Assembler definition
161
#	Not used as assember files are treated as 'c' files
162
 
163
 
164
###############################################################################
165
#..     Archiver
166
#
167
#       Swicthes
168
#           -V              Verbose
169
#           -o file         Output file
170
#
171
ar              = $(XX_PRE) "$(msp430_librarian)"
172
ar_init         =
173
ar_flags        = -aq $@
174
ar_o_switch     = $^
175
ar_term         =
176
 
177
 
178
 
179
define ar_pre
180
        @$(echo) [\$@] Creating library archive.. ; \
181
        $(rm) -f $@
182
endef
183
 
184
ifndef LEAVETMP
185
define ar_post
186
endef
187
else
188
define ar_post
189
endef
190
endif
191
 
192
 
193
###############################################################################
194
#..     Archive Merge
195
#	Not currently supported.
196
#	Can add if required
197
#
198
 
199
 
200
###############################################################################
201
#..     Linker
202
#
203
#	Add CC definitions and options
204
#		May(don't know) be used by the linker
205
#	Add the header file search path to the linker
206
#		Used to locate linker command files
207
#	Add library search path to the linker
208
#		Used within linker command files
209
#
210
ld              = $(XX_PRE) $(msp430_compiler)
211
ld_cmdfile      = $(basename $@).ld
212
ld_flags        = -@$(ld_cmdfile)
213
msp430_libs   = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(MSP430_LIBS)))))
214
 
215
 
216
define ld_pre
217
        $(XX_PRE)$(echo) [$@] Linking program .. ;\
218
        export LIB; \
219
                LIB="$(subst $(space),;,$(LIBDIRS));$(MSP430_LIBS)"; \
220
        $(cmdfile) -W0ko$(ld_cmdfile) "\
221
                $(patsubst %,%\\n,$(CFLAGS)) \
222
                $(patsubst %,--define=%\\n,$(cc_defines)) \
223
                $(subst =,$(space),$(patsubst %,%\\n,$(msp430_flags))) \
224
                --run_linker\\n \
225
                --search_path=$(dir $<)\\n \
226
                $(patsubst %,--search_path=%\\n,$(INCDIRS)) \
227
                $(subst $(spacealt),$(space),$(patsubst %,--search_path=\"%\"\\n,$(msp430_includes))) \
228
                $(patsubst %,--search_path=%\\n,$(LIBDIRS)) \
229
                $(subst $(spacealt),$(space),$(patsubst %,--search_path=\"%\"\\n,$(msp430_libs))) \
230
		$($(notdir $(basename $@))_ld)"
231
        $(call show_cmdfile,$(ld_cmdfile))
232
 
233
endef
234
 
235
ifndef LEAVETMP
236
define ld_post
237
        @$(rm) -f $(ld_cmdfile)
238
endef
239
else
240
define ld_post
241
endef
242
endif
243
 
244
#
245
#   Create Library dependency file
246
#
247
define LDDEPEND
248
        $(XX_PRE) export LIB; \
249
                LIB="$(subst $(space),;,$(LIBDIRS));$(MSP430_LIBS)"; \
250
        $(cmdfile) -W1ko$(@) "$($(DPLIST))" 
251
endef
252
 
253
################################################################################
254
#
371 dpurdie 255
#    Post Process COFF files into IMG files
369 dpurdie 256
#	$1 - coff file (input)
257
#	$2 - img file (output)
258
#	$3 - Build Version String (input)
371 dpurdie 259
#   Generates .img file and a .hex file
260
#   The .hex file is a buried dependency
261
#
369 dpurdie 262
define COFF2IMG
263
    @$(echo) "[$@] Convert COFF to IMG.."
264
    $(XX_PRE)$(TOOL_VXP430IMG) $1 $2 $3
265
endef
266
 
267
 
268
 
269
#