Subversion Repositories DevTools

Rev

Rev 5858 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
227 dpurdie 3
#
4
# File:         TOOLSET/AVR_IAR.rul[e]
5
# Contents:     IAR rules as used for the AVR
6
#               Make definitions for the IAR tools.
7
#
8
# Description:
9
#       This file provides Toolset rules for the target makefiles
10
#       The file is dropped into the target makefile
11
#
12
# Revision History:
13
#       16-Aug-04   DDP     Created
14
###############################################################################
15
 
16
###############################################################################
17
#..     Remove "undef" warnings
18
#
19
cc_includes     +=
20
cc_defines      +=
21
as_includes     +=
22
as_defines      +=
23
cxx_includes    +=
24
cxx_defines     +=
25
 
26
###############################################################################
27
#..     Parse user options
28
#       Global options already parsed
29
#       These options extend the global options
30
#
31
ifdef OPTIONS
32
endif
33
 
34
###############################################################################
35
#..     C Compiler definition
36
#
37
#
38
#   Compiler flags
39
#       --cpu=cpu                   Specify cpu type
40
#       -D Symbol                   Define a symbol
41
#       --debug                     Include debug information
42
#       -e                          Enables language extensions
43
#       --ec++                      Default language is C++
44
#       --eprom_size=N              Set eeprom size
45
#       --enhanced_core             Allow enhanced core instructions
46
#       -f file                     Read commands from a file
47
#       --initializers_in_flash     Places aggregate initializers in flash memory
48
#       --no_clustering             Disables clustering of variables
49
#       --no_code_motion            Disables code motion optimization
50
#       --no_cross_call             Disables cross-call optimization
51
#       --no_cse                    Disables common sub-expression elimination
52
#       --no_inline                 Disables function inlining
53
#       -lA file/dir                Generate a list file
54
#       -lC file/dir                Generate a list file
55
#       -m[stl]                     Memory model
56
#       -o filename                 Output filename
57
#       --require_prototypes        Verifies that prototypes are proper
58
#       -s[2369]                    Optimise code for speed, none,Low,Med,Hi
59
#       --strict_ansi
60
#       --silent                    Supress banner
61
#       -v[0-6]                     Specify processor variant
62
#       -y                          Places constants and literals
63
#       -z[2369]                    Optimise code for size, none,Low,Med,Hi
64
#
65
#
5679 dpurdie 66
cc              = $(CC_PRE) "$(avr_iar_compiler)"
227 dpurdie 67
cc_init         =
68
cc_o_switch     =
69
cc_object       = -o $@
70
cc_source       = $<
71
cc_cmdfile      = $(basename $@).cmd
72
cc_flags        = --silent -f $(cc_cmdfile)
73
cc_defines      = $(AVR_IAR_DEFINES)
74
iar_includes    = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES)))))
75
iar_flags       = $(AVR_IAR_FLAGS)
76
 
77
cc_filter      := "$(notdir $(wildcard $(GBE_ROOT)/warnings.iar*))"
78
ifeq ($(strip $(cc_filter)), "warnings.iar")
79
cc_redirect     = 1
80
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.iar
81
endif
82
 
83
ifdef LEAVETMP
84
iar_flags       += -lC=$(basename $@).lst
85
endif
86
 
87
ifdef USE_STRICT_ANSI
88
iar_flags       += --strict_ansi
89
else
90
iar_flags       += -e
91
endif
92
 
93
 
94
ifdef USE_OPTIMISE
95
iar_flags       +=
96
else
97
iar_flags       += 
98
endif
99
 
100
ifdef USE_DEBUGINFO
101
cc_defines       += DEBUG
102
else
103
cc_defines       += NDEBUG
104
endif
105
 
106
ifeq "$(DEBUG)" "1"
107
iar_flags       += --debug
108
else
109
iar_flags       +=
110
endif
111
 
112
ifdef ALVL
113
cc_defines       += ALVL=$(ALVL)
114
endif
115
 
116
ifdef DLVL
117
cc_defines       += DLVL=$(DLVL)
118
endif
119
 
120
cc_defines      += __SOURCE__=$(notdir $<)
121
 
122
define cc_pre
5680 dpurdie 123
        @$(echo) "[$<] compiling..";\
227 dpurdie 124
        $(cmdfile) -ko$(cc_cmdfile) "\
125
                $(patsubst %,%\\n,$(CFLAGS)) \
126
                $(patsubst %,-D%\\n,$(cc_defines)) \
127
                $(subst =,$(space),$(patsubst %,%\\n,$(iar_flags))) \
128
                -I $(dir $<)\\n \
129
                $(patsubst %,-I %\\n,$(INCDIRS)) \
130
                $(patsubst %,-I %\\n,$(cc_includes)) \
131
                $(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_includes))) \
5680 dpurdie 132
                $(cc_object)" ;\
5741 dpurdie 133
        $(call show_cmdfile,$(cc_cmdfile))
5680 dpurdie 134
 
227 dpurdie 135
endef
136
 
137
ifndef LEAVETMP
138
define cc_post
139
        @$(rm) -f $(cc_cmdfile)
140
endef
141
else
142
define cc_post
143
endef
144
endif
145
 
146
###############################################################################
147
#..     C/C++ dependencies
148
#       depend and depend.err
149
#
150
iar_depend      = -D__STDC__
151
ifeq "$(DEBUG)" "1"
152
iar_depend      += -DDEBUG
153
endif
154
ifdef ALVL
155
iar_depend      += -DALVL=$(ALVL)
156
endif
157
ifdef DLVL
158
iar_depend      += -DDLVL=$(DLVL)
159
endif
160
iar_depend      += -D__SOURCE__=$(notdir $<)
161
 
162
ccdep           = $(XX_PRE)$(GBE_BIN)/mkdepend
163
ccdep_init      =
164
ccdep_o_switch  = -f -
165
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
166
ccdep_flags     = -MM -b -We -p \$$\(OBJDIR\)/ -o .$(o) \
167
                  $(filter -D%, $(CFLAGS)) \
168
                  $(filter -U%, $(CFLAGS)) \
169
                  $(patsubst %,-D%,$(cc_defines)) \
170
                  $(patsubst %,%,$(iar_depend)) \
171
                  $(patsubst %,-I %,$(INCDIRS)) \
172
                  $(patsubst %,-Y %,$(cc_includes)) \
173
                  $(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(iar_includes))) \
174
                  $(patsubst %,-Y %,$(NODEPDIRS))
175
 
176
ccdep_pre       =
177
ccdep_post      =
178
 
179
 
180
#..     C++ Compiler definition
181
#
182
cxx             = $(CC_PRE) $(iar_cpp_compiler)
183
cxx_init        =
184
cxx_o_switch    =
185
cxx_object      = -o $@
186
cxx_source      = $<
187
cxx_cmdfile     = $(basename $@).cmd
188
cxx_flags       = --ec++ -f $(cxx_cmdfile)
189
 
190
define cxx_pre
6177 dpurdie 191
        @$(echo) '[$<] compiling..' ; \
227 dpurdie 192
        $(cmdfile) -ko$(cxx_cmdfile) "\
193
                $(patsubst %,%\\n,$(CFLAGS)) \
194
                $(patsubst %,-D%\\n,$(cc_defines)) \
195
                $(subst =,$(space),$(patsubst %,%\\n,$(iar_flags))) \
196
                -I $(dir $<)\\n \
197
                $(patsubst %,-I %\\n,$(INCDIRS)) \
198
                $(patsubst %,-I %\\n,$(cc_includes)) \
199
                $(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_includes))) \
5741 dpurdie 200
                $(cxx_object)" ;\
201
        $(call show_cmdfile,$(cxx_cmdfile))
227 dpurdie 202
endef
203
 
204
ifndef LEAVETMP
205
define cxx_post
206
        @$(rm) -f $(cxx_cmdfile)
207
endef
208
else
209
define cxx_post
210
endef
211
endif
212
 
213
 
214
###############################################################################
215
#..     Assembler definition
216
#
217
# Note:  All the options go on the command line at present so this
218
#        passes a minimal set of definitions. (v4.3)
219
#
220
#       Assembler switches
221
#           -Ifile              Extend include path
222
#           -o file             Specfify output file
223
#           -S                  No messages
224
#           -r                  Generate symbolic debug info
225
#           -D symbol           Define a symbol
226
#           -f cmd_file         Take options from a command file
227
#
228
 
229
as              = $(XX_PRE) "$(avr_iar_assembler)"
230
as_init         =
231
as_o_switch     = -o $@
232
as_source       = $<
233
as_cmdfile      =
234
 
235
as_includes     =
236
as_flags        = -S $(AVR_IAR_ASFLAGS)
237
as_defines      = $(AVR_IAR_ASDEFINES)
238
 
239
#ifdef ASFLAGS
240
as_flags        += $(ASFLAGS)
241
#endif
242
 
243
ifeq "$(DEBUG)" "1"
244
as_flags        += -r
245
else
246
as_flags        +=
247
endif
248
 
249
ifdef as_defines
250
as_flags    += $(addprefix -D,$(as_defines))
251
endif
252
 
253
#ifdef INCDIRS
254
as_flags      += $(patsubst %,-I%,$(strip $(INCDIRS)))
255
#endif
256
 
257
ifdef as_includes
258
as_flags      += $(patsubst %,-I%,$(strip $(as_includes)))
259
endif
260
 
261
#ifdef AVR_IAR_INCLUDES
262
as_flags      += $(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES))))) ))
263
#endif
264
 
265
define as_pre
6177 dpurdie 266
    @$(echo) '[$@] Assembling file..'
227 dpurdie 267
endef
268
define as_post
269
endef
270
 
271
 
272
###############################################################################
273
#..     Archiver
274
#
275
#       Swicthes
276
#           -V              Verbose
277
#           -o file         Output file
278
#
279
ar              = $(XX_PRE) "$(avr_iar_librarian)"
280
ar_init         =
281
ar_flags        = $^
282
ar_o_switch     = -o $@
283
ar_term         =
284
 
285
 
286
 
287
define ar_pre
6177 dpurdie 288
        @$(echo) '[$@] Creating library archive..' ; \
227 dpurdie 289
        $(rm) -f $@
290
endef
291
 
292
ifndef LEAVETMP
293
define ar_post
294
endef
295
else
296
define ar_post
297
endef
298
endif
299
 
300
 
301
###############################################################################
302
#..     Archive Merge
303
#
304
armerge              = $(XX_PRE) "$(avr_iar_librarian)"
305
armerge_init         =
306
armerge_flags        = $^
307
armerge_o_switch     = -o $@
308
 
309
define armerge_pre
6177 dpurdie 310
        @$(echo) '[$@] Creating a Merged library..' ; \
227 dpurdie 311
        $(rm) -f $@
312
endef
313
 
314
ifndef LEAVETMP
315
define armerge_post
316
endef
317
else
318
define armerge_post
319
endef
320
endif
321
 
322
 
323
###############################################################################
324
#..     Linker
325
#
5679 dpurdie 326
ld              = $(XX_PRE) "$(avr_iar_linker)"
227 dpurdie 327
ld_cmdfile      = $(basename $@).ld
328
ld_flags        = -f $(ld_cmdfile)
329
 
330
define ld_pre
6177 dpurdie 331
        $(XX_PRE)$(echo) '[$@] Linking program ..' ;\
227 dpurdie 332
        export IAR_LIB; \
333
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
334
        $(cmdfile) -W2ko$(ld_cmdfile) "$($(notdir $(basename $@))_ld)"
335
endef
336
 
337
ifndef LEAVETMP
338
define ld_post
339
        @$(rm) -f $(ld_cmdfile)
340
endef
341
else
342
define ld_post
343
endef
344
endif
345
 
346
define LD_IAR
347
        $(show_environment)
348
        $(ld_pre)
349
        $(ld) $(ld_flags)
350
        $(ld_post)
351
endef
352
 
353
#
354
#   Create Library dependency file
355
#
356
define LDDEPEND
357
        $(XX_PRE) export IAR_LIB; \
358
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 359
        $(cmdfile) -W1ko$(@) "$($(DPLIST))" 
227 dpurdie 360
endef
361
 
362
 
363
#
364
#   Program Loader processing
365
#   Args:   $1 Path to the exe
366
#           $2 Path to the ProgLoader
367
#
368
#   The process
5858 dpurdie 369
#       Remove last line from the executable (S9 Entry Point and Termination)
370
#       Remove the first line from the ProgLoader (S0 Header)
227 dpurdie 371
#       Concatenate the exe + progloader to the original file name
372
#
373
define  LD_IAR_PROCESS
374
    $(XX_PRE) $(echo) "[$@]Process Program Loader .." ;\
375
    sed '-e$$d' $1 >$1.ed ;\
5858 dpurdie 376
    sed '-e1d' $2 >$2.ed ;\
227 dpurdie 377
    rm -f $1.keep ;\
378
    mv $1 $1.keep ;\
379
    cat $1.ed $2.ed >$1   ;\
380
    rm $1.ed $2.ed
381
endef
382
 
383
#
5726 dpurdie 384
#	Generate SREC file
385
#	Not used by all versions of IAR
386
#	Args:	$1	Path to the out file (input)
387
#			$2  Path to the SREC file (output)
5757 dpurdie 388
# 			$3  Additional Args
5726 dpurdie 389
#
390
define GENERATE_SREC
391
    $(XX_PRE) $(echo) "[$@]Generate SREC .." ;\
392
    rm -f $2;\
5757 dpurdie 393
    "$(avr_iar_elftool)" --srec --verbose $3 $1 $2 
5726 dpurdie 394
endef
395
 
396
#
227 dpurdie 397
#   Generate SXML file
398
#   Args:   $1  Path to the S19 file
399
#           $2  Path to the SXML file (output)
400
#           $3  Payload Type
401
#           $4  Major version
402
#           $5  Minor version
403
#           $6  Patch
404
#           $7  Build
5679 dpurdie 405
#			$8  WrapperTag. Has _Image appended
227 dpurdie 406
#
407
define GENERATE_SXML
408
    $(XX_PRE) $(echo) "[$@]Generate SXML .." ;\
409
    rm -f $2;\
5679 dpurdie 410
    echo "<$8_Image>" >$2;\
227 dpurdie 411
    echo "  <Header>" >>$2;\
412
    echo "    <version>0</version>" >>$2;\
413
    echo "    <builddate>$$(date +%c)</builddate>" >>$2;\
414
    echo "    <buildtime>$$(date +%s)</buildtime>" >>$2;\
415
    echo "    <platform>$(GBE_PLATFORM)</platform>" >>$2;\
416
    echo "    <type>$3</type>" >>$2;\
417
    echo "    <major>$4</major>" >>$2;\
418
    echo "    <minor>$5</minor>" >>$2;\
419
    echo "    <patch>$6</patch>" >>$2;\
420
    echo "    <build>$7</build>" >>$2;\
421
    echo "    <encrypted>false</encrypted>" >>$2;\
422
    echo "    <binary>false</binary>" >>$2;\
423
    echo "  </Header>" >>$2;\
424
    echo "  <Data>" >>$2;\
425
    cat $1 >>$2;\
426
    echo "  </Data>" >>$2;\
5679 dpurdie 427
    echo "</$8_Image>" >>$2
227 dpurdie 428
endef
429
 
430
#