Subversion Repositories DevTools

Rev

Rev 6177 | 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))) \
6925 dpurdie 128
                $(subst =,$(space),$(patsubst %,%\\n,$(AVR_IAR_CC_FLAGS))) \
227 dpurdie 129
                -I $(dir $<)\\n \
130
                $(patsubst %,-I %\\n,$(INCDIRS)) \
131
                $(patsubst %,-I %\\n,$(cc_includes)) \
132
                $(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_includes))) \
5680 dpurdie 133
                $(cc_object)" ;\
5741 dpurdie 134
        $(call show_cmdfile,$(cc_cmdfile))
5680 dpurdie 135
 
227 dpurdie 136
endef
137
 
138
ifndef LEAVETMP
139
define cc_post
140
        @$(rm) -f $(cc_cmdfile)
141
endef
142
else
143
define cc_post
144
endef
145
endif
146
 
147
###############################################################################
148
#..     C/C++ dependencies
149
#       depend and depend.err
150
#
151
iar_depend      = -D__STDC__
152
ifeq "$(DEBUG)" "1"
153
iar_depend      += -DDEBUG
154
endif
155
ifdef ALVL
156
iar_depend      += -DALVL=$(ALVL)
157
endif
158
ifdef DLVL
159
iar_depend      += -DDLVL=$(DLVL)
160
endif
161
iar_depend      += -D__SOURCE__=$(notdir $<)
162
 
163
ccdep           = $(XX_PRE)$(GBE_BIN)/mkdepend
164
ccdep_init      =
165
ccdep_o_switch  = -f -
166
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
167
ccdep_flags     = -MM -b -We -p \$$\(OBJDIR\)/ -o .$(o) \
168
                  $(filter -D%, $(CFLAGS)) \
169
                  $(filter -U%, $(CFLAGS)) \
170
                  $(patsubst %,-D%,$(cc_defines)) \
171
                  $(patsubst %,%,$(iar_depend)) \
172
                  $(patsubst %,-I %,$(INCDIRS)) \
173
                  $(patsubst %,-Y %,$(cc_includes)) \
174
                  $(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(iar_includes))) \
175
                  $(patsubst %,-Y %,$(NODEPDIRS))
176
 
177
ccdep_pre       =
178
ccdep_post      =
179
 
180
 
181
#..     C++ Compiler definition
182
#
6925 dpurdie 183
cxx             = $(CC_PRE) "$(avr_iar_cpp_compiler)"
227 dpurdie 184
cxx_init        =
185
cxx_o_switch    =
186
cxx_object      = -o $@
187
cxx_source      = $<
188
cxx_cmdfile     = $(basename $@).cmd
6925 dpurdie 189
cxx_flags       = -f $(cxx_cmdfile)
227 dpurdie 190
 
191
define cxx_pre
6925 dpurdie 192
        @$(echo) "[$<] compiling..";\
227 dpurdie 193
        $(cmdfile) -ko$(cxx_cmdfile) "\
6925 dpurdie 194
                $(patsubst %,%\\n,$(CXXFLAGS)) \
227 dpurdie 195
                $(patsubst %,-D%\\n,$(cc_defines)) \
196
                $(subst =,$(space),$(patsubst %,%\\n,$(iar_flags))) \
6925 dpurdie 197
                $(subst =,$(space),$(patsubst %,%\\n,$(AVR_IAR_CXX_FLAGS))) \
227 dpurdie 198
                -I $(dir $<)\\n \
199
                $(patsubst %,-I %\\n,$(INCDIRS)) \
200
                $(patsubst %,-I %\\n,$(cc_includes)) \
201
                $(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_includes))) \
5741 dpurdie 202
                $(cxx_object)" ;\
203
        $(call show_cmdfile,$(cxx_cmdfile))
227 dpurdie 204
endef
205
 
206
ifndef LEAVETMP
207
define cxx_post
208
        @$(rm) -f $(cxx_cmdfile)
209
endef
210
else
211
define cxx_post
212
endef
213
endif
214
 
215
 
216
###############################################################################
217
#..     Assembler definition
218
#
219
# Note:  All the options go on the command line at present so this
220
#        passes a minimal set of definitions. (v4.3)
221
#
222
#       Assembler switches
223
#           -Ifile              Extend include path
224
#           -o file             Specfify output file
225
#           -S                  No messages
226
#           -r                  Generate symbolic debug info
227
#           -D symbol           Define a symbol
228
#           -f cmd_file         Take options from a command file
229
#
230
 
231
as              = $(XX_PRE) "$(avr_iar_assembler)"
232
as_init         =
233
as_o_switch     = -o $@
234
as_source       = $<
235
as_cmdfile      =
236
 
237
as_includes     =
238
as_flags        = -S $(AVR_IAR_ASFLAGS)
239
as_defines      = $(AVR_IAR_ASDEFINES)
240
 
241
#ifdef ASFLAGS
242
as_flags        += $(ASFLAGS)
243
#endif
244
 
245
ifeq "$(DEBUG)" "1"
246
as_flags        += -r
247
else
248
as_flags        +=
249
endif
250
 
251
ifdef as_defines
252
as_flags    += $(addprefix -D,$(as_defines))
253
endif
254
 
255
#ifdef INCDIRS
256
as_flags      += $(patsubst %,-I%,$(strip $(INCDIRS)))
257
#endif
258
 
259
ifdef as_includes
260
as_flags      += $(patsubst %,-I%,$(strip $(as_includes)))
261
endif
262
 
263
#ifdef AVR_IAR_INCLUDES
264
as_flags      += $(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES))))) ))
265
#endif
266
 
267
define as_pre
6177 dpurdie 268
    @$(echo) '[$@] Assembling file..'
227 dpurdie 269
endef
270
define as_post
271
endef
272
 
273
 
274
###############################################################################
275
#..     Archiver
276
#
277
#       Swicthes
278
#           -V              Verbose
279
#           -o file         Output file
280
#
281
ar              = $(XX_PRE) "$(avr_iar_librarian)"
282
ar_init         =
283
ar_flags        = $^
284
ar_o_switch     = -o $@
285
ar_term         =
286
 
287
 
288
 
289
define ar_pre
6177 dpurdie 290
        @$(echo) '[$@] Creating library archive..' ; \
227 dpurdie 291
        $(rm) -f $@
292
endef
293
 
294
ifndef LEAVETMP
295
define ar_post
296
endef
297
else
298
define ar_post
299
endef
300
endif
301
 
302
 
303
###############################################################################
304
#..     Archive Merge
305
#
306
armerge              = $(XX_PRE) "$(avr_iar_librarian)"
307
armerge_init         =
308
armerge_flags        = $^
309
armerge_o_switch     = -o $@
310
 
311
define armerge_pre
6177 dpurdie 312
        @$(echo) '[$@] Creating a Merged library..' ; \
227 dpurdie 313
        $(rm) -f $@
314
endef
315
 
316
ifndef LEAVETMP
317
define armerge_post
318
endef
319
else
320
define armerge_post
321
endef
322
endif
323
 
324
 
325
###############################################################################
326
#..     Linker
327
#
5679 dpurdie 328
ld              = $(XX_PRE) "$(avr_iar_linker)"
227 dpurdie 329
ld_cmdfile      = $(basename $@).ld
330
ld_flags        = -f $(ld_cmdfile)
331
 
332
define ld_pre
6177 dpurdie 333
        $(XX_PRE)$(echo) '[$@] Linking program ..' ;\
227 dpurdie 334
        export IAR_LIB; \
335
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
336
        $(cmdfile) -W2ko$(ld_cmdfile) "$($(notdir $(basename $@))_ld)"
337
endef
338
 
339
ifndef LEAVETMP
340
define ld_post
341
        @$(rm) -f $(ld_cmdfile)
342
endef
343
else
344
define ld_post
345
endef
346
endif
347
 
348
define LD_IAR
349
        $(show_environment)
350
        $(ld_pre)
351
        $(ld) $(ld_flags)
352
        $(ld_post)
353
endef
354
 
355
#
356
#   Create Library dependency file
357
#
358
define LDDEPEND
359
        $(XX_PRE) export IAR_LIB; \
360
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 361
        $(cmdfile) -W1ko$(@) "$($(DPLIST))" 
227 dpurdie 362
endef
363
 
364
 
365
#
366
#   Program Loader processing
367
#   Args:   $1 Path to the exe
368
#           $2 Path to the ProgLoader
369
#
370
#   The process
5858 dpurdie 371
#       Remove last line from the executable (S9 Entry Point and Termination)
372
#       Remove the first line from the ProgLoader (S0 Header)
227 dpurdie 373
#       Concatenate the exe + progloader to the original file name
374
#
375
define  LD_IAR_PROCESS
376
    $(XX_PRE) $(echo) "[$@]Process Program Loader .." ;\
377
    sed '-e$$d' $1 >$1.ed ;\
5858 dpurdie 378
    sed '-e1d' $2 >$2.ed ;\
227 dpurdie 379
    rm -f $1.keep ;\
380
    mv $1 $1.keep ;\
381
    cat $1.ed $2.ed >$1   ;\
382
    rm $1.ed $2.ed
383
endef
384
 
385
#
5726 dpurdie 386
#	Generate SREC file
387
#	Not used by all versions of IAR
388
#	Args:	$1	Path to the out file (input)
389
#			$2  Path to the SREC file (output)
5757 dpurdie 390
# 			$3  Additional Args
5726 dpurdie 391
#
392
define GENERATE_SREC
393
    $(XX_PRE) $(echo) "[$@]Generate SREC .." ;\
394
    rm -f $2;\
5757 dpurdie 395
    "$(avr_iar_elftool)" --srec --verbose $3 $1 $2 
5726 dpurdie 396
endef
397
 
398
#
227 dpurdie 399
#   Generate SXML file
400
#   Args:   $1  Path to the S19 file
401
#           $2  Path to the SXML file (output)
402
#           $3  Payload Type
403
#           $4  Major version
404
#           $5  Minor version
405
#           $6  Patch
406
#           $7  Build
5679 dpurdie 407
#			$8  WrapperTag. Has _Image appended
227 dpurdie 408
#
409
define GENERATE_SXML
410
    $(XX_PRE) $(echo) "[$@]Generate SXML .." ;\
411
    rm -f $2;\
5679 dpurdie 412
    echo "<$8_Image>" >$2;\
227 dpurdie 413
    echo "  <Header>" >>$2;\
414
    echo "    <version>0</version>" >>$2;\
415
    echo "    <builddate>$$(date +%c)</builddate>" >>$2;\
416
    echo "    <buildtime>$$(date +%s)</buildtime>" >>$2;\
417
    echo "    <platform>$(GBE_PLATFORM)</platform>" >>$2;\
418
    echo "    <type>$3</type>" >>$2;\
419
    echo "    <major>$4</major>" >>$2;\
420
    echo "    <minor>$5</minor>" >>$2;\
421
    echo "    <patch>$6</patch>" >>$2;\
422
    echo "    <build>$7</build>" >>$2;\
423
    echo "    <encrypted>false</encrypted>" >>$2;\
424
    echo "    <binary>false</binary>" >>$2;\
425
    echo "  </Header>" >>$2;\
426
    echo "  <Data>" >>$2;\
427
    cat $1 >>$2;\
428
    echo "  </Data>" >>$2;\
5679 dpurdie 429
    echo "</$8_Image>" >>$2
227 dpurdie 430
endef
431
 
432
#