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
 
65
msp430_flags       += --silicon_version=mspx
66
#msp430_flags       += --make_global
67
msp430_flags       += --gcc
68
msp430_flags       += --define=__MSP430F5438A__
69
msp430_flags       += --diag_warning=225
70
msp430_flags       += --silicon_errata=CPU21
71
msp430_flags       += --silicon_errata=CPU22
72
msp430_flags       += --silicon_errata=CPU23
73
msp430_flags       += --printf_support=minimal
74
 
75
ifdef LEAVETMP
76
msp430_flags       += --keep_asm --asm_directory=$(@D)
77
endif
78
 
79
ifdef USE_STRICT_ANSI
80
msp430_flags       += --strict_ansi
81
endif
82
 
83
 
84
ifdef USE_OPTIMISE
85
msp430_flags       += -O2
86
else
87
msp430_flags       +=
88
endif
89
 
90
ifdef USE_DEBUGINFO
91
cc_defines       += DEBUG
92
else
93
cc_defines       += NDEBUG
94
endif
95
 
96
ifeq "$(DEBUG)" "1"
97
msp430_flags       +=
98
else
99
msp430_flags       +=
100
endif
101
 
102
cc_defines      += __SOURCE__=$(notdir $<)
103
 
104
define cc_pre
105
        @$(echo) "[$<] compiling.."; \
106
        $(cmdfile) -ko$(cc_cmdfile) "\
107
                $(patsubst %,%\\n,$(CFLAGS)) \
108
                $(patsubst %,--define=%\\n,$(cc_defines)) \
109
                $(subst =,$(space),$(patsubst %,%\\n,$(msp430_flags))) \
110
                --include_path=$(dir $<)\\n \
111
                $(patsubst %,--include_path=%\\n,$(INCDIRS)) \
112
                $(subst $(spacealt),$(space),$(patsubst %,--include_path=\"%\"\\n,$(msp430_includes))) \
113
                $(cc_object)"
114
        $(call show_cmdfile,$(cc_cmdfile))
115
 
116
endef
117
 
118
ifndef LEAVETMP
119
define cc_post
120
        @$(rm) -f $(cc_cmdfile)
121
endef
122
else
123
define cc_post
124
endef
125
endif
126
 
127
###############################################################################
128
#..     C/C++ dependencies
129
#       depend and depend.err
130
#
131
msp430_depend      = -D__STDC__
132
ifeq "$(DEBUG)" "1"
133
msp430_depend      += -DDEBUG
134
endif
135
msp430_depend      += -D__SOURCE__=$(notdir $<)
136
 
137
ccdep           = $(XX_PRE)$(GBE_BIN)/mkdepend
138
ccdep_init      =
139
ccdep_o_switch  = -f -
140
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
141
ccdep_flags     = -MM -b -We -p \$$\(OBJDIR\)/ -o .$(o) \
142
                  $(filter -D%, $(CFLAGS)) \
143
                  $(filter -U%, $(CFLAGS)) \
144
                  $(patsubst %,-D%,$(cc_defines)) \
145
                  $(patsubst %,%,$(msp430_depend)) \
146
                  $(patsubst %,-I %,$(INCDIRS)) \
147
                  $(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(msp430_includes))) \
148
                  $(patsubst %,-Y %,$(NODEPDIRS))
149
 
150
ccdep_pre       =
151
ccdep_post      =
152
 
153
 
154
###############################################################################
155
#..     Assembler definition
156
#	Not used as assember files are treated as 'c' files
157
 
158
 
159
###############################################################################
160
#..     Archiver
161
#
162
#       Swicthes
163
#           -V              Verbose
164
#           -o file         Output file
165
#
166
ar              = $(XX_PRE) "$(msp430_librarian)"
167
ar_init         =
168
ar_flags        = -aq $@
169
ar_o_switch     = $^
170
ar_term         =
171
 
172
 
173
 
174
define ar_pre
175
        @$(echo) [\$@] Creating library archive.. ; \
176
        $(rm) -f $@
177
endef
178
 
179
ifndef LEAVETMP
180
define ar_post
181
endef
182
else
183
define ar_post
184
endef
185
endif
186
 
187
 
188
###############################################################################
189
#..     Archive Merge
190
#	Not currently supported.
191
#	Can add if required
192
#
193
 
194
 
195
###############################################################################
196
#..     Linker
197
#
198
#	Add CC definitions and options
199
#		May(don't know) be used by the linker
200
#	Add the header file search path to the linker
201
#		Used to locate linker command files
202
#	Add library search path to the linker
203
#		Used within linker command files
204
#
205
ld              = $(XX_PRE) $(msp430_compiler)
206
ld_cmdfile      = $(basename $@).ld
207
ld_flags        = -@$(ld_cmdfile)
208
msp430_libs   = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(MSP430_LIBS)))))
209
 
210
 
211
define ld_pre
212
        $(XX_PRE)$(echo) [$@] Linking program .. ;\
213
        export LIB; \
214
                LIB="$(subst $(space),;,$(LIBDIRS));$(MSP430_LIBS)"; \
215
        $(cmdfile) -W0ko$(ld_cmdfile) "\
216
                $(patsubst %,%\\n,$(CFLAGS)) \
217
                $(patsubst %,--define=%\\n,$(cc_defines)) \
218
                $(subst =,$(space),$(patsubst %,%\\n,$(msp430_flags))) \
219
                --run_linker\\n \
220
                --search_path=$(dir $<)\\n \
221
                $(patsubst %,--search_path=%\\n,$(INCDIRS)) \
222
                $(subst $(spacealt),$(space),$(patsubst %,--search_path=\"%\"\\n,$(msp430_includes))) \
223
                $(patsubst %,--search_path=%\\n,$(LIBDIRS)) \
224
                $(subst $(spacealt),$(space),$(patsubst %,--search_path=\"%\"\\n,$(msp430_libs))) \
225
		$($(notdir $(basename $@))_ld)"
226
        $(call show_cmdfile,$(ld_cmdfile))
227
 
228
endef
229
 
230
ifndef LEAVETMP
231
define ld_post
232
        @$(rm) -f $(ld_cmdfile)
233
endef
234
else
235
define ld_post
236
endef
237
endif
238
 
239
#
240
#   Create Library dependency file
241
#
242
define LDDEPEND
243
        $(XX_PRE) export LIB; \
244
                LIB="$(subst $(space),;,$(LIBDIRS));$(MSP430_LIBS)"; \
245
        $(cmdfile) -W1ko$(@) "$($(DPLIST))" 
246
endef
247
 
248
################################################################################
249
#
250
#	Post Process COFF files into IMG files
251
#	$1 - coff file (input)
252
#	$2 - img file (output)
253
#	$3 - Build Version String (input)
254
define COFF2IMG
255
    @$(echo) "[$@] Convert COFF to IMG.."
256
    $(XX_PRE)$(TOOL_VXP430IMG) $1 $2 $3
257
endef
258
 
259
 
260
 
261
#