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