Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
5709 dpurdie 2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
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)" ;\
133
                $(call show_cmdfile,$(cc_cmdfile))
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
191
        @$(echo) [\$<] compiling.. ; \
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))) \
200
                $(cxx_object)"
201
endef
202
 
203
ifndef LEAVETMP
204
define cxx_post
205
        @$(rm) -f $(cxx_cmdfile)
206
endef
207
else
208
define cxx_post
209
endef
210
endif
211
 
212
 
213
###############################################################################
214
#..     Assembler definition
215
#
216
# Note:  All the options go on the command line at present so this
217
#        passes a minimal set of definitions. (v4.3)
218
#
219
#       Assembler switches
220
#           -Ifile              Extend include path
221
#           -o file             Specfify output file
222
#           -S                  No messages
223
#           -r                  Generate symbolic debug info
224
#           -D symbol           Define a symbol
225
#           -f cmd_file         Take options from a command file
226
#
227
 
228
as              = $(XX_PRE) "$(avr_iar_assembler)"
229
as_init         =
230
as_o_switch     = -o $@
231
as_source       = $<
232
as_cmdfile      =
233
 
234
as_includes     =
235
as_flags        = -S $(AVR_IAR_ASFLAGS)
236
as_defines      = $(AVR_IAR_ASDEFINES)
237
 
238
#ifdef ASFLAGS
239
as_flags        += $(ASFLAGS)
240
#endif
241
 
242
ifeq "$(DEBUG)" "1"
243
as_flags        += -r
244
else
245
as_flags        +=
246
endif
247
 
248
ifdef as_defines
249
as_flags    += $(addprefix -D,$(as_defines))
250
endif
251
 
252
#ifdef INCDIRS
253
as_flags      += $(patsubst %,-I%,$(strip $(INCDIRS)))
254
#endif
255
 
256
ifdef as_includes
257
as_flags      += $(patsubst %,-I%,$(strip $(as_includes)))
258
endif
259
 
260
#ifdef AVR_IAR_INCLUDES
261
as_flags      += $(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES))))) ))
262
#endif
263
 
264
define as_pre
265
    @$(echo) [$@] Assembling file
266
endef
267
define as_post
268
endef
269
 
270
 
271
###############################################################################
272
#..     Archiver
273
#
274
#       Swicthes
275
#           -V              Verbose
276
#           -o file         Output file
277
#
278
ar              = $(XX_PRE) "$(avr_iar_librarian)"
279
ar_init         =
280
ar_flags        = $^
281
ar_o_switch     = -o $@
282
ar_term         =
283
 
284
 
285
 
286
define ar_pre
287
        @$(echo) [\$@] Creating library archive.. ; \
288
        $(rm) -f $@
289
endef
290
 
291
ifndef LEAVETMP
292
define ar_post
293
endef
294
else
295
define ar_post
296
endef
297
endif
298
 
299
 
300
###############################################################################
301
#..     Archive Merge
302
#
303
armerge              = $(XX_PRE) "$(avr_iar_librarian)"
304
armerge_init         =
305
armerge_flags        = $^
306
armerge_o_switch     = -o $@
307
 
308
define armerge_pre
309
        @$(echo) [\$@] Creating a Merged library.. ; \
310
        $(rm) -f $@
311
endef
312
 
313
ifndef LEAVETMP
314
define armerge_post
315
endef
316
else
317
define armerge_post
318
endef
319
endif
320
 
321
 
322
###############################################################################
323
#..     Linker
324
#
5679 dpurdie 325
ld              = $(XX_PRE) "$(avr_iar_linker)"
227 dpurdie 326
ld_cmdfile      = $(basename $@).ld
327
ld_flags        = -f $(ld_cmdfile)
328
 
329
define ld_pre
330
        $(XX_PRE)$(echo) [$@] Linking program .. ;\
331
        export IAR_LIB; \
332
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
333
        $(cmdfile) -W2ko$(ld_cmdfile) "$($(notdir $(basename $@))_ld)"
334
endef
335
 
336
ifndef LEAVETMP
337
define ld_post
338
        @$(rm) -f $(ld_cmdfile)
339
endef
340
else
341
define ld_post
342
endef
343
endif
344
 
345
define LD_IAR
346
        $(show_environment)
347
        $(ld_pre)
348
        $(ld) $(ld_flags)
349
        $(ld_post)
350
endef
351
 
352
#
353
#   Create Library dependency file
354
#
355
define LDDEPEND
356
        $(XX_PRE) export IAR_LIB; \
357
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 358
        $(cmdfile) -W1ko$(@) "$($(DPLIST))" 
227 dpurdie 359
endef
360
 
361
 
362
#
363
#   Program Loader processing
364
#   Args:   $1 Path to the exe
365
#           $2 Path to the ProgLoader
366
#
367
#   The process
368
#       Remove 1st line from the executable
369
#       Remove the last 2 lines from the ProgLoader
370
#       Concatenate the exe + progloader to the original file name
371
#
372
define  LD_IAR_PROCESS
373
    $(XX_PRE) $(echo) "[$@]Process Program Loader .." ;\
374
    sed '-e$$d' $1 >$1.ed ;\
375
    sed '-e1,2d' $2 >$2.ed ;\
376
    rm -f $1.keep ;\
377
    mv $1 $1.keep ;\
378
    cat $1.ed $2.ed >$1   ;\
379
    rm $1.ed $2.ed
380
endef
381
 
382
#
5726 dpurdie 383
#	Generate SREC file
384
#	Not used by all versions of IAR
385
#	Args:	$1	Path to the out file (input)
386
#			$2  Path to the SREC file (output)
387
#
388
define GENERATE_SREC
389
    $(XX_PRE) $(echo) "[$@]Generate SREC .." ;\
390
    rm -f $2;\
5732 dpurdie 391
    "$(avr_iar_elftool)" --srec --verbose $1 $2
5726 dpurdie 392
endef
393
 
394
#
227 dpurdie 395
#   Generate SXML file
396
#   Args:   $1  Path to the S19 file
397
#           $2  Path to the SXML file (output)
398
#           $3  Payload Type
399
#           $4  Major version
400
#           $5  Minor version
401
#           $6  Patch
402
#           $7  Build
5679 dpurdie 403
#			$8  WrapperTag. Has _Image appended
227 dpurdie 404
#
405
define GENERATE_SXML
406
    $(XX_PRE) $(echo) "[$@]Generate SXML .." ;\
407
    rm -f $2;\
5679 dpurdie 408
    echo "<$8_Image>" >$2;\
227 dpurdie 409
    echo "  <Header>" >>$2;\
410
    echo "    <version>0</version>" >>$2;\
411
    echo "    <builddate>$$(date +%c)</builddate>" >>$2;\
412
    echo "    <buildtime>$$(date +%s)</buildtime>" >>$2;\
413
    echo "    <platform>$(GBE_PLATFORM)</platform>" >>$2;\
414
    echo "    <type>$3</type>" >>$2;\
415
    echo "    <major>$4</major>" >>$2;\
416
    echo "    <minor>$5</minor>" >>$2;\
417
    echo "    <patch>$6</patch>" >>$2;\
418
    echo "    <build>$7</build>" >>$2;\
419
    echo "    <encrypted>false</encrypted>" >>$2;\
420
    echo "    <binary>false</binary>" >>$2;\
421
    echo "  </Header>" >>$2;\
422
    echo "  <Data>" >>$2;\
423
    cat $1 >>$2;\
424
    echo "  </Data>" >>$2;\
5679 dpurdie 425
    echo "</$8_Image>" >>$2
227 dpurdie 426
endef
427
 
428
#